diff --git a/doc/v2/module.html b/doc/v2/module.html new file mode 100644 index 00000000..f39ff4e8 --- /dev/null +++ b/doc/v2/module.html @@ -0,0 +1,258 @@ + + + + + +
|
+ |
+ Boost.Python+ +Header <boost/python/module.hpp>+ |
module
+
+ module
+ synopsis
+
+ module
+ constructor
+
+ module
+ modifier functions
+
+ module
+ observer functions
+ {{Introductory text}} + +
BOOST_PYTHON_MODULE_INIT(name)
+ is used to declare Python
+ module initialization functions. The name argument must
+ exactly match the name of the module to be initialized, and must conform to
+ Python's identifier naming
+ rules. Where you would normally write
+
+void initname()
+{
+ ...
+
+ Boost.Python modules should be initialized with
+
+BOOST_PYTHON_MODULE_INIT(name)
+{
+ ...
+
+
+ moduleThis class represents the Python extension module under construction. It + provides functions for adding attributes and for retrieving the underlying + Python module object. + +
module
+ synopsis
+namespace boost { namespace python
+{
+ class module : public module_base
+ {
+ public:
+ module(const char* name);
+
+ // modifier functions
+ module& setattr(const char* name, PyObject*);
+ module& setattr(const char* name, PyTypeObject*);
+ module& setattr(const char* name, ref const&);
+
+ module& add(PyTypeObject* x);
+ template <class T, class Bases, class HolderGenerator>
+ module& add(class_<T,Bases,HolderGenerator> const& c);
+
+ template <class Fn>
+ module& def(char const* name, Fn fn);
+ template <class Fn, class ResultHandler>
+ module& def(char const* name, Fn fn, ResultHandler handler);
+
+ // observer function
+ ref object() const;
+ };
+
+}}
+
+
+ module
+ constructor+module(const char* name); ++ +
name is a ntbs whose value matches the
+ argument passed to BOOST_PYTHON_MODULE_INIT.
+
+ module object representing a
+ Python module named name.
+ module modifier
+ functions+module& setattr(const char* name, PyObject* obj); +module& setattr(const char* name, PyTypeObject* obj); +module& setattr(const char* name, ref const& r); ++ +
name is a ntbs which conforms to
+ Python's identifier
+ naming rules. In the first two forms, obj is non-null.
+ In the third form, r.get() is non-null.
+
+ make_function(), the
+ usual overloading procedure applies.
+ In the first two forms, ownership of a reference to obj is transferred
+ from caller to callee, even if an exception is thrown.
+
+ *this
+ +module& add(PyTypeObject* x); + +template <class T, class Bases, class HolderGenerator> +module& add(class_<T,Bases,HolderGenerator> const& c); ++ +
x is non-null
+
+ x to the Python module under construction, with the name
+ given by the type's tp_name
+ field. The second form adds the extension class object being constructed
+ by c to the module, with the same name that was passed to
+ c's constructor.
+
+ *this
+
+ +template <class Fn> +module& def(char const* name, Fn fn); + +template <class Fn, class ResultHandler> +module& def(char const* name, Fn fn, ResultHandler handler); ++ +
f is a non-null pointer-to-function or
+ pointer-to-member-function. name is a ntbs which conforms to
+ Python's identifier
+ naming rules. If supplied, policy conforms to the CallPolicy concept requirements.
+
+ make_function(f) to
+ the extension module being defined, with the given name. If
+ the module already has an attribute named name, the
+ usual overloading procedure applies.
+
+ *this
+ module observer
+ functions+ref object() const; ++ +
ref object which holds a reference to
+ the Python module object created by the module constructor.
+ C++ module definition: +
+#include <boost/python/module.hpp>
+
+char const* greet()
+{
+ return "hello, Boost.Python!";
+}
+
+BOOST_PYTHON_MODULE_INIT(boost_greet)
+{
+ module("boost_greet")
+ .def("greet", greet);
+}
+
+
+Interactive Python:
++>>> import boost_greet +>>> boost_greet.greet() +'hello, Boost.Python!' ++ +
Revised + + 14 February, 2002 + + + +
© Copyright Dave + Abrahams 2002. All Rights Reserved. +