From 53d2398e0654b67463c4326b7dc8ba134d925711 Mon Sep 17 00:00:00 2001
From: "Ralf W. Grosse-Kunstleve"
- Right now, the only supported configuration is one in which the BPL
- source files are statically linked with the source for your extension
- module. You may first build them into a library and link it with your
- extension module source, but the effect is the same as compiling all
- the source files together. Some users have successfully built the
- sources into a shared library, and support for a shared library
- build is planned, but not yet implemented. The BPL source files are:
-
- Next: Enums
- Previous: A Peek Under the Hood
- Up: Top
-
- © Copyright David Abrahams 2000. Permission to copy, use, modify,
- sell and distribute this document is granted provided this copyright
- notice appears in all copies. This document is provided ``as
- is'' without express or implied warranty, and with no claim as to
- its suitability for any purpose.
-
- Updated: Nov 26, 2000
+ The build process for Boost is currently undergoing some evolution,
+ and, it is to be hoped, improvement. The following facts may help:
+
+ When extension modules are built with Visual C++ using
+ -D_DEBUG, Python defaults to force linking with a
+ special debugging version of the Python DLL. Since this debug DLL
+ isn't supplied with the default Python installation for Windows,
+ Boost.Python uses boost/python/detail/wrap_python.hpp
+ to temporarily undefine _DEBUG when Python.h is
+ #included.
+
+ If you want the extra runtime checks available with the debugging
+ version of the library, #define BOOST_DEBUG_PYTHON to
+ re-enable library forcing, and link with the DebugPython version of
+ boost_python.lib. You'll need to get the debugging version
+ of the Python executable (python_d.exe) and DLL
+ (python20_d.dll or python15_d.dll). The Python
+ sources include project files for building these. If you download them, change the name of the
+ top-level directory to src, and install it under
+ c:\tools\python, the workspace supplied by Boost.Python will
+ be able to use it without modification. Just open
+ c:\tools\python\src\pcbuild\pcbuild.dsw and invoke "build
+ all" to generate all the debugging targets.
+
+ If you do not #define BOOST_DEBUG_PYTHON, be sure that
+ any source files #include <boost/python/detail/wrap_python.hpp>
+ instead of the usual Python.h, or you will have link
+ incompatibilities. Next: Wrapping Enums Previous: A Peek Under the Hood Up: Top
+
+ © Copyright David Abrahams 2000. Permission to copy, use, modify,
+ sell and distribute this document is granted provided this copyright
+ notice appears in all copies. This document is provided ``as is'' without
+ express or implied warranty, and with no claim as to its suitability for
+ any purpose.
+
+ Updated: Mar 6, 2001
- Like BPL, CXX attempts to
+ Like Boost.Python, CXX attempts to
provide a C++-oriented interface to Python. In most cases, as with the
boost library, it relieves the user from worrying about
reference-counts. Both libraries automatically convert thrown C++
@@ -40,9 +41,15 @@
As far as I can tell, CXX enables one to write what is essentially
idiomatic Python code in C++, manipulating Python objects through the
- same fully-generic interfaces we use in Python. While you're hardly programming directly to the ``bare
- metal'' with CXX, it basically presents a ``C++-ized''
- version of the Python 'C' API.
+ same fully-generic interfaces we use in Python. While you're hardly
+ programming directly to the ``bare metal'' with CXX, it basically
+ presents a ``C++-ized'' version of the Python 'C' API. Some fraction of
+ that capability is available in Boost.Python through boost/python/objects.hpp,
+ which provides C++ objects corresponding to Python lists, tuples,
+ strings, and dictionaries, and through boost/python/callback.hpp,
+ which allows you to call back into python with C++ arguments.
Paul F. Dubois, the original
@@ -65,7 +72,7 @@ that.''
- By contrast, BPL doesn't attempt to parse C++ - the problem is simply
+ By contrast, Boost.Python doesn't attempt to parse C++ - the problem is simply
too complex to do correctly. Technically, one does
- write code by hand to use BPL. The goal, however, has been to make
+ write code by hand to use Boost.Python. The goal, however, has been to make
that code nearly as simple as listing the names of the classes and
member functions you want to expose in Python.
@@ -95,7 +102,7 @@ that.''
- ExtensionClasses in Zope use the same underlying mechanism as BPL
+ ExtensionClasses in Zope use the same underlying mechanism as Boost.Python
to support subclassing of extension types in Python, including
multiple-inheritance. Both systems support pickling/unpickling of
extension class instances in very similar ways. Both systems rely on the
@@ -158,31 +165,35 @@ an inheritance relationship?
The major differences are:
- Next: A Simple Example Using BPL
+ Next: A Simple Example Using Boost.Python
Previous: A Brief Introduction to writing Python Extension Modules
Up: Top
@@ -215,6 +226,6 @@ an inheritance relationship?
express or implied warranty, and with no claim as to its suitability
for any purpose.
- Updated: Nov 26, 2000
+ Updated: Mar 6, 2001
Because there is in general no way to deduce that a value of arbitrary type T
@@ -17,24 +18,39 @@ enums). Once you have done that, you can write some simple
If you are satisfied with a Python int as a way to represent your enum
-values, we provide a shorthand for these functions. You just need to
-instantiate
- Next: Pointers
+ Next: Pointers and Smart Pointers
Previous: Building an Extension Module
Up: Top
@@ -98,6 +115,6 @@ my_class.add(boost::python::to_python(enum_value_2), "enum_value_2");
is'' without express or implied warranty, and with no claim as to
its suitability for any purpose.
- Updated: Nov 26, 2000
+ Updated: Mar 6, 2001
- Here is the C++ code for a python module called
That's it! If we build this shared library and put it on our
- We can even make a subclass of
- Pretty cool! You can't do that with an ordinary Python extension type!
-
- Of course, you may now have a slightly empty feeling in the pit of
- your little pythonic stomach. Perhaps you feel your subclass deserves
- to have a
- Next: Overridable virtual functions
+ Next: Exporting Classes
Previous: Comparisons with other systems Up:
Top
@@ -125,6 +77,6 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
express or implied warranty, and with no claim as to its suitability
for any purpose.
- Updated: Nov 26, 2000
+ Updated: Mar 6, 2000
diff --git a/doc/exporting_classes.html b/doc/exporting_classes.html
new file mode 100644
index 00000000..e5932e70
--- /dev/null
+++ b/doc/exporting_classes.html
@@ -0,0 +1,144 @@
+
+
+ Now let's expose a C++ class to Python:
+
+
+ To expose the class, we use a class_builder in addition to the
+ module_builder from the previous example. Class member functions
+ are exposed by using the def() member function on the
+ class_builder:
+
+Now we can use the class normally from Python:
+
+
+ We can even make a subclass of
+ Pretty cool! You can't do that with an ordinary Python extension type!
+
+ Of course, you may now have a slightly empty feeling in the pit of
+ your little pythonic stomach. Perhaps you wanted to see the following
+ wordy invitation:
+
+
+ Next: Overridable virtual functions
+ Previous: A Simple Example Up:
+ Top
+
+ © Copyright David Abrahams 2000. Permission to copy, use, modify,
+ sell and distribute this document is granted provided this copyright
+ notice appears in all copies. This document is provided "as is" without
+ express or implied warranty, and with no claim as to its suitability
+ for any purpose.
+
+ Updated: Mar 6, 2001
+
-
-
Building an Extension Module
-
-
-
-extclass.cpp
-functions.cpp
-init_function.cpp
-module.cpp
-newtypes.cpp
-objects.cpp
-py.cpp
-subclass.cpp
-
-
+
+ Building an
+ Extension Module
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Comparisons with
+ src="../../../c++boost.gif" alt= "c++boost.gif (8819 bytes)">
+ Comparisons with
Other Systems
CXX
-Paul Dubois
languages. Swig relies on a parser to read your source code and produce
additional source code files which can be compiled into a Python (or
Perl or Tcl) extension module. It has been successfully used to create
- many Python extension modules. Like BPL, SWIG is trying to allow an
+ many Python extension modules. Like Boost.Python, SWIG is trying to allow an
existing interface to be wrapped with little or no change to the
existing code. The documentation says ``SWIG parses a form of ANSI C
syntax that has been extended with a number of special directives. As a
@@ -78,15 +85,15 @@ that.''
-Paul Dubois
couldnt handle templates, didnt do func overloading properly etc. For
ANSI C libraries this was fine. But for usual C++ code this was a
problem. Simple things work. But for anything very complicated (or
- realistic), one had to write code by hand. I believe BPL doesn't have
+ realistic), one had to write code by hand. I believe Boost.Python doesn't have
this problem[sic]... IMHO overloaded functions are very important to
wrap correctly.''
-Prabhu Ramachandran
-Paul Dubois
SIP
is a system similar to SWIG, though seemingly more
- C++-oriented. The author says that like BPL, SIP supports overriding
+ C++-oriented. The author says that like Boost.Python, SIP supports overriding
extension class member functions in Python subclasses. It appears to
have been designed specifically to directly support some features of
PyQt/PyKDE, which is its primary client. Documentation is almost
@@ -113,7 +120,7 @@ that.''
-Paul Dubois
to a wide range of computer languages, including Common Lisp, C++, C,
Modula-3, and Python. ILU can parse the ISL to generate a C++ language
header file describing the interface, of which the user is expected to
- provide an implementation. Unlike BPL, this means that the system
+ provide an implementation. Unlike Boost.Python, this means that the system
imposes implementation details on your C++ code at the deepest level. It
is worth noting that some of the C++ names generated by ILU are supposed
to be reserved to the C++ implementation. It is unclear from the
@@ -148,7 +155,7 @@ an inheritance relationship?
Zope ExtensionClasses
+
BaseClass.method''.
Wrapping enums
+ src="../../../c++boost.gif" alt= "c++boost.gif (8819 bytes)">
+ Wrapping enums
from_python() and to_python() functions.
boost::python::enum_as_int_converters<EnumType> where
+values, we provide a shorthand for these functions. You just need to cause
+boost::python::enum_as_int_converters<EnumType> to be
+instantiated, where
EnumType is your enumerated type. There are two convenient ways to do this:
-
+
+
+Some buggy C++ implementations require a class to be instantiated in the same
+namespace in which it is defined. In that case, the simple incantation above becomes:
+
+
+ template class boost::python::enum_as_int_converters<my_enum>;
+
-
...
} // close my_namespace
+
// drop into namespace python and explicitly instantiate
-BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround
- template class enum_as_int_converters
+
+
+
// instantiate as base class in any namespace
struct EnumTypeConverters
: boost::python::enum_as_int_converters<EnumType>
@@ -71,7 +87,8 @@ BOOST_PYTHON_END_CONVERSION_NAMESPACE
long type.
You may also want to add a bunch of lines like this to your module
-initialization:
+initialization. These bind the corresponding enum values to the appropriate
+names so they can be used from Python:
mymodule.add(boost::python::to_python(enum_value_1), "enum_value_1");
@@ -83,12 +100,12 @@ You can also add these to an extension class definition, if your enum happens to
be local to a class and you want the analogous interface in Python:
-my_class.add(boost::python::to_python(enum_value_1), "enum_value_1");
-my_class.add(boost::python::to_python(enum_value_2), "enum_value_2");
+my_class_builder.add(boost::python::to_python(enum_value_1), "enum_value_1");
+my_class_builder.add(boost::python::to_python(enum_value_2), "enum_value_2");
...
#include <string>
-namespace hello {
- class world
- {
- public:
- world(int);
- ~world();
- std::string greet() const { return "hi, world"; }
- ...
- };
- std::size_t length(const world& x) { return std::strlen(x.greet()); }
+namespace { // Avoid cluttering the global namespace.
+
+ // A couple of simple C++ functions that we want to expose to Python.
+ std::string greet() { return "hello, world"; }
+ int square(int number) { return number * number; }
}
hello
- which exposes the API using:
+ Here is the C++ code for a python module called getting_started1
+ which exposes the API.
#include <boost/python/class_builder.hpp>
-// Python requires an exported function called init<module-name> in every
-// extension module. This is where we build the module contents.
-extern "C"
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-void inithello()
+namespace python = boost::python;
+
+BOOST_PYTHON_MODULE_INIT(getting_started1)
{
- try
- {
- // create an object representing this extension module
- boost::python::module_builder m("hello");
- // Create the Python type object for our extension class
- boost::python::class_builder<hello::world> world_class(m, "world");
- // Add the __init__ function
- world_class.def(boost::python::constructor<int>());
- // Add a regular member function
- world_class.def(&hello::world::get, "get");
- // Add a regular function to the module
- m.def(hello::length, "length");
- }
- catch(...)
- {
- boost::python::handle_exception(); // Deal with the exception for Python
- }
+ try
+ {
+ // Create an object representing this extension module.
+ python::module_builder this_module("getting_started1");
+
+ // Add regular functions to the module.
+ this_module.def(greet, "greet");
+ this_module.def(square, "square");
+ }
+ catch(...)
+ {
+ python::handle_exception(); // Deal with the exception for Python
+ }
}
-// Win32 DLL boilerplate
-#if defined(_WIN32)
-#include <windows.h>
-extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
-{
- return 1;
-}
-#endif // _WIN32
- PYTHONPATH we can now access our C++ class and function from
+ PYTHONPATH we can now access our C++ functions from
Python.
->>> import hello
->>> hi_world = hello.world(3)
->>> hi_world.greet()
-'hi, world'
->>> hello.length(hi_world)
-9
+>>> import getting_started1
+>>> print getting_started1.greet()
+hello, world
+>>> number = 11
+>>> print number, '*', number, '=', getting_started1.square(number)
+11 * 11 = 121
- hello.world:
-
-
-
->>> class my_subclass(hello.world):
-... def greet(self):
-... return 'hello, world'
-...
->>> y = my_subclass(4)
->>> y.greet()
-'hello, world'
-
-
-
-
->>> hello.length(y)
-9
-
- length() of 12? If so, read on...
-
+
+
+
+ Exporting Classes
+
+
+#include <iostream>
+#include <string>
+
+namespace { // Avoid cluttering the global namespace.
+
+ // A friendly class.
+ class hello
+ {
+ public:
+ hello(const std::string& country) { this->country = country; }
+ std::string greet() const { return "Hello from " + country; }
+ private:
+ std::string country;
+ };
+
+ // A function taking a hello object as an argument.
+ std::string invite(const hello& w) {
+ return w.greet() + "! Please come soon!";
+ }
+}
+
+
+
+#include <boost/python/class_builder.hpp>
+namespace python = boost::python;
+
+BOOST_PYTHON_MODULE_INIT(getting_started2)
+{
+ try
+ {
+ // Create an object representing this extension module.
+ python::module_builder this_module("getting_started2");
+
+ // Create the Python type object for our extension class.
+ python::class_builder<hello> hello_class(this_module, "hello");
+
+ // Add the __init__ function.
+ hello_class.def(python::constructor<std::string>());
+ // Add a regular member function.
+ hello_class.def(&hello::greet, "greet");
+
+ // Add invite() as a regular function to the module.
+ this_module.def(invite, "invite");
+
+ // Even better, invite() can also be made a member of hello_class!!!
+ hello_class.def(invite, "invite");
+ }
+ catch(...)
+ {
+ python::handle_exception(); // Deal with the exception for Python
+ }
+}
+
+
+Notes:
+>>> from getting_started2 import *
+>>> hi = hello('California')
+>>> hi.greet()
+'Hello from California'
+>>> invite(hi)
+'Hello from California! Please come soon!'
+>>> hi.invite()
+'Hello from California! Please come soon!'
+
+
+ hello.world:
+
+
+
+>>> class wordy(hello):
+... def greet(self):
+... return hello.greet(self) + ', where the weather is fine'
+...
+>>> hi2 = wordy('Florida')
+>>> hi2.greet()
+'Hello from Florida, where the weather is fine'
+>>> invite(hi2)
+'Hello from Florida! Please come soon!'
+
+
+ After all, invite calls hello::greet(), and you
+ reimplemented that in your Python subclass, wordy. If so, read on...
+
+
+'Hello from Florida, where the weather is fine! Please come soon!'
+
Next: Comparisons with Other Systems Up:
The Boost Python Library (BPL)
+ align="center" height="86">
The Boost Python Library (Boost.Python)
Synopsis
@@ -15,9 +15,9 @@
href="http://www.python.org">Python such that the Python interface is
very similar to the C++ interface. It is designed to be minimally
intrusive on your C++ design. In most cases, you should not have to alter
- your C++ classes in any way in order to use them with BPL. The system
+ your C++ classes in any way in order to use them with Boost.Python. The system
should simply ``reflect'' your C++ classes and functions into
- Python. The major features of BPL include support for:
+ Python. The major features of Boost.Python include support for:
BPL has been tested in the following configurations: +
Boost.Python is known to have been tested in the following configurations:
Documentation is a major ongoing project; assistance is greatly
- appreciated! In the meantime, useful examples of every BPL feature should
+ appreciated! In the meantime, useful examples of every Boost.Python feature should
be evident in the regression test files
- © Copyright David Abrahams 2000. Permission to copy, use, modify,
+ © Copyright David Abrahams 2001. Permission to copy, use, modify,
sell and distribute this document is granted provided this copyright
notice appears in all copies. This document is provided ``as is'' without
express or implied warranty, and with no claim as to its suitability for
any purpose.
- Updated: Nov 26, 2000
+ Updated: Mar 6, 2001
diff --git a/doc/inheritance.html b/doc/inheritance.html
index d11899c8..cd95c744 100644
--- a/doc/inheritance.html
+++ b/doc/inheritance.html
@@ -12,10 +12,10 @@
- BPL extension classes support single and multiple-inheritance in
+ Boost.Python extension classes support single and multiple-inheritance in
Python, just like regular Python classes. You can arbitrarily mix
built-in Python classes with extension classes in a derived class'
- tuple of bases. Whenever a BPL extension class is among the bases for a
+ tuple of bases. Whenever a Boost.Python extension class is among the bases for a
new class in Python, the result is an extension class:
- BPL also allows us to represent C++ inheritance relationships so that
+ Boost.Python also allows us to represent C++ inheritance relationships so that
wrapped derived classes may be passed where values, pointers, or
references to a base class are expected as arguments. The
- © Copyright David Abrahams 2000. Permission to copy, use, modify,
+ © Copyright David Abrahams 2001. Permission to copy, use, modify,
sell and distribute this document is granted provided this copyright
notice appears in all copies. This document is provided ``as
is'' without express or implied warranty, and with no claim as to
its suitability for any purpose.
- Updated: Nov 26, 2000
+ Updated: Mar 6, 2001
diff --git a/doc/overriding.html b/doc/overriding.html
index ae629580..7b28add1 100644
--- a/doc/overriding.html
+++ b/doc/overriding.html
@@ -9,7 +9,7 @@
- In the previous example we exposed a simple
+ In the previous example we exposed a simple
C++ class in Python and showed that we could write a subclass. We even
redefined one of the functions in our derived class. Now we will learn
how to make the function behave virtually when called from C++.
@@ -17,16 +17,17 @@
In this example, it is assumed that In this example, it is assumed that
- Finally, we add test/comprehensive.[py/hpp/the boost mailing list.
Inheritance in Python
+objects of wrapped class Derived may be passed where Base is expected
+
@@ -37,7 +37,7 @@
objects of wrapped class Derived may be passed where Base is expectedReflecting C++ Inheritance Relationships
declare_base member function of
@@ -76,11 +76,7 @@ int get_derived_x(const Derived& d) {
// namespace alias for code brevity
namespace python = boost::python;
-extern "C"
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-void initmy_module()
+BOOST_PYTHON_MODULE_INIT(my_module)
{
try
{
@@ -115,11 +111,19 @@ void initmy_module()
>>> derived = Derived()
>>> get_name(base)
'Base'
-
+
+
+
+objects of wrapped class Derived can be passed where Derived is
+expected but where type information has been lost.
+
>>> get_name(derived)
'Derived'
-
objects of wrapped class Derived can be passed where Derived is
-expected but where type information has been lost.
+
+
+
>>> get_derived_x(derived_as_base())
-1
diff --git a/doc/overloading.html b/doc/overloading.html
index 6979efd0..242e023f 100644
--- a/doc/overloading.html
+++ b/doc/overloading.html
@@ -29,7 +29,7 @@ private:
};
...
-void initoverload_demo()
+BOOST_PYTHON_MODULE_INIT(overload_demo)
{
try
{
@@ -144,12 +144,12 @@ namespace scope as Python member functions.
Previous: Overridable Virtual Functions
Up: Top
Overridable Virtual Functions
Example
-world::greet() is a virtual
+hello::greet() is a virtual
member function:
@@ -37,21 +38,28 @@ class world
-class world
+class hello
{
public:
- world(int);
- virtual ~world();
- virtual std::string greet() const { return "hi, world"; }
+ hello(const std::string& country) { this->country = country; }
+ virtual std::string greet() const { return "Hello from " + country; }
+ virtual ~hello(); // Good practice
+ ...
};
-
PyObject* data member that holds a
- reference to the corresponding Python object.
+ PyObject* data member (usually
+ called self) that holds a pointer to the Python object corresponding
+ to our C++ hello instance.
- PyObject* argument
- in the data member described above.
+ PyObject* argument. The initial argument should be stored in the self data
+ member described above.
+
+ boost::python::callback<return-type>::call_method() to call
+ callback<return-type>::call_method(self, "name", args...) to call
the Python override.
-struct world_callback : world
+struct hello_callback : hello
{
- world_callback(PyObject* self, int x) // 2
- : world(x),
- m_self(self) {}
+ // hello constructor storing initial self_ parameter
+ hello_callback(PyObject* self_, const std::string& x) // 2
+ : hello(x), self(self_) {}
- std::string greet() const // 3
- { return boost::python::callback<std::string>::call_method(m_self, "get"); }
+ // In case hello is returned by-value from a wrapped function
+ hello_callback(PyObject* self_, const hello& x) // 3
+ : hello(x), self(self_) {}
- static std::string default_get(const hello::world& self) const // 4
- { return self.world::greet(); }
+ // Override greet to call back into Python
+ std::string greet() const // 4
+ { return boost::python::callback<std::string>::call_method(m_self, "greet"); }
+
+ // Supplies the default implementation of greet
+ static std::string default_greet(const hello& self) const // 5
+ { return self.hello::greet(); }
private:
PyObject* m_self; // 1
};
world_callback to the
- class_builder<> declaration in our module initialization
+ Finally, we add hello_callback to the
+ class_builder<> declaration in our module initialization
function, and when we define the function, we must tell py_cpp about the default
implementation:
// Create the Python type object for our extension class
-boost::python::class_builder<hello::world,world_callback> world_class(hello, "world");
+"hello_class">Python type object
- Now our subclass of hello.world behaves as expected:
+ Now our Python subclass of hello behaves as expected:
->>> class my_subclass(hello.world):
+>>> class wordy(hello):
... def greet(self):
-... return 'hello, world'
+... return hello.greet(self) + ', where the weather is fine'
...
->>> hello.length(my_subclass())
-12
+>>> hi2 = wordy('Florida')
+>>> hi2.greet()
+'Hello from Florida, where the weather is fine'
+>>> invite(hi2)
+'Hello from Florida, where the weather is fine! Please come soon!'
-
*You may ask, "Why do we need this derived
class? This could have been designed so that everything gets done right
- inside of hello::world." One of the goals of py_cpp is to be
+ inside of hello." One of the goals of py_cpp is to be
minimally intrusive on an existing C++ design. In principle, it should be
possible to expose the interface for a 3rd party library without changing
it. To unintrusively hook into the virtual functions so that a Python
@@ -117,10 +133,10 @@ world_class.def(&world::get, "get", &world_callback::default_get)
deal with than a virtual function with a default implementation. First of
all, you obviously don't need to supply
a default implementation. Secondly, you don't need to call
- def() on the extension_class<> instance
+ def() on the extension_class<> instance
for the virtual function. In fact, you wouldn't want to: if the
corresponding attribute on the Python class stays undefined, you'll get an
- AttributeError in Python when you try to call the function,
+ AttributeError in Python when you try to call the function,
indicating that it should have been implemented. For example:
@@ -132,11 +148,7 @@ struct baz_callback {
int pure(int x) { boost::python::callback<int>::call_method(m_self, "pure", x); }
};
-extern "C"
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-initfoobar()
+BOOST_PYTHON_MODULE_INIT(foobar)
{
try
{
@@ -182,14 +194,14 @@ href="http://cs.calvin.edu/c++/C++Standard-Nov97/basic.html#basic.def.odr">ODR
Next: Function Overloading
- Previous: A Simple Example Using py_cpp
+ Previous: Exporting Classes
Up: Top
- © Copyright David Abrahams 2000. Permission to copy, use, modify,
+ © Copyright David Abrahams 2001. Permission to copy, use, modify,
sell and distribute this document is granted provided this copyright
notice appears in all copies. This document is provided "as is" without
express or implied warranty, and with no claim as to its suitability for
any purpose.
- Updated: Nov 26, 2000
+ Updated: Mar 6, 2001
diff --git a/doc/pickle.html b/doc/pickle.html
index 0e64d6fc..7b559e68 100644
--- a/doc/pickle.html
+++ b/doc/pickle.html
@@ -1,6 +1,6 @@
- BPL Pickle Support
+ Boost.Python Pickle Support
@@ -11,7 +11,7 @@
-BPL Pickle Support
+Boost.Python Pickle Support
Pickle is a Python module for object serialization, also known
as persistence, marshalling, or flattening.
@@ -39,16 +39,16 @@ described in detail in the Python Library Reference for pickle:
- However, most C++ classes wrapped with the BPL will have member data + However, most C++ classes wrapped with Boost.Python will have member data that are not restored correctly by this procedure. To alert the user to this problem, a safety guard is provided. If both __getinitargs__ - and __getstate__ are not defined, the BPL tests if the class has an + and __getstate__ are not defined, Boost.Python tests if the class has an attribute __dict_defines_state__. An exception is raised if this attribute is not defined: @@ -151,7 +151,7 @@ Both __getinitargs__ and __getstate__ are not defined. __getstate__ is defined and the instance's __dict__ is not empty.
@@ -170,7 +170,7 @@ __getstate__ is defined and the instance's __dict__ is not empty. To alert the user to this highly unobvious problem, a safety guard is provided. If __getstate__ is defined and the instance's __dict__ is - not empty, the BPL tests if the class has an attribute + not empty, Boost.Python tests if the class has an attribute __getstate_manages_dict__. An exception is raised if this attribute is not defined: diff --git a/doc/pointers.html b/doc/pointers.html index e26cea02..fdbee797 100644 --- a/doc/pointers.html +++ b/doc/pointers.html @@ -13,7 +13,7 @@
In general, raw pointers passed to or returned from functions are problematic -for BPL because pointers have too many potential meanings. Is it an iterator? +for Boost.Python because pointers have too many potential meanings. Is it an iterator? A pointer to a single element? An array? When used as a return value, is the caller expected to manage (delete) the pointed-to object or is the pointer really just a reference? If the latter, what happens to Python references to the @@ -46,7 +46,7 @@ const Foo& f_wrapper() { return *f(); } my_module.def(f_wrapper, "f");
-Foo must have a public copy constructor for this technique to work, since BPL
+Foo must have a public copy constructor for this technique to work, since Boost.Python
converts const T& values to_python by copying the T
value into a new extension instance.
diff --git a/doc/special.html b/doc/special.html
index 50cee505..0caa1924 100644
--- a/doc/special.html
+++ b/doc/special.html
@@ -12,7 +12,7 @@
Overview
- BPL supports all of the standard
special method names supported by real Python class instances
except __complex__ (more on the reasons my_class.def(boost::python::constructor<...>())
- (see section "A Simple Example Using BPL").
+ (see section "A Simple Example Using Boost.Python").
__str__ and __cmp__. This is explained in the next section and the Table of
Automatically Wrapped Methods.
@@ -117,7 +117,7 @@ foo_class.def(&to_string, "__str__");
href="http://www.python.org/doc/current/ref/numeric-types.html">numeric
protocols. This is the same basic technique used to expose
to_string() as __str__() above, and is covered in detail below. BPL also supports
+ href="#numeric_manual">covered in detail below. Boost.Python also supports
automatic wrapping of numeric operators whenever they have already
been defined in C++.
@@ -174,7 +174,7 @@ a = i + b;
bignum_class.def(boost::python::operators<boost::python::op_add>(), boost::python::right_operand<int>());
bignum_class.def(boost::python::operators<boost::python::op_add>(), boost::python::left_operand<int>());
- BPL uses overloading to register several variants of the same
+ Boost.Python uses overloading to register several variants of the same
operation (more on this in the context of
coercion). Again, several operators can be exported at once:
@@ -283,13 +283,13 @@ bignum_class.def(&rmod, "__rmod__");
coercion functions can be difficult if many type combinations must be
supported.
- BPL solves this problem the same way that C++ does: with overloading. This technique drastically
simplifies the code neccessary to support operators: you just register
- operators for all desired type combinations, and BPL automatically
+ operators for all desired type combinations, and Boost.Python automatically
ensures that the correct function is called in each case; there is no
need for user-defined coercion functions. To enable operator
- overloading, BPL provides a standard coercion which is implicitly
+ overloading, Boost.Python provides a standard coercion which is implicitly
registered whenever automatic operator wrapping is used.
If you wrap all operator functions manually, but still want to use
@@ -370,7 +370,7 @@ bignum_class.def((ternary_function2)&power, "__pow__");
In the second variant, however, BigNum appears only as second
argument, and in the last one it's the third argument. These functions
- must be presented to BPL such that that the BigNum
+ must be presented to Boost.Python such that that the BigNum
argument appears in first position:
@@ -397,7 +397,7 @@ Note that "__rrpow__" is an extension not present in plain Python.
Table of Automatically Wrapped Methods
- BPL can automatically wrap the following
special methods:
@@ -772,13 +772,13 @@ KeyError: 2
Customized Attribute Access
- Just like built-in Python classes, BPL extension classes support special
the usual attribute access methods __getattr__,
__setattr__, and __delattr__.
Because writing these functions can
be tedious in the common case where the attributes being accessed are
- known statically, BPL checks the special names
+ known statically, Boost.Python checks the special names
-
@@ -794,7 +794,7 @@ KeyError: 2
following shows how we can implement a ``computed attribute'' in Python:
->>> class Range(AnyBPLExtensionClass):
+>>> class Range(AnyBoost.PythonExtensionClass):
... def __init__(self, start, end):
... self.start = start
... self.end = end
@@ -810,7 +810,7 @@ KeyError: 2
Direct Access to Data Members
- BPL uses the special
+ Boost.Python uses the special
__xxxattr__<name>__ functionality described above
to allow direct access to data members through the following special
functions on class_builder<> and
diff --git a/doc/under-the-hood.html b/doc/under-the-hood.html
index 902804d3..733f0f54 100644
--- a/doc/under-the-hood.html
+++ b/doc/under-the-hood.html
@@ -22,7 +22,7 @@
"example1.html#add_world_class">add it to the module it goes into the
module's dictionary to be looked up under the name "world".
- BPL uses C++'s template argument deduction mechanism to determine the
+ Boost.Python uses C++'s template argument deduction mechanism to determine the
types of arguments to functions (except constructors, for which we must
provide an argument list
because they can't be named in C++). Then, it calls the appropriate
@@ -48,7 +48,7 @@
the top of your module's init function, then def the member
functions later to avoid problems with inter-class dependencies.
- Next: Building a Module with BPL
+ Next: Building a Module with Boost.Python
Previous: Special Method and Operator Support
Up: Top
From 00cea4ff83e2d64c3273fab652171cf4ca192a88 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
Date: Wed, 7 Mar 2001 03:40:47 +0000
Subject: [PATCH 04/23] Added getting_started targets
[SVN r9471]
---
build/build.dsw | 34 ++++++++++++++++++++++++++++++++++
build/build.opt | Bin 86528 -> 116224 bytes
2 files changed, 34 insertions(+)
diff --git a/build/build.dsw b/build/build.dsw
index f4ee1a11..8de38493 100644
--- a/build/build.dsw
+++ b/build/build.dsw
@@ -30,6 +30,40 @@ Package=<4>
###############################################################################
+Project: "getting_started1"=.\getting_started1\getting_started1.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name bpl_static
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "getting_started2"=.\getting_started2\getting_started2.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+ begin source code control
+ getting_started2
+ .\getting_started2
+ end source code control
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name bpl_static
+ End Project Dependency
+}}}
+
+###############################################################################
+
Project: "rwgk1"=.\rwgk1\rwgk1.dsp - Package Owner=<4>
Package=<5>
diff --git a/build/build.opt b/build/build.opt
index 5086795feff7997de1d0b50d82b2404da330c819..89eb84a706504d37bff9685be4808fda8baf9b81 100644
GIT binary patch
literal 116224
zcmca`Uhu)fjZzO8(10BSGsD0CoD6J8;!F$-42&?o00YCn|NsAkxG);Tu3}(d_&*AU
zObGn_|Np-N0|Nsy0|NsK0|Nsq0|PkD*%=rZI2afhI2jlixEL51xEUbv&C9^Rz{kMA
zz|X+IAi%)DAjrVLAjH7HAk4tPAi}`FAPQ9{&cMJR!N9;E$-uxM#lXNI&A`AQ!@$5G
z%fP@O$H2fK4^(z@W##z@X2-z+k|@z+lM0z+l9{z+lY4z+eJZXU4$5V9vn6V8Ot^V9CJ1V8y_|
zV9mh5V8g(`V9UV3V8_6~V9&t7;K0DZ;K;zh;Kabd;LO0l;KIPb;L50|P@M0|P@60|P@c0|P?}
z0|P@UR8Kks149M_14AYQ149-A14A|g149l214AwY14AAI14BLo1497=14AJL149u5
z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zTwVG9LIa<623>%G0t@G@4j@So)=IXDDap^zK^Z?SNCqD^4;@l9GKf#nOUcP$kY!+C
zU}a!*-~?TOP?Vpe>kMmja4;}B@WMo$ic%A^VKPh%3=N_#i6x1k5h4ZO%;LnH%=En6
z)Vvay3RVV&0|Ji8$*IM~3SpV~IpEV%VUlbN3j)H$dYEfbyTuC1T!vPVflFYKqlvIVJN`O!v-b>h5(Q|L4F#=qalDL1V+#Q!xAW?LZcxtLPB8l{J#+r(WBlR4FN16P|w^r
zdj2Pta2XXE4S~@R7!85Z5Eu=C;T!^N42%q%3>BuTBNlnht($q+TFFXXVR?xJ=vT|6#pu)hw
z!rUY^(FC!G*oXnN8XRK33xtA`YB-k{!|pyT2A!6xR&C_yYGm$c?5t~O?q;fMXy{^~
z>*!|aq-$W{Xy9yV;AZLKYF5j@09|~}02&+vEwcpSKmYfBFCae~=sq-)CfC*u}`e
zz&^m?a+869;WacQU^JA=fCv}xWFvHvAO^A|AOZGgiCUwYAkrx$GDf=DwN1qD!wzP=x%uCKGO-YUM
zb@lZRill0oTw;RcBbEUU6Oi9QafD2R*dVNoEliw)LSjI}^nR}4dd>j>R4H6Q83=^`
zK?8+(fCFU-BLl-$P$|fOpg{ow!V1_k5oi+#Ct
z7(|e0ko!Pb8y+IayIerWxyN9f+)kC`0;-2V_yRKngEkLV)D`Tzj?)(`FZilIf=!^*w@=TB^E=@|1GhCo&ReE
z={w?HPCmN+7u4RfvKn3gi!WV`uKy*jkQ!b8TZFa;$SIKuX=il(Z+>10XjSm&`rrIK
eP?roe#4)=5cXa(P+7jc@^}nFZF^WfS2mk=&D+65s
From 98b31ed07389a28079818dc2806674e5da1f2137 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
Date: Wed, 7 Mar 2001 03:53:14 +0000
Subject: [PATCH 05/23] use BOOST_PYTHON_MODULE_INIT, update getting_started2
for better documentation
[SVN r9472]
---
example/getting_started1.cpp | 4 +---
example/getting_started2.cpp | 33 ++++++++++++++++----------------
example/getting_started3.cpp | 4 +---
example/getting_started4.cpp | 4 +---
example/getting_started5.cpp | 4 +---
example/test_getting_started2.py | 26 +++++++++++++++++--------
6 files changed, 38 insertions(+), 37 deletions(-)
diff --git a/example/getting_started1.cpp b/example/getting_started1.cpp
index 9679a2a4..7a8e9087 100644
--- a/example/getting_started1.cpp
+++ b/example/getting_started1.cpp
@@ -12,9 +12,7 @@ namespace python = boost::python;
// Python requires an exported function called init in every
// extension module. This is where we build the module contents.
-extern "C"
-DL_EXPORT(void)
-initgetting_started1()
+BOOST_PYTHON_MODULE_INIT(getting_started1)
{
try
{
diff --git a/example/getting_started2.cpp b/example/getting_started2.cpp
index 82b4a6df..72b04105 100644
--- a/example/getting_started2.cpp
+++ b/example/getting_started2.cpp
@@ -1,29 +1,28 @@
#include
#include
-#include
-namespace python = boost::python;
namespace { // Avoid cluttering the global namespace.
// A friendly class.
- class world
+ class hello
{
+ public:
+ hello(const std::string& country) { this->country = country; }
+ std::string greet() const { return "Hello from " + country; }
private:
std::string country;
- public:
- world(const std::string& country) { this->country = country; }
- std::string greet() const { return "Hello from " + country + "!"; }
};
- // A function taking a world object as an argument.
- std::string invite(const world& w) {
- return w.greet() + " Please come soon!";
+ // A function taking a hello object as an argument.
+ std::string invite(const hello& w) {
+ return w.greet() + "! Please come soon!";
}
}
-extern "C"
-DL_EXPORT(void)
-initgetting_started2()
+#include
+namespace python = boost::python;
+
+BOOST_PYTHON_MODULE_INIT(getting_started2)
{
try
{
@@ -31,18 +30,18 @@ initgetting_started2()
python::module_builder this_module("getting_started2");
// Create the Python type object for our extension class.
- python::class_builder world_class(this_module, "world");
+ python::class_builder hello_class(this_module, "hello");
// Add the __init__ function.
- world_class.def(python::constructor());
+ hello_class.def(python::constructor());
// Add a regular member function.
- world_class.def(&world::greet, "greet");
+ hello_class.def(&hello::greet, "greet");
// Add invite() as a regular function to the module.
this_module.def(invite, "invite");
- // Even better, invite() can also be made a member of world_class!!!
- world_class.def(invite, "invite");
+ // Even better, invite() can also be made a member of hello_class!!!
+ hello_class.def(invite, "invite");
}
catch(...)
{
diff --git a/example/getting_started3.cpp b/example/getting_started3.cpp
index 7e827249..799f5cac 100644
--- a/example/getting_started3.cpp
+++ b/example/getting_started3.cpp
@@ -91,9 +91,7 @@ namespace { // Avoid cluttering the global namespace.
}
}
-extern "C"
-DL_EXPORT(void)
-initgetting_started3()
+BOOST_PYTHON_MODULE_INIT(getting_started3)
{
try
{
diff --git a/example/getting_started4.cpp b/example/getting_started4.cpp
index 0c7bd7ee..199ef7a9 100644
--- a/example/getting_started4.cpp
+++ b/example/getting_started4.cpp
@@ -74,9 +74,7 @@ namespace { // Avoid cluttering the global namespace.
}
}
-extern "C"
-DL_EXPORT(void)
-initgetting_started4()
+BOOST_PYTHON_MODULE_INIT(getting_started4)
{
try
{
diff --git a/example/getting_started5.cpp b/example/getting_started5.cpp
index c9f1ce36..be033224 100644
--- a/example/getting_started5.cpp
+++ b/example/getting_started5.cpp
@@ -103,9 +103,7 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
BOOST_PYTHON_END_CONVERSION_NAMESPACE
-extern "C"
-DL_EXPORT(void)
-initgetting_started5()
+BOOST_PYTHON_MODULE_INIT(getting_started5)
{
try
{
diff --git a/example/test_getting_started2.py b/example/test_getting_started2.py
index 09215816..49cf765d 100644
--- a/example/test_getting_started2.py
+++ b/example/test_getting_started2.py
@@ -1,11 +1,21 @@
-r'''>>> import getting_started2
- >>> w = getting_started2.world('California')
- >>> print w.greet()
- Hello from California!
- >>> print getting_started2.invite(w)
- Hello from California! Please come soon!
- >>> print w.invite()
- Hello from California! Please come soon!
+r'''>>> from getting_started2 import *
+ >>> hi = hello('California')
+ >>> hi.greet()
+ 'Hello from California'
+ >>> invite(hi)
+ 'Hello from California! Please come soon!'
+ >>> hi.invite()
+ 'Hello from California! Please come soon!'
+
+ >>> class wordy(hello):
+ ... def greet(self):
+ ... return hello.greet(self) + ', where the weather is fine'
+ ...
+ >>> hi2 = wordy('Florida')
+ >>> hi2.greet()
+ 'Hello from Florida, where the weather is fine'
+ >>> invite(hi2)
+ 'Hello from Florida! Please come soon!'
'''
def run(args = None):
From 041409d71570d18cd25351936c4f817db47cd520 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
Date: Wed, 7 Mar 2001 03:53:56 +0000
Subject: [PATCH 06/23] use BOOST_PYTHON_MODULE_INIT
[SVN r9473]
---
test/comprehensive.cpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/test/comprehensive.cpp b/test/comprehensive.cpp
index 3d173310..7699b01f 100644
--- a/test/comprehensive.cpp
+++ b/test/comprehensive.cpp
@@ -1131,11 +1131,7 @@ void init_module()
boost_python_test.add(new boost::python::meta_class);
}
-extern "C"
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-void initboost_python_test()
+BOOST_PYTHON_MODULE_INIT(boost_python_test)
{
try {
bpl_test::init_module();
From a350b666faafe048311aabcc7d9baa48732fce72 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
Date: Wed, 7 Mar 2001 03:56:25 +0000
Subject: [PATCH 07/23] Added BOOST_PYTHON_MODULE_INIT
[SVN r9475]
---
include/boost/python/detail/config.hpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp
index 3207f7c6..9792695e 100644
--- a/include/boost/python/detail/config.hpp
+++ b/include/boost/python/detail/config.hpp
@@ -57,4 +57,10 @@
# define BOOST_CSTD_ std
# endif
+#ifdef _WIN32
+# define BOOST_PYTHON_MODULE_INIT(name) extern "C" __declspec(dllexport) void init##name()
+#else
+# define BOOST_PYTHON_MODULE_INIT(name) extern "C" void init##name()
+#endif
+
#endif // CONFIG_DWA052200_H_
From 5759ce9ba0ad80126051762d56492ce0a33b5239 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
Date: Wed, 7 Mar 2001 22:27:22 +0000
Subject: [PATCH 08/23] no message
[SVN r9482]
---
build/getting_started1/getting_started1.dsp | 136 ++++++++++++++++++++
build/getting_started2/getting_started2.dsp | 135 +++++++++++++++++++
2 files changed, 271 insertions(+)
create mode 100644 build/getting_started1/getting_started1.dsp
create mode 100644 build/getting_started2/getting_started2.dsp
diff --git a/build/getting_started1/getting_started1.dsp b/build/getting_started1/getting_started1.dsp
new file mode 100644
index 00000000..a41eb057
--- /dev/null
+++ b/build/getting_started1/getting_started1.dsp
@@ -0,0 +1,136 @@
+# Microsoft Developer Studio Project File - Name="getting_started1" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=getting_started1 - Win32 DebugPython
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "getting_started1.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "getting_started1.mak" CFG="getting_started1 - Win32 DebugPython"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "getting_started1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "getting_started1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "getting_started1 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=xicl6.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "getting_started1 - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"c:\tools\python\libs"
+
+!ELSEIF "$(CFG)" == "getting_started1 - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /GR /GX /ZI /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs"
+
+!ELSEIF "$(CFG)" == "getting_started1 - Win32 DebugPython"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugPython"
+# PROP BASE Intermediate_Dir "DebugPython"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugPython"
+# PROP Intermediate_Dir "DebugPython"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"DebugPython/boost_python_test_d.pdb" /debug /machine:I386 /out:"DebugPython/getting_started1_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\PCbuild"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "getting_started1 - Win32 Release"
+# Name "getting_started1 - Win32 Debug"
+# Name "getting_started1 - Win32 DebugPython"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\example\getting_started1.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/build/getting_started2/getting_started2.dsp b/build/getting_started2/getting_started2.dsp
new file mode 100644
index 00000000..284bab21
--- /dev/null
+++ b/build/getting_started2/getting_started2.dsp
@@ -0,0 +1,135 @@
+# Microsoft Developer Studio Project File - Name="getting_started2" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=getting_started2 - Win32 DebugPython
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "getting_started2.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "getting_started2.mak" CFG="getting_started2 - Win32 DebugPython"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "getting_started2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "getting_started2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "getting_started2 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "getting_started2"
+# PROP Scc_LocalPath "."
+CPP=xicl6.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "getting_started2 - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"c:\tools\python\libs"
+
+!ELSEIF "$(CFG)" == "getting_started2 - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs"
+
+!ELSEIF "$(CFG)" == "getting_started2 - Win32 DebugPython"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "getting_started2___Win32_DebugPython"
+# PROP BASE Intermediate_Dir "getting_started2___Win32_DebugPython"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "getting_started2___Win32_DebugPython"
+# PROP Intermediate_Dir "getting_started2___Win32_DebugPython"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"DebugPython/getting_started2_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\pcbuild"
+
+!ENDIF
+
+# Begin Target
+
+# Name "getting_started2 - Win32 Release"
+# Name "getting_started2 - Win32 Debug"
+# Name "getting_started2 - Win32 DebugPython"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\example\getting_started2.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
From 945344b3cd440b9260b2536cb2b3c3f9e0c24714 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
Date: Wed, 7 Mar 2001 23:31:32 +0000
Subject: [PATCH 09/23] *** empty log message ***
[SVN r9483]
---
doc/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/index.html b/doc/index.html
index 5a64bf62..c6e0722e 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -97,7 +97,7 @@ among others.
- The members of the boost mailing list and the Python community
supplied invaluable early feedback. In particular, Ron Clarke, Mark Evans,
- Anton Gluck, Chuck Ingold, Prabhu Ramachandran,n and Barry Scott took the
+ Anton Gluck, Chuck Ingold, Prabhu Ramachandran, and Barry Scott took the
brave step of trying to use Boost.Python while it was still in early
stages of development.
From bdbd9a0f5fcd711bd3fbca0477914fbf9c741348 Mon Sep 17 00:00:00 2001
From: "Ralf W. Grosse-Kunstleve"
Date: Thu, 8 Mar 2001 01:32:12 +0000
Subject: [PATCH 10/23] class_builder ->
class_builder<your_class>
[SVN r9484]
---
doc/pickle.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/pickle.html b/doc/pickle.html
index 7b559e68..ef3d8d0d 100644
--- a/doc/pickle.html
+++ b/doc/pickle.html
@@ -132,7 +132,7 @@ Both __getinitargs__ and __getstate__ are not defined.
this is, e.g.:
- class_builder py_your_class(your_module, "your_class");
+ class_builder<your_class> py_your_class(your_module, "your_class");
py_your_class.dict_defines_state();
@@ -185,7 +185,7 @@ __getstate__ is defined and the instance's __dict__ is not empty.
E.g. in C++:
- class_builder py_your_class(your_module, "your_class");
+ class_builder<your_class> py_your_class(your_module, "your_class");
py_your_class.getstate_manages_dict();
From a55948071695439f870126c1d686d4aeac4df8b3 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
Date: Thu, 8 Mar 2001 03:01:29 +0000
Subject: [PATCH 11/23] py_cpp => Boost.Python
[SVN r9485]
---
doc/overriding.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/overriding.html b/doc/overriding.html
index 7b28add1..b29bf0e6 100644
--- a/doc/overriding.html
+++ b/doc/overriding.html
@@ -92,7 +92,7 @@ struct hello_callback : hello
Finally, we add hello_callback to the
class_builder<> declaration in our module initialization
- function, and when we define the function, we must tell py_cpp about the default
+ function, and when we define the function, we must tell Boost.Python about the default
implementation:
@@ -120,7 +120,7 @@ hello_class.def(&hello::greet, "greet", &hello_callback::default_gree
*You may ask, "Why do we need this derived
class? This could have been designed so that everything gets done right
- inside of hello." One of the goals of py_cpp is to be
+ inside of hello." One of the goals of Boost.Python is to be
minimally intrusive on an existing C++ design. In principle, it should be
possible to expose the interface for a 3rd party library without changing
it. To unintrusively hook into the virtual functions so that a Python
From 33ea0dbdeeadd3b4ad77f223843276d9a08867f6 Mon Sep 17 00:00:00 2001
From: "Ralf W. Grosse-Kunstleve"
Date: Fri, 9 Mar 2001 02:40:06 +0000
Subject: [PATCH 12/23] temp file before branching
[SVN r9515]
---
doc/cross_module_dependencies.html | 253 +++++++++++++++++++++++++++++
1 file changed, 253 insertions(+)
create mode 100644 doc/cross_module_dependencies.html
diff --git a/doc/cross_module_dependencies.html b/doc/cross_module_dependencies.html
new file mode 100644
index 00000000..3d416bf5
--- /dev/null
+++ b/doc/cross_module_dependencies.html
@@ -0,0 +1,253 @@
+
+
+ Cross-extension-module dependencies
+
+
+
+
+
+
+
+Cross-extension-module dependencies
+
+It is good programming practice to organize large projects as modules
+that interact with each other via well defined interfaces. With
+Boost.Python it is possible to reflect this organization at the C++
+level at the Python level. This is, each logical C++ module can be
+organized as a separate Python extension module.
+
+
+At first sight this might seem natural and straightforward. However, it
+is a fairly complex problem to establish cross-extension-module
+dependencies while maintaining the same ease of use Boost.Python
+provides for classes that are wrapped in the same extension module. To
+a large extent this complexity can be hidden from the author of a
+Boost.Python extension module, but not entirely.
+
+
The recipe
+
+Suppose there is an extension module that exposes certain instances of
+the C++ std::vector template library such that it can be used from
+Python in the following manner:
+
+
+import std_vector
+v = std_vector.double([1, 2, 3, 4])
+v.push_back(5)
+v.size()
+
+
+Suppose the std_vector module is done well and reflects all C++
+functions that are useful at the Python level, for all C++ built-in
+data types (std_vector.int, std_vector.long, etc.).
+
+
+Suppose further that there is statistic module with a C++ class that
+has constructors or member functions that use or return a std::vector.
+For example:
+
+
+class xy {
+ private:
+ std::vector<double> m_x;
+ std::vector<double> m_y;
+ public:
+ xy(const std::vector<double>& x, const std::vector<double>& y) : m_x(x), m_y(y) {}
+ const std::vector<double>& x() const { return m_x; }
+ const std::vector<double>& y() const { return m_y; }
+ double correlation();
+}
+
+
+What is more natural then reusing the std_vector extension module to
+expose these constructors or functions to Python?
+
+
+Unfortunately, what seems natural needs a little work in both the
+std_vector and the statistics module.
+
+
+In the std_vector extension module, std::vector<double> needs to be
+exposed to Python with the x_class_builder<> template instead of the
+regular class_builder<>. For example:
+
+
+ x_class_builder<std::vector<double> > v_double(std_vector_module, "double");
+
+
+In the extension module that wraps class xy we need to use
+the import_class_builder<> template:
+
+
+ import_class_builder<std::vector<double> > v_double("std_vector", "double");
+
+
+That is all. All the properties that are defined for std_vector.double
+in the std_vector Boost.Python module will be available for the
+returned objects of xy.x() and xy.y(). Similarly, the constructor for
+xy will accept objects that were created by the std_vector module.
+
+Non-copyable types
+
+The x_class_builder<T> instantiates template functions that invoke the
+copy constructor of T. For a T that is non-copyable this will result in
+compile-time error messages. In such a case, another variety of the
+class_builder<>, the xptr_class_builder<> must be used.
+For example:
+
+
+xptr_class_builder<store> py_store(your_module, "store");
+
+
+The corresponding import_class_builder<> does not need any special
+attention:
+
+
+import_class_builder<store> py_store("noncopyable_export", "store");
+
+
+Python module search path
+
+The std_vector and statistics modules can now be used in the following
+way:
+
+
+import std_vector
+import statistics
+x = std_vector.double([1, 2, 3, 4])
+y = std_vector.double([2, 4, 6, 8])
+xy = statistics.xy(x, y)
+xy.correlation()
+
+
+In this example it is clear that Python has to be able to find both the
+std_vector and the statistics extension module. In other words, both
+extension modules need to be in the Python module search path
+(sys.path).
+
+
+The situation is not always that obvious. Suppose the statistics
+module has a random function that returns a vector of random
+numbers with a given length:
+
+
+import statistics
+x = statistics.random(5)
+y = statistics.random(5)
+xy = statistics.xy(x, y)
+xy.correlation()
+
+
+A naive user will not easily anticipate that the std_vector module is
+used to pass the x and y vectors around. If the std_vector module is in
+the Python module search path, this form of ignorance is of no harm.
+On the contrary, we are glad that we do not have to bother the user
+with details like this.
+
+
+If the std_vector module is not in the Python module search path, a
+Python exception will be raised:
+
+
+Traceback (innermost last):
+ File "foo.py", line 2, in ?
+ x = statistics.random(5)
+ImportError: No module named std_vector
+
+
+As is the case with any system of a non-trivial complexity, it is
+important that the setup is consistent and complete.
+
+Two-way module dependencies
+
+Boost.Python supports two-way module dependencies. This is best
+illustrated by a simple example.
+
+
+Suppose there is a module ivect that implements vectors of integers,
+and a similar module dvect that implements vectors of doubles. We want
+to be able do convert an integer vector to a double vector and vice
+versa. For example:
+
+
+import ivect
+iv = ivect.ivect((1,2,3,4,5))
+dv = iv.as_dvect()
+
+
+The last expression will implicitly import the dvect module in order to
+enable the conversion of the C++ representation of dvect to a Python
+object. The analogous is possible for a dvect:
+
+
+import dvect
+dv = dvect.dvect((1,2,3,4,5))
+iv = dv.as_ivect()
+
+
+Now the ivect module is imported implicitly.
+
+
+Note that the two-way dependencies are possible because the
+dependencies are resolved only when needed. This is, the initialization
+of the ivect module does not rely on the dvect module, and vice versa.
+Only if as_dvect() or as_ivect() is actually invoked will the
+corresponding module be implicitly imported. This also means that, for
+example, the dvect module does not have to be available at all if
+as_dvect() is never used.
+
+
Clarification of compile-time and link-time dependencies
+
+Boost.Python's support for resolving cross-module dependencies at
+runtime does not imply that compile-time dependencies are eliminated.
+For example, the statistics extension module in the example above will
+need to #include <vector>. This is immediately obvious from the
+definition of class xy.
+
+
+If a library is wrapped that consists of both header files and compiled
+components (e.g. libdvect.a, dvect.lib, etc.), both the Boost.Python
+extension module with the x_class_wrapper<> and the module with the
+import_class_wrapper<> need to be linked against the object library.
+Ideally one would build a shared library (e.g. libdvect.so, dvect.dll,
+etc.). However, this introduces the issue of getting the search path
+for the dynamic loading configured correctly. For small libraries it is
+therefore often more convenient to ignore the fact that the object
+files are loaded into memory more than once.
+
+
+The main purpose of Boost.Python's support for resolving cross-module
+dependencies at runtime is to allow for a modular system layout. With
+this support it is straightforward to reflect C++ code organization at
+the Python level. Without the cross-module support, a multi-purpose
+module like std_vector would be impractical because the entire wrapper
+code would somehow have to be duplicated in all extension modules that
+use it, making them harder to maintain and harder to build.
+
+
+Finally, there is an important psychological component. If a group of
+classes is lumped together with many others in a huge module, the
+authors will have difficulties in being identified with their work.
+The situation is much more transparent if the work is represented by
+a module with a recognizable name. This is not just a question of
+strong egos, but also of getting credit and funding.
+
+
Why not use the x_class_builder universally?
+
+There is some overhead associated with the Boost.Python cross-module
+support. Depending on the platform, the code generated by
+x_class_builder<> is roughly 10%-20% larger than that generated by
+class_builder<>. For a large extension module with many wrapped
+classes, this could mean a significant difference. Therefore the
+general recommendation is to use x_class_wrapper<> only for classes
+that are likely to be used as function arguments or return values in
+other modules.
+
+
+
+Author: Ralf W. Grosse-Kunstleve, March 2001
+
+
From a6b0fa546a1d0f0cfc08068ebaa9bfad3c7c8b9a Mon Sep 17 00:00:00 2001
From: "Ralf W. Grosse-Kunstleve"
Date: Fri, 9 Mar 2001 02:41:16 +0000
Subject: [PATCH 13/23] temp file removed after branching.
[SVN r9516]
---
doc/cross_module_dependencies.html | 253 -----------------------------
1 file changed, 253 deletions(-)
delete mode 100644 doc/cross_module_dependencies.html
diff --git a/doc/cross_module_dependencies.html b/doc/cross_module_dependencies.html
deleted file mode 100644
index 3d416bf5..00000000
--- a/doc/cross_module_dependencies.html
+++ /dev/null
@@ -1,253 +0,0 @@
-
-
- Cross-extension-module dependencies
-
-
-
-
-
-
-
-Cross-extension-module dependencies
-
-It is good programming practice to organize large projects as modules
-that interact with each other via well defined interfaces. With
-Boost.Python it is possible to reflect this organization at the C++
-level at the Python level. This is, each logical C++ module can be
-organized as a separate Python extension module.
-
-
-At first sight this might seem natural and straightforward. However, it
-is a fairly complex problem to establish cross-extension-module
-dependencies while maintaining the same ease of use Boost.Python
-provides for classes that are wrapped in the same extension module. To
-a large extent this complexity can be hidden from the author of a
-Boost.Python extension module, but not entirely.
-
-
The recipe
-
-Suppose there is an extension module that exposes certain instances of
-the C++ std::vector template library such that it can be used from
-Python in the following manner:
-
-
-import std_vector
-v = std_vector.double([1, 2, 3, 4])
-v.push_back(5)
-v.size()
-
-
-Suppose the std_vector module is done well and reflects all C++
-functions that are useful at the Python level, for all C++ built-in
-data types (std_vector.int, std_vector.long, etc.).
-
-
-Suppose further that there is statistic module with a C++ class that
-has constructors or member functions that use or return a std::vector.
-For example:
-
-
-class xy {
- private:
- std::vector<double> m_x;
- std::vector<double> m_y;
- public:
- xy(const std::vector<double>& x, const std::vector<double>& y) : m_x(x), m_y(y) {}
- const std::vector<double>& x() const { return m_x; }
- const std::vector<double>& y() const { return m_y; }
- double correlation();
-}
-
-
-What is more natural then reusing the std_vector extension module to
-expose these constructors or functions to Python?
-
-
-Unfortunately, what seems natural needs a little work in both the
-std_vector and the statistics module.
-
-
-In the std_vector extension module, std::vector<double> needs to be
-exposed to Python with the x_class_builder<> template instead of the
-regular class_builder<>. For example:
-
-
- x_class_builder<std::vector<double> > v_double(std_vector_module, "double");
-
-
-In the extension module that wraps class xy we need to use
-the import_class_builder<> template:
-
-
- import_class_builder<std::vector<double> > v_double("std_vector", "double");
-
-
-That is all. All the properties that are defined for std_vector.double
-in the std_vector Boost.Python module will be available for the
-returned objects of xy.x() and xy.y(). Similarly, the constructor for
-xy will accept objects that were created by the std_vector module.
-
-Non-copyable types
-
-The x_class_builder<T> instantiates template functions that invoke the
-copy constructor of T. For a T that is non-copyable this will result in
-compile-time error messages. In such a case, another variety of the
-class_builder<>, the xptr_class_builder<> must be used.
-For example:
-
-
-xptr_class_builder<store> py_store(your_module, "store");
-
-
-The corresponding import_class_builder<> does not need any special
-attention:
-
-
-import_class_builder<store> py_store("noncopyable_export", "store");
-
-
-Python module search path
-
-The std_vector and statistics modules can now be used in the following
-way:
-
-
-import std_vector
-import statistics
-x = std_vector.double([1, 2, 3, 4])
-y = std_vector.double([2, 4, 6, 8])
-xy = statistics.xy(x, y)
-xy.correlation()
-
-
-In this example it is clear that Python has to be able to find both the
-std_vector and the statistics extension module. In other words, both
-extension modules need to be in the Python module search path
-(sys.path).
-
-
-The situation is not always that obvious. Suppose the statistics
-module has a random function that returns a vector of random
-numbers with a given length:
-
-
-import statistics
-x = statistics.random(5)
-y = statistics.random(5)
-xy = statistics.xy(x, y)
-xy.correlation()
-
-
-A naive user will not easily anticipate that the std_vector module is
-used to pass the x and y vectors around. If the std_vector module is in
-the Python module search path, this form of ignorance is of no harm.
-On the contrary, we are glad that we do not have to bother the user
-with details like this.
-
-
-If the std_vector module is not in the Python module search path, a
-Python exception will be raised:
-
-
-Traceback (innermost last):
- File "foo.py", line 2, in ?
- x = statistics.random(5)
-ImportError: No module named std_vector
-
-
-As is the case with any system of a non-trivial complexity, it is
-important that the setup is consistent and complete.
-
-Two-way module dependencies
-
-Boost.Python supports two-way module dependencies. This is best
-illustrated by a simple example.
-
-
-Suppose there is a module ivect that implements vectors of integers,
-and a similar module dvect that implements vectors of doubles. We want
-to be able do convert an integer vector to a double vector and vice
-versa. For example:
-
-
-import ivect
-iv = ivect.ivect((1,2,3,4,5))
-dv = iv.as_dvect()
-
-
-The last expression will implicitly import the dvect module in order to
-enable the conversion of the C++ representation of dvect to a Python
-object. The analogous is possible for a dvect:
-
-
-import dvect
-dv = dvect.dvect((1,2,3,4,5))
-iv = dv.as_ivect()
-
-
-Now the ivect module is imported implicitly.
-
-
-Note that the two-way dependencies are possible because the
-dependencies are resolved only when needed. This is, the initialization
-of the ivect module does not rely on the dvect module, and vice versa.
-Only if as_dvect() or as_ivect() is actually invoked will the
-corresponding module be implicitly imported. This also means that, for
-example, the dvect module does not have to be available at all if
-as_dvect() is never used.
-
-
Clarification of compile-time and link-time dependencies
-
-Boost.Python's support for resolving cross-module dependencies at
-runtime does not imply that compile-time dependencies are eliminated.
-For example, the statistics extension module in the example above will
-need to #include <vector>. This is immediately obvious from the
-definition of class xy.
-
-
-If a library is wrapped that consists of both header files and compiled
-components (e.g. libdvect.a, dvect.lib, etc.), both the Boost.Python
-extension module with the x_class_wrapper<> and the module with the
-import_class_wrapper<> need to be linked against the object library.
-Ideally one would build a shared library (e.g. libdvect.so, dvect.dll,
-etc.). However, this introduces the issue of getting the search path
-for the dynamic loading configured correctly. For small libraries it is
-therefore often more convenient to ignore the fact that the object
-files are loaded into memory more than once.
-
-
-The main purpose of Boost.Python's support for resolving cross-module
-dependencies at runtime is to allow for a modular system layout. With
-this support it is straightforward to reflect C++ code organization at
-the Python level. Without the cross-module support, a multi-purpose
-module like std_vector would be impractical because the entire wrapper
-code would somehow have to be duplicated in all extension modules that
-use it, making them harder to maintain and harder to build.
-
-
-Finally, there is an important psychological component. If a group of
-classes is lumped together with many others in a huge module, the
-authors will have difficulties in being identified with their work.
-The situation is much more transparent if the work is represented by
-a module with a recognizable name. This is not just a question of
-strong egos, but also of getting credit and funding.
-
-
Why not use the x_class_builder universally?
-
-There is some overhead associated with the Boost.Python cross-module
-support. Depending on the platform, the code generated by
-x_class_builder<> is roughly 10%-20% larger than that generated by
-class_builder<>. For a large extension module with many wrapped
-classes, this could mean a significant difference. Therefore the
-general recommendation is to use x_class_wrapper<> only for classes
-that are likely to be used as function arguments or return values in
-other modules.
-
-
-
-Author: Ralf W. Grosse-Kunstleve, March 2001
-
-
From 55321b87785ef71e51669bc562211dc534884032 Mon Sep 17 00:00:00 2001
From: "Ralf W. Grosse-Kunstleve"
Date: Fri, 9 Mar 2001 18:59:59 +0000
Subject: [PATCH 14/23] HTML 4.0 Strict fixes.
[SVN r9530]
---
doc/pickle.html | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/doc/pickle.html b/doc/pickle.html
index ef3d8d0d..49f5c605 100644
--- a/doc/pickle.html
+++ b/doc/pickle.html
@@ -1,15 +1,15 @@
-
-
- Boost.Python Pickle Support
-
-
+
+
+Boost.Python Pickle Support
+
+
-
Boost.Python Pickle Support
@@ -28,15 +28,14 @@ can be written to a file.
The Boost Python Library supports the pickle module by emulating the
interface implemented by Jim Fulton's ExtensionClass module that is
-included in the ZOPE distribution
-(http://www.zope.org/).
+included in the
+ZOPE
+distribution.
This interface is similar to that for regular Python classes as
-described in detail in the Python Library Reference for pickle:
-
-
- http://www.python.org/doc/current/lib/module-pickle.html
-
+described in detail in the
+Python Library Reference for pickle.
The Boost.Python Pickle Interface
@@ -220,4 +219,4 @@ __getstate__ is defined and the instance's __dict__ is not empty.
Author: Ralf W. Grosse-Kunstleve, March 2001
-
+
From 494f12090f4090d1678f7f2b5fb06130e9814fca Mon Sep 17 00:00:00 2001
From: "Ralf W. Grosse-Kunstleve"
Date: Fri, 9 Mar 2001 19:02:12 +0000
Subject: [PATCH 15/23] Use only one (although the validator did not
complain).
[SVN r9531]
---
doc/pickle.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/pickle.html b/doc/pickle.html
index 49f5c605..3ec8c928 100644
--- a/doc/pickle.html
+++ b/doc/pickle.html
@@ -38,7 +38,7 @@ described in detail in the
>Python Library Reference for pickle.
-The Boost.Python Pickle Interface
+The Boost.Python Pickle Interface
At the user level, the Boost.Python pickle interface involves three special
methods:
@@ -93,7 +93,7 @@ returned by __getstate__ need not be a dictionary. The __getstate__ and
__setstate__ methods can do what they want.
-Pitfalls and Safety Guards
+Pitfalls and Safety Guards
In Boost.Python extension modules with many extension classes, providing
complete pickle support for all classes would be a significant
@@ -202,7 +202,7 @@ __getstate__ is defined and the instance's __dict__ is not empty.
- If __getinitargs__ is not defined, the class constructor will be - called without arguments. + If __getinitargs__ is not defined, the class constructor + will be called without arguments.
- If __getstate__ is not defined, the instance's __dict__ is pickled - (if it is not empty). + If __getstate__ is not defined, the instance's + __dict__ is pickled (if it is not empty).
- If __setstate__ is not defined, the result of __getstate__ must be - a Python dictionary. The items of this dictionary are added to - the instance's __dict__. + If __setstate__ is not defined, the result of + __getstate__ must be a Python dictionary. The items of this + dictionary are added to the instance's __dict__. +
- However, most C++ classes wrapped with Boost.Python will have member data - that are not restored correctly by this procedure. To alert the user - to this problem, a safety guard is provided. If both __getinitargs__ - and __getstate__ are not defined, Boost.Python tests if the class has an - attribute __dict_defines_state__. An exception is raised if this + However, most C++ classes wrapped with Boost.Python will have member + data that are not restored correctly by this procedure. To alert the + user to this problem, a safety guard is provided. If both + __getinitargs__ and __getstate__ are not defined, + Boost.Python tests if the class has an attribute + __dict_defines_state__. An exception is raised if this attribute is not defined:
@@ -147,41 +153,44 @@ Both __getinitargs__ and __getstate__ are not defined.
To alert the user to this highly unobvious problem, a safety guard is - provided. If __getstate__ is defined and the instance's __dict__ is - not empty, Boost.Python tests if the class has an attribute - __getstate_manages_dict__. An exception is raised if this attribute - is not defined: + provided. If __getstate__ is defined and the instance's + __dict__ is not empty, Boost.Python tests if the class has + an attribute __getstate_manages_dict__. An exception is + raised if this attribute is not defined:
RuntimeError: Incomplete pickle support (__getstate_manages_dict__ not set)
To resolve this problem, it should first be established that the
- __getstate__ and __setstate__ methods manage the instances's __dict__
- correctly. Note that this can be done both at the C++ and the Python
- level. Finally, the safety guard should intentionally be overridden.
- E.g. in C++:
+ __getstate__ and __setstate__ methods manage the
+ instances's __dict__ correctly. Note that this can be done
+ both at the C++ and the Python level. Finally, the safety guard
+ should intentionally be overridden. E.g. in C++:
class_builder<your_class> py_your_class(your_module, "your_class");
@@ -206,15 +215,24 @@ __getstate__ is defined and the instance's __dict__ is not empty.
struct baz {
virtual int pure(int) = 0;
+ int calls_pure(int x) { return pure(x) + 1000; }
};
struct baz_callback {
@@ -154,7 +155,7 @@ BOOST_PYTHON_MODULE_INIT(foobar)
{
boost::python::module_builder foobar("foobar");
boost::python::class_builder<baz,baz_callback> baz_class("baz");
- baz_class.def(&baz::pure, "pure");
+ baz_class.def(&baz::calls_pure, "calls_pure");
}
catch(...)
{
@@ -173,12 +174,18 @@ BOOST_PYTHON_MODULE_INIT(foobar)
Traceback (innermost last):
File "<stdin>", line 1, in ?
AttributeError: pure
+>>> x.calls_pure(1)
+Traceback (innermost last):
+ File "<stdin>", line 1, in ?
+AttributeError: pure
>>> class mumble(baz):
... def pure(self, x): return x + 1
...
>>> y = mumble()
>>> y.pure(99)
100
+>>> y.calls_pure(99)
+1100
Next: Function Overloading
Previous: Exporting Classes
From 678fa006de24673b654fc057a165e79a2108a734 Mon Sep 17 00:00:00 2001
From: "Ralf W. Grosse-Kunstleve"
+Updated: March 10, 2001
From 14acb1af8c1ef20c1a49ea1a2901e6b49817f2e2 Mon Sep 17 00:00:00 2001
From: Dave Abrahams
+ width="277" height="86">
Boost.Python Pickle Support
@@ -229,12 +229,17 @@ Both __getinitargs__ and __getstate__ are not defined.
Example
-An example that shows how to provide pickle support is available in the
+An example that shows how to configure pickle support is available in the
boost/lib/python/example directory
(getting_started3.cpp).
-
-Author: Ralf W. Grosse-Kunstleve, March 2001
-
+© Copyright Ralf W. Grosse-Kunstleve 2001. Permission to copy,
+use, modify, sell and distribute this document is granted provided this
+copyright notice appears in all copies. This document is provided "as
+is" without express or implied warranty, and with no claim as to its
+suitability for any purpose.
+
+