diff --git a/doc/building.html b/doc/building.html index f066c2f1..b50dcb87 100644 --- a/doc/building.html +++ b/doc/building.html @@ -118,9 +118,9 @@ Windows: c:/Python(10*Version), e.g. c:/Python24
- Unix: /usr/local + *nix/Cygwin: /usr - On Unix, this should be the --prefix= directory used + On *nix, this should be the --prefix= directory used to configure Python when it was built and installed. @@ -176,7 +176,7 @@ CYGWIN_PYTHON_[DEBUG_]ROOT - unix-style path containing the include/ directory + *nix-style path containing the include/ directory containing python$(CYGWIN_PYTHON_[DEBUG_]VERSION)/python.h. @@ -223,8 +223,10 @@

Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users

-

You will need to create a MinGW-compatible version of the Python - library; the one shipped with Python will only work with a +

If you are using a version of Python prior to 2.4.1 with a + MinGW prior to 3.0.0 (with binutils-2.13.90-20030111-1), you will + need to create a MinGW-compatible version of the Python library; + the one shipped with Python will only work with a Microsoft-compatible linker. Follow the instructions in the "Non-Microsoft" section of the "Building Extensions: Tips And Tricks" chapter in The first two variants of the boost_python library are built by default, and are compatible with the default Python distribution. The debug-python variant corresponds to a - specially-built debugging version of Python. On Unix platforms, this + specially-built debugging version of Python. On *nix platforms, this python is built by adding --with-pydebug when configuring the Python build. On Windows, the debugging version of Python is generated by the "Win32 Debug" target of the PCBuild.dsw diff --git a/doc/news.html b/doc/news.html index f3b82e62..22b0cad3 100644 --- a/doc/news.html +++ b/doc/news.html @@ -1,138 +1,171 @@ - - - - + + + + - Boost.Python - News/Change Log - + Boost.Python - News/Change Log + - - - - + +
-

-

-
+ + - - -
+

+

+
-

Boost.Python

+
+

Boost.Python

-

News/Change Log

-
-


+

News/Change Log

+ + + +
-
-
14 October 2005 - 1.33.1 release
+
+
19 October 2005 - 1.33.1 release
-
-
    -
  • The build now assumes Python 2.4 by default, rather than 2.2
  • -
  • Support Python that's built without Unicode support
  • -
  • Support for wrapping classes with overloaded - address-of (&) operators
  • -
-
-
14 August 2005 - 1.33 release
+
+
    +
  • wrapper<T> can now be used as expected with a + held type of some-smart-pointer<T>
  • -
    -
      -
    • Support for docstrings on nonstatic properties.
    • -
    • We now export the client-provided docstrings for init<optional<> > and -XXX_FUNCTION_OVERLOADS() for only the last overload.
    • +
    • The build now assumes Python 2.4 by default, rather than 2.2
    • -
    • Fixed some support for Embedded VC++ 4
    • +
    • Support Python that's built without Unicode support
    • -
    • Better support for rvalue from-python conversions of shared_ptr: -always return a pointer that holds the owning python object *unless* -the python object contains a NULL shared_ptr holder of the right type. -
    • +
    • Support for wrapping classes with overloaded address-of + (&) operators
    • +
    +
    -
  • Support for exposing vector<T*> with the indexing suite.
  • -
  • Support for GCC-3.3 on MacOS.
  • -
  • updated visual studio project build file to include two new files (slice.cpp and wrapper.cpp)
  • -
  • Added search feature to the index page.
  • -
  • Numerous fixes to the tutorial -
  • Numerous workarounds for MSVC 6 and 7, GCC 2.96, and EDG 2.45
  • -
-
-
11 March 2005
+
14 August 2005 - 1.33 release
-
-
    -
  • Added a hack that will fool PyDoc into working with Boost.Python, thanks to Nick Rasmussen
  • -
-
-
19 November 2004 - 1.32 release
+
+
    +
  • Support for docstrings on nonstatic properties.
  • -
    -
      -
    • Updated to use the Boost Software License.
    • -
    • A new, better method of wrapping classes with virtual functions has been implemented.
    • -
    • Support for upcoming GCC symbol export control features have been folded in, thanks to Niall Douglas.
    • -
    • Improved support for std::auto_ptr-like types.
    • -
    • The Visual C++ bug that makes top-level cv-qualification of function parameter types part of the function type has been worked around.
    • -
    • Components used by other libraries have been moved out of python/detail and into boost/detail to improve dependency relationships.
    • -
    • Miscellaneous bug fixes and compiler workarounds.
    • -
    -
    -
    8 Sept 2004
    +
  • We now export the client-provided docstrings for + init<optional<> > and + XXX_FUNCTION_OVERLOADS() for only the last + overload.
  • -
    - Support for Python's Bool type, thanks to Daniel Holth. -
    +
  • Fixed some support for Embedded VC++ 4
  • -
    11 Sept 2003
    +
  • Better support for rvalue from-python conversions of shared_ptr: + always return a pointer that holds the owning python object *unless* + the python object contains a NULL shared_ptr holder of the right + type.
  • -
    -
      -
    • Changed the response to multiple to-python converters being - registered for the same type from a hard error into warning; - Boost.Python now reports the offending type in the message.
    • +
    • Support for exposing vector<T*> with the + indexing suite.
    • -
    • Added builtin std::wstring conversions
    • +
    • Support for GCC-3.3 on MacOS.
    • -
    • Added std::out_of_range => Python - IndexError exception conversion, thanks to Raoul Gough
    • -
    -
    +
  • updated visual studio project build file to include two new files + (slice.cpp and wrapper.cpp)
  • -
    9 Sept 2003
    +
  • Added search feature to the index page.
  • -
    Added new str
    +
  • Numerous fixes to the tutorial
  • -
    constructors which take a range of characters, allowing strings - containing nul ('\0') characters.
    +
  • Numerous workarounds for MSVC 6 and 7, GCC 2.96, and EDG + 2.45
  • +
+
-
8 Sept 2003
+
11 March 2005
-
Added the ability to create methods from function objects (with an - operator()); see the make_function docs for - more info.
+
+
    +
  • Added a hack that will fool PyDoc into working with Boost.Python, + thanks to Nick Rasmussen
  • +
+
-
10 August 2003
+
19 November 2004 - 1.32 release
-
Added the new properties unit tests contributed by Roman Yakovenko and documented - add_static_property at his urging.
+
+
    +
  • Updated to use the Boost Software License.
  • -
    1 August 2003
    +
  • A new, + better method of wrapping classes with virtual functions has been + implemented.
  • -
    - Added the new arg class contributed by Nikolay Mladenov which supplies the - ability to wrap functions that can be called with ommitted arguments - in the middle: -
    +        
  • Support for upcoming GCC symbol export control features have been + folded in, thanks to Niall Douglas.
  • + +
  • Improved support for std::auto_ptr-like types.
  • + +
  • The Visual C++ bug that makes top-level cv-qualification + of function parameter types part of the function type has been worked + around.
  • + +
  • Components used by other libraries have been moved out of + python/detail and into boost/detail to + improve dependency relationships.
  • + +
  • Miscellaneous bug fixes and compiler workarounds.
  • +
+
+ +
8 Sept 2004
+ +
Support for Python's Bool type, thanks to Daniel Holth.
+ +
11 Sept 2003
+ +
+
    +
  • Changed the response to multiple to-python converters being + registered for the same type from a hard error into warning; + Boost.Python now reports the offending type in the message.
  • + +
  • Added builtin std::wstring conversions
  • + +
  • Added std::out_of_range => Python + IndexError exception conversion, thanks to Raoul Gough
  • +
+
+ +
9 Sept 2003
+ +
Added new str
+ +
constructors which take a range of characters, allowing strings + containing nul ('\0') characters.
+ +
8 Sept 2003
+ +
Added the ability to create methods from function objects (with an + operator()); see the make_function docs for + more info.
+ +
10 August 2003
+ +
Added the new properties unit tests contributed by + Roman Yakovenko and + documented add_static_property at his urging.
+ +
1 August 2003
+ +
+ Added the new arg class contributed by Nikolay Mladenov which supplies the + ability to wrap functions that can be called with ommitted arguments in + the middle: +
 void f(int x = 0, double y = 3.14, std::string z = std::string("foo"));
 
 BOOST_PYTHON_MODULE(test)
@@ -141,111 +174,104 @@ BOOST_PYTHON_MODULE(test)
        , (arg("x", 0), arg("y", 3.14), arg("z", "foo")));
 }
  
-
- And in Python: -
+
And in Python: +
 >>> import test
 >>> f(0, z = "bar")
 >>> f(z = "bar", y = 0.0)
-
- Thanks, Nikolay! -
+Thanks, Nikolay! + -
22 July 2003
+
22 July 2003
-
Killed the dreaded "bad argument type for builtin operation" error. - Argument errors now show the actual and expected argument types!
+
Killed the dreaded "bad argument type for builtin operation" error. + Argument errors now show the actual and expected argument types!
-
19 July 2003
+
19 July 2003
-
Added the new return_arg policy from Nikolay Mladenov. Thanks, - Nikolay!
+
Added the new return_arg policy from Nikolay Mladenov. Thanks, Nikolay!
-
18 March, 2003
+
18 March, 2003
-
Gottfried - Ganßauge has contributed opaque pointer support.
- Bruno da Silva de Oliveira - has contributed the exciting Pyste - ("Pie-steh") package.
+
Gottfried + Ganßauge has contributed opaque pointer support.
+ Bruno da Silva de + Oliveira has contributed the exciting Pyste ("Pie-steh") package.
-
24 February 2003
+
24 February 2003
-
Finished improved support for boost::shared_ptr. Now - any wrapped object of C++ class X can be converted - automatically to shared_ptr<X>, regardless of how it - was wrapped. The shared_ptr will manage the lifetime of - the Python object which supplied the X, rather than just - the X object itself, and when such a - shared_ptr is converted back to Python, the original - Python object will be returned.
+
Finished improved support for boost::shared_ptr. Now any + wrapped object of C++ class X can be converted automatically + to shared_ptr<X>, regardless of how it was wrapped. + The shared_ptr will manage the lifetime of the Python object + which supplied the X, rather than just the X + object itself, and when such a shared_ptr is converted back + to Python, the original Python object will be returned.
-
19 January 2003
+
19 January 2003
-
Integrated staticmethod support from Nikolay Mladenov. Thanks, - Nikolay!
+
Integrated staticmethod support from Nikolay Mladenov. Thanks, Nikolay!
-
29 December 2002
+
29 December 2002
-
Added Visual Studio project file and instructions from Brett - Calcott. Thanks, Brett!
+
Added Visual Studio project file and instructions from Brett Calcott. + Thanks, Brett!
-
20 December 2002
+
20 December 2002
-
Added automatic downcasting for pointers, references, and smart - pointers to polymorphic class types upon conversion to python
+
Added automatic downcasting for pointers, references, and smart + pointers to polymorphic class types upon conversion to python
-
18 December 2002
+
18 December 2002
-
Optimized from_python conversions for wrapped classes by putting - the conversion logic in the shared library instead of registering - separate converters for each class in each extension module
+
Optimized from_python conversions for wrapped classes by putting the + conversion logic in the shared library instead of registering separate + converters for each class in each extension module
-
19 November 2002
+
19 November 2002
-
Removed the need for users to cast base class member function - pointers when used as arguments to add_property
+
Removed the need for users to cast base class member function + pointers when used as arguments to add_property
-
13 December 2002
+
13 December 2002
-
Allow exporting of enum_ values into enclosing - scope.
- Fixed unsigned integer conversions to deal correctly with numbers that - are out-of-range of signed long.
+
Allow exporting of enum_ values into enclosing + scope.
+ Fixed unsigned integer conversions to deal correctly with numbers that + are out-of-range of signed long.
-
14 November 2002
+
14 November 2002
-
Auto-detection of class data members wrapped with make_getter
+
Auto-detection of class data members wrapped with make_getter
-
13 November 2002
+
13 November 2002
-
Full Support for std::auto_ptr<> added.
+
Full Support for std::auto_ptr<> added.
-
October 2002
+
October 2002
-
Ongoing updates and improvements to tutorial documentation
+
Ongoing updates and improvements to tutorial documentation
-
10 October 2002
+
10 October 2002
-
Boost.Python V2 is released!
-
-
+
Boost.Python V2 is released!
+
+
-

Revised - - 19 November 2004 - -

+

Revised + + 19 November 2004 +

-

© Copyright Dave - Abrahams 2002-2003.

- +

© Copyright Dave + Abrahams 2002-2003.

+ - diff --git a/doc/v2/class.html b/doc/v2/class.html index a6693fcd..3130fa5b 100644 --- a/doc/v2/class.html +++ b/doc/v2/class.html @@ -1,214 +1,219 @@ - - - - + + + + - Boost.Python - <boost/python/class.hpp>, - <boost/python/class_fwd.hpp> - + Boost.Python - <boost/python/class.hpp>, + <boost/python/class_fwd.hpp> + - - - - + +
-

C++ Boost

-
+ + - - -
+

+

+
-

Boost.Python

+
+

Boost.Python

-

Headers <boost/python/class.hpp>, - <boost/python/class_fwd.hpp>

-
-
+

Headers <boost/python/class.hpp>, + <boost/python/class_fwd.hpp>

+ + + +
-

Contents

+

Contents

-
-
Introduction
+
+
Introduction
-
Classes
+
Classes
-
-
-
Class template - class_
+
+
+
Class template + class_
-
-
-
Class class_ - synopsis
+
+
+
Class class_ + synopsis
-
Class class_ - constructors
+
Class class_ + constructors
-
Class class_ - modifier functions
-
-
+
Class class_ + modifier functions
+
+
-
Class template - bases
+
Class template bases
-
-
-
Class template - bases synopsis
-
-
-
-
+
+
+
Class template + bases synopsis
+
+
+
+
-
Example(s)
-
-
+
Example(s)
+
+
-

Introduction

+

Introduction

-

<boost/python/class.hpp> defines the interface - through which users expose their C++ classes to Python. It declares the - class_ class template, which is parameterized on the class - type being exposed. It also exposes the init, - optional and bases utility class templates, - which are used in conjunction with class_.

+

<boost/python/class.hpp> defines the interface + through which users expose their C++ classes to Python. It declares the + class_ class template, which is parameterized on the class + type being exposed. It also exposes the init, + optional and bases utility class templates, which + are used in conjunction with class_.

-

<boost/python/class_fwd.hpp> contains a forward - declaration of the class_ class template.

+

<boost/python/class_fwd.hpp> contains a forward + declaration of the class_ class template.

-

Classes

+

Classes

-

Class template - class_<T, Bases, HeldType, - NonCopyable>

+

Class template + class_<T, Bases, HeldType, + NonCopyable>

-

Creates a Python class associated with the C++ type passed as its - first parameter. Although it has four template parameters, only the first - one is required. The three optional arguments can actually be supplied - in any order; Boost.Python determines - the role of the argument from its type.
-
-

+

Creates a Python class associated with the C++ type passed as its first + parameter. Although it has four template parameters, only the first one is + required. The three optional arguments can actually be supplied + in any order; Boost.Python determines + the role of the argument from its type.
+

- - - +
Template Parameter
+ + - + - + - - + + - - + + - + - - + + - - + + - + - + - - + + - - + + - + - + - - + + - - + + - + - + - - -
Template ParameterRequirementsRequirementsSemanticsSemanticsDefault
Default
T
TA class type.A class type.The class being wrapped
The class being wrapped
Bases
BasesA specialization of bases<...> which - specifies previously-exposed C++ base classes of T[1].A specialization of bases<...> which + specifies previously-exposed C++ base classes of T[1].Registers from_python conversions from wrapped - T instances to each of its exposed direct and indirect - bases. For each polymorphic base B, registers - conversions from indirectly-held wrapped B instances to - T.Registers from_python conversions from wrapped + T instances to each of its exposed direct and indirect + bases. For each polymorphic base B, registers conversions + from indirectly-held wrapped B instances to + T.bases<>
bases<>
HeldType
HeldTypeMust be T, a class derived from T, or a - Dereferenceable type for which - pointee<HeldType>::type - is T or a class derived from T.Must be T, a class derived from T, or a + Dereferenceable type for which + pointee<HeldType>::type is + T or a class derived from T.Specifies the type which is actually embedded in a Python object - wrapping a T instance. More details below.Specifies the type that is actually embedded in a Python object + wrapping a T instance when T's constructor is + called or when a T or T* is converted to + Python without the use of + ptr, + ref, or Call Policies + such as return_internal_reference. + More details below.T
T
NonCopyable
NonCopyableIf supplied, must be boost::noncopyable.If supplied, must be boost::noncopyable.Suppresses automatic registration of to_python - conversions which copy T instances. Required when - T has no publicly-accessible copy constructor.Suppresses automatic registration of to_python + conversions which copy T instances. Required when + T has no publicly-accessible copy constructor.An unspecified type other than - boost::noncopyable.
+ An unspecified type other than + boost::noncopyable. + + -

HeldType Semantics

+

HeldType Semantics

-
    -
  1. If HeldType is derived from T, its exposed - constructor(s) must accept an initial PyObject* argument - which refers back to the Python object that contains the - HeldType instance, as shown in this example. This argument is not - included in the init-expression passed to def(init_expr), below, - nor is it passed explicitly by users when Python instances of - T are created. This idiom allows C++ virtual functions - which will be overridden in Python to access the Python object so the - Python method can be invoked. Boost.Python automatically registers - additional converters which allow wrapped instances of T - to be passed to wrapped C++ functions expecting HeldType - arguments.
  2. +
      +
    1. If HeldType is derived from T, its exposed + constructor(s) must accept an initial PyObject* argument + which refers back to the Python object that contains the + HeldType instance, as shown in this example. This argument is not + included in the init-expression passed to def(init_expr), below, nor is + it passed explicitly by users when Python instances of T are + created. This idiom allows C++ virtual functions which will be overridden + in Python to access the Python object so the Python method can be + invoked. Boost.Python automatically registers additional converters which + allow wrapped instances of T to be passed to wrapped C++ + functions expecting HeldType arguments.
    2. -
    3. Because Boost.Python will always allow wrapped instances of - T to be passed in place of HeldType - arguments, specifying a smart pointer for HeldType allows - users to pass Python T instances where a smart - pointer-to-T is expected. Smart pointers such as - std::auto_ptr<> or boost::shared_ptr<> - which contain a nested type element_type designating the - referent type are automatically supported; additional smart pointer - types can be supported by specializing pointee<HeldType>.
    4. +
    5. Because Boost.Python will always allow wrapped instances of + T to be passed in place of HeldType arguments, + specifying a smart pointer for HeldType allows users to pass + Python T instances where a smart pointer-to-T + is expected. Smart pointers such as std::auto_ptr<> or + boost::shared_ptr<> + which contain a nested type element_type designating the + referent type are automatically supported; additional smart pointer types + can be supported by specializing pointee<HeldType>.
    6. -
    7. As in case 1 above, when HeldType is a smart pointer - to a class derived from T, the initial - PyObject* argument must be supplied by all of - HeldType's exposed constructors.
    8. +
    9. As in case 1 above, when HeldType is a smart pointer to + a class derived from T, the initial PyObject* + argument must be supplied by all of HeldType's exposed + constructors.
    10. -
    11. Except in cases 1 and 3, users may optionally specify that T itself - gets initialized with a similar initial PyObject* argument - by specializing has_back_reference<T>.
    12. -
    +
  3. Except in cases 1 and 3, users may optionally specify that T itself + gets initialized with a similar initial PyObject* argument + by specializing has_back_reference<T>.
  4. +
-

Class template class_ - synopsis

-
+  

Class + template class_ synopsis

+
 namespace boost { namespace python
 {
   template <class T
@@ -272,7 +277,7 @@ namespace boost { namespace python
     void add_property(char const* name, Get const& fget, char const* doc=0);
     template <class Get, class Set>
     void add_property(
-    	char const* name, Get const& fget, Set const& fset, char const* doc=0);
+        char const* name, Get const& fget, Set const& fset, char const* doc=0);
 
     template <class Get>
     void add_static_property(char const* name, Get const& fget);
@@ -287,9 +292,9 @@ namespace boost { namespace python
 }}
 
-

Class template class_ - constructors

-
+  

Class template + class_ constructors

+
 class_(char const* name);
 class_(char const* name, char const* docstring);
 template <class Init>
@@ -298,82 +303,80 @@ template <class Init>
 class_(char const* name, char const* docstring, Init init_spec);
 
-
-
Requires: name is an ntbs which conforms to Python's identifier - naming rules. If docstring is supplied, it must be an - ntbs. If init_spec is - supplied, it must be either the special enumeration constant - no_init or an init-expression compatible with - T.
+
+
Requires: name is an ntbs which conforms to Python's identifier + naming rules. If docstring is supplied, it must be an + ntbs. If init_spec is + supplied, it must be either the special enumeration constant + no_init or an init-expression compatible with + T.
-
Effects: Constructs a class_ object holding a - Boost.Python extension class named name. The - named attribute of the current scope is bound to the new - extension class.
+
Effects: Constructs a class_ object holding a + Boost.Python extension class named name. The + named attribute of the current scope is bound to the new extension + class.
-
-
    -
  • If supplied, the value of docstring is bound to - the __doc__ attribute of the extension class.
  • +
    +
      +
    • If supplied, the value of docstring is bound to the + __doc__ attribute of the extension class.
    • -
    • If init_spec is no_init, a special - __init__ function is generated which always raises a - Python exception. Otherwise, this->def(init_spec) - is called.
    • +
    • If init_spec is no_init, a special + __init__ function is generated which always raises a + Python exception. Otherwise, this->def(init_spec) is + called.
    • -
    • If init_spec is not supplied, - this->def(init<>()) is called.
    • -
    -
    +
  • If init_spec is not supplied, + this->def(init<>()) is called.
  • +
+
-
Rationale:Allowing the user to specify constructor arguments - in the class_<> constructor helps her to avoid the - common run-time errors which result from invoking wrapped member - functions without having exposed an __init__ function - which creates the requisite T instance. Types which are - not default-constructible will cause a compile-time error unless - Init is supplied. The user must always supply - name as there is currently no portable method to derive - the text of the class name from its type.
-
+
Rationale:Allowing the user to specify constructor arguments + in the class_<> constructor helps her to avoid the + common run-time errors which result from invoking wrapped member + functions without having exposed an __init__ function which + creates the requisite T instance. Types which are not + default-constructible will cause a compile-time error unless + Init is supplied. The user must always supply + name as there is currently no portable method to derive the + text of the class name from its type.
+
-

Class template - class_ modifier functions

-
+  

Class + template class_ modifier functions

+
 template <class Init>
 class_& def(Init init_expr);
 
-
-
Requires: init_expr is the result of an init-expression compatible with - T.
+
+
Requires: init_expr is the result of an init-expression compatible with + T.
-
Effects: For each valid - prefix P of Init, adds an - __init__(...) function overload to the - extension class accepting P as arguments. Each overload - generated constructs an object of HeldType according to - the semantics described above, using a copy of - init_expr's call policies. - If the longest valid prefix of - Init contains N types and init_expr - holds M keywords, an initial sequence of the keywords are used - for all but the first N - M arguments of - each overload.
+
Effects: For each valid + prefix P of Init, adds an + __init__(...) function overload to the + extension class accepting P as arguments. Each overload + generated constructs an object of HeldType according to the + semantics described above, using a copy of + init_expr's call policies. + If the longest valid prefix of + Init contains N types and init_expr + holds M keywords, an initial sequence of the keywords are used + for all but the first N - M arguments of each + overload.
-
Returns: *this
+
Returns: *this
-
Rationale: Allows users to easily expose a class' - constructor to Python.
-
-
- -
+    
Rationale: Allows users to easily expose a class' constructor + to Python.
+

+
 template <class F>
 class_& def(char const* name, Fn fn);
 template <class Fn, class A1>
@@ -384,363 +387,347 @@ template <class Fn, class A1, class A2, class A3>
 class_& def(char const* name, Fn fn, A1 const& a1, A2 const& a2, A3 const& a3);
 
-
-
Requires: name is an ntbs which conforms to Python's identifier - naming rules.
+
+
Requires: name is an ntbs which conforms to Python's identifier + naming rules.
-
-
    -
  • - If a1 is the result of an overload-dispatch-expression, - only the second form is allowed and fn must be a pointer to - function or pointer to member function whose arity is the same as A1's maximum - arity. +
    +
      +
    • If a1 is the result of an overload-dispatch-expression, + only the second form is allowed and fn must be a pointer to function + or pointer to member function whose + arity is the same as A1's maximum + arity. -
      -
      Effects: For each prefix P of - Fn's sequence of argument types, beginning with - the one whose length is A1's minimum - arity, adds a - name(...) method overload to - the extension class. Each overload generated invokes - a1's call-expression with P, using a copy - of a1's call - policies. If the longest valid prefix of A1 - contains N types and a1 holds M - keywords, an initial sequence of the keywords are used for all - but the first N - M arguments of - each overload.
      -
      -
      -
    • +
      +
      Effects: For each prefix P of + Fn's sequence of argument types, beginning with the + one whose length is A1's minimum + arity, adds a + name(...) method overload to + the extension class. Each overload generated invokes + a1's call-expression with P, using a copy + of a1's call + policies. If the longest valid prefix of A1 + contains N types and a1 holds M + keywords, an initial sequence of the keywords are used for all + but the first N - M arguments of each + overload.
      +
      + -
    • - Otherwise, a single method overload is built around fn, which - must not be null: +
    • Otherwise, a single method overload is built around fn, which + must not be null: -
        -
      • If fn is a function pointer, its first argument must be of - the form U, cv&, - cv*, or - cv* const&, where - T* is convertible to U*, and - a1-a3, if supplied, may be selected - in any order from the table below.
      • +
          +
        • If fn is a function pointer, its first argument must be of + the form U, U cv&, U + cv*, or U cv* const&, + where T* is convertible to U*, and + a1-a3, if supplied, may be selected in + any order from the table below.
        • -
        • Otherwise, if fn is a member function pointer, its target - must be T or one of its public base classes, and - a1-a3, if supplied, may be selected - in any order from the table below.
        • +
        • Otherwise, if fn is a member function pointer, its target + must be T or one of its public base classes, and + a1-a3, if supplied, may be selected in + any order from the table below.
        • -
        • Otherwise, Fn must be [derived from] object, and - a1-a2, if supplied, may be selcted in any order - from the first two rows of the table below. To be useful, - fn should be - callable.
        • -
        +
      • Otherwise, Fn must be [derived from] + object, and + a1-a2, if supplied, may be selcted in any order from + the first two rows of the table below. To be useful, + fn should be + callable.
      • +
      - - - +
      Memnonic Name
      + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - -
      Memnonic NameRequirements/Type propertiesRequirements/Type propertiesEffects
      Effects
      docstring
      docstringAny ntbs.Any ntbs.Value will be bound to the __doc__ attribute - of the resulting method overload. If an earlier overload - supplied a docstring, two newline characters and the new - docstring are appended to it.
      Value will be bound to the __doc__ attribute + of the resulting method overload. If an earlier overload + supplied a docstring, two newline characters and the new + docstring are appended to it.
      policies
      policiesA model of CallPoliciesA model of CallPoliciesA copy will be used as the call policies of the resulting - method overload.
      A copy will be used as the call policies of the resulting + method overload.
      keywords
      keywordsThe result of a keyword-expression - specifying no more arguments than the arity of fn.The result of a keyword-expression + specifying no more arguments than the arity of fn.A copy will be used as the call policies of the resulting - method overload.
      -
    • -
    -
    + A copy will be used as the call policies of the resulting + method overload. + + +
  • +
+
-
Returns: *this
-
-
+    
Returns: *this
+
+
 class_& staticmethod(char const* name);
 
-
-
Requires: name is an ntbs which conforms to Python's identifier - naming rules, and corresponds to a method whose overloads have all - been defined.
+
+
Requires: name is an ntbs which conforms to Python's identifier + naming rules, and corresponds to a method whose overloads have all + been defined.
-
Effects: Replaces the existing named attribute x with - the result of invoking staticmethod(x) - in Python. Specifies that the corresponding method is static and - therefore no object instance will be passed to it. This is equivalent - to the Python statement:
+
Effects: Replaces the existing named attribute x with + the result of invoking staticmethod(x) + in Python. Specifies that the corresponding method is static and + therefore no object instance will be passed to it. This is equivalent to + the Python statement:
-
-
+    
+
 setattr(self, name, staticmethod(getattr(self, name)))
 
-
+
-
Note: Attempting to invoke def(name,...) after - invoking staticmethod(name) will raise a RuntimeError.
+
Note: Attempting to invoke def(name,...) after + invoking staticmethod(name) will raise a RuntimeError.
-
Returns: *this
-
-
- -
+    
Returns: *this
+

+
 template <unspecified>
 class_& def(detail::operator_<unspecified>);
 
-
-
Effects: Adds a Python special method as - described here.
+
+
Effects: Adds a Python special method as + described here.
-
Returns: *this
-
-
+    
Returns: *this
+
+
 template <class U>
 class_& setattr(char const* name, U const& u);
 
-
-
Requires: name is an ntbs which conforms to Python's identifier - naming rules.
+
+
Requires: name is an ntbs which conforms to Python's identifier + naming rules.
-
Effects: Converts u to Python and adds it to the attribute - dictionary of the extension class:
+
Effects: Converts u to Python and adds it to the attribute + dictionary of the extension class:
-
-
- PyObject_SetAttrString(this->ptr(), name, object(u).ptr()); -
-
+
+
+ PyObject_SetAttrString(this->ptr(), + name, object(u).ptr()); +
+
-
Returns: *this
-
-
- -
+    
Returns: *this
+

+
 template <class Get>
 void add_property(char const* name, Get const& fget, char const* doc=0);
 template <class Get, class Set>
 void add_property(
-	char const* name, Get const& fget, Set const& fset, char const* doc=0);
+        char const* name, Get const& fget, Set const& fset, char const* doc=0);
 
-
-
Requires: name is an ntbs which conform to Python's identifier - naming rules.
+
+
Requires: name is an ntbs which conform to Python's identifier + naming rules.
-
Effects: Creates a new Python property - class instance, passing object(fget) (and object(fset) in the - second form) with an (optional) docstring doc to its constructor, - then adds that property to the Python class object under construction - with the given attribute name.
+
Effects: Creates a new Python property + class instance, passing object(fget) (and + object(fset) in + the second form) with an (optional) docstring doc to its + constructor, then adds that property to the Python class object under + construction with the given attribute name.
-
Returns: *this
+
Returns: *this
-
Rationale: Allows users to easily expose functions that can - be invoked from Python with attribute access syntax.
-
-
-
+    
Rationale: Allows users to easily expose functions that can be + invoked from Python with attribute access syntax.
+

+
 template <class Get>
 void add_static_property(char const* name, Get const& fget);
 template <class Get, class Set>
 void add_static_property(char const* name, Get const& fget, Set const& fset);
 
-
-
Requires: name is an ntbs which conforms to Python's identifier - naming rules.
+
+
Requires: name is an ntbs which conforms to Python's identifier + naming rules.
-
Effects: Creates a Boost.Python.StaticProperty object, - passing object(fget) (and object(fset) in the - second form) to its constructor, then adds that property to the Python - class under construction with the given attribute name. - StaticProperty is a special subclass of Python's property - class which can be called without an initial self - argument.
+
Effects: Creates a Boost.Python.StaticProperty object, passing + object(fget) + (and object(fset) in the second + form) to its constructor, then adds that property to the Python class + under construction with the given attribute name. + StaticProperty is a special subclass of Python's property + class which can be called without an initial self + argument.
-
Returns: *this
+
Returns: *this
-
Rationale: Allows users to easily expose functions that can - be invoked from Python with static attribute access syntax.
-
-
-
+    
Rationale: Allows users to easily expose functions that can be + invoked from Python with static attribute access syntax.
+

+
 template <class D>
 class_& def_readonly(char const* name, D T::*pm, char const* doc=0);
 template <class D>
 class_& def_readonly(char const* name, D const& d);
 
-
-
Requires: name is an ntbs which conforms to Python's identifier - naming rules. doc is also an ntbs.
+
+
Requires: name is an ntbs which conforms to Python's identifier + naming rules. doc is also an ntbs.
-
Effects:
+
Effects:
-
-
+    
+
 this->add_property(name, make_getter(pm), doc);
-
- and -
+
and +
 this->add_static_property(name, make_getter(d));
-
- respectively.
-
-
+
respectively.
+
+
-
Returns: *this
+
Returns: *this
-
Rationale: Allows users to easily expose a class' data - member or free variable such that it can be inspected from Python with - a natural syntax.
-
-
+    
Rationale: Allows users to easily expose a class' data member + or free variable such that it can be inspected from Python with a natural + syntax.
+
+
 template <class D>
 class_& def_readwrite(char const* name, D T::*pm, char const* doc=0);
 template <class D>
 class_& def_readwrite(char const* name, D& d);
 
-
-
Effects:
+
+
Effects:
-
-
+    
+
 this->add_property(name, make_getter(pm), make_setter(pm), doc);
-
- and -
+
and +
 this->add_static_property(name, make_getter(d), make_setter(d));
-
- respectively.
-
-
+
respectively.
+
+
-
Returns: *this
+
Returns: *this
-
Rationale: Allows users to easily expose a class' data or - free variable member such that it can be inspected and set from Python - with a natural syntax.
-
-
+    
Rationale: Allows users to easily expose a class' data or free + variable member such that it can be inspected and set from Python with a + natural syntax.
+
+
 template <typename PickleSuite>
 class_& def_pickle(PickleSuite const&);
 
-
-
Requires: PickleSuite must be publically derived from pickle_suite.
+
+
Requires: PickleSuite must be publically derived from pickle_suite.
-
Effects: Defines a legal combination of the special - attributes and methods: __getinitargs__, - __getstate__, __setstate__, - __getstate_manages_dict__, - __safe_for_unpickling__, __reduce__
+
Effects: Defines a legal combination of the special attributes + and methods: __getinitargs__, __getstate__, + __setstate__, __getstate_manages_dict__, + __safe_for_unpickling__, __reduce__
-
Returns: *this
+
Returns: *this
-
Rationale: Provides an easy to use - high-level interface for establishing complete pickle support for - the wrapped class. The user is protected by compile-time consistency - checks.
-
-
-
+    
Rationale: Provides an easy to use + high-level interface for establishing complete pickle support for the + wrapped class. The user is protected by compile-time consistency + checks.
+

+
 class_& enable_pickling();
 
-
-
Effects: Defines the __reduce__ method and - the __safe_for_unpickling__ attribute. +
+
Effects: Defines the __reduce__ method and the + __safe_for_unpickling__ attribute.
-
Returns: *this
+
Returns: *this
-
Rationale: Light-weight alternative to - def_pickle(). Enables implementation of - pickle support from Python.
-
-
- +
Rationale: Light-weight alternative to + def_pickle(). Enables implementation of pickle support from Python.
+

-

Class template - bases<T1, T2,...TN>

+

Class template + bases<T1, T2,...TN>

-

An MPL sequence - which can be used in class_<...> - instantiations indicate a list of base classes.

+

An MPL + sequence which can be used in + class_<...> instantiations indicate a list + of base classes.

-

Class template bases - synopsis

-
+  

Class + template bases synopsis

+
 namespace boost { namespace python
 {
   template <T1 = unspecified,...Tn = unspecified>
@@ -749,10 +736,10 @@ namespace boost { namespace python
 }}
 
-

Example(s)

+

Example(s)

-

Given a C++ class declaration:

-
+  

Given a C++ class declaration:

+
 class Foo : public Bar, public Baz
 {
  public:
@@ -766,9 +753,8 @@ class Foo : public Bar, public Baz
  private:
    ...
 };
-
- A corresponding Boost.Python extension class can be created with: -
+
A corresponding Boost.Python extension class can be created with: +
 using namespace boost::python;
 
 class_<Foo,bases<Bar,Baz> >("Foo",
@@ -783,22 +769,19 @@ class_<Foo,bases<Bar,Baz> >("Foo",
    .def_readwrite("value", &Foo::value)
    ;
 
-
- [1] By "previously-exposed" we mean that the for - each B in bases, an instance of - class_<B, ...> must have - already been constructed. -
+  
+ [1] By "previously-exposed" we + mean that the for each B in bases, an instance of + class_<B, ...> must have + already been constructed. +
 class_<Base>("Base");
 class_<Derived, bases<Base> >("Derived");
-
- Revised - - 5 August, 2002 - +
Revised + + 1 November, 2005 -

© Copyright Dave Abrahams 2002.

- +

© Copyright Dave + Abrahams 2002.

+ - diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp index 5ca5adb8..3f2a19eb 100644 --- a/include/boost/python/detail/config.hpp +++ b/include/boost/python/detail/config.hpp @@ -29,14 +29,14 @@ # endif # if defined(BOOST_MSVC) -# if _MSC_VER <= 1200 +# if _MSC_VER < 1300 # define BOOST_MSVC6_OR_EARLIER 1 # endif -# pragma warning (disable : 4786) // disable truncated debug symbols -# pragma warning (disable : 4251) // disable exported dll function -# pragma warning (disable : 4800) //'int' : forcing value to bool 'true' or 'false' -# pragma warning (disable : 4275) // non dll-interface class +# pragma warning (disable : 4786) // disable truncated debug symbols +# pragma warning (disable : 4251) // disable exported dll function +# pragma warning (disable : 4800) //'int' : forcing value to bool 'true' or 'false' +# pragma warning (disable : 4275) // non dll-interface class # elif defined(__ICL) && __ICL < 600 // Intel C++ 5 @@ -68,13 +68,13 @@ #if defined(BOOST_PYTHON_DYNAMIC_LIB) -# if !defined(_WIN32) && !defined(__CYGWIN__) \ - && defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >=5 \ - && !defined(BOOST_PYTHON_GCC_SYMBOL_VISIBILITY) -# define BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY +# if !defined(_WIN32) && !defined(__CYGWIN__) \ + && !defined(BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY) \ + && BOOST_WORKAROUND(__GNUC__, >= 3) && (__GNUC_MINOR__ >=5 || __GNUC__ > 3) +# define BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY 1 # endif -# if defined(BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY) +# if BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY # if defined(BOOST_PYTHON_SOURCE) # define BOOST_PYTHON_DECL __attribute__ ((visibility("default"))) # define BOOST_PYTHON_BUILD_DLL diff --git a/include/boost/python/detail/wrap_python.hpp b/include/boost/python/detail/wrap_python.hpp index 4921578f..cce01868 100644 --- a/include/boost/python/detail/wrap_python.hpp +++ b/include/boost/python/detail/wrap_python.hpp @@ -22,6 +22,26 @@ #ifdef _DEBUG # ifndef BOOST_DEBUG_PYTHON +# ifdef _MSC_VER + // VC8.0 will complain if system headers are #included both with + // and without _DEBUG defined, so we have to #include all the + // system headers used by pyconfig.h right here. +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif # undef _DEBUG // Don't let Python force the debug library just because we're debugging. # define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H # endif @@ -97,7 +117,7 @@ typedef int pid_t; # define HAVE_LONG_LONG 1 # define LONG_LONG long long -# endif +# endif # elif defined(__MWERKS__) @@ -143,6 +163,10 @@ typedef int pid_t; #ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H # undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H # define _DEBUG +# ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H +# undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H +# undef _CRT_NOFORCE_MANIFEST +# endif #endif #if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2 diff --git a/include/boost/python/module_init.hpp b/include/boost/python/module_init.hpp index 64599a38..7770f531 100644 --- a/include/boost/python/module_init.hpp +++ b/include/boost/python/module_init.hpp @@ -42,7 +42,7 @@ extern "C" \ } \ void init_module_##name() -# elif (defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >=5) +# elif BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY # define BOOST_PYTHON_MODULE_INIT(name) \ void init_module_##name(); \ diff --git a/include/boost/python/object/class_metadata.hpp b/include/boost/python/object/class_metadata.hpp index c29787fb..bf0e2748 100755 --- a/include/boost/python/object/class_metadata.hpp +++ b/include/boost/python/object/class_metadata.hpp @@ -30,6 +30,10 @@ # include # include # include + +# include +# include + # include # include @@ -49,6 +53,12 @@ struct register_base_of template inline void operator()(Base*) const { +# if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) + BOOST_MPL_ASSERT_NOT((is_same)); +# else + BOOST_STATIC_ASSERT(!(is_same::value)); +# endif + // Register the Base class register_dynamic_id(); @@ -58,7 +68,7 @@ struct register_base_of // Register the down-cast, if appropriate. this->register_downcast((Base*)0, is_polymorphic()); } - + private: static inline void register_downcast(void*, mpl::false_) {} @@ -186,7 +196,7 @@ struct class_metadata , mpl::if_< use_value_holder , value_holder - , pointer_holder + , pointer_holder > >::type holder; @@ -199,7 +209,8 @@ struct class_metadata template inline static void register_aux(python::wrapper*) { - class_metadata::register_aux2((T2*)0, mpl::true_()); + typedef typename mpl::not_ >::type use_callback; + class_metadata::register_aux2((T2*)0, use_callback()); } inline static void register_aux(void*) @@ -242,6 +253,7 @@ struct class_metadata // inline static void maybe_register_class_to_python(void*, mpl::true_) {} + template inline static void maybe_register_class_to_python(T2*, mpl::false_) { diff --git a/include/boost/python/override.hpp b/include/boost/python/override.hpp index b6fa97a0..93496741 100755 --- a/include/boost/python/override.hpp +++ b/include/boost/python/override.hpp @@ -55,12 +55,15 @@ namespace detail } # endif -# if !defined(BOOST_MSVC) || BOOST_WORKAROUND(_MSC_FULL_VER, > 140040607) +# if defined(BOOST_MSVC) && BOOST_WORKAROUND(_MSC_FULL_VER, <= 140040607) || BOOST_WORKAROUND(BOOST_INTEL_WIN, >= 900) + // No operator T& +# else + template operator T&() const { converter::return_from_python converter; - return converter(m_obj.release()); + return converter(const_cast&>(m_obj).release()); } # endif diff --git a/src/converter/type_id.cpp b/src/converter/type_id.cpp index 39db65d9..3fc64a6f 100644 --- a/src/converter/type_id.cpp +++ b/src/converter/type_id.cpp @@ -21,6 +21,14 @@ # ifdef BOOST_PYTHON_HAVE_GCC_CP_DEMANGLE # if defined(__GNUC__) && __GNUC__ >= 3 + +// http://lists.debian.org/debian-gcc/2003/09/msg00055.html notes +// that, in cxxabi.h of gcc-3.x for x < 4, this type is used before it +// is declared. +# if __GNUC__ == 3 && __GNUC_MINOR__ < 4 +class __class_type_info; +# endif + # include # endif # endif diff --git a/test/polymorphism2.cpp b/test/polymorphism2.cpp index b5c773e0..8aefbc3a 100755 --- a/test/polymorphism2.cpp +++ b/test/polymorphism2.cpp @@ -13,6 +13,14 @@ #include #include +#include + +#ifdef HELD_BY_AUTO_PTR +# define HELD_PTR(X) , std::auto_ptr< X > +#else +# define HELD_PTR(X) +#endif + using namespace boost::python; struct P @@ -123,19 +131,23 @@ C& getCCppObj () A* pass_a(A* x) { return x; } +#ifdef HELD_BY_AUTO_PTR +BOOST_PYTHON_MODULE_INIT(polymorphism2_auto_ptr_ext) +#else BOOST_PYTHON_MODULE_INIT(polymorphism2_ext) +#endif { - class_("A") + class_("A") .def("f", &A::f, &ACallback::default_f) ; def("getBCppObj", getBCppObj, return_value_policy()); - class_,boost::noncopyable>("C") + class_,boost::noncopyable>("C") .def("f", &C::f) ; - class_,boost::noncopyable>("D") + class_,boost::noncopyable>("D") .def("f", &D::f) .def("g", &D::g) ; @@ -152,7 +164,7 @@ BOOST_PYTHON_MODULE_INIT(polymorphism2_ext) .def("f", pure_virtual(&P::f)) ; - class_ >("Q") + class_ >("Q") .def("g", &P::g) // make sure virtual inheritance doesn't interfere ; } diff --git a/test/polymorphism2.py b/test/polymorphism2.py index 01f6f2f2..2690bac9 100644 --- a/test/polymorphism2.py +++ b/test/polymorphism2.py @@ -2,7 +2,7 @@ # Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) import unittest -from polymorphism2_ext import * +import sys class PolymorphTest(unittest.TestCase): @@ -77,11 +77,18 @@ class PolymorphTest(unittest.TestCase): r = R() self.failUnlessEqual ('R.f', r.f()) - -if __name__ == "__main__": - - # remove the option which upsets unittest + +def test(): + # remove the option that upsets unittest import sys sys.argv = [ x for x in sys.argv if x != '--broken-auto-ptr' ] - unittest.main() + +# This nasty hack basically says that if we're loaded by another module, we'll +# be testing polymorphism2_auto_ptr_ext instead of polymorphism2_ext. +if __name__ == "__main__": + from polymorphism2_ext import * + test() +else: + from polymorphism2_auto_ptr_ext import * +