|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-06-02 18:51:17
Author: eric_niebler
Date: 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
New Revision: 46061
URL: http://svn.boost.org/trac/boost/changeset/46061
Log:
merged from trunk
Added:
branches/proto/v4/boost/spirit/home/qi/detail/construct_fwd.hpp
- copied unchanged from r46047, /trunk/boost/spirit/home/qi/detail/construct_fwd.hpp
branches/proto/v4/libs/unordered/doc/diagrams/buckets.svg
- copied unchanged from r46047, /trunk/libs/unordered/doc/diagrams/buckets.svg
branches/proto/v4/tools/build/v2/tools/types/objc.jam
- copied unchanged from r46047, /trunk/tools/build/v2/tools/types/objc.jam
Removed:
branches/proto/v4/libs/unordered/doc/diagrams/buckets.dia
Properties modified:
branches/proto/v4/ (props changed)
Binary files modified:
branches/proto/v4/libs/unordered/doc/diagrams/buckets.png
Text files modified:
branches/proto/v4/boost/asio/detail/null_thread.hpp | 5
branches/proto/v4/boost/asio/detail/posix_thread.hpp | 5
branches/proto/v4/boost/asio/detail/win_thread.hpp | 73 ++++
branches/proto/v4/boost/asio/detail/wince_thread.hpp | 5
branches/proto/v4/boost/config/stdlib/stlport.hpp | 2
branches/proto/v4/boost/foreach.hpp | 2
branches/proto/v4/boost/iostreams/chain.hpp | 6
branches/proto/v4/boost/iostreams/code_converter.hpp | 12
branches/proto/v4/boost/iostreams/combine.hpp | 19
branches/proto/v4/boost/iostreams/compose.hpp | 4
branches/proto/v4/boost/iostreams/detail/adapter/mode_adapter.hpp | 6
branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream.hpp | 1
branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp | 1
branches/proto/v4/boost/iostreams/detail/buffer.hpp | 5
branches/proto/v4/boost/iostreams/detail/forward.hpp | 58 ++-
branches/proto/v4/boost/iostreams/device/file.hpp | 8
branches/proto/v4/boost/iostreams/filter/gzip.hpp | 518 ++++++++++++++++++++++++---------
branches/proto/v4/boost/iostreams/filter/symmetric.hpp | 6
branches/proto/v4/boost/iostreams/invert.hpp | 1
branches/proto/v4/boost/iostreams/stream.hpp | 1
branches/proto/v4/boost/iostreams/stream_buffer.hpp | 1
branches/proto/v4/boost/iostreams/tee.hpp | 3
branches/proto/v4/boost/phoenix/scope/let.hpp | 119 +++++++
branches/proto/v4/boost/spirit/home/lex/lexer.hpp | 1
branches/proto/v4/boost/spirit/home/lex/lexer/action.hpp | 4
branches/proto/v4/boost/spirit/home/lex/lexer/lexer_actions.hpp | 2
branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp | 13
branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp | 15
branches/proto/v4/boost/spirit/home/lex/tokenize_and_parse.hpp | 63 ++++
branches/proto/v4/boost/spirit/home/qi/detail/assign_to.hpp | 1
branches/proto/v4/boost/spirit/home/qi/nonterminal/grammar.hpp | 19 -
branches/proto/v4/boost/spirit/home/qi/nonterminal/nonterminal.hpp | 2
branches/proto/v4/boost/spirit/home/support/attribute_transform.hpp | 15
branches/proto/v4/boost/unordered/detail/hash_table_impl.hpp | 19
branches/proto/v4/boost/xpressive/basic_regex.hpp | 2
branches/proto/v4/libs/asio/test/strand.cpp | 15
branches/proto/v4/libs/config/test/boost_has_tr1_function.ipp | 2
branches/proto/v4/libs/iostreams/example/container_device.hpp | 6
branches/proto/v4/libs/iostreams/test/gzip_test.cpp | 65 +++
branches/proto/v4/libs/spirit/doc/qi_and_karma/generating.qbk | 2
branches/proto/v4/libs/spirit/doc/qi_and_karma/parsing.qbk | 26
branches/proto/v4/libs/spirit/example/lex/print_numbers.cpp | 11
branches/proto/v4/libs/spirit/example/lex/static_lexer/word_count_static.cpp | 7
branches/proto/v4/libs/spirit/example/lex/strip_comments.cpp | 5
branches/proto/v4/libs/spirit/example/lex/strip_comments_lexer.cpp | 1
branches/proto/v4/libs/spirit/example/lex/word_count.cpp | 4
branches/proto/v4/libs/spirit/example/lex/word_count_functor.flex | 3
branches/proto/v4/libs/spirit/example/lex/word_count_functor_flex.cpp | 3
branches/proto/v4/libs/spirit/test/qi/grammar_fail.cpp | 3
branches/proto/v4/libs/unordered/doc/Jamfile.v2 | 33 ++
branches/proto/v4/libs/unordered/doc/bibliography.xml | 4
branches/proto/v4/libs/unordered/doc/buckets.qbk | 88 +++--
branches/proto/v4/libs/unordered/doc/hash_equality.qbk | 4
branches/proto/v4/libs/unordered/doc/unordered.qbk | 10
branches/proto/v4/libs/unordered/test/exception/Jamfile.v2 | 2
branches/proto/v4/libs/unordered/test/helpers/exception_test.hpp | 2
branches/proto/v4/libs/unordered/test/objects/memory.hpp | 4
branches/proto/v4/libs/unordered/test/unordered/Jamfile.v2 | 2
branches/proto/v4/libs/unordered/test/unordered/bucket_tests.cpp | 4
branches/proto/v4/libs/unordered/test/unordered/compile_tests.hpp | 2
branches/proto/v4/libs/unordered/test/unordered/constructor_tests.cpp | 4
branches/proto/v4/libs/unordered/test/unordered/copy_tests.cpp | 8
branches/proto/v4/libs/unordered/test/unordered/load_factor_tests.cpp | 4
branches/proto/v4/libs/unordered/test/unordered/move_tests.cpp | 18
branches/proto/v4/libs/unordered/test/unordered/rehash_tests.cpp | 4
branches/proto/v4/libs/unordered/test/unordered/swap_tests.cpp | 18
branches/proto/v4/tools/build/v2/build/toolset.jam | 8
branches/proto/v4/tools/build/v2/tools/darwin.jam | 13
branches/proto/v4/tools/build/v2/tools/make.jam | 16
branches/proto/v4/tools/build/v2/tools/msvc.jam | 10
branches/proto/v4/tools/build/v2/tools/python.jam | 617 ++++++++++++++++++++-------------------
branches/proto/v4/tools/build/v2/util/string.jam | 86 +++--
branches/proto/v4/tools/jam/src/execunix.c | 2
branches/proto/v4/tools/regression/xsl_reports/build_results.sh | 5
74 files changed, 1412 insertions(+), 726 deletions(-)
Modified: branches/proto/v4/boost/asio/detail/null_thread.hpp
==============================================================================
--- branches/proto/v4/boost/asio/detail/null_thread.hpp (original)
+++ branches/proto/v4/boost/asio/detail/null_thread.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -39,9 +39,12 @@
: private noncopyable
{
public:
+ // The purpose of the thread.
+ enum purpose { internal, external };
+
// Constructor.
template <typename Function>
- null_thread(Function f)
+ null_thread(Function f, purpose = internal)
{
boost::system::system_error e(
boost::asio::error::operation_not_supported, "thread");
Modified: branches/proto/v4/boost/asio/detail/posix_thread.hpp
==============================================================================
--- branches/proto/v4/boost/asio/detail/posix_thread.hpp (original)
+++ branches/proto/v4/boost/asio/detail/posix_thread.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -43,9 +43,12 @@
: private noncopyable
{
public:
+ // The purpose of the thread.
+ enum purpose { internal, external };
+
// Constructor.
template <typename Function>
- posix_thread(Function f)
+ posix_thread(Function f, purpose = internal)
: joined_(false)
{
std::auto_ptr<func_base> arg(new func<Function>(f));
Modified: branches/proto/v4/boost/asio/detail/win_thread.hpp
==============================================================================
--- branches/proto/v4/boost/asio/detail/win_thread.hpp (original)
+++ branches/proto/v4/boost/asio/detail/win_thread.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -44,17 +44,53 @@
: private noncopyable
{
public:
+ // The purpose of the thread.
+ enum purpose { internal, external };
+
// Constructor.
template <typename Function>
- win_thread(Function f)
+ win_thread(Function f, purpose p = internal)
+ : exit_event_(0)
{
std::auto_ptr<func_base> arg(new func<Function>(f));
+
+ ::HANDLE entry_event = 0;
+ if (p == internal)
+ {
+ arg->entry_event_ = entry_event = ::CreateEvent(0, true, false, 0);
+ if (!entry_event)
+ {
+ DWORD last_error = ::GetLastError();
+ boost::system::system_error e(
+ boost::system::error_code(last_error,
+ boost::asio::error::get_system_category()),
+ "thread.entry_event");
+ boost::throw_exception(e);
+ }
+
+ arg->exit_event_ = exit_event_ = ::CreateEvent(0, true, false, 0);
+ if (!exit_event_)
+ {
+ DWORD last_error = ::GetLastError();
+ ::CloseHandle(entry_event);
+ boost::system::system_error e(
+ boost::system::error_code(last_error,
+ boost::asio::error::get_system_category()),
+ "thread.exit_event");
+ boost::throw_exception(e);
+ }
+ }
+
unsigned int thread_id = 0;
thread_ = reinterpret_cast<HANDLE>(::_beginthreadex(0, 0,
win_thread_function, arg.get(), 0, &thread_id));
if (!thread_)
{
DWORD last_error = ::GetLastError();
+ if (entry_event)
+ ::CloseHandle(entry_event);
+ if (exit_event_)
+ ::CloseHandle(exit_event_);
boost::system::system_error e(
boost::system::error_code(last_error,
boost::asio::error::get_system_category()),
@@ -62,18 +98,36 @@
boost::throw_exception(e);
}
arg.release();
+
+ if (entry_event)
+ {
+ ::WaitForSingleObject(entry_event, INFINITE);
+ ::CloseHandle(entry_event);
+ }
}
// Destructor.
~win_thread()
{
::CloseHandle(thread_);
+
+ // The exit_event_ handle is deliberately allowed to leak here since it
+ // is an error for the owner of an internal thread not to join() it.
}
// Wait for the thread to exit.
void join()
{
- ::WaitForSingleObject(thread_, INFINITE);
+ if (exit_event_)
+ {
+ ::WaitForSingleObject(exit_event_, INFINITE);
+ ::CloseHandle(exit_event_);
+ ::TerminateThread(thread_, 0);
+ }
+ else
+ {
+ ::WaitForSingleObject(thread_, INFINITE);
+ }
}
private:
@@ -84,6 +138,8 @@
public:
virtual ~func_base() {}
virtual void run() = 0;
+ ::HANDLE entry_event_;
+ ::HANDLE exit_event_;
};
template <typename Function>
@@ -106,13 +162,26 @@
};
::HANDLE thread_;
+ ::HANDLE exit_event_;
};
inline unsigned int __stdcall win_thread_function(void* arg)
{
std::auto_ptr<win_thread::func_base> func(
static_cast<win_thread::func_base*>(arg));
+
+ if (func->entry_event_)
+ ::SetEvent(func->entry_event_);
+
func->run();
+
+ if (HANDLE exit_event = func->exit_event_)
+ {
+ func.reset();
+ ::SetEvent(exit_event);
+ ::Sleep(INFINITE);
+ }
+
return 0;
}
Modified: branches/proto/v4/boost/asio/detail/wince_thread.hpp
==============================================================================
--- branches/proto/v4/boost/asio/detail/wince_thread.hpp (original)
+++ branches/proto/v4/boost/asio/detail/wince_thread.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -43,9 +43,12 @@
: private noncopyable
{
public:
+ // The purpose of the thread.
+ enum purpose { internal, external };
+
// Constructor.
template <typename Function>
- wince_thread(Function f)
+ wince_thread(Function f, purpose = internal)
{
std::auto_ptr<func_base> arg(new func<Function>(f));
DWORD thread_id = 0;
Modified: branches/proto/v4/boost/config/stdlib/stlport.hpp
==============================================================================
--- branches/proto/v4/boost/config/stdlib/stlport.hpp (original)
+++ branches/proto/v4/boost/config/stdlib/stlport.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -98,8 +98,10 @@
//
// We always have SGI style hash_set, hash_map, and slist:
//
+#ifndef _STLP_NO_EXTENSIONS
#define BOOST_HAS_HASH
#define BOOST_HAS_SLIST
+#endif
//
// STLport does a good job of importing names into namespace std::,
Modified: branches/proto/v4/boost/foreach.hpp
==============================================================================
--- branches/proto/v4/boost/foreach.hpp (original)
+++ branches/proto/v4/boost/foreach.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -42,7 +42,7 @@
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
|| (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x570)) \
- || BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
+ || BOOST_WORKAROUND(__DECCXX_VER, <= 60590042)
# define BOOST_FOREACH_NO_RVALUE_DETECTION
# endif
// Some compilers do not correctly implement the lvalue/rvalue conversion
Modified: branches/proto/v4/boost/iostreams/chain.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/chain.hpp (original)
+++ branches/proto/v4/boost/iostreams/chain.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -229,9 +229,9 @@
void push_impl(const T& t, int buffer_size = -1, int pback_size = -1)
{
typedef typename iostreams::category_of<T>::type category;
- typedef typename unwrap_ios<T>::type policy_type;
+ typedef typename unwrap_ios<T>::type component_type;
typedef stream_buffer<
- policy_type,
+ component_type,
BOOST_IOSTREAMS_CHAR_TRAITS(char_type),
Alloc, Mode
> streambuf_t;
@@ -252,7 +252,7 @@
buf(new streambuf_t(t, buffer_size, pback_size));
list().push_back(buf.get());
buf.release();
- if (is_device<policy_type>::value) {
+ if (is_device<component_type>::value) {
pimpl_->flags_ |= f_complete | f_open;
for ( iterator first = list().begin(),
last = list().end();
Modified: branches/proto/v4/boost/iostreams/code_converter.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/code_converter.hpp (original)
+++ branches/proto/v4/boost/iostreams/code_converter.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -138,8 +138,8 @@
is_direct<Device>,
direct_adapter<Device>,
Device
- >::type policy_type;
- typedef optional< concept_adapter<policy_type> > storage_type;
+ >::type device_type;
+ typedef optional< concept_adapter<device_type> > storage_type;
typedef is_convertible<device_category, two_sequence> is_double;
typedef conversion_buffer<Codecvt, Alloc> buffer_type;
@@ -168,7 +168,7 @@
buf_.second().resize(buffer_size);
buf_.second().set(0, 0);
}
- dev_.reset(concept_adapter<policy_type>(dev));
+ dev_.reset(concept_adapter<device_type>(dev));
flags_ = f_open;
}
@@ -200,7 +200,7 @@
bool is_open() const { return (flags_ & f_open) != 0;}
- policy_type& dev() { return **dev_; }
+ device_type& dev() { return **dev_; }
enum flag_type {
f_open = 1,
@@ -243,7 +243,7 @@
typedef detail::code_converter_impl<
Device, Codecvt, Alloc
> impl_type;
- typedef typename impl_type::policy_type policy_type;
+ typedef typename impl_type::device_type device_type;
typedef typename impl_type::buffer_type buffer_type;
typedef typename detail::codecvt_holder<Codecvt>::codecvt_type codecvt_type;
typedef typename detail::codecvt_intern<Codecvt>::type intern_type;
@@ -298,7 +298,7 @@
}
const codecvt_type& cvt() { return impl().cvt_.get(); }
- policy_type& dev() { return impl().dev(); }
+ device_type& dev() { return impl().dev(); }
buffer_type& in() { return impl().buf_.first(); }
buffer_type& out() { return impl().buf_.second(); }
impl_type& impl() { return *this->pimpl_; }
Modified: branches/proto/v4/boost/iostreams/combine.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/combine.hpp (original)
+++ branches/proto/v4/boost/iostreams/combine.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -45,6 +45,10 @@
//
template<typename Source, typename Sink>
class combined_device {
+private:
+ typedef typename category_of<Source>::type in_category;
+ typedef typename category_of<Sink>::type out_category;
+ typedef typename char_type_of<Sink>::type sink_char_type;
public:
typedef typename char_type_of<Source>::type char_type;
struct category
@@ -53,6 +57,11 @@
closable_tag,
localizable_tag
{ };
+ BOOST_STATIC_ASSERT(is_device<Source>::value);
+ BOOST_STATIC_ASSERT(is_device<Sink>::value);
+ BOOST_STATIC_ASSERT((is_convertible<in_category, input>::value));
+ BOOST_STATIC_ASSERT((is_convertible<out_category, output>::value));
+ BOOST_STATIC_ASSERT((is_same<char_type, sink_char_type>::value));
combined_device(const Source& src, const Sink& snk);
std::streamsize read(char_type* s, std::streamsize n);
std::streamsize write(const char_type* s, std::streamsize n);
@@ -61,8 +70,6 @@
void imbue(const std::locale& loc);
#endif
private:
- typedef typename char_type_of<Sink>::type sink_char_type;
- BOOST_STATIC_ASSERT((is_same<char_type, sink_char_type>::value));
Source src_;
Sink sink_;
};
@@ -81,6 +88,7 @@
private:
typedef typename category_of<InputFilter>::type in_category;
typedef typename category_of<OutputFilter>::type out_category;
+ typedef typename char_type_of<OutputFilter>::type output_char_type;
public:
typedef typename char_type_of<InputFilter>::type char_type;
struct category
@@ -88,6 +96,11 @@
closable_tag,
localizable_tag
{ };
+ BOOST_STATIC_ASSERT(is_filter<InputFilter>::value);
+ BOOST_STATIC_ASSERT(is_filter<OutputFilter>::value);
+ BOOST_STATIC_ASSERT((is_convertible<in_category, input>::value));
+ BOOST_STATIC_ASSERT((is_convertible<out_category, output>::value));
+ BOOST_STATIC_ASSERT((is_same<char_type, output_char_type>::value));
combined_filter(const InputFilter& in, const OutputFilter& out);
template<typename Source>
@@ -120,8 +133,6 @@
void imbue(const std::locale& loc);
#endif
private:
- typedef typename char_type_of<OutputFilter>::type output_char_type;
- BOOST_STATIC_ASSERT((is_same<char_type, output_char_type>::value));
InputFilter in_;
OutputFilter out_;
};
Modified: branches/proto/v4/boost/iostreams/compose.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/compose.hpp (original)
+++ branches/proto/v4/boost/iostreams/compose.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -74,6 +74,8 @@
is_std_io<Device>, Device&,
else_, Device
>::type value_type;
+ BOOST_STATIC_ASSERT(is_filter<Filter>::value);
+ BOOST_STATIC_ASSERT(is_device<Device>::value);
public:
typedef typename char_type_of<Filter>::type char_type;
struct category
@@ -140,6 +142,8 @@
!(is_convertible<first_mode, output>::value) ||
(is_convertible<first_mode, dual_use>::value)
);
+ BOOST_STATIC_ASSERT(is_filter<Filter1>::value);
+ BOOST_STATIC_ASSERT(is_filter<Filter2>::value);
public:
typedef typename char_type_of<Filter1>::type char_type;
struct category
Modified: branches/proto/v4/boost/iostreams/detail/adapter/mode_adapter.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/detail/adapter/mode_adapter.hpp (original)
+++ branches/proto/v4/boost/iostreams/detail/adapter/mode_adapter.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -31,7 +31,7 @@
private:
struct empty_base { };
public:
- typedef typename wrapped_type<T>::type policy_type;
+ typedef typename wrapped_type<T>::type component_type;
typedef typename char_type_of<T>::type char_type;
struct category
: Mode,
@@ -43,7 +43,7 @@
#endif
localizable_tag
{ };
- explicit mode_adapter(const policy_type& t) : t_(t) { }
+ explicit mode_adapter(const component_type& t) : t_(t) { }
// Device member functions.
@@ -88,7 +88,7 @@
void imbue(const Locale& loc)
{ iostreams::imbue(t_, loc); }
private:
- policy_type t_;
+ component_type t_;
};
//------------------Implementation of mode_adapter----------------------------//
Modified: branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream.hpp (original)
+++ branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -35,7 +35,6 @@
detail::stream_traits<
Device, Tr
>::stream_type stream_type;
- typedef Device policy_type;
public:
stream() { }
template<typename U0>
Modified: branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp (original)
+++ branches/proto/v4/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -35,7 +35,6 @@
detail::stream_buffer_traits<
T, Tr, Alloc, Mode
>::type base_type;
- typedef T policy_type;
public:
typedef typename char_type_of<T>::type char_type;
struct category
Modified: branches/proto/v4/boost/iostreams/detail/buffer.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/detail/buffer.hpp (original)
+++ branches/proto/v4/boost/iostreams/detail/buffer.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -104,11 +104,6 @@
iostreams::read(src, this->data() + keep, this->size() - keep);
if (result != -1)
this->set(0, keep + result);
- //return result == this->size() - keep ?
- // traits_type::good() :
- // keep == -1 ?
- // traits_type::eof() :
- // traits_type::would_block();
return result == -1 ?
traits_type::eof() :
result == 0 ?
Modified: branches/proto/v4/boost/iostreams/detail/forward.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/detail/forward.hpp (original)
+++ branches/proto/v4/boost/iostreams/detail/forward.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -12,7 +12,7 @@
# pragma once
#endif
-#include <boost/config.hpp> // BOOST_MSVC
+#include <boost/config.hpp> // BOOST_MSVC, BOOST_NO_SFINAE
#include <boost/detail/workaround.hpp>
#include <boost/iostreams/detail/config/limits.hpp>
#include <boost/iostreams/detail/push_params.hpp>
@@ -23,36 +23,43 @@
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
+#include <boost/type_traits/is_same.hpp>
//------Macros for defining forwarding constructors and open overloads--------//
//
-// Macro: BOOST_IOSTREAMS_DEFINE_FORWARDING_FUNCTIONS(mode, name, helper).
+// Macro: BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args)
// Description: Defines constructors and overloads of 'open' which construct
-// a device using the given argument list and pass it to 'open_impl'.
-// Assumes that 'policy_type' is an alias for the device type.
-// Not supported on Intel 7.1 and VC6.5.
+// a device using the specified argument list and pass it to the specified
+// helper function
+// class - The class name
+// impl - The helper function
+// device - The device type
+// params - The list of formal parameters trailing the device parameter in
+// the helper function's signature
+// params - The list of arguments passed to the helper function, following the
+// device argument
//
-#define BOOST_IOSTREAMS_FORWARD(class, impl, policy, params, args) \
- class(const policy& t params()) \
+#define BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args) \
+ class(const device& t params()) \
{ this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- class(policy& t params()) \
+ class(device& t params()) \
{ this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- class(const ::boost::reference_wrapper<policy>& ref params()) \
+ class(const ::boost::reference_wrapper<device>& ref params()) \
{ this->impl(ref args()); } \
- void open(const policy& t params()) \
+ void open(const device& t params()) \
{ this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- void open(policy& t params()) \
+ void open(device& t params()) \
{ this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- void open(const ::boost::reference_wrapper<policy>& ref params()) \
+ void open(const ::boost::reference_wrapper<device>& ref params()) \
{ this->impl(ref args()); } \
BOOST_PP_REPEAT_FROM_TO( \
1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
- BOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, policy) \
+ BOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, device) \
) \
BOOST_PP_REPEAT_FROM_TO( \
1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
- BOOST_IOSTREAMS_FORWARDING_FN, (class, impl, policy) \
+ BOOST_IOSTREAMS_FORWARDING_FN, (class, impl, device) \
) \
/**/
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
@@ -61,7 +68,8 @@
BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
- BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u)) \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
{ this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
@@ -72,7 +80,8 @@
BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
void open \
( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
- BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u)) \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
{ this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u) ); } \
@@ -84,7 +93,8 @@
#define BOOST_IOSTREAMS_FORWARDING_CTOR(z, n, tuple) \
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
- (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u)) \
+ (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
{ this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
(BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
@@ -92,11 +102,23 @@
/**/
#define BOOST_IOSTREAMS_FORWARDING_FN(z, n, tuple) \
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
- void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u)) \
+ void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
{ this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
(BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
/**/
+// Disable forwarding constructors if first parameter type is the same
+// as the device type
+#if !defined(BOOST_NO_SFINAE) && \
+ !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
+# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param) \
+ , typename boost::disable_if< boost::is_same<device, param> >::type* = 0 \
+ /**/
+#else
+# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param)
+#endif
+
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED
Modified: branches/proto/v4/boost/iostreams/device/file.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/device/file.hpp (original)
+++ branches/proto/v4/boost/iostreams/device/file.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -51,6 +51,7 @@
BOOST_IOS::openmode base_mode =
BOOST_IOS::in | BOOST_IOS::out );
std::streamsize read(char_type* s, std::streamsize n);
+ bool putback(char_type c);
std::streamsize write(const char_type* s, std::streamsize n);
std::streampos seek( stream_offset off, BOOST_IOS::seekdir way,
BOOST_IOS::openmode which =
@@ -87,6 +88,7 @@
closable_tag
{ };
using basic_file<Ch>::read;
+ using basic_file<Ch>::putback;
using basic_file<Ch>::seek;
using basic_file<Ch>::is_open;
using basic_file<Ch>::close;
@@ -150,6 +152,12 @@
}
template<typename Ch>
+inline bool basic_file<Ch>::putback(char_type c)
+{
+ return !!pimpl_->file_.sputbackc(c);
+}
+
+template<typename Ch>
inline std::streamsize basic_file<Ch>::write
(const char_type* s, std::streamsize n)
{ return pimpl_->file_.sputn(s, n); }
Modified: branches/proto/v4/boost/iostreams/filter/gzip.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/filter/gzip.hpp (original)
+++ branches/proto/v4/boost/iostreams/filter/gzip.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -19,6 +19,7 @@
#include <boost/config.hpp> // STATIC_CONSTANT, STDC_NAMESPACE,
// DINKUMWARE_STDLIB, __STL_CONFIG_H.
#include <algorithm> // min.
+#include <cassert>
#include <cstdio> // EOF.
#include <cstddef> // size_t.
#include <ctime> // std::time_t.
@@ -34,7 +35,8 @@
#include <boost/iostreams/operations.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filter/zlib.hpp>
-#include <boost/iostreams/pipeline.hpp>
+#include <boost/iostreams/pipeline.hpp>
+#include <boost/iostreams/putback.hpp>
// Must come last.
#if defined(BOOST_MSVC)
@@ -47,6 +49,8 @@
#endif
namespace boost { namespace iostreams {
+
+//------------------Definitions of constants----------------------------------//
namespace gzip {
@@ -59,6 +63,7 @@
const int bad_length = 3; // Recorded length doesn't match data.
const int bad_header = 4; // Malformed header.
const int bad_footer = 5; // Malformed footer.
+const int bad_method = 6; // Unsupported compression method.
namespace magic {
@@ -118,6 +123,8 @@
} // End namespace gzip.
+//------------------Definition of gzip_params---------------------------------//
+
//
// Class name: gzip_params.
// Description: Subclass of zlib_params with an additional field
@@ -142,6 +149,8 @@
std::time_t mtime;
};
+//------------------Definition of gzip_error----------------------------------//
+
//
// Class name: gzip_error.
// Description: Subclass of std::ios_base::failure thrown to indicate
@@ -163,6 +172,8 @@
int zlib_error_code_;
};
+//------------------Definition of gzip_compressor-----------------------------//
+
//
// Template name: gzip_compressor
// Description: Model of OutputFilter implementing compression in the
@@ -283,7 +294,7 @@
flags_ = 0;
}
- enum flag_type {
+ enum state_type {
f_header_done = 1,
f_body_done = f_header_done << 1,
f_footer_done = f_body_done << 1
@@ -297,6 +308,81 @@
typedef basic_gzip_compressor<> gzip_compressor;
+//------------------Definition of helper templates for decompression----------//
+
+namespace detail {
+
+// Processes gzip headers
+class gzip_header {
+public:
+ gzip_header() { reset(); }
+
+ // Members for processing header data
+ void process(char c);
+ bool done() const { return state_ == s_done; }
+ void reset();
+
+ // Members for accessing header data
+ std::string file_name() const { return file_name_; }
+ std::string comment() const { return comment_; }
+ bool text() const { return (flags_ & gzip::flags::text) != 0; }
+ int os() const { return os_; }
+ std::time_t mtime() const { return mtime_; }
+private:
+ enum state_type {
+ s_id1 = 1,
+ s_id2 = s_id1 + 1,
+ s_cm = s_id2 + 1,
+ s_flg = s_cm + 1,
+ s_mtime = s_flg + 1,
+ s_xfl = s_mtime + 1,
+ s_os = s_xfl + 1,
+ s_xlen = s_os + 1,
+ s_extra = s_xlen + 1,
+ s_name = s_extra + 1,
+ s_comment = s_name + 1,
+ s_hcrc = s_comment + 1,
+ s_done = s_hcrc + 1
+ };
+ std::string file_name_;
+ std::string comment_;
+ int os_;
+ std::time_t mtime_;
+ int flags_;
+ int state_;
+ int offset_; // Offset within fixed-length region.
+ int xlen_; // Bytes remaining in extra field.
+};
+
+// Processes gzip footers
+class gzip_footer {
+public:
+ gzip_footer() { reset(); }
+
+ // Members for processing footer data
+ void process(char c);
+ bool done() const { return state_ == s_done; }
+ void reset();
+
+ // Members for accessing footer data
+ zlib::ulong crc() const { return crc_; }
+ zlib::ulong uncompressed_size() const { return isize_; }
+private:
+ enum state_type {
+ s_crc = 1,
+ s_isize = s_crc + 1,
+ s_done = s_isize + 1
+ };
+ zlib::ulong crc_;
+ zlib::ulong isize_;
+ int state_;
+ int offset_;
+};
+
+} // End namespace boost::iostreams::detail.
+
+//------------------Definition of basic_gzip_decompressor---------------------//
+
//
// Template name: basic_gzip_decompressor
// Description: Model of InputFilter implementing compression in the
@@ -304,6 +390,9 @@
//
template<typename Alloc = std::allocator<char> >
class basic_gzip_decompressor : basic_zlib_decompressor<Alloc> {
+private:
+ typedef basic_zlib_decompressor<Alloc> base_type;
+ typedef typename base_type::string_type string_type;
public:
typedef char char_type;
struct category
@@ -316,35 +405,72 @@
template<typename Source>
std::streamsize read(Source& src, char_type* s, std::streamsize n)
{
- if ((flags_ & f_header_read) == 0) {
- non_blocking_adapter<Source> nb(src);
- read_header(nb);
- flags_ |= f_header_read;
- }
-
- if ((flags_ & f_footer_read) != 0)
- return -1;
-
- try {
- std::streamsize result = 0;
- std::streamsize amt;
- if ((amt = base_type::read(src, s, n)) != -1) {
- result += amt;
- if (amt < n) { // Double check for EOF.
- amt = base_type::read(src, s + result, n - result);
- if (amt != -1)
+ typedef char_traits<char> traits_type;
+ std::streamsize result = 0;
+ peekable_source<Source> peek(src, putback_);
+ while (result < n && state_ != s_done) {
+ if (state_ == s_start) {
+ state_ = s_header;
+ header_.reset();
+ footer_.reset();
+ }
+ if (state_ == s_header) {
+ int c = boost::iostreams::get(peek);
+ if (traits_type::is_eof(c)) {
+ throw gzip_error(gzip::bad_header);
+ } else if (traits_type::would_block(c)) {
+ break;
+ }
+ header_.process(c);
+ if (header_.done())
+ state_ = s_body;
+ } else if (state_ == s_body) {
+ try {
+ std::streamsize amt =
+ base_type::read(peek, s + result, n - result);
+ if (amt != -1) {
result += amt;
+ if (amt < n - result)
+ break;
+ } else {
+ peek.putback(this->unconsumed_input());
+ state_ = s_footer;
+ }
+ } catch (const zlib_error& e) {
+ throw gzip_error(e);
+ }
+ } else { // state_ == s_footer
+ int c = boost::iostreams::get(peek);
+ if (traits_type::is_eof(c)) {
+ throw gzip_error(gzip::bad_footer);
+ } else if (traits_type::would_block(c)) {
+ break;
+ }
+ footer_.process(c);
+ if (footer_.done()) {
+ if (footer_.crc() != this->crc())
+ throw gzip_error(gzip::bad_crc);
+ int c = boost::iostreams::get(peek);
+ if (traits_type::is_eof(c)) {
+ state_ = s_done;
+ } else {
+ peek.putback(c);
+ base_type::close(peek, BOOST_IOS::in);
+ state_ = s_start;
+ header_.reset();
+ footer_.reset();
+ }
}
}
- if (amt == -1) {
- non_blocking_adapter<Source> nb(src);
- read_footer(nb);
- flags_ |= f_footer_read;
- }
- return result;
- } catch (const zlib_error& e) {
- throw gzip_error(e);
}
+ if (peek.has_unconsumed_input()) {
+ putback_ = peek.unconsumed_input();
+ } else {
+ putback_.clear();
+ }
+ return result != 0 || state_ != s_done ?
+ result :
+ -1;
}
template<typename Source>
@@ -353,136 +479,95 @@
try {
base_type::close(src, BOOST_IOS::in);
} catch (const zlib_error& e) {
- flags_ = 0;
+ state_ = s_start;
+ header_.reset();
+ footer_.reset();
throw gzip_error(e);
}
- flags_ = 0;
+ state_ = s_start;
}
- std::string file_name() const { return file_name_; }
- std::string comment() const { return comment_; }
- bool text() const { return (flags_ & gzip::flags::text) != 0; }
- int os() const { return os_; }
- std::time_t mtime() const { return mtime_; }
+ std::string file_name() const { return header_.file_name(); }
+ std::string comment() const { return header_.comment(); }
+ bool text() const { return header_.text(); }
+ int os() const { return header_.os(); }
+ std::time_t mtime() const { return header_.mtime(); }
private:
- typedef basic_zlib_decompressor<Alloc> base_type;
- typedef BOOST_IOSTREAMS_CHAR_TRAITS(char) traits_type;
- static bool is_eof(int c) { return traits_type::eq_int_type(c, EOF); }
static gzip_params make_params(int window_bits);
+ // Source adapter allowing an arbitrary character sequence to be put back.
template<typename Source>
- static uint8_t read_uint8(Source& src, int error)
- {
- int c;
- if ((c = boost::iostreams::get(src)) == EOF || c == WOULD_BLOCK)
- throw gzip_error(error);
- return static_cast<uint8_t>(traits_type::to_char_type(c));
- }
+ struct peekable_source {
+ typedef char char_type;
+ struct category : source_tag, peekable_tag { };
+ explicit peekable_source(Source& src, const string_type& putback = "")
+ : src_(src), putback_(putback), offset_(0)
+ { }
+ std::streamsize read(char* s, std::streamsize n)
+ {
+ std::streamsize result = 0;
- template<typename Source>
- static uint32_t read_uint32(Source& src, int error)
- {
- uint8_t b1 = read_uint8(src, error);
- uint8_t b2 = read_uint8(src, error);
- uint8_t b3 = read_uint8(src, error);
- uint8_t b4 = read_uint8(src, error);
- return b1 + (b2 << 8) + (b3 << 16) + (b4 << 24);
- }
+ // Copy characters from putback buffer
+ std::streamsize pbsize =
+ static_cast<std::streamsize>(putback_.size());
+ if (offset_ < pbsize) {
+ result = (std::min)(n, pbsize - offset_);
+ BOOST_IOSTREAMS_CHAR_TRAITS(char)::copy(
+ s, putback_.data() + offset_, result);
+ offset_ += result;
+ if (result == n)
+ return result;
+ }
- template<typename Source>
- std::string read_string(Source& src)
- {
- std::string result;
- while (true) {
- int c;
- if (is_eof(c = boost::iostreams::get(src)))
- throw gzip_error(gzip::bad_header);
- else if (c == 0)
- return result;
- else
- result += static_cast<char>(c);
+ // Read characters from src_
+ std::streamsize amt =
+ boost::iostreams::read(src_, s + result, n - result);
+ return amt != -1 ?
+ result + amt :
+ result ? result : -1;
+ }
+ bool putback(char c)
+ {
+ if (offset_) {
+ putback_[--offset_] = c;
+ return true;
+ } else {
+ return boost::iostreams::putback(src_, c);
+ }
+ }
+ void putback(const string_type& s)
+ {
+ putback_.replace(0, offset_, s);
+ offset_ = 0;
}
- }
-
- template<typename Source>
- void read_header(Source& src) // Source is non-blocking.
- {
- // Reset saved values.
- #if BOOST_WORKAROUND(__GNUC__, == 2) && defined(__STL_CONFIG_H) || \
- BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) \
- /**/
- file_name_.erase(0, std::string::npos);
- comment_.erase(0, std::string::npos);
- #else
- file_name_.clear();
- comment_.clear();
- #endif
- os_ = gzip::os_unknown;
- mtime_ = 0;
-
- int flags;
- // Read header, without checking header crc.
- if ( boost::iostreams::get(src) != gzip::magic::id1 || // ID1.
- boost::iostreams::get(src) != gzip::magic::id2 || // ID2.
- is_eof(boost::iostreams::get(src)) || // CM.
- is_eof(flags = boost::iostreams::get(src)) ) // FLG.
+ // Returns true if some characters have been putback but not re-read.
+ bool has_unconsumed_input() const
{
- throw gzip_error(gzip::bad_header);
+ return offset_ < static_cast<std::streamsize>(putback_.size());
}
- mtime_ = read_uint32(src, gzip::bad_header); // MTIME.
- read_uint8(src, gzip::bad_header); // XFL.
- os_ = read_uint8(src, gzip::bad_header); // OS.
- if (flags & boost::iostreams::gzip::flags::text)
- flags_ |= f_text;
-
- // Skip extra field. (From J. Halleaux; see note at top.)
- if (flags & gzip::flags::extra) {
- int length =
- static_cast<int>(
- read_uint8(src, gzip::bad_header) +
- (read_uint8(src, gzip::bad_header) << 8)
- );
- // length is garbage if EOF but the loop below will quit anyway.
- do { }
- while (length-- != 0 && !is_eof(boost::iostreams::get(src)));
- }
-
- if (flags & gzip::flags::name) // Read file name.
- file_name_ = read_string(src);
- if (flags & gzip::flags::comment) // Read comment.
- comment_ = read_string(src);
- if (flags & gzip::flags::header_crc) { // Skip header crc.
- read_uint8(src, gzip::bad_header);
- read_uint8(src, gzip::bad_header);
+
+ // Returns the sequence of characters that have been put back but not re-read.
+ string_type unconsumed_input() const
+ {
+ return string_type(putback_, offset_, putback_.size() - offset_);
}
- }
+ Source& src_;
+ string_type putback_;
+ std::streamsize offset_;
+ };
- template<typename Source>
- void read_footer(Source& src)
- {
- typename base_type::string_type footer =
- this->unconsumed_input();
- int c;
- while (!is_eof(c = boost::iostreams::get(src)))
- footer += c;
- detail::range_adapter<input, std::string>
- rng(footer.begin(), footer.end());
- if (read_uint32(rng, gzip::bad_footer) != this->crc())
- throw gzip_error(gzip::bad_crc);
- if (static_cast<int>(read_uint32(rng, gzip::bad_footer)) != this->total_out())
- throw gzip_error(gzip::bad_length);
- }
- enum flag_type {
- f_header_read = 1,
- f_footer_read = f_header_read << 1,
- f_text = f_footer_read << 1
+ enum state_type {
+ s_start = 1,
+ s_header = s_start + 1,
+ s_body = s_header + 1,
+ s_footer = s_body + 1,
+ s_done = s_footer + 1
};
- std::string file_name_;
- std::string comment_;
- int os_;
- std::time_t mtime_;
- int flags_;
+ detail::gzip_header header_;
+ detail::gzip_footer footer_;
+ string_type putback_;
+ int state_;
};
BOOST_IOSTREAMS_PIPABLE(basic_gzip_decompressor, 1)
@@ -574,13 +659,164 @@
return amt;
}
+//------------------Implementation of gzip_header-----------------------------//
+
+namespace detail {
+
+void gzip_header::process(char c)
+{
+ uint8_t value = static_cast<uint8_t>(c);
+ switch (state_) {
+ case s_id1:
+ if (value != gzip::magic::id1)
+ throw gzip_error(gzip::bad_header);
+ state_ = s_id2;
+ break;
+ case s_id2:
+ if (value != gzip::magic::id2)
+ throw gzip_error(gzip::bad_header);
+ state_ = s_cm;
+ break;
+ case s_cm:
+ if (value != gzip::method::deflate)
+ throw gzip_error(gzip::bad_method);
+ state_ = s_flg;
+ break;
+ case s_flg:
+ flags_ = value;
+ state_ = s_mtime;
+ break;
+ case s_mtime:
+ mtime_ += value << (offset_ * 8);
+ if (offset_ == 3) {
+ state_ = s_xfl;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ break;
+ case s_xfl:
+ state_ = s_os;
+ break;
+ case s_os:
+ os_ = value;
+ if (flags_ & gzip::flags::extra) {
+ state_ = s_extra;
+ } else if (flags_ & gzip::flags::name) {
+ state_ = s_name;
+ } else if (flags_ & gzip::flags::comment) {
+ state_ = s_comment;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ break;
+ case s_xlen:
+ xlen_ += value << (offset_ * 8);
+ if (offset_ == 1) {
+ state_ = s_extra;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ break;
+ case s_extra:
+ if (--xlen_ == 0) {
+ if (flags_ & gzip::flags::name) {
+ state_ = s_name;
+ } else if (flags_ & gzip::flags::comment) {
+ state_ = s_comment;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ }
+ break;
+ case s_name:
+ if (c != 0) {
+ file_name_ += c;
+ } else if (flags_ & gzip::flags::comment) {
+ state_ = s_comment;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ break;
+ case s_comment:
+ if (c != 0) {
+ comment_ += c;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ break;
+ case s_hcrc:
+ if (offset_ == 1) {
+ state_ = s_done;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ break;
+ default:
+ assert(0);
+ }
+}
+
+void gzip_header::reset()
+{
+ file_name_.clear();
+ comment_.clear();
+ os_ = flags_ = offset_ = xlen_ = 0;
+ mtime_ = 0;
+ state_ = s_id1;
+}
+
+//------------------Implementation of gzip_footer-----------------------------//
+
+void gzip_footer::process(char c)
+{
+ uint8_t value = static_cast<uint8_t>(c);
+ if (state_ == s_crc) {
+ crc_ += value << (offset_ * 8);
+ if (offset_ == 3) {
+ state_ = s_isize;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ } else if (state_ == s_isize) {
+ isize_ += value << (offset_ * 8);
+ if (offset_ == 3) {
+ state_ = s_done;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ } else {
+ assert(0);
+ }
+}
+
+void gzip_footer::reset()
+{
+ crc_ = isize_ = offset_ = 0;
+ state_ = s_crc;
+}
+
+} // End namespace boost::iostreams::detail.
+
//------------------Implementation of gzip_decompressor-----------------------//
template<typename Alloc>
basic_gzip_decompressor<Alloc>::basic_gzip_decompressor
(int window_bits, int buffer_size)
: base_type(make_params(window_bits), buffer_size),
- os_(gzip::os_unknown), mtime_(0), flags_(0)
+ state_(s_start)
{ }
template<typename Alloc>
Modified: branches/proto/v4/boost/iostreams/filter/symmetric.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/filter/symmetric.hpp (original)
+++ branches/proto/v4/boost/iostreams/filter/symmetric.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -71,8 +71,9 @@
> >
class symmetric_filter {
public:
- typedef typename char_type_of<SymmetricFilter>::type char_type;
- typedef std::basic_string<char_type> string_type;
+ typedef typename char_type_of<SymmetricFilter>::type char_type;
+ typedef BOOST_IOSTREAMS_CHAR_TRAITS(char_type) traits_type;
+ typedef std::basic_string<char_type, traits_type, Alloc> string_type;
struct category
: dual_use,
filter_tag,
@@ -217,7 +218,6 @@
template<typename Sink>
bool flush(Sink& snk, mpl::true_)
{
- typedef char_traits<char_type> traits_type;
std::streamsize amt =
static_cast<std::streamsize>(buf().ptr() - buf().data());
std::streamsize result =
Modified: branches/proto/v4/boost/iostreams/invert.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/invert.hpp (original)
+++ branches/proto/v4/boost/iostreams/invert.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -44,6 +44,7 @@
template<typename Filter>
class inverse {
private:
+ BOOST_STATIC_ASSERT(is_filter<Filter>::value);
typedef typename category_of<Filter>::type base_category;
typedef reference_wrapper<Filter> filter_ref;
public:
Modified: branches/proto/v4/boost/iostreams/stream.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/stream.hpp (original)
+++ branches/proto/v4/boost/iostreams/stream.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -123,7 +123,6 @@
detail::stream_traits<
Device, Tr
>::stream_type stream_type;
- typedef Device policy_type;
public:
stream() { }
BOOST_IOSTREAMS_FORWARD( stream, open_impl, Device,
Modified: branches/proto/v4/boost/iostreams/stream_buffer.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/stream_buffer.hpp (original)
+++ branches/proto/v4/boost/iostreams/stream_buffer.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -73,7 +73,6 @@
detail::stream_buffer_traits<
T, Tr, Alloc, Mode
>::type base_type;
- typedef T policy_type;
public:
typedef typename char_type_of<T>::type char_type;
struct category
Modified: branches/proto/v4/boost/iostreams/tee.hpp
==============================================================================
--- branches/proto/v4/boost/iostreams/tee.hpp (original)
+++ branches/proto/v4/boost/iostreams/tee.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -48,6 +48,7 @@
optimally_buffered_tag
{ };
+ BOOST_STATIC_ASSERT(is_device<Device>::value);
BOOST_STATIC_ASSERT((
is_convertible< // Using mode_of causes failures on VC6-7.0.
BOOST_DEDUCED_TYPENAME iostreams::category_of<Device>::type, output
@@ -120,6 +121,8 @@
output,
input
>::type mode;
+ BOOST_STATIC_ASSERT(is_device<Device>::value);
+ BOOST_STATIC_ASSERT(is_device<Sink>::value);
BOOST_STATIC_ASSERT((
is_same<
char_type,
Modified: branches/proto/v4/boost/phoenix/scope/let.hpp
==============================================================================
--- branches/proto/v4/boost/phoenix/scope/let.hpp (original)
+++ branches/proto/v4/boost/phoenix/scope/let.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -148,6 +148,33 @@
};
};
+ #define LET_EXPR(Map, Right) \
+ proto::expr< \
+ tag::let_ \
+ , proto::list2<actor<proto::expr<proto::tag::terminal, proto::term<Map> > >,Right>\
+ > \
+ /**/
+
+ #define LOCAL_VAR(Tag) \
+ proto::expr<proto::tag::terminal, proto::term<local_variable<Tag> > > \
+ /**/
+
+ #define SUB_GRAMMAR(SubGrammar, Map) \
+ proto::or_< \
+ /* If the current expression is a local variable declared in*/ \
+ /* a let() call ...*/ \
+ proto::when< \
+ proto::if_<is_local_variable<Map> > \
+ /* ... evaluate it using the local variable evaluator*/ \
+ , local_variable_evaluator \
+ > \
+ /* Otherwise, defer handling of the current expression to the*/ \
+ /* currently active sub-grammar. This will also handle local*/ \
+ /* variables declared in outer let() expressions.*/ \
+ , SubGrammar \
+ > \
+ /**/
+
////////////////////////////////////////////////////////////////////////////////////////
template<typename Map, typename Callable = proto::callable>
struct is_local_variable : proto::transform<is_local_variable<Map> >
@@ -157,14 +184,94 @@
{
typedef mpl::false_ result_type;
};
-
+
template<typename Tag, typename State, typename Data>
- struct impl<proto::expr<proto::tag::terminal, proto::term<local_variable<Tag> > >, State, Data>
+ struct impl<LOCAL_VAR(Tag), State, Data>
{
typedef typename fusion::result_of::has_key<Map, Tag>::type result_type;
};
};
+ //////////////////////////////////////////////////////////////////////////////////////////
+ //template<typename SubGrammar, typename Callable = proto::callable>
+ //struct is_let_expression
+ // : proto::transform<is_let_expression<SubGrammar> >
+ //{
+ // template<typename Expr, typename, typename>
+ // struct impl
+ // {
+ // typedef mpl::false_ result_type;
+ // };
+
+ // template<typename Map, typename Right, typename State, typename Data>
+ // struct impl<LET_EXPR(Map, Right), State, Data>
+ // {
+ // typedef
+ // proto::or_<proto::if_<is_local_variable<Map> >, SubGrammar>
+ // sub_grammar;
+
+ // typedef
+ // proto::matches<Right, evaluator<SUB_GRAMMAR(SubGrammar, Map) > >
+ // result_type;
+ // };
+
+ // template<typename Map, typename Right, typename State, typename Data>
+ // struct impl<LET_EXPR(Map, Right) &, State, Data>
+ // : impl<LET_EXPR(Map, Right), State, Data>
+ // {};
+
+ // template<typename Map, typename Right, typename State, typename Data>
+ // struct impl<LET_EXPR(Map, Right) const &, State, Data>
+ // : impl<LET_EXPR(Map, Right), State, Data>
+ // {};
+ //};
+
+ //////////////////////////////////////////////////////////////////////////////////////////
+ //template<typename SubGrammar, typename Callable = proto::callable>
+ //struct evaluate_let_expression
+ // : proto::transform<evaluate_let_expression<SubGrammar> >
+ //{
+ // template<typename Expr, typename State, typename Data>
+ // struct impl
+ // : proto::transform_impl<Expr, State, Data>
+ // {
+ // typedef
+ // typename impl::expr
+ // expr;
+
+ // typedef
+ // typename expr::proto_child0::proto_base_expr::proto_child0
+ // map_type;
+ //
+ // typedef
+ // scope<map_type, typename impl::state_param, Data, SubGrammar>
+ // scope_type;
+
+ // typedef
+ // typename evaluator<SUB_GRAMMAR(SubGrammar, map_type) >::template impl<
+ // typename expr::proto_child1
+ // , scope_type
+ // , Data
+ // >
+ // evaluator_impl;
+
+ // typedef typename evaluator_impl::result_type result_type;
+ //
+ // result_type operator()(
+ // typename impl::expr_param expr
+ // , typename impl::state_param state
+ // , typename impl::data_param data
+ // ) const
+ // {
+ // return evaluator_impl()(
+ // expr.proto_base().child1
+ // , scope_type(expr.proto_base().child0.proto_base().child0, state, data)
+ // , data
+ // );
+ // }
+ // };
+ //};
+
////////////////////////////////////////////////////////////////////////////////////////
template<typename SubGrammar>
struct with_grammar
@@ -246,6 +353,10 @@
>
{};
};
+
+ #undef LET_EXPR
+ #undef LOCAL_VAR
+ #undef SUB_GRAMMAR
}
////////////////////////////////////////////////////////////////////////////////////////////
@@ -254,6 +365,10 @@
template<typename SubGrammar>
struct extension<tag::let_, SubGrammar>
: detail::with_grammar<SubGrammar>::let_extension
+ //: proto::when<
+ // proto::if_<detail::is_let_expression<SubGrammar> >
+ // , detail::evaluate_let_expression<SubGrammar>
+ // >
{};
////////////////////////////////////////////////////////////////////////////////////////////
Modified: branches/proto/v4/boost/spirit/home/lex/lexer.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/lex/lexer.hpp (original)
+++ branches/proto/v4/boost/spirit/home/lex/lexer.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -18,6 +18,7 @@
#include <boost/spirit/home/lex/lexer/string_token_def.hpp>
#include <boost/spirit/home/lex/lexer/sequence.hpp>
#include <boost/spirit/home/lex/lexer/action.hpp>
+#include <boost/spirit/home/lex/lexer/lexer_actions.hpp>
#include <boost/spirit/home/lex/lexer/lexer.hpp>
#include <boost/spirit/home/lex/lexer/meta_grammar.hpp>
Modified: branches/proto/v4/boost/spirit/home/lex/lexer/action.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/lex/lexer/action.hpp (original)
+++ branches/proto/v4/boost/spirit/home/lex/lexer/action.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -28,8 +28,8 @@
}
template <typename Range, typename LexerContext>
- void operator()(Range const&, std::size_t, LexerContext& ctx,
- bool&) const
+ void operator()(Range const&, std::size_t, bool&,
+ LexerContext& ctx) const
{
ctx.set_state_name(new_state);
}
Modified: branches/proto/v4/boost/spirit/home/lex/lexer/lexer_actions.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/lex/lexer/lexer_actions.hpp (original)
+++ branches/proto/v4/boost/spirit/home/lex/lexer/lexer_actions.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -25,7 +25,7 @@
}
template <typename Range, typename LexerContext>
- void operator()(Range const& r, std::size_t, LexerContext&, bool&) const
+ void operator()(Range const& r, std::size_t, bool&, LexerContext&) const
{
os << r;
}
Modified: branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp (original)
+++ branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -42,6 +42,7 @@
template <typename Iterator>
struct Data<Iterator, mpl::false_, mpl::false_>
{
+ typedef std::size_t state_type;
typedef iterator_range<Iterator> iterpair_type;
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
@@ -89,7 +90,12 @@
: Data<Iterator, mpl::false_, mpl::false_>
{
typedef Data<Iterator, mpl::false_, mpl::false_> base_type;
- typedef std::size_t state_type;
+
+ typedef typename base_type::state_type state_type;
+ typedef typename base_type::char_type char_type;
+ typedef
+ typename base_type::semantic_actions_type
+ semantic_actions_type;
// initialize the shared data
template <typename IterData>
@@ -130,9 +136,8 @@
typedef Data<Iterator, mpl::false_, HasState> base_type;
typedef iterator_range<Iterator> iterpair_type;
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
+ typedef typename base_type::state_type state_type;
+ typedef typename base_type::char_type char_type;
typedef void functor_type(iterpair_type, std::size_t, bool&, Data&);
typedef boost::function<functor_type> functor_wrapper_type;
Modified: branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp (original)
+++ branches/proto/v4/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -42,6 +42,7 @@
template <typename Iterator>
struct Data<Iterator, mpl::false_, mpl::false_>
{
+ typedef std::size_t state_type;
typedef iterator_range<Iterator> iterpair_type;
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
@@ -90,7 +91,13 @@
: Data<Iterator, mpl::false_, mpl::false_>
{
typedef Data<Iterator, mpl::false_, mpl::false_> base_type;
-
+
+ typedef typename base_type::state_type state_type;
+ typedef typename base_type::char_type char_type;
+ typedef
+ typename base_type::semantic_actions_type
+ semantic_actions_type;
+
// initialize the shared data
template <typename IterData>
Data (IterData const& data_, Iterator& first_, Iterator const& last_)
@@ -122,10 +129,10 @@
: Data<Iterator, mpl::false_, HasState>
{
typedef Data<Iterator, mpl::false_, HasState> base_type;
+
typedef iterator_range<Iterator> iterpair_type;
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
+ typedef typename base_type::state_type state_type;
+ typedef typename base_type::char_type char_type;
typedef void functor_type(iterpair_type, std::size_t, bool&, Data&);
typedef boost::function<functor_type> functor_wrapper_type;
Modified: branches/proto/v4/boost/spirit/home/lex/tokenize_and_parse.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/lex/tokenize_and_parse.hpp (original)
+++ branches/proto/v4/boost/spirit/home/lex/tokenize_and_parse.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -9,6 +9,7 @@
#include <boost/spirit/home/qi/meta_grammar.hpp>
#include <boost/spirit/home/qi/skip.hpp>
+#include <boost/spirit/home/qi/nonterminal/grammar.hpp>
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/lex/lexer.hpp>
#include <boost/mpl/assert.hpp>
@@ -81,6 +82,21 @@
}
///////////////////////////////////////////////////////////////////////////
+ template <
+ typename Iterator, typename LexerExpr,
+ template <typename, typename> class Def
+ >
+ inline bool
+ tokenize_and_parse(Iterator& first, Iterator last, LexerExpr const& lex,
+ qi::grammar_class<Def>& gc)
+ {
+ typedef typename LexerExpr::iterator_type iterator_type;
+ Def<iterator_type, unused_type> def(gc);
+ qi::grammar<Def<iterator_type, unused_type> > g(def);
+ return tokenize_and_parse(first, last, lex, g);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
template <typename Iterator, typename LexerExpr, typename ParserExpr,
typename Attribute>
inline bool
@@ -107,6 +123,21 @@
}
///////////////////////////////////////////////////////////////////////////
+ template <
+ typename Iterator, typename LexerExpr,
+ template <typename, typename> class Def, typename Attribute
+ >
+ inline bool
+ tokenize_and_parse(Iterator& first, Iterator last, LexerExpr const& lex,
+ qi::grammar_class<Def>& gc, Attribute& attr)
+ {
+ typedef typename LexerExpr::iterator_type iterator_type;
+ Def<iterator_type, unused_type> def(gc);
+ qi::grammar<Def<iterator_type, unused_type> > g(def);
+ return tokenize_and_parse(first, last, lex, g, attr);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
//
// The tokenize_and_phrase_parse() function is one of the main Spirit API
// functions. It simplifies using a lexer as the underlying token source
@@ -198,6 +229,21 @@
///////////////////////////////////////////////////////////////////////////
template <
+ typename Iterator, typename LexerExpr,
+ template <typename, typename> class Def, typename Skipper
+ >
+ inline bool
+ tokenize_and_phrase_parse(Iterator& first, Iterator last,
+ LexerExpr const& lex, qi::grammar_class<Def>& gc, Skipper const& skipper)
+ {
+ typedef typename LexerExpr::iterator_type iterator_type;
+ Def<iterator_type, unused_type> def(gc);
+ qi::grammar<Def<iterator_type, unused_type> > g(def);
+ return tokenize_and_phrase_parse(first, last, lex, g, skipper);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <
typename Iterator, typename LexerExpr, typename ParserExpr,
typename Attribute, typename Skipper
>
@@ -242,6 +288,23 @@
}
///////////////////////////////////////////////////////////////////////////
+ template <
+ typename Iterator, typename LexerExpr,
+ template <typename, typename> class Def,
+ typename Skipper, typename Attribute
+ >
+ inline bool
+ tokenize_and_phrase_parse(Iterator& first, Iterator last,
+ LexerExpr const& lex, qi::grammar_class<Def>& gc, Skipper const& skipper,
+ Attribute& attr)
+ {
+ typedef typename LexerExpr::iterator_type iterator_type;
+ Def<iterator_type, unused_type> def(gc);
+ qi::grammar<Def<iterator_type, unused_type> > g(def);
+ return tokenize_and_phrase_parse(first, last, lex, g, skipper, attr);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
//
// The tokenize() function is one of the main Spirit API functions. It
// simplifies using a lexer to tokenize a given input sequence. It's main
Modified: branches/proto/v4/boost/spirit/home/qi/detail/assign_to.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/qi/detail/assign_to.hpp (original)
+++ branches/proto/v4/boost/spirit/home/qi/detail/assign_to.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -9,6 +9,7 @@
#if !defined(BOOST_SPIRIT_ASSIGN_TO_APR_16_2006_0812PM)
#define BOOST_SPIRIT_ASSIGN_TO_APR_16_2006_0812PM
+#include <boost/spirit/home/qi/detail/construct_fwd.hpp>
#include <boost/spirit/home/support/unused.hpp>
#include <boost/ref.hpp>
Modified: branches/proto/v4/boost/spirit/home/qi/nonterminal/grammar.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/qi/nonterminal/grammar.hpp (original)
+++ branches/proto/v4/boost/spirit/home/qi/nonterminal/grammar.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -164,25 +164,6 @@
friend struct nonterminal_director;
};
-
- ///////////////////////////////////////////////////////////////////////////
- // Generator functions helping to construct a proper grammar object
- // instance
- ///////////////////////////////////////////////////////////////////////////
- template <typename Definition>
- inline grammar<Definition>
- make_parser(Definition const& def)
- {
- return grammar<Definition>(def);
- }
-
- template <typename Definition, typename Start>
- inline grammar<Definition>
- make_parser(Definition const& def, Start const& start)
- {
- return grammar<Definition>(def, start);
- }
-
///////////////////////////////////////////////////////////////////////////
// The grammar_class template
///////////////////////////////////////////////////////////////////////////
Modified: branches/proto/v4/boost/spirit/home/qi/nonterminal/nonterminal.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/qi/nonterminal/nonterminal.hpp (original)
+++ branches/proto/v4/boost/spirit/home/qi/nonterminal/nonterminal.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -7,7 +7,7 @@
#if !defined(BOOST_SPIRIT_NONTERMINAL_FEB_19_2007_0236PM)
#define BOOST_SPIRIT_NONTERMINAL_FEB_19_2007_0236PM
-#include <boost/spirit/home/qi/nonterminal/nonterminal.hpp>
+#include <boost/spirit/home/support/nonterminal/nonterminal.hpp>
#include <boost/spirit/home/support/nonterminal/locals.hpp>
#include <boost/spirit/home/support/argument.hpp>
Modified: branches/proto/v4/boost/spirit/home/support/attribute_transform.hpp
==============================================================================
--- branches/proto/v4/boost/spirit/home/support/attribute_transform.hpp (original)
+++ branches/proto/v4/boost/spirit/home/support/attribute_transform.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -11,6 +11,7 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/component.hpp>
#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/support/detail/values.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/is_sequence.hpp>
#include <boost/variant/variant_fwd.hpp>
@@ -25,16 +26,21 @@
namespace traits
{
+ using boost::spirit::detail::not_is_variant;
+
// Here, we provide policies for stripping single element fusion
// sequences. Add more specializations as needed.
- template <typename T, typename IsSequence>
+ template <typename T, typename IsSequence, typename Enable = void>
struct strip_single_element_sequence
{
typedef T type;
};
template <typename T>
- struct strip_single_element_sequence<fusion::vector<T>, mpl::false_>
+ struct strip_single_element_sequence<
+ fusion::vector<T>, mpl::false_,
+ typename boost::enable_if<not_is_variant<T> >::type
+ >
{
// Strips single element fusion vectors into its 'naked'
// form: vector<T> --> T
@@ -42,7 +48,10 @@
};
template <typename T>
- struct strip_single_element_sequence<fusion::vector<T>, mpl::true_>
+ struct strip_single_element_sequence<
+ fusion::vector<T>, mpl::true_,
+ typename boost::enable_if<not_is_variant<T> >::type
+ >
{
// Strips single element fusion vectors into its 'naked'
// form: vector<T> --> T, but does so only if T is not a fusion
Modified: branches/proto/v4/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/proto/v4/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/proto/v4/boost/unordered/detail/hash_table_impl.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -1648,6 +1648,7 @@
#if BOOST_UNORDERED_EQUIVALENT_KEYS
+#if !(defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL))
// Insert (equivalent key containers)
// if hash function throws, basic exception safety
@@ -1676,7 +1677,8 @@
return insert_hint_impl(it, a);
}
-#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
+#else
+
// Insert (equivalent key containers)
// (I'm using an overloaded insert for both 'insert' and 'emplace')
@@ -1850,6 +1852,8 @@
}
}
+#if !(defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL))
+
// Insert (unique keys)
// if hash function throws, basic exception safety
@@ -1902,7 +1906,8 @@
return insert(v).first;
}
-#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
+#else
+
// Insert (unique keys)
// (I'm using an overloaded insert for both 'insert' and 'emplace')
//
@@ -1949,10 +1954,8 @@
// Nothing after this point can throw.
- link_ptr n = data_.link_node_in_bucket(a, bucket);
-
- return std::pair<iterator_base, bool>(
- iterator_base(bucket, n), true);
+ return std::pair<iterator_base, bool>(iterator_base(bucket,
+ data_.link_node_in_bucket(a, bucket)), true);
}
}
@@ -1993,7 +1996,7 @@
// if hash function throws, basic exception safety
// strong otherwise
template<typename... Args>
- iterator_base insert_hint(iterator_base const& it, Args&&... args)
+ iterator_base insert_hint(iterator_base const&, Args&&... args)
{
// Life is complicated - just call the normal implementation.
return insert(std::forward<Args>(args)...).first;
@@ -2148,7 +2151,7 @@
return it1 == end1 && it2 == end2;
}
#else
- static inline bool group_equals(link_ptr it1, link_ptr it2,
+ static inline bool group_equals(link_ptr, link_ptr,
type_wrapper<key_type>*)
{
return true;
Modified: branches/proto/v4/boost/xpressive/basic_regex.hpp
==============================================================================
--- branches/proto/v4/boost/xpressive/basic_regex.hpp (original)
+++ branches/proto/v4/boost/xpressive/basic_regex.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -239,7 +239,7 @@
// No-op for invalid static regexes.
/// INTERNAL ONLY
template<typename Expr>
- void compile_(Expr const &expr, mpl::false_)
+ void compile_(Expr const &, mpl::false_)
{
}
Modified: branches/proto/v4/libs/asio/test/strand.cpp
==============================================================================
--- branches/proto/v4/libs/asio/test/strand.cpp (original)
+++ branches/proto/v4/libs/asio/test/strand.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -161,6 +161,21 @@
// The run() calls will not return until all work has finished.
BOOST_CHECK(count == 3);
BOOST_CHECK(exception_count == 2);
+
+ count = 0;
+ ios.reset();
+
+ // Check for clean shutdown when handlers posted through an orphaned strand
+ // are abandoned.
+ {
+ strand s2(ios);
+ s2.post(boost::bind(increment, &count));
+ s2.post(boost::bind(increment, &count));
+ s2.post(boost::bind(increment, &count));
+ }
+
+ // No handlers can be called until run() is called.
+ BOOST_CHECK(count == 0);
}
test_suite* init_unit_test_suite(int, char*[])
Modified: branches/proto/v4/libs/config/test/boost_has_tr1_function.ipp
==============================================================================
--- branches/proto/v4/libs/config/test/boost_has_tr1_function.ipp (original)
+++ branches/proto/v4/libs/config/test/boost_has_tr1_function.ipp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -11,7 +11,7 @@
#include <functional>
-namespace boost_has_tr1_bind{
+namespace boost_has_tr1_function{
using std::tr1::function;
Modified: branches/proto/v4/libs/iostreams/example/container_device.hpp
==============================================================================
--- branches/proto/v4/libs/iostreams/example/container_device.hpp (original)
+++ branches/proto/v4/libs/iostreams/example/container_device.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -5,8 +5,8 @@
// See http://www.boost.org/libs/iostreams for documentation.
-#ifndef BOOST_IOSTREAMS_CONTAINTER_DEVICE_HPP_INCLUDED
-#define BOOST_IOSTREAMS_CONTAINTER_DEVICE_HPP_INCLUDED
+#ifndef BOOST_IOSTREAMS_EXAMPLE_CONTAINTER_DEVICE_HPP_INCLUDED
+#define BOOST_IOSTREAMS_EXAMPLE_CONTAINTER_DEVICE_HPP_INCLUDED
#include <algorithm> // copy, min.
#include <cassert>
@@ -152,4 +152,4 @@
} } } // End namespaces example, iostreams, boost.
-#endif // #ifndef BOOST_IOSTREAMS_CONTAINTER_DEVICE_HPP_INCLUDED
+#endif // #ifndef BOOST_IOSTREAMS_EXAMPLE_CONTAINTER_DEVICE_HPP_INCLUDED
Modified: branches/proto/v4/libs/iostreams/test/gzip_test.cpp
==============================================================================
--- branches/proto/v4/libs/iostreams/test/gzip_test.cpp (original)
+++ branches/proto/v4/libs/iostreams/test/gzip_test.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -6,8 +6,14 @@
// See http://www.boost.org/libs/iostreams for documentation.
#include <string>
+#include <boost/iostreams/copy.hpp>
+#include <boost/iostreams/device/array.hpp>
+#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/test.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
+#include <boost/ref.hpp>
+#include <boost/range/iterator_range.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include "detail/sequence.hpp"
@@ -16,18 +22,36 @@
using namespace boost;
using namespace boost::iostreams;
using namespace boost::iostreams::test;
+namespace io = boost::iostreams;
using boost::unit_test::test_suite;
struct gzip_alloc : std::allocator<char> { };
-void gzip_test()
+void compression_test()
{
- text_sequence data;
- BOOST_CHECK(
- test_filter_pair( gzip_compressor(),
- gzip_decompressor(),
- std::string(data.begin(), data.end()) )
- );
+ text_sequence data;
+
+ // Test compression and decompression with metadata
+ for (int i = 0; i < 4; ++i) {
+ gzip_params params;
+ if (i & 1) {
+ params.file_name = "original file name";
+ }
+ if (i & 2) {
+ params.comment = "detailed file description";
+ }
+ gzip_compressor out(params);
+ gzip_decompressor in;
+ BOOST_CHECK(
+ test_filter_pair( boost::ref(out),
+ boost::ref(in),
+ std::string(data.begin(), data.end()) )
+ );
+ BOOST_CHECK(in.file_name() == params.file_name);
+ BOOST_CHECK(in.comment() == params.comment);
+ }
+
+ // Test compression and decompression with custom allocator
BOOST_CHECK(
test_filter_pair( basic_gzip_compressor<gzip_alloc>(),
basic_gzip_decompressor<gzip_alloc>(),
@@ -35,9 +59,34 @@
);
}
+void multiple_member_test()
+{
+ text_sequence data;
+ std::vector<char> temp, dest;
+
+ // Write compressed data to temp, twice in succession
+ filtering_ostream out;
+ out.push(gzip_compressor());
+ out.push(io::back_inserter(temp));
+ io::copy(make_iterator_range(data), out);
+ out.push(io::back_inserter(temp));
+ io::copy(make_iterator_range(data), out);
+
+ // Read compressed data from temp into dest
+ filtering_istream in;
+ in.push(gzip_decompressor());
+ in.push(array_source(&temp[0], temp.size()));
+ io::copy(in, io::back_inserter(dest));
+
+ // Check that dest consists of two copies of data
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin()));
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
+}
+
test_suite* init_unit_test_suite(int, char* [])
{
test_suite* test = BOOST_TEST_SUITE("gzip test");
- test->add(BOOST_TEST_CASE(&gzip_test));
+ test->add(BOOST_TEST_CASE(&compression_test));
+ test->add(BOOST_TEST_CASE(&multiple_member_test));
return test;
}
Modified: branches/proto/v4/libs/spirit/doc/qi_and_karma/generating.qbk
==============================================================================
--- branches/proto/v4/libs/spirit/doc/qi_and_karma/generating.qbk (original)
+++ branches/proto/v4/libs/spirit/doc/qi_and_karma/generating.qbk 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -18,7 +18,5 @@
[heading The tokenize_and_phrase_parse() function]
-[heading The make_parser() function]
-
[endsect]
Modified: branches/proto/v4/libs/spirit/doc/qi_and_karma/parsing.qbk
==============================================================================
--- branches/proto/v4/libs/spirit/doc/qi_and_karma/parsing.qbk (original)
+++ branches/proto/v4/libs/spirit/doc/qi_and_karma/parsing.qbk 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -18,15 +18,21 @@
information depending on the data passed by the parser and the
hierarchical context of the parser it is attached to.
-Parsers come in different flavors. The Spirit library comes bundled with an extensive set of pre-defined parsers that perform various parsing tasks from the trivial to the complex. The parser, as a concept, has a public conceptual interface contract. Following the contract, anyone can write a conforming parser that will play along well with the library's predefined components. We shall provide a blueprint detailing the conceptual interface of the parser later.
-
-Clients of the library generally do not need to write their own hand-coded parsers at all. Spirit has an immense repertoire of pre-defined parsers covering all aspects of syntax and semantic analysis. We shall examine this repertoire of parsers in the following sections. In the rare case where a specific functionality is not available, it is extremely easy to write a user-defined parser. The ease in writing a parser entity is the main reason for Spirit's extensibility.
-
-
-
-
-
-
+Parsers come in different flavors. The Spirit library comes bundled with an
+extensive set of pre-defined parsers that perform various parsing tasks from
+the trivial to the complex. The parser, as a concept, has a public conceptual
+interface contract. Following the contract, anyone can write a conforming
+parser that will play along well with the library's predefined components. We
+shall provide a blueprint detailing the conceptual interface of the parser
+later.
+
+Clients of the library generally do not need to write their own hand-coded
+parsers at all. Spirit has an immense repertoire of pre-defined parsers
+covering all aspects of syntax and semantic analysis. We shall examine this
+repertoire of parsers in the following sections. In the rare case where a
+specific functionality is not available, it is extremely easy to write a
+user-defined parser. The ease in writing a parser entity is the main reason
+for Spirit's extensibility.
[heading The API functions exposed by __qi__ ]
@@ -38,7 +44,5 @@
[heading The tokenize_and_phrase_parse() function]
-[heading The make_parser() function]
-
[endsect]
Modified: branches/proto/v4/libs/spirit/example/lex/print_numbers.cpp
==============================================================================
--- branches/proto/v4/libs/spirit/example/lex/print_numbers.cpp (original)
+++ branches/proto/v4/libs/spirit/example/lex/print_numbers.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -52,10 +52,11 @@
///////////////////////////////////////////////////////////////////////////////
// Grammar definition
///////////////////////////////////////////////////////////////////////////////
-template <typename Iterator>
-struct print_numbers_grammar : grammar_def<Iterator>
+template <typename Iterator, typename Skipper>
+struct print_numbers_grammar : grammar_def<Iterator, Skipper>
{
- print_numbers_grammar()
+ template <typename Class>
+ print_numbers_grammar(Class& self)
{
start = *( token(lex::min_token_id) [ std::cout << _1 << "\n" ]
| token(lex::min_token_id+1)
@@ -89,14 +90,14 @@
// now we use the types defined above to create the lexer and grammar
// object instances needed to invoke the parsing process
print_numbers_tokens<lexer_type> print_tokens; // Our token definition
- print_numbers_grammar<iterator_type> def; // Our grammar definition
+ grammar_class<print_numbers_grammar> print; // Our grammar definition
// Parsing is done based on the the token stream, not the character
// stream read from the input.
std::string str (read_from_file(1 == argc ? "print_numbers.input" : argv[1]));
base_iterator_type first = str.begin();
bool r = tokenize_and_parse(first, str.end(), make_lexer(print_tokens),
- make_parser(def));
+ print);
if (r) {
std::cout << "-------------------------\n";
Modified: branches/proto/v4/libs/spirit/example/lex/static_lexer/word_count_static.cpp
==============================================================================
--- branches/proto/v4/libs/spirit/example/lex/static_lexer/word_count_static.cpp (original)
+++ branches/proto/v4/libs/spirit/example/lex/static_lexer/word_count_static.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -100,10 +100,9 @@
char const* first = str.c_str();
char const* last = &first[str.size()];
- // Parsing is done based on the the token stream, not the character
- // stream read from the input.
- bool r = tokenize_and_parse(first, last, make_lexer(word_count),
- make_parser(def));
+ // Parsing is done based on the the token stream, not the character stream.
+ qi::grammar<word_count_grammar<iterator_type> > g(def);
+ bool r = tokenize_and_parse(first, last, make_lexer(word_count), g);
if (r) { // success
std::cout << "lines: " << def.l << ", words: " << def.w
Modified: branches/proto/v4/libs/spirit/example/lex/strip_comments.cpp
==============================================================================
--- branches/proto/v4/libs/spirit/example/lex/strip_comments.cpp (original)
+++ branches/proto/v4/libs/spirit/example/lex/strip_comments.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -141,8 +141,9 @@
// stream read from the input.
std::string str (read_from_file(1 == argc ? "strip_comments.input" : argv[1]));
base_iterator_type first = str.begin();
- bool r = tokenize_and_parse(first, str.end(), make_lexer(strip_comments),
- make_parser(def));
+
+ qi::grammar<strip_comments_grammar<iterator_type> > g(def);
+ bool r = tokenize_and_parse(first, str.end(), make_lexer(strip_comments), g);
if (r) {
std::cout << "-------------------------\n";
Modified: branches/proto/v4/libs/spirit/example/lex/strip_comments_lexer.cpp
==============================================================================
--- branches/proto/v4/libs/spirit/example/lex/strip_comments_lexer.cpp (original)
+++ branches/proto/v4/libs/spirit/example/lex/strip_comments_lexer.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -35,7 +35,6 @@
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/lex_lexer_lexertl.hpp>
-#include <boost/spirit/lex/lexer/lexer_actions.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
Modified: branches/proto/v4/libs/spirit/example/lex/word_count.cpp
==============================================================================
--- branches/proto/v4/libs/spirit/example/lex/word_count.cpp (original)
+++ branches/proto/v4/libs/spirit/example/lex/word_count.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -156,8 +156,8 @@
// stream read from the input. The function `tokenize_and_parse()` wraps
// the passed iterator range `[first, last)` by the lexical analyzer and
// uses its exposed iterators to parse the toke stream.
- bool r = tokenize_and_parse(first, last, make_lexer(word_count),
- make_parser(def));
+ qi::grammar<word_count_grammar<iterator_type> > g(def);
+ bool r = tokenize_and_parse(first, last, make_lexer(word_count), g);
if (r) {
std::cout << "lines: " << def.l << ", words: " << def.w
Modified: branches/proto/v4/libs/spirit/example/lex/word_count_functor.flex
==============================================================================
--- branches/proto/v4/libs/spirit/example/lex/word_count_functor.flex (original)
+++ branches/proto/v4/libs/spirit/example/lex/word_count_functor.flex 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -26,7 +26,7 @@
return true;
}
-void main(int argc, char* argv[])
+int main(int argc, char* argv[])
{
int tok = EOF;
int c = 0, w = 0, l = 0;
@@ -44,6 +44,7 @@
} while (EOF != tok);
printf("lines: %d, words: %d, characters: %d\n", l, w, c);
fclose(yyin);
+ return 0;
}
extern "C" int yywrap()
Modified: branches/proto/v4/libs/spirit/example/lex/word_count_functor_flex.cpp
==============================================================================
--- branches/proto/v4/libs/spirit/example/lex/word_count_functor_flex.cpp (original)
+++ branches/proto/v4/libs/spirit/example/lex/word_count_functor_flex.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -1543,7 +1543,7 @@
return true;
}
-void main(int argc, char* argv[])
+int main(int argc, char* argv[])
{
int tok = EOF;
int c = 0, w = 0, l = 0;
@@ -1561,6 +1561,7 @@
} while (EOF != tok);
printf("lines: %d, words: %d, characters: %d\n", l, w, c);
fclose(yyin);
+ return 0;
}
extern "C" int yywrap()
Modified: branches/proto/v4/libs/spirit/test/qi/grammar_fail.cpp
==============================================================================
--- branches/proto/v4/libs/spirit/test/qi/grammar_fail.cpp (original)
+++ branches/proto/v4/libs/spirit/test/qi/grammar_fail.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -35,7 +35,8 @@
char const* end = &input[strlen(input)+1];
num_list def;
- bool r = phrase_parse(input, end, make_parser(def),
+ grammar<num_list> g(def);
+ bool r = phrase_parse(input, end, g,
space | ('%' >> *~char_('\n') >> '\n'));
return 0;
Modified: branches/proto/v4/libs/unordered/doc/Jamfile.v2
==============================================================================
--- branches/proto/v4/libs/unordered/doc/Jamfile.v2 (original)
+++ branches/proto/v4/libs/unordered/doc/Jamfile.v2 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -3,6 +3,9 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+path-constant images_location : ../ ;
+path-constant admonishment_location : ../../../../doc/src/images ;
+
xml unordered : unordered.qbk ;
boostbook standalone : unordered :
<xsl:param>admon.graphics.path=images/
@@ -16,8 +19,38 @@
<xsl:param>toc.section.depth=1
<xsl:param>toc.max.depth=1
+ <xsl:param>boost.compact.typedef=0
+ <xsl:param>boost.compact.function=0
+ <xsl:param>boost.compact.enum=0
+
<dependency>css
<dependency>images
+
+ # PDF Options:
+ # TOC Generation: this is needed for FOP-0.9 and later:
+ <xsl:param>fop1.extensions=0
+ <format>pdf:<xsl:param>xep.extensions=1
+ # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
+ <format>pdf:<xsl:param>fop.extensions=0
+ # No indent on body text:
+ <format>pdf:<xsl:param>body.start.indent=0pt
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.inner=0.5in
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.outer=0.5in
+ # Paper type = A4
+ <format>pdf:<xsl:param>paper.type=A4
+ # Yes, we want graphics for admonishments:
+ <xsl:param>admon.graphics=1
+ # Set this one for PDF generation *only*:
+ # default png graphics are awful in PDF form,
+ # better use SVG's instead:
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>use.role.for.mediaobject=1
+ <format>pdf:<xsl:param>preferred.mediaobject.role=print
+ <format>pdf:<xsl:param>img.src.path=$(images_location)/
+ #<format>pdf:<xsl:param>admon.graphics.path=$(admonishment_location)
+ <format>pdf:<xsl:param>draft.mode="no"
;
install css : [ glob $(BOOST_ROOT)/doc/src/*.css ]
Modified: branches/proto/v4/libs/unordered/doc/bibliography.xml
==============================================================================
--- branches/proto/v4/libs/unordered/doc/bibliography.xml (original)
+++ branches/proto/v4/libs/unordered/doc/bibliography.xml 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -1,6 +1,6 @@
-<section id="unordered.bibliography" label="Bibliography">
+<section id="unordered.bibliography">
+<title>Bibliography</title>
<bibliography>
- <title>Bibliography</title>
<biblioentry>
<biblioset relation="journal">
<title>C/C++ Users Journal</title>
Modified: branches/proto/v4/libs/unordered/doc/buckets.qbk
==============================================================================
--- branches/proto/v4/libs/unordered/doc/buckets.qbk (original)
+++ branches/proto/v4/libs/unordered/doc/buckets.qbk 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -10,7 +10,7 @@
`B`, `C`, `D` and `E` (this is just for illustration, containers will typically
have more buckets).
-[$../../libs/unordered/doc/diagrams/buckets.png]
+[diagram buckets]
In order to decide which bucket to place an element in, the container applies
the hash function, `Hash`, to the element's key (for `unordered_set` and
@@ -35,37 +35,53 @@
the search slower. This is known as a collision. To keep things fast we try to
keep collisions to a minimum.
-[table Methods for Accessing Buckets
- [[Method] [Description]]
-
- [
- [``size_type bucket_count() const``]
- [The number of buckets.]
- ]
- [
- [``size_type max_bucket_count() const``]
- [An upper bound on the number of buckets.]
- ]
- [
- [``size_type bucket_size(size_type n) const``]
- [The number of elements in bucket `n`.]
- ]
- [
- [``size_type bucket(key_type const& k) const``]
- [Returns the index of the bucket which would contain k]
- ]
- [
- [``
- local_iterator begin(size_type n);
- local_iterator end(size_type n);
- const_local_iterator begin(size_type n) const;
- const_local_iterator end(size_type n) const;
- const_local_iterator cbegin(size_type n) const;
- const_local_iterator cend(size_type n) const;
- ``]
- [Return begin and end iterators for bucket `n`.]
- ]
-]
+'''
+<table frame="all"><title>Methods for Accessing Buckets</title>
+ <tgroup cols="2">
+ <thead><row>
+ <entry><para>Method</para></entry>
+ <entry><para>Description</para></entry>
+ </row></thead>
+ <tbody>
+ <row>
+ <entry>'''`size_type bucket_count() const`'''</entry>
+ <entry>'''The number of buckets.'''</entry>
+ </row>
+ <row>
+ <entry>'''`size_type max_bucket_count() const`'''</entry>
+ <entry>'''An upper bound on the number of buckets.'''</entry>
+ </row>
+ <row>
+ <entry>'''`size_type bucket_size(size_type n) const`'''</entry>
+ <entry>'''The number of elements in bucket `n`.'''</entry>
+ </row>
+ <row>
+ <entry>'''`size_type bucket(key_type const& k) const`'''</entry>
+ <entry>'''Returns the index of the bucket which would contain k'''</entry>
+ </row>
+ <row>
+ <entry>'''`local_iterator begin(size_type n);`'''</entry>
+ <entry morerows='5'>'''Return begin and end iterators for bucket `n`.'''</entry>
+ </row>
+ <row>
+ <entry>'''`local_iterator end(size_type n);`'''</entry>
+ </row>
+ <row>
+ <entry>'''`const_local_iterator begin(size_type n) const;`'''</entry>
+ </row>
+ <row>
+ <entry>'''`const_local_iterator end(size_type n) const;`'''</entry>
+ </row>
+ <row>
+ <entry>'''`const_local_iterator cbegin(size_type n) const;`'''</entry>
+ </row>
+ <row>
+ <entry>'''`const_local_iterator cend(size_type n) const;`'''</entry>
+ </row>
+ </tbody>
+ </tgroup>
+</table>
+'''
[h2 Controlling the number of buckets]
@@ -100,19 +116,19 @@
[[Method] [Description]]
[
- [``float load_factor() const``]
+ [`float load_factor() const`]
[The average number of elements per bucket.]
]
[
- [``float max_load_factor() const``]
+ [`float max_load_factor() const`]
[Returns the current maximum load factor.]
]
[
- [``float max_load_factor(float z)``]
+ [`float max_load_factor(float z)`]
[Changes the container's maximum load factor, using `z` as a hint.]
]
[
- [``void rehash(size_type n)``]
+ [`void rehash(size_type n)`]
[Changes the number of buckets so that there at least n buckets, and
so that the load factor is less than the maximum load factor.]
]
Deleted: branches/proto/v4/libs/unordered/doc/diagrams/buckets.dia
==============================================================================
Binary file. No diff available.
Modified: branches/proto/v4/libs/unordered/doc/diagrams/buckets.png
==============================================================================
Binary files. No diff available.
Modified: branches/proto/v4/libs/unordered/doc/hash_equality.qbk
==============================================================================
--- branches/proto/v4/libs/unordered/doc/hash_equality.qbk (original)
+++ branches/proto/v4/libs/unordered/doc/hash_equality.qbk 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -63,11 +63,11 @@
[[Method] [Description]]
[
- [``hasher hash_function() const``]
+ [`hasher hash_function() const`]
[Returns the container's hash function.]
]
[
- [``key_equal key_eq() const``]
+ [`key_equal key_eq() const`]
[Returns the container's key equality function.]
]
]
Modified: branches/proto/v4/libs/unordered/doc/unordered.qbk
==============================================================================
--- branches/proto/v4/libs/unordered/doc/unordered.qbk (original)
+++ branches/proto/v4/libs/unordered/doc/unordered.qbk 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -17,6 +17,16 @@
]
]
+[template diagram[name] '''<inlinemediaobject>
+<imageobject role="html">
+<imagedata align = "center" fileref="../../libs/unordered/doc/diagrams/'''[name]'''.png"></imagedata>
+</imageobject>
+<imageobject role="print">
+<imagedata align = "center" fileref="../../libs/unordered/doc/diagrams/'''[name]'''.svg"></imagedata>
+</imageobject>
+</inlinemediaobject>''']
+
+
[include:unordered intro.qbk]
[include:unordered buckets.qbk]
[include:unordered hash_equality.qbk]
Modified: branches/proto/v4/libs/unordered/test/exception/Jamfile.v2
==============================================================================
--- branches/proto/v4/libs/unordered/test/exception/Jamfile.v2 (original)
+++ branches/proto/v4/libs/unordered/test/exception/Jamfile.v2 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -11,7 +11,7 @@
project unordered-test/exception-tests
: requirements
<toolset>intel-linux:"<cxxflags>-strict_ansi -cxxlib-icc"
- <toolset>gcc:<cxxflags>-Wsign-promo
+ <toolset>gcc:<cxxflags>"-Wsign-promo -Wunused-parameter"
;
test-suite unordered-exception
Modified: branches/proto/v4/libs/unordered/test/helpers/exception_test.hpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/helpers/exception_test.hpp (original)
+++ branches/proto/v4/libs/unordered/test/helpers/exception_test.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -210,7 +210,7 @@
}
template <class Test>
- void exception_safety(Test const& f, char const* name) {
+ void exception_safety(Test const& f, char const* /*name*/) {
test_runner<Test> runner(f);
iteration = 0;
Modified: branches/proto/v4/libs/unordered/test/objects/memory.hpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/objects/memory.hpp (original)
+++ branches/proto/v4/libs/unordered/test/objects/memory.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -153,12 +153,12 @@
if(count_allocations > 0) --count_allocations;
}
- void track_construct(void* ptr, std::size_t /*size*/, int tag)
+ void track_construct(void* /*ptr*/, std::size_t /*size*/, int /*tag*/)
{
++count_constructions;
}
- void track_destroy(void* ptr, std::size_t /*size*/, int tag)
+ void track_destroy(void* /*ptr*/, std::size_t /*size*/, int /*tag*/)
{
BOOST_CHECK(count_constructions > 0);
if(count_constructions > 0) --count_constructions;
Modified: branches/proto/v4/libs/unordered/test/unordered/Jamfile.v2
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/Jamfile.v2 (original)
+++ branches/proto/v4/libs/unordered/test/unordered/Jamfile.v2 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -8,7 +8,7 @@
project unordered-test/unordered
: requirements
<toolset>intel-linux:"<cxxflags>-strict_ansi -cxxlib-icc"
- <toolset>gcc:<cxxflags>-Wsign-promo
+ <toolset>gcc:<cxxflags>"-Wsign-promo -Wunused-parameter"
#<toolset>msvc:<cxxflags>/W4
;
Modified: branches/proto/v4/libs/unordered/test/unordered/bucket_tests.cpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/bucket_tests.cpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/bucket_tests.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -16,11 +16,11 @@
test::seed_t seed(54635);
template <class X>
-void tests(X* = 0)
+void tests(X* = 0, test::random_generator generator = test::default_generator)
{
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
X x(v.begin(), v.end());
Modified: branches/proto/v4/libs/unordered/test/unordered/compile_tests.hpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/compile_tests.hpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/compile_tests.hpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -149,6 +149,8 @@
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
BOOST_MPL_ASSERT((boost::is_same<value_type, std::pair<key_type const, T> >));
+ r.insert(std::pair<Key const, T>(k, v));
+
#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
Key k_lvalue(k);
T v_lvalue(v);
Modified: branches/proto/v4/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/constructor_tests.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -253,12 +253,12 @@
}
template <class T>
-void map_constructor_test(T* = 0)
+void map_constructor_test(T* = 0, test::random_generator const& generator = test::default_generator)
{
std::cerr<<"map_constructor_test\n";
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME T::key_type, BOOST_DEDUCED_TYPENAME T::mapped_type> > list;
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
list l(v.begin(), v.end());
T x(l.begin(), l.end());
Modified: branches/proto/v4/libs/unordered/test/unordered/copy_tests.cpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/copy_tests.cpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/copy_tests.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -36,7 +36,7 @@
}
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end());
T y(x);
@@ -50,7 +50,7 @@
// is much lower than the load factor. The hash table is not allowed
// to rehash, but the destination container should probably allocate
// enough buckets to decrease the load factor appropriately.
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end());
x.max_load_factor(x.load_factor() / 4);
T y(x);
@@ -95,7 +95,7 @@
}
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end(), 0, hf, eq, al);
T y(x);
@@ -106,7 +106,7 @@
}
{
- test::random_values<T> v(500);
+ test::random_values<T> v(500, generator);
T x(v.begin(), v.end(), 0, hf, eq, al);
T y(x, al2);
Modified: branches/proto/v4/libs/unordered/test/unordered/load_factor_tests.cpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/load_factor_tests.cpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/load_factor_tests.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -34,13 +34,13 @@
}
template <class X>
-void insert_test(X*, float mlf)
+void insert_test(X*, float mlf, test::random_generator generator = test::default_generator)
{
X x;
x.max_load_factor(mlf);
float b = x.max_load_factor();
- test::random_values<X> values(1000);
+ test::random_values<X> values(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
it = values.begin(), end = values.end(); it != end; ++it)
Modified: branches/proto/v4/libs/unordered/test/unordered/move_tests.cpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/move_tests.cpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/move_tests.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -17,7 +17,7 @@
test::seed_t seed(98624);
template<class T>
- T empty(T* ptr) {
+ T empty(T*) {
return T();
}
@@ -61,7 +61,7 @@
}
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
test::object_count count;
T y(create(v, count));
BOOST_CHECK(count == test::global_object_count);
@@ -71,10 +71,10 @@
}
template <class T>
- void move_assign_tests1(T* ptr, test::random_generator const& generator = test::default_generator)
+ void move_assign_tests1(T*, test::random_generator const& generator = test::default_generator)
{
{
- test::random_values<T> v(500);
+ test::random_values<T> v(500, generator);
test::object_count count;
T y;
y = create(v, count);
@@ -85,11 +85,9 @@
}
template <class T>
- void move_construct_tests2(T* ptr,
+ void move_construct_tests2(T*,
test::random_generator const& generator = test::default_generator)
{
- move_construct_tests1(ptr);
-
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
@@ -98,7 +96,7 @@
test::object_count count;
{
- test::random_values<T> v(500);
+ test::random_values<T> v(500, generator);
T y(create(v, count, hf, eq, al, 0.5));
BOOST_CHECK(count == test::global_object_count);
test::check_container(y, v);
@@ -111,7 +109,7 @@
{
// TODO: To do this correctly requires the fancy new allocator stuff.
- test::random_values<T> v(500);
+ test::random_values<T> v(500, generator);
T y(create(v, count, hf, eq, al, 2.0), al2);
BOOST_CHECK(count != test::global_object_count);
test::check_container(y, v);
@@ -123,7 +121,7 @@
}
{
- test::random_values<T> v(25);
+ test::random_values<T> v(25, generator);
T y(create(v, count, hf, eq, al, 1.0), al);
#if defined(BOOST_HAS_RVALUE_REFS)
BOOST_CHECK(count == test::global_object_count);
Modified: branches/proto/v4/libs/unordered/test/unordered/rehash_tests.cpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/rehash_tests.cpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/rehash_tests.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -33,9 +33,9 @@
}
template <class X>
-void rehash_test1(X* = 0)
+void rehash_test1(X* = 0, test::random_generator generator = test::default_generator)
{
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
test::ordered<X> tracker;
tracker.insert_range(v.begin(), v.end());
X x(v.begin(), v.end());
Modified: branches/proto/v4/libs/unordered/test/unordered/swap_tests.cpp
==============================================================================
--- branches/proto/v4/libs/unordered/test/unordered/swap_tests.cpp (original)
+++ branches/proto/v4/libs/unordered/test/unordered/swap_tests.cpp 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -32,7 +32,7 @@
}
template <class X>
-void swap_tests1(X* = 0)
+void swap_tests1(X*, test::random_generator generator = test::default_generator)
{
{
X x;
@@ -45,14 +45,14 @@
}
{
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
X x, y(v.begin(), v.end());
swap_test_impl(x, y);
swap_test_impl(x, y);
}
{
- test::random_values<X> vx(1000), vy(1000);
+ test::random_values<X> vx(1000, generator), vy(1000, generator);
X x(vx.begin(), vx.end()), y(vy.begin(), vy.end());
swap_test_impl(x, y);
swap_test_impl(x, y);
@@ -60,7 +60,7 @@
}
template <class X>
-void swap_tests2(X* ptr = 0)
+void swap_tests2(X* ptr = 0, test::random_generator generator = test::default_generator)
{
swap_tests1(ptr);
@@ -75,14 +75,14 @@
}
{
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
X x(v.begin(), v.end(), 0, hasher(1), key_equal(1));
X y(0, hasher(2), key_equal(2));
swap_test_impl(x, y);
}
{
- test::random_values<X> vx(100), vy(50);
+ test::random_values<X> vx(100, generator), vy(50, generator);
X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1));
X y(vy.begin(), vy.end(), 0, hasher(2), key_equal(2));
swap_test_impl(x, y);
@@ -91,7 +91,7 @@
#if BOOST_UNORDERED_SWAP_METHOD == 1
{
- test::random_values<X> vx(100), vy(50);
+ test::random_values<X> vx(100, generator), vy(50, generator);
X x(vx.begin(), vx.end(), 0, hasher(), key_equal(), allocator_type(1));
X y(vy.begin(), vy.end(), 0, hasher(), key_equal(), allocator_type(2));
try {
@@ -101,14 +101,14 @@
}
#else
{
- test::random_values<X> vx(50), vy(100);
+ test::random_values<X> vx(50, generator), vy(100, generator);
X x(vx.begin(), vx.end(), 0, hasher(), key_equal(), allocator_type(1));
X y(vy.begin(), vy.end(), 0, hasher(), key_equal(), allocator_type(2));
swap_test_impl(x, y);
}
{
- test::random_values<X> vx(100), vy(100);
+ test::random_values<X> vx(100, generator), vy(100, generator);
X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1), allocator_type(1));
X y(vy.begin(), vy.end(), 0, hasher(2), key_equal(2), allocator_type(2));
swap_test_impl(x, y);
Modified: branches/proto/v4/tools/build/v2/build/toolset.jam
==============================================================================
--- branches/proto/v4/tools/build/v2/build/toolset.jam (original)
+++ branches/proto/v4/tools/build/v2/build/toolset.jam 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -135,7 +135,6 @@
}
}
-
if $(condition) && ! $(condition:G=) && ! $(hack-hack)
{
# We have condition in the form '<feature>', that is, without value.
@@ -153,8 +152,7 @@
condition = [ normalize-condition $(condition) ] ;
}
- add-flag $(rule-or-module) : $(variable-name)
- : $(condition) : $(values) ;
+ add-flag $(rule-or-module) : $(variable-name) : $(condition) : $(values) ;
}
@@ -327,8 +325,8 @@
local settings = $(.stv.$(key)) ;
if ! $(settings)
{
- settings = [
- set-target-variables-aux $(rule-or-module) : $(property-set) ] ;
+ settings = [ set-target-variables-aux $(rule-or-module) :
+ $(property-set) ] ;
if ! $(settings)
{
Modified: branches/proto/v4/tools/build/v2/tools/darwin.jam
==============================================================================
--- branches/proto/v4/tools/build/v2/tools/darwin.jam (original)
+++ branches/proto/v4/tools/build/v2/tools/darwin.jam 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -49,12 +49,18 @@
common.handle-options darwin : $(condition) : $(command) : $(options) ;
- # GCC 4.0 and higher in Darwin does not have -fcoalesce-templates.
local gccversion = [ SHELL "$(command:J= ) -dumpversion" ] ;
+
+ # GCC 4.0 and higher in Darwin does not have -fcoalesce-templates.
if $(gccversion) < "4.0.0"
{
flags darwin.compile.c++ OPTIONS $(condition) : -fcoalesce-templates ;
}
+ # GCC 4.2 and higher in Darwin does not have -Wno-long-double.
+ if $(gccversion) < "4.2.0"
+ {
+ flags darwin.compile OPTIONS $(condition) : -Wno-long-double ;
+ }
gcc.init-link-flags darwin darwin $(condition) ;
@@ -107,9 +113,6 @@
# The following adds objective-c support to darwin.
# Thanks to http://thread.gmane.org/gmane.comp.lib.boost.build/13759
-type.register OBJECTIVE_C : m ;
-type.register OBJECTIVE_CPP : mm ;
-
generators.register-c-compiler darwin.compile.m : OBJECTIVE_C : OBJ : <toolset>darwin ;
generators.register-c-compiler darwin.compile.mm : OBJECTIVE_CPP : OBJ : <toolset>darwin ;
@@ -208,7 +211,7 @@
flags darwin.link OPTIONS <variant>release : -Wl,-dead_strip -no_dead_strip_inits_and_terms ;
flags darwin.compile OPTIONS <link>shared : -dynamic ;
-flags darwin.compile OPTIONS : -Wno-long-double -no-cpp-precomp -gdwarf-2 ;
+flags darwin.compile OPTIONS : -no-cpp-precomp -gdwarf-2 ;
flags darwin.link FRAMEWORK <framework> ;
Modified: branches/proto/v4/tools/build/v2/tools/make.jam
==============================================================================
--- branches/proto/v4/tools/build/v2/tools/make.jam (original)
+++ branches/proto/v4/tools/build/v2/tools/make.jam 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -35,14 +35,14 @@
# 'm' will always be set -- we add '@' ourselves in 'make' rule below.
local m = [ MATCH ^@(.*) : $(action-name) ] ;
- local a = [ new action $(source-targets) : $(m[1])
- : $(property-set) ] ;
+ local a = [ new action $(source-targets) : $(m[1]) : $(property-set) ] ;
local t = [ new file-target $(self.name) exact
- : [ type.type $(self.name) ] : $(self.project) : $(a) ] ;
+ : [ type.type $(self.name) ] : $(self.project) : $(a) ] ;
return [ property-set.empty ] [ virtual-target.register $(t) ] ;
}
}
+
# Declares the 'make' main target.
#
rule make ( target-name : sources * : generating-rule + : requirements *
@@ -60,11 +60,11 @@
requirements += <action>$(generating-rule) ;
targets.main-target-alternative
- [ new make-target-class $(target-name) : $(project)
- : [ targets.main-target-sources $(sources) : $(target-name) ]
- : [ targets.main-target-requirements $(requirements) : $(project) ]
- : [ targets.main-target-default-build : $(project) ]
- : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ]
+ [ new make-target-class $(target-name) : $(project)
+ : [ targets.main-target-sources $(sources) : $(target-name) ]
+ : [ targets.main-target-requirements $(requirements) : $(project) ]
+ : [ targets.main-target-default-build : $(project) ]
+ : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ]
] ;
}
Modified: branches/proto/v4/tools/build/v2/tools/msvc.jam
==============================================================================
--- branches/proto/v4/tools/build/v2/tools/msvc.jam (original)
+++ branches/proto/v4/tools/build/v2/tools/msvc.jam 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -435,8 +435,14 @@
# Some version of msvc have a bug, that cause deprecation
# warning to be emitted even with /W0
toolset.flags $(toolset).compile CFLAGS $(condition)/<warnings>off : /wd4996 ;
- # 64-bit compatibility warning
- toolset.flags $(toolset).compile CFLAGS $(condition)/<warnings>all : /Wp64 ;
+
+ if [ MATCH ^([78]\\.) : $(version) ]
+ {
+ # 64-bit compatibility warning
+ # deprecated since 9.0, see
+ # http://msdn.microsoft.com/en-us/library/yt4xw8fh.aspx
+ toolset.flags $(toolset).compile CFLAGS $(condition)/<warnings>all : /Wp64 ;
+ }
}
#
Modified: branches/proto/v4/tools/build/v2/tools/python.jam
==============================================================================
--- branches/proto/v4/tools/build/v2/tools/python.jam (original)
+++ branches/proto/v4/tools/build/v2/tools/python.jam 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -7,11 +7,11 @@
#
# This module defines
#
-# - a project 'python' with a target 'python' in it, that corresponds
-# to the python library
+# - a project 'python' with a target 'python' in it, that corresponds to the
+# python library
#
-# - a main target rule 'python-extension' which can be used
-# to build a python extension.
+# - a main target rule 'python-extension' which can be used to build a python
+# extension.
#
# Extensions that use Boost.Python must explicitly link to it.
@@ -24,7 +24,7 @@
import "class" : new ;
import os ;
import common ;
-import toolset : flags ;
+import toolset ;
import regex ;
import numbers ;
import string ;
@@ -35,20 +35,19 @@
import set ;
import builtin ;
-# Make this module a project
+
+# Make this module a project.
project.initialize $(__name__) ;
project python ;
-# Save the project so that if 'init' is called several
-# times we define new targets in the python project,
-# not in whatever project we were called by.
+# Save the project so that if 'init' is called several times we define new
+# targets in the python project, not in whatever project we were called by.
.project = [ project.current ] ;
-# Dynamic linker lib. Necessary to specify it explicitly
-# on some platforms.
+# Dynamic linker lib. Necessary to specify it explicitly on some platforms.
lib dl ;
-# This contains 'openpty' function need by python. Again, on
-# some system need to pass this to linker explicitly.
+# This contains 'openpty' function need by python. Again, on some system need to
+# pass this to linker explicitly.
lib util ;
# Python uses pthread symbols.
lib pthread ;
@@ -56,44 +55,38 @@
lib rt ;
# The pythonpath feature specifies additional elements for the PYTHONPATH
-# environment variable, set by run-pyd. For example, pythonpath can be used
-# to access Python modules that are part of the product being built, but
-# are not installed in the development system's default paths.
+# environment variable, set by run-pyd. For example, pythonpath can be used to
+# access Python modules that are part of the product being built, but are not
+# installed in the development system's default paths.
feature.feature pythonpath : : free optional path ;
-# Initializes the Python toolset. Note that all parameters are
-# optional.
+# Initializes the Python toolset. Note that all parameters are optional.
+#
+# - version -- the version of Python to use. Should be in Major.Minor format,
+# for example 2.3. Do not include the subminor version.
+#
+# - cmd-or-prefix: Preferably, a command that invokes a Python interpreter.
+# Alternatively, the installation prefix for Python libraries and includes. If
+# empty, will be guessed from the version, the platform's installation
+# patterns, and the python executables that can be found in PATH.
+#
+# - includes: the include path to Python headers. If empty, will be guessed.
+#
+# - libraries: the path to Python library binaries. If empty, will be guessed.
+# On MacOS/Darwin, you can also pass the path of the Python framework.
#
-# - version -- the version of Python to use. Should be in Major.Minor
-# format, for example 2.3. Do not include the subminor version.
+# - condition: if specified, should be a set of properties that are matched
+# against the build configuration when Boost.Build selects a Python
+# configuration to use.
#
-# - cmd-or-prefix: Preferably, a command that invokes a Python
-# interpreter. Alternatively, the installation prefix for Python
-# libraries and includes. If empty, will be guessed from the
-# version, the platform's installation patterns, and the python
-# executables that can be found in PATH.
-#
-# - includes: the include path to Python headers. If empty, will be
-# guessed.
-#
-# - libraries: the path to Python library binaries. If empty, will be
-# guessed. On MacOS/Darwin, you can also pass the path of the
-# Python framework.
-#
-# - condition: if specified, should be a set of properties that are
-# matched against the build configuration when Boost.Build selects a
-# Python configuration to use.
-#
-# - extension-suffix: A string to append to the name of extension
-# modules before the true filename extension. Ordinarily we would
-# just compute this based on the value of the <python-debugging>
-# feature. However ubuntu's python-dbg package uses the windows
-# convention of appending _d to debug-build extension modules. We
-# have no way of detecting ubuntu, or of probing python for the "_d"
-# requirement, and if you configure and build python using
-# --with-pydebug, you'll be using the standard *nix convention.
-# Defaults to "" (or "_d" when targeting windows and
-# <python-debugging> is set).
+# - extension-suffix: A string to append to the name of extension modules before
+# the true filename extension. Ordinarily we would just compute this based on
+# the value of the <python-debugging> feature. However ubuntu's python-dbg
+# package uses the windows convention of appending _d to debug-build extension
+# modules. We have no way of detecting ubuntu, or of probing python for the
+# "_d" requirement, and if you configure and build python using
+# --with-pydebug, you'll be using the standard *nix convention. Defaults to ""
+# (or "_d" when targeting windows and <python-debugging> is set).
#
# Example usage:
#
@@ -119,8 +112,9 @@
project.pop-current ;
}
-# A simpler version of SHELL that grabs stderr as well as stdout, but
-# returns nothing if there's an error.
+# A simpler version of SHELL that grabs stderr as well as stdout, but returns
+# nothing if there's an error.
+#
local rule shell-cmd ( cmd )
{
debug-message running command '$(cmd)" 2>&1"' ;
@@ -135,34 +129,34 @@
}
}
-# Try to identify Cygwin symlinks. Invoking such a file directly as
-# an NT executable from a native Windows build of bjam would be fatal
-# to the bjam process. One /can/ invoke them through sh.exe or
-# bash.exe, if you can prove that those aren't also symlinks ;-)
+
+# Try to identify Cygwin symlinks. Invoking such a file directly as an NT
+# executable from a native Windows build of bjam would be fatal to the bjam
+# process. One /can/ invoke them through sh.exe or bash.exe, if you can prove
+# that those aren't also symlinks ;-)
#
-# If a symlink is found returns non-empty; we try to extract the
-# target of the symlink from the file and return that.
+# If a symlink is found returns non-empty; we try to extract the target of the
+# symlink from the file and return that.
#
# Note: 1. only works on NT 2. path is a native path.
local rule is-cygwin-symlink ( path )
{
local is-symlink = ;
- # Look for a file with the given path having the S attribute set,
- # as cygwin symlinks do. /-C means "do not use thousands
- # separators in file sizes."
+ # Look for a file with the given path having the S attribute set, as cygwin
+ # symlinks do. /-C means "do not use thousands separators in file sizes."
local dir-listing = [ shell-cmd "DIR /-C /A:S "$(path) ] ;
if $(dir-listing)
{
- # escape any special regex characters in the base part of the path
+ # Escape any special regex characters in the base part of the path.
local base-pat = [ regex.escape $(path:D=) : ].[()*+?|\\$^ : \\ ] ;
- # extract the file's size from the directory listing
+ # Extract the file's size from the directory listing.
local size-of-system-file = [ MATCH "([0-9]+) "$(base-pat) : $(dir-listing) : 1 ] ;
- # if the file has a reasonably small size, look for the
- # special symlink identification text
+ # If the file has a reasonably small size, look for the special symlink
+ # identification text.
if $(size-of-system-file) && [ numbers.less $(size-of-system-file) 1000 ]
{
local link = [ SHELL "FIND /OFF \"!<symlink>\" \""$(path)"\" 2>&1" ] ;
@@ -184,7 +178,9 @@
return $(is-symlink) ;
}
-# Append ext to each member of names that does not contain '.'
+
+# Append ext to each member of names that does not contain '.'.
+#
local rule default-extension ( names * : ext * )
{
local result ;
@@ -199,10 +195,11 @@
return $(result) ;
}
-# Tries to determine whether invoking "cmd" would actually attempt to
-# launch a cygwin symlink.
+
+# Tries to determine whether invoking "cmd" would actually attempt to launch a
+# cygwin symlink.
#
-# Note: only works on NT
+# Note: only works on NT.
local rule invokes-cygwin-symlink ( cmd )
{
local dirs = $(cmd:D) ;
@@ -220,6 +217,7 @@
}
}
+
local rule debug-message ( message * )
{
if --debug-configuration in [ modules.peek : ARGV ]
@@ -228,11 +226,12 @@
}
}
+
# Like W32_GETREG, except prepend HKEY_CURRENT_USER\SOFTWARE and
-# HKEY_LOCAL_MACHINE\SOFTWARE to the first argument, returning the
-# first result found. Also accounts for the fact that on 64-bit
-# machines, 32-bit software has its own area, under
-# SOFTWARE\Wow6432node.
+# HKEY_LOCAL_MACHINE\SOFTWARE to the first argument, returning the first result
+# found. Also accounts for the fact that on 64-bit machines, 32-bit software has
+# its own area, under SOFTWARE\Wow6432node.
+#
local rule software-registry-value ( path : data ? )
{
local result ;
@@ -250,6 +249,7 @@
return $(result) ;
}
+
.windows-drive-letter-re = ^([A-Za-z]):[\\/](.*) ;
.cygwin-drive-letter-re = ^/cygdrive/([a-z])/(.*) ;
@@ -257,21 +257,23 @@
.working-drive-letter = [ SUBST $(.working-directory) $(.windows-drive-letter-re) $1 ] ;
.working-drive-letter ?= [ SUBST $(.working-directory) $(.cygwin-drive-letter-re) $1 ] ;
+
local rule windows-to-cygwin-path ( path )
{
- # if path is rooted with a drive letter, rewrite it using the
- # /cygdrive mountpoint
+ # If path is rooted with a drive letter, rewrite it using the /cygdrive
+ # mountpoint.
local p = [ SUBST $(path:T) $(.windows-drive-letter-re) /cygdrive/$1/$2 ] ;
- # else if path is rooted without a drive letter, use the working directory
- p ?= [ SUBST $(path:T) ^/(.*) /cygdrive/$(.working-drive-letter:L)/$2 ] ;
+ # Else if path is rooted without a drive letter, use the working directory.
+ p ?= [ SUBST $(path:T) ^/(.*) /cygdrive/$(.working-drive-letter:L)/$2 ] ;
- # else return the path unchanged
+ # Else return the path unchanged.
return $(p:E=$(path:T)) ;
}
-# :W only works in Cygwin builds of bjam. This one works on NT builds
-# as well.
+
+# :W only works in Cygwin builds of bjam. This one works on NT builds as well.
+#
local rule cygwin-to-windows-path ( path )
{
path = $(path:R="") ; # strip any trailing slash
@@ -289,10 +291,8 @@
while $(head)
{
- local root = [
- software-registry-value "Cygnus Solutions\\Cygwin\\mounts v2\\"$(head)
- : native
- ] ;
+ local root = [ software-registry-value
+ "Cygnus Solutions\\Cygwin\\mounts v2\\"$(head) : native ] ;
if $(root)
{
@@ -314,7 +314,9 @@
return [ regex.replace $(path:R="") / \\ ] ;
}
-# Convert a *nix path to native
+
+# Convert a *nix path to native.
+#
local rule *nix-path-to-native ( path )
{
if [ os.name ] = NT
@@ -324,7 +326,9 @@
return $(path) ;
}
-# Convert an NT path to native
+
+# Convert an NT path to native.
+#
local rule windows-path-to-native ( path )
{
if [ os.name ] = NT
@@ -337,13 +341,15 @@
}
}
-# Return nonempty if path looks like a windows path, i.e. it starts
-# with a drive letter or contains backslashes.
+
+# Return nonempty if path looks like a windows path, i.e. it starts with a drive
+# letter or contains backslashes.
local rule guess-windows-path ( path )
{
return [ SUBST $(path) ($(.windows-drive-letter-re)|.*([\\]).*) $1 ] ;
}
+
local rule path-to-native ( paths * )
{
local result ;
@@ -362,8 +368,9 @@
return $(result) ;
}
-# Validate the version string and extract the major/minor part we care
-# about
+
+# Validate the version string and extract the major/minor part we care about.
+#
local rule split-version ( version )
{
local major-minor = [ MATCH ^([0-9]+)\.([0-9]+)(.*)$ : $(version) : 1 2 3 ] ;
@@ -378,16 +385,18 @@
return $(major-minor[1]) $(major-minor[2]) ;
}
-# Build a list of versions from 3.0 down to 1.5. Because bjam
-# can't enumerate registry sub-keys, we have no way of finding
-# a version with a 2-digit minor version, e.g. 2.10 -- let's
-# hope that never happens.
+
+# Build a list of versions from 3.0 down to 1.5. Because bjam can't enumerate
+# registry sub-keys, we have no way of finding a version with a 2-digit minor
+# version, e.g. 2.10 -- let's hope that never happens.
+#
.version-countdown = ;
for local v in [ numbers.range 15 30 ]
{
.version-countdown = [ SUBST $(v) (.)(.*) $1.$2 ] $(.version-countdown) ;
}
+
local rule windows-installed-pythons ( version ? )
{
version ?= $(.version-countdown) ;
@@ -409,6 +418,7 @@
return $(interpreters) ;
}
+
local rule darwin-installed-pythons ( version ? )
{
version ?= $(.version-countdown) ;
@@ -420,12 +430,14 @@
return $(prefix)/Versions/$(version)/bin/python ;
}
-# Assume "python-cmd" invokes a python interpreter and invoke it to
-# extract all the information we care about from its "sys" module.
-# Returns void if unsuccessful.
+
+# Assume "python-cmd" invokes a python interpreter and invoke it to extract all
+# the information we care about from its "sys" module. Returns void if
+# unsuccessful.
+#
local rule probe ( python-cmd )
{
- # Avoid invoking a Cygwin symlink on NT
+ # Avoid invoking a Cygwin symlink on NT.
local skip-symlink ;
if [ os.name ] = NT
{
@@ -447,13 +459,11 @@
}
else
{
- # Prepare a List of Python format strings and expressions that
- # can be used to print the constants we want from the sys
- # module.
-
- # We don't really want sys.version since that's a complicated
- # string, so get the information from sys.version_info
- # instead.
+ # Prepare a List of Python format strings and expressions that can be
+ # used to print the constants we want from the sys module.
+
+ # We don't really want sys.version since that's a complicated string, so
+ # get the information from sys.version_info instead.
local format = "version=%d.%d" ;
local exprs = "version_info[0]" "version_info[1]" ;
@@ -463,22 +473,21 @@
exprs += $(s) ;
}
- # Invoke Python and ask it for all those values
+ # Invoke Python and ask it for all those values.
local full-cmd =
- $(python-cmd)" -c \"from sys import *; print '"$(format:J=\\n)"' % ("$(exprs:J=,)")\"" ;
+ $(python-cmd)" -c \"from sys import *; print '"$(format:J=\\n)"' % ("$(exprs:J=,)")\"" ;
local output = [ shell-cmd $(full-cmd) ] ;
if $(output)
{
- # Parse the output to get all the results
+ # Parse the output to get all the results.
local nl = "
" ;
for s in $(sys-elements)
{
- # These variables are expected to be declared local in
- # the caller, so Jam's dynamic scoping will set their
- # values there.
+ # These variables are expected to be declared local in the
+ # caller, so Jam's dynamic scoping will set their values there.
sys.$(s) = [ SUBST $(output) \\<$(s)=([^$(nl)]+) $1 ] ;
}
}
@@ -486,30 +495,29 @@
}
}
-# Make sure the "libraries" and "includes" variables (in an enclosing
-# scope) have a value based on the information given.
-local rule compute-default-paths (
- target-os : version ? : prefix ? : exec-prefix ? )
+
+# Make sure the "libraries" and "includes" variables (in an enclosing scope)
+# have a value based on the information given.
+#
+local rule compute-default-paths ( target-os : version ? : prefix ? :
+ exec-prefix ? )
{
exec-prefix ?= $(prefix) ;
if $(target-os) = windows
{
- # The exec_prefix is where you're supposed to look for
- # machine-specific libraries.
+ # The exec_prefix is where you're supposed to look for machine-specific
+ # libraries.
local default-library-path = $(exec-prefix)\\libs ;
local default-include-path = $(:E=Include:R=$(prefix)) ;
- # If the interpreter was found in a directory
- # called "PCBuild" or "PCBuild8," assume we're
- # looking at a Python built from the source
- # distro, and go up one additional level to the
- # default root. Otherwise, the default root is
- # the directory where the interpreter was found.
-
- # We ask Python itself what the executable path is
- # in case of intermediate symlinks or shell
- # scripts.
+ # If the interpreter was found in a directory called "PCBuild" or
+ # "PCBuild8," assume we're looking at a Python built from the source
+ # distro, and go up one additional level to the default root. Otherwise,
+ # the default root is the directory where the interpreter was found.
+
+ # We ask Python itself what the executable path is in case of
+ # intermediate symlinks or shell scripts.
local executable-dir = $(sys.executable:D) ;
if [ MATCH ^(PCBuild) : $(executable-dir:D=) ]
@@ -517,8 +525,7 @@
debug-message "This Python appears to reside in a source distribution;" ;
debug-message "prepending \""$(executable-dir)"\" to default library search path" ;
- default-library-path = $(executable-dir)
- $(default-library-path) ;
+ default-library-path = $(executable-dir) $(default-library-path) ;
default-include-path = $(:E=PC:R=$(executable-dir:D)) $(default-include-path) ;
@@ -537,11 +544,11 @@
}
}
-# The version of the python interpreter to use
+# The version of the python interpreter to use.
feature.feature python : : propagated ;
feature.feature python.interpreter : : free ;
-flags python.capture-output PYTHON : <python.interpreter> ;
+toolset.flags python.capture-output PYTHON : <python.interpreter> ;
#
# Support for Python configured --with-pydebug
@@ -549,79 +556,78 @@
feature.feature python-debugging : off on : propagated ;
builtin.variant debug-python : debug : <python-debugging>on ;
+
# Return a list of candidate commands to try when looking for a Python
-# interpreter. prefix is expected to be a native path.
+# interpreter. prefix is expected to be a native path.
+#
local rule candidate-interpreters ( version ? : prefix ? : target-os )
{
local bin-path = bin ;
if $(target-os) = windows
{
- # on Windows, look in the root directory itself and, to work
- # with the result of a build-from-source, the PCBuild directory
- bin-path = PCBuild8 PCBuild "" ;
+ # On Windows, look in the root directory itself and, to work with the
+ # result of a build-from-source, the PCBuild directory.
+ bin-path = PCBuild8 PCBuild "" ;
}
bin-path = $(bin-path:R=$(prefix)) ;
if $(target-os) in windows darwin
{
- return # Search:
- $(:E=python:R=$(bin-path)) # Relative to the prefix, if any
- python # In the PATH
- [ $(target-os)-installed-pythons $(version) ] # Standard install locations
+ return # Search:
+ $(:E=python:R=$(bin-path)) # Relative to the prefix, if any
+ python # In the PATH
+ [ $(target-os)-installed-pythons $(version) ] # Standard install locations
;
}
else
{
- # Search relative to the prefix, or if none supplied, in PATH
+ # Search relative to the prefix, or if none supplied, in PATH.
local unversioned = $(:E=python:R=$(bin-path:E=)) ;
- # if a version was specified, look for a python with that
- # specific version appended before looking for one called,
- # simply, "python"
+ # If a version was specified, look for a python with that specific
+ # version appended before looking for one called, simply, "python"
return $(unversioned)$(version) $(unversioned) ;
}
}
-# Compute system library dependencies for targets linking with
-# static Python libraries.
+
+# Compute system library dependencies for targets linking with static Python
+# libraries.
+#
+# On many systems, Python uses libraries such as pthreads or libdl. Since static
+# libraries carry no library dependency information of their own that the linker
+# can extract, these extra dependencies have to be given explicitly on the link
+# line of the client. The information about these dependencies is packaged into
+# the "python" target below.
+#
+# Even where Python itself uses pthreads, it never allows extension modules to
+# be entered concurrently (unless they explicitly give up the interpreter lock).
+# Therefore, extension modules don't need the efficiency overhead of threadsafe
+# code as produced by <threading>multi, and we handle libpthread along with
+# other libraries here. Note: this optimization is based on an assumption that
+# the compiler generates link-compatible code in both the single- and
+# multi-threaded cases, and that system libraries don't change their ABIs
+# either.
#
-# On many systems, Python uses libraries such as pthreads or
-# libdl. Since static libraries carry no library dependency
-# information of their own that the linker can extract, these
-# extra dependencies have to be given explicitly on the link line
-# of the client. The information about these dependencies is
-# packaged into the "python" target below.
-
-# Even where Python itself uses pthreads, it never allows
-# extension modules to be entered concurrently (unless they
-# explicitly give up the interpreter lock). Therefore, extension
-# modules don't need the efficiency overhead of threadsafe code as
-# produced by <threading>multi, and we handle libpthread along
-# with other libraries here. Note: this optimization is based on
-# an assumption that the compiler generates link-compatible code
-# in both the single- and multi-threaded cases, and that system
-# libraries don't change their ABIs either.
+# Returns a list of usage-requirements that link to the necessary system
+# libraries.
#
-# Returns a list of usage-requirements that link to the necessary
-# system libraries.
local rule system-library-dependencies ( target-os )
{
switch $(target-os)
{
case s[uo][nl]* : # solaris, sun, sunos
- # Add a librt dependency for the gcc toolset on SunOS (the
- # sun toolset adds -lrt unconditionally). While this
- # appears to duplicate the logic already in gcc.jam, it
- # doesn't as long as we're not forcing <threading>multi.
-
- # On solaris 10,
- # distutils.sysconfig.get_config_var('LIBS') yields
- # '-lresolv -lsocket -lnsl -lrt -ldl'. However, that
- # doesn't seem to be the right list for extension modules.
- # For example, on my installation, adding -ldl causes at
- # least one test to fail because the library can't be
- # found and removing it causes no failures.
+ # Add a librt dependency for the gcc toolset on SunOS (the sun
+ # toolset adds -lrt unconditionally). While this appears to
+ # duplicate the logic already in gcc.jam, it doesn't as long as
+ # we're not forcing <threading>multi.
+
+ # On solaris 10, distutils.sysconfig.get_config_var('LIBS') yields
+ # '-lresolv -lsocket -lnsl -lrt -ldl'. However, that doesn't seem to
+ # be the right list for extension modules. For example, on my
+ # installation, adding -ldl causes at least one test to fail because
+ # the library can't be found and removing it causes no failures.
# Apparently, though, we need to add -lrt for gcc.
return <toolset>gcc:<library>rt ;
@@ -640,11 +646,13 @@
}
}
+
# Declare a target to represent Python's library.
+#
local rule declare-libpython-target ( version ? : requirements * )
{
- # Compute the representation of Python version in the name of
- # Python's library file.
+ # Compute the representation of Python version in the name of Python's
+ # library file.
local lib-version = $(version) ;
if <target-os>windows in $(requirements)
{
@@ -664,13 +672,14 @@
ECHO *** warning: to 'using python'. ;
}
- # Declare it
+ # Declare it.
lib python.lib : : <name>python$(lib-version) $(requirements) ;
}
-# implementation of init
-local rule configure (
- version ? : cmd-or-prefix ? : includes * : libraries ? : condition * : extension-suffix ? )
+
+# Implementation of init.
+local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
+ condition * : extension-suffix ? )
{
local prefix ;
local exec-prefix ;
@@ -687,7 +696,7 @@
}
extension-suffix ?= "" ;
- # Normalize and dissect any version number
+ # Normalize and dissect any version number.
local major-minor ;
if $(version)
{
@@ -699,7 +708,7 @@
if ! $(cmd-or-prefix) || [ GLOB $(cmd-or-prefix) : * ]
{
- # if the user didn't pass a command, whatever we got was a prefix
+ # If the user didn't pass a command, whatever we got was a prefix.
prefix = $(cmd-or-prefix) ;
cmds-to-try = [ candidate-interpreters $(version) : $(prefix) : $(target-os) ] ;
}
@@ -708,9 +717,9 @@
# Work with the command the user gave us.
cmds-to-try = $(cmd-or-prefix) ;
- # On windows, don't nail down the interpreter command just yet
- # in case the user specified something that turns out to be a
- # cygwin symlink, which could bring down bjam if we invoke it.
+ # On windows, don't nail down the interpreter command just yet in case
+ # the user specified something that turns out to be a cygwin symlink,
+ # which could bring down bjam if we invoke it.
if $(target-os) != windows
{
interpreter-cmd = $(cmd-or-prefix) ;
@@ -724,15 +733,15 @@
# Anything left to find or check?
if ! ( $(interpreter-cmd) && $(includes) && $(libraries) )
{
- # Values to be extracted from python's sys module. These will
- # be set by the probe rule, above, using Jam's dynamic scoping.
+ # Values to be extracted from python's sys module. These will be set by
+ # the probe rule, above, using Jam's dynamic scoping.
local sys-elements = version platform prefix exec_prefix executable ;
local sys.$(sys-elements) ;
- # compute the string Python's sys.platform needs to match. If
- # not targeting windows or cygwin we'll assume only native
- # builds can possibly run, so we won't require a match and we
- # leave sys.platform blank.
+ # Compute the string Python's sys.platform needs to match. If not
+ # targeting windows or cygwin we'll assume only native builds can
+ # possibly run, so we won't require a match and we leave sys.platform
+ # blank.
local platform ;
switch $(target-os)
{
@@ -742,7 +751,7 @@
while $(cmds-to-try)
{
- # pop top command
+ # Pop top command.
local cmd = $(cmds-to-try[1]) ;
cmds-to-try = $(cmds-to-try[2-]) ;
@@ -751,7 +760,7 @@
{
fallback-version ?= $(sys.version) ;
- # Check for version/platform validity
+ # Check for version/platform validity.
for local x in version platform
{
if $($(x)) && $($(x)) != $(sys.$(x))
@@ -768,15 +777,12 @@
exec-prefix = $(sys.exec_prefix) ;
- compute-default-paths
- $(target-os)
- : $(sys.version)
- : $(sys.prefix)
- : $(sys.exec_prefix) ;
+ compute-default-paths $(target-os) : $(sys.version) :
+ $(sys.prefix) : $(sys.exec_prefix) ;
version = $(sys.version) ;
interpreter-cmd ?= $(cmd) ;
- cmds-to-try = ; # All done.
+ cmds-to-try = ; # All done.
}
}
else
@@ -822,13 +828,12 @@
debug-message " DLL search path:" \"$(exec-prefix:E=<empty>)\" ;
}
-
#
- # End autoconfiguration sequence
+ # End autoconfiguration sequence.
#
local target-requirements = $(condition) ;
- # Add the version, if any, to the target requirements
+ # Add the version, if any, to the target requirements.
if $(version)
{
if ! $(version) in [ feature.values python ]
@@ -840,11 +845,11 @@
target-requirements += <target-os>$(target-os) ;
- # See if we can find a framework directory on darwin
+ # See if we can find a framework directory on darwin.
local framework-directory ;
if $(target-os) = darwin
{
- # Search upward for the framework directory
+ # Search upward for the framework directory.
local framework-directory = $(libraries[-1]) ;
while $(framework-directory:D=) && $(framework-directory:D=) != Python.framework
{
@@ -864,14 +869,14 @@
local dll-path = $(libraries) ;
- # Make sure that we can find the Python DLL on windows
+ # Make sure that we can find the Python DLL on windows.
if $(target-os) = windows && $(exec-prefix)
{
dll-path += $(exec-prefix) ;
}
#
- # prepare usage requirements
+ # Prepare usage requirements.
#
local usage-requirements = [ system-library-dependencies $(target-os) ] ;
usage-requirements += <include>$(includes) <python.interpreter>$(interpreter-cmd) ;
@@ -879,8 +884,8 @@
{
if $(target-os) = windows
{
- # in pyconfig.h, Py_DEBUG is set if _DEBUG is set. If we
- # define Py_DEBUG we'll get multiple definition warnings.
+ # In pyconfig.h, Py_DEBUG is set if _DEBUG is set. If we define
+ # Py_DEBUG we'll get multiple definition warnings.
usage-requirements += <define>_DEBUG ;
}
else
@@ -888,7 +893,7 @@
usage-requirements += <define>Py_DEBUG ;
}
}
-
+
# Global, but conditional, requirements to give access to the interpreter
# for general utilities, like other toolsets, that run Python scripts.
toolset.add-requirements
@@ -899,7 +904,7 @@
#
# Declare the "python" target. This should really be called
- # python_for_embedding
+ # python_for_embedding.
#
if $(framework-directory)
@@ -915,113 +920,115 @@
{
declare-libpython-target $(version) : $(target-requirements) ;
- # This is an evil hack. On, Windows, when Python is embedded,
- # nothing seems to set up sys.path to include Python's
- # standard library
- # (http://article.gmane.org/gmane.comp.python.general/544986). The
- # evil here, aside from the workaround necessitated by
- # Python's bug, is that:
+ # This is an evil hack. On, Windows, when Python is embedded, nothing
+ # seems to set up sys.path to include Python's standard library
+ # (http://article.gmane.org/gmane.comp.python.general/544986). The evil
+ # here, aside from the workaround necessitated by Python's bug, is that:
#
- # a. we're guessing the location of the python standard
- # library from the location of pythonXX.lib
+ # a. we're guessing the location of the python standard library from the
+ # location of pythonXX.lib
#
- # b. we're hijacking the <testing.launcher> property to get
- # the environment variable set up, and the user may want to
- # use it for something else (e.g. launch the debugger).
+ # b. we're hijacking the <testing.launcher> property to get the
+ # environment variable set up, and the user may want to use it for
+ # something else (e.g. launch the debugger).
local set-PYTHONPATH ;
if $(target-os) = windows
{
- set-PYTHONPATH =
- [ common.prepend-path-variable-command PYTHONPATH : $(libraries:D)/Lib ] ;
+ set-PYTHONPATH = [ common.prepend-path-variable-command PYTHONPATH :
+ $(libraries:D)/Lib ] ;
}
alias python
:
: $(target-requirements)
:
- # why python.lib must be listed here instead of along with
- # the system libs is a mystery, but if we don't do it, on
- # cygwin, -lpythonX.Y never appears in the command line
- # (although it does on linux).
+ # Why python.lib must be listed here instead of along with the
+ # system libs is a mystery, but if we don't do it, on cygwin,
+ # -lpythonX.Y never appears in the command line (although it does on
+ # linux).
: $(usage-requirements)
<testing.launcher>$(set-PYTHONPATH)
<library-path>$(libraries) <dll-path>$(dll-path) <library>python.lib
;
}
- # On *nix, we don't want to link either Boost.Python or Python
- # extensions to libpython, because the Python interpreter itself
- # provides all those symbols. If we linked to libpython, we'd get
- # duplicate symbols. So declare two targets -- one for building
- # extensions and another for embedding
+ # On *nix, we don't want to link either Boost.Python or Python extensions to
+ # libpython, because the Python interpreter itself provides all those
+ # symbols. If we linked to libpython, we'd get duplicate symbols. So declare
+ # two targets -- one for building extensions and another for embedding.
#
# Unlike most *nix systems, Mac OS X's linker does not permit undefined
- # symbols when linking a shared library. So, we still need to link
- # against the Python framework, even when building extensions.
- # Note that framework builds of Python always use shared libraries,
- # so we do not need to worry about duplicate Python symbols.
+ # symbols when linking a shared library. So, we still need to link against
+ # the Python framework, even when building extensions. Note that framework
+ # builds of Python always use shared libraries, so we do not need to worry
+ # about duplicate Python symbols.
if $(target-os) in windows cygwin darwin
{
alias python_for_extensions : python : $(target-requirements) ;
}
- # On AIX we need Python extensions and Boost.Python to import symbols
- # from the Python interpreter. Dynamic libraries opened with dlopen()
- # do not inherit the symbols from the Python interpreter.
+ # On AIX we need Python extensions and Boost.Python to import symbols from
+ # the Python interpreter. Dynamic libraries opened with dlopen() do not
+ # inherit the symbols from the Python interpreter.
else if $(target-os) = aix
{
alias python_for_extensions
- :
- : $(target-requirements)
- :
- : $(usage-requirements) <linkflags>-Wl,-bI:$(libraries[1])/python.exp
- ;
+ :
+ : $(target-requirements)
+ :
+ : $(usage-requirements) <linkflags>-Wl,-bI:$(libraries[1])/python.exp
+ ;
}
else
{
alias python_for_extensions
- :
- : $(target-requirements)
- :
- : $(usage-requirements)
- ;
+ :
+ : $(target-requirements)
+ :
+ : $(usage-requirements)
+ ;
}
}
+
rule configured ( )
{
return $(.configured) ;
}
+
type.register PYTHON_EXTENSION : : SHARED_LIB ;
+
local rule register-extension-suffix ( root : condition * )
{
local suffix ;
switch [ feature.get-values target-os : $(condition) ]
{
- case windows : suffix = pyd ;
- case cygwin : suffix = dll ;
- case hpux :
- {
- if [ feature.get-values python : $(condition) ] in 1.5 1.6 2.0 2.1 2.2 2.3 2.4
- {
- suffix = sl ;
- }
- else
- {
- suffix = so ;
- }
- }
- case * : suffix = so ;
+ case windows : suffix = pyd ;
+ case cygwin : suffix = dll ;
+ case hpux :
+ {
+ if [ feature.get-values python : $(condition) ] in 1.5 1.6 2.0 2.1 2.2 2.3 2.4
+ {
+ suffix = sl ;
+ }
+ else
+ {
+ suffix = so ;
+ }
+ }
+ case * : suffix = so ;
}
type.set-generated-target-suffix PYTHON_EXTENSION : $(condition) : <$(root).$(suffix)> ;
}
+
# Unset 'lib' prefix for PYTHON_EXTENSION
type.set-generated-target-prefix PYTHON_EXTENSION : : "" ;
+
rule python-extension ( name : sources * : requirements * : default-build * :
usage-requirements * )
{
@@ -1044,7 +1051,7 @@
IMPORT python : python-extension : : python-extension ;
-# Support for testing
+# Support for testing.
type.register PY : py ;
type.register RUN_PYD_OUTPUT ;
type.register RUN_PYD : : TEST ;
@@ -1113,38 +1120,38 @@
local extension = [ generators.construct $(project) $(name) :
PYTHON_EXTENSION : $(property-set) : $(s) $(libs) ] ;
- # The important part of usage requirements returned
- # from PYTHON_EXTENSION generator are xdll-path
- # properties that will allow us to find the python
- # extension at runtime.
+ # The important part of usage requirements returned from
+ # PYTHON_EXTENSION generator are xdll-path properties that will
+ # allow us to find the python extension at runtime.
property-set = [ $(property-set).add $(extension[1]) ] ;
- # Ignore usage requirements. We're a top-level
- # generator and nobody is going to use what we
- # generate.
+ # Ignore usage requirements. We're a top-level generator and
+ # nobody is going to use what we generate.
new-sources += $(extension[2-]) ;
}
}
property-set = [ $(property-set).add-raw <dependency>$(other-pythons) ] ;
- result = [ construct-result $(python) $(extensions) $(new-sources)
- : $(project) $(name) : $(property-set) ] ;
+ result = [ construct-result $(python) $(extensions) $(new-sources) :
+ $(project) $(name) : $(property-set) ] ;
}
}
+
generators.register
[ new python-test-generator python.capture-output : : RUN_PYD_OUTPUT ] ;
generators.register-standard testing.expect-success
: RUN_PYD_OUTPUT : RUN_PYD ;
-# There are two different ways of spelling OS names. One is used for
-# [ os.name ] and the other is used for the <host-os> and <target-os>
-# properties. Until that is remedied, this sets up a crude mapping
-# from the latter to the former, that will work *for the purposes of
-# cygwin/NT cross-builds only*. Couldn't think of a better name than
-# "translate"
+
+# There are two different ways of spelling OS names. One is used for [ os.name ]
+# and the other is used for the <host-os> and <target-os> properties. Until that
+# is remedied, this sets up a crude mapping from the latter to the former, that
+# will work *for the purposes of cygwin/NT cross-builds only*. Couldn't think of
+# a better name than "translate".
+#
.translate-os-windows = NT ;
.translate-os-cygwin = CYGWIN ;
local rule translate-os ( src-os )
@@ -1153,55 +1160,56 @@
return $(x[1]) ;
}
+
# Extract the path to a single ".pyd" source. This is used to build the
# PYTHONPATH for running bpl tests.
+#
local rule pyd-pythonpath ( source )
{
return [ on $(source) return $(LOCATE) $(SEARCH) ] ;
}
-# The flag settings on testing.capture-output do not
-# apply to python.capture output at the moment.
-# Redo this explicitly.
+
+# The flag settings on testing.capture-output do not apply to python.capture
+# output at the moment. Redo this explicitly.
toolset.flags python.capture-output ARGS <testing.arg> ;
+
+
rule capture-output ( target : sources * : properties * )
{
- # Setup up proper DLL search path.
- # Here, $(sources[1]) is python module and $(sources[2]) is
- # DLL. Only $(sources[1]) is passed to testing.capture-output,
- # so RUN_PATH variable on $(sources[2]) is not consulted. Move it
- # over explicitly.
+ # Setup up proper DLL search path. Here, $(sources[1]) is python module and
+ # $(sources[2]) is DLL. Only $(sources[1]) is passed to
+ # testing.capture-output, so RUN_PATH variable on $(sources[2]) is not
+ # consulted. Move it over explicitly.
RUN_PATH on $(sources[1]) = [ on $(sources[2-]) return $(RUN_PATH) ] ;
PYTHONPATH = [ sequence.transform pyd-pythonpath : $(sources[2-]) ] ;
PYTHONPATH += [ feature.get-values pythonpath : $(properties) ] ;
-
- # After test is run, we remove the Python module, but not the Python
- # script.
- testing.capture-output $(target) : $(sources[1]) : $(properties)
- : $(sources[2-]) ;
-
- # PYTHONPATH is different; it will be interpreted by whichever
- # Python is invoked and so must follow path rules for the target
- # os. The only OSes where we can run pythons for other OSes
- # currently are NT and CYGWIN, so we only need to handle those
- # cases.
+
+ # After test is run, we remove the Python module, but not the Python script.
+ testing.capture-output $(target) : $(sources[1]) : $(properties) :
+ $(sources[2-]) ;
+
+ # PYTHONPATH is different; it will be interpreted by whichever Python is
+ # invoked and so must follow path rules for the target os. The only OSes
+ # where we can run pythons for other OSes currently are NT and CYGWIN, so we
+ # only need to handle those cases.
local target-os = [ feature.get-values target-os : $(properties) ] ;
- # oddly, host-os isn't in properties, so grab the default value.
+ # Oddly, host-os isn't in properties, so grab the default value.
local host-os = [ feature.defaults host-os ] ;
host-os = $(host-os:G=) ;
if $(target-os) != $(host-os)
{
- PYTHONPATH =
- [ sequence.transform $(host-os)-to-$(target-os)-path : $(PYTHONPATH) ] ;
+ PYTHONPATH = [ sequence.transform $(host-os)-to-$(target-os)-path :
+ $(PYTHONPATH) ] ;
}
- local path-separator =
- [ os.path-separator [ translate-os $(target-os) ] ] ;
- local set-PYTHONPATH =
- [ common.variable-setting-command PYTHONPATH : $(PYTHONPATH:J=$(path-separator)) ] ;
+ local path-separator = [ os.path-separator [ translate-os $(target-os) ] ] ;
+ local set-PYTHONPATH = [ common.variable-setting-command PYTHONPATH :
+ $(PYTHONPATH:J=$(path-separator)) ] ;
LAUNCHER on $(target) = $(set-PYTHONPATH) [ on $(target) return $(PYTHON) ] ;
}
+
rule bpl-test ( name : sources * : requirements * )
{
sources ?= $(name).py $(name).cpp ;
@@ -1210,6 +1218,5 @@
: $(requirements) : $(name) ] ;
}
-IMPORT $(__name__) : bpl-test : : bpl-test ;
-
+IMPORT $(__name__) : bpl-test : : bpl-test ;
Modified: branches/proto/v4/tools/build/v2/util/string.jam
==============================================================================
--- branches/proto/v4/tools/build/v2/util/string.jam (original)
+++ branches/proto/v4/tools/build/v2/util/string.jam 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -1,10 +1,11 @@
-# Copyright 2002 Dave Abrahams
-# Copyright 2002, 2003 Rene Rivera
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+# Copyright 2002 Dave Abrahams
+# Copyright 2002, 2003 Rene Rivera
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import regex ;
+
# Characters considered whitespace, as a list.
.whitespace-chars = " " " " "
" ;
@@ -12,6 +13,7 @@
# Characters considered whitespace, as a single string.
.whitespace = $(.whitespace-chars:J="") ;
+
# Returns the canonical set of whitespace characters, as a list.
#
rule whitespace-chars ( )
@@ -19,6 +21,7 @@
return $(.whitespace-chars) ;
}
+
# Returns the canonical set of whitespace characters, as a single string.
#
rule whitespace ( )
@@ -26,11 +29,12 @@
return $(.whitespace) ;
}
-# Splits the given string into a list of strings composed
-# of each character of the string in sequence.
+
+# Splits the given string into a list of strings composed of each character of
+# the string in sequence.
#
rule chars (
- string # The string to split.
+ string # The string to split.
)
{
local result ;
@@ -40,18 +44,19 @@
string = $(s[9]) ;
result += $(s[1-8]) ;
}
-
- # trim off empty strings
+
+ # Trim off empty strings.
while $(result[1]) && ! $(result[-1])
{
result = $(result[1--2]) ;
}
-
+
return $(result) ;
}
-# Apply a set of standard transformations to string to produce an
-# abbreviation no more than 5 characters long
+
+# Apply a set of standard transformations to string to produce an abbreviation
+# no more than 5 characters long.
#
rule abbreviate ( string )
{
@@ -60,22 +65,22 @@
{
return $(r) ;
}
- # Anything less than 4 characters gets no abbreviation
+ # Anything less than 4 characters gets no abbreviation.
else if ! [ MATCH (....) : $(string) ]
{
- $(.abbreviated-$(string)) = $(string) ;
+ .abbreviated-$(string) = $(string) ;
return $(string) ;
}
else
{
- # Separate the initial letter in case it's a vowel
+ # Separate the initial letter in case it's a vowel.
local s1 = [ MATCH ^(.)(.*) : $(string) ] ;
-
- # drop trailing "ing"
+
+ # Drop trailing "ing".
local s2 = [ MATCH ^(.*)ing$ : $(s1[2]) ] ;
s2 ?= $(s1[2]) ;
-
- # Reduce all doubled characters to one
+
+ # Reduce all doubled characters to one.
local last = "" ;
for local c in [ chars $(s2) ]
{
@@ -86,38 +91,40 @@
}
}
s2 = $(r:J="") ;
-
- # Chop all vowels out of the remainder
+
+ # Chop all vowels out of the remainder.
s2 = [ regex.replace $(s2) [AEIOUaeiou] "" ] ;
- # Shorten remaining consonants to 4 characters
+ # Shorten remaining consonants to 4 characters.
s2 = [ MATCH ^(.?.?.?.?) : $(s2) ] ;
-
- # Glue the initial character back on to the front
+
+ # Glue the initial character back on to the front.
s2 = $(s1[1])$(s2) ;
-
- $(.abbreviated-$(string)) = $(s2) ;
+
+ .abbreviated-$(string) = $(s2) ;
return $(s2) ;
}
}
-# Concatenates the given strings, inserting the given separator
-# between each string.
+
+# Concatenates the given strings, inserting the given separator between each
+# string.
#
rule join (
- strings * # The strings to join.
- : separator ? # The optional separator.
+ strings * # The strings to join.
+ : separator ? # The optional separator.
)
{
separator ?= "" ;
return $(strings:J=$(separator)) ;
}
+
# Split a string into whitespace separated words.
#
rule words (
- string # The string to split.
- : whitespace * # Optional, characters to consider as whitespace.
+ string # The string to split.
+ : whitespace * # Optional, characters to consider as whitespace.
)
{
whitespace = $(whitespace:J="") ;
@@ -135,10 +142,11 @@
return $(w) ;
}
+
# Check that the given string is composed entirely of whitespace.
#
rule is-whitespace (
- string ? # The string to test.
+ string ? # The string to test.
)
{
if ! $(string) { return true ; }
@@ -151,7 +159,7 @@
{
import assert ;
assert.result a b c : chars abc ;
-
+
assert.result rntm : abbreviate runtime ;
assert.result ovrld : abbreviate overload ;
assert.result dbg : abbreviate debugging ;
@@ -160,20 +168,20 @@
assert.result aaa : abbreviate aaa ;
assert.result qck : abbreviate quack ;
assert.result sttc : abbreviate static ;
-
- # check boundary cases
+
+ # Check boundary cases.
assert.result a : chars a ;
assert.result : chars "" ;
assert.result a b c d e f g h : chars abcdefgh ;
assert.result a b c d e f g h i : chars abcdefghi ;
assert.result a b c d e f g h i j : chars abcdefghij ;
assert.result a b c d e f g h i j k : chars abcdefghijk ;
-
+
assert.result a//b/c/d : join a "" b c d : / ;
assert.result abcd : join a "" b c d ;
-
+
assert.result a b c : words "a b c" ;
-
+
assert.true is-whitespace " " ;
assert.false is-whitespace " a b c " ;
assert.true is-whitespace "" ;
Modified: branches/proto/v4/tools/jam/src/execunix.c
==============================================================================
--- branches/proto/v4/tools/jam/src/execunix.c (original)
+++ branches/proto/v4/tools/jam/src/execunix.c 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -25,7 +25,7 @@
# ifdef USE_EXECUNIX
# include <sys/times.h>
-# if defined(__APPLE__) && defined(__ppc__)
+# if defined(__APPLE__)
# define NO_VFORK
# endif
Modified: branches/proto/v4/tools/regression/xsl_reports/build_results.sh
==============================================================================
--- branches/proto/v4/tools/regression/xsl_reports/build_results.sh (original)
+++ branches/proto/v4/tools/regression/xsl_reports/build_results.sh 2008-06-02 18:51:11 EDT (Mon, 02 Jun 2008)
@@ -103,11 +103,6 @@
reports="dd,ds,i,n"
;;
- release)
- tag=branches/release
- reports="dd,ds,i,n"
- ;;
-
release-1_35_0)
tag=tags/release/Boost_1_35_0
reports="dd,ud,ds,us,ddr,udr,dsr,usr,i,n,e"
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk