diff --git a/doc/v2/class.html b/doc/v2/class.html
index 768a1444..c3e95f74 100644
--- a/doc/v2/class.html
+++ b/doc/v2/class.html
@@ -345,7 +345,7 @@ class_& def(Init init_expr);
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
+ 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.
@@ -378,17 +378,21 @@ class_& def(char const* name, Fn fn, A1 const& a1, A2 const& a2, A3
a1 is the result of an overload-dispatch-expression,
- only the second is allowed and fn must be a pointer to function
- or pointer to member function whose signature is compatible with
- A1.
+ "overloads.html#overload-dispatch-expression">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.
A1, adds a
- name(...) function overload
- to the extension class. Each overload generated invokes
+ 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
diff --git a/doc/v2/init.html b/doc/v2/init.html
new file mode 100644
index 00000000..710287ef
--- /dev/null
+++ b/doc/v2/init.html
@@ -0,0 +1,250 @@
+
+
+
+
+
+
+
+
+ |
+ |
+
+
+ Boost.Python+ +Headers <boost/python/init.hpp>, + <boost/python/class_fwd.hpp>+ |
+
initoptional<boost/python/init.hpp> defines the interface for
+ exposing C++ constructors to Python as extension class
+ __init__ functions.
__init__ methods to be generated for an extension class, and
+ the result has the following properties:
+
+ ++ ++
+- docstring: An ntbs + whose value will bound to the method's
+ +__doc__+ attribute- keywords: A keyword-expression which will be + used to name (a trailing subsequence of) the arguments to the + generated
+ +__init__function(s).- call policies: An instance of a model of CallPolicies.
+ +- argument types: An MPL sequence of C++ argument types + which will be used to construct the wrapped C++ object. An init + expression has one or more + valid prefixes which are given by a sequence of + prefixes of its argument types.
+
init<T1 =
+ unspecified, T2 =
+ unspecified,...Tn =
+ unspecified>A MPL sequence which
+ can be used to specify a family of one or more __init__
+ functions. Only the last Ti supplied
+ may be an instantiation of optional<...>.
init
+ synopsis
+namespace boost { namespace python
+{
+ template <T1 = unspecified,...Tn = unspecified>
+ struct init
+ {
+ init(char const* doc = 0);
+ template <class Keywords> init(Keywords const& kw, char const* doc = 0);
+ template <class Keywords> init(char const* doc, Keywords const& kw);
+
+ template <class CallPolicies>
+ unspecified operator[](CallPolicies const& policies) const
+ };
+}}
+
+
+ init
+ constructors+init(char const* doc = 0); +template <class Keywords> init(Keywords const& kw, char const* doc = 0); +template <class Keywords> init(char const* doc, Keywords const& kw); ++ +
doc is an ntbs. If supplied, kw is the
+ result of a doc and whose keywords are
+ a reference to kw. If the first form is used, the
+ resulting expression's keywords are empty. The expression's
+ call policies are an instance of default_call_policies.
+ If Tn is optional<U1, U2,...
+ Um>, the
+ expression's valid prefixes are given by:+ (+ Otherwise, the expression has one valid prefix given by the + the template arguments the user specified. +T1, T2,...Tn-1), + (T1, T2,...Tn-1 +, U1), + (T1, T2,...Tn-1 +, U1, U2), + ...(T1, T2,...Tn-1 +, U1, U2,...Um). +
init
+ observer functions+template <class Policies> +unspecified operator[](Policies const& policies) const ++ +
init object except that its call
+ policies are replaced by a reference to
+ policies.optional<T1
+ = unspecified, T2 =
+ unspecified,...Tn =
+ unspecified>A MPL sequence which
+ can be used to specify the optional arguments to an __init__
+ function.
optional synopsis
+namespace boost { namespace python
+{
+ template <T1 = unspecified,...Tn = unspecified>
+ struct optional {};
+}}
+
+
+ Given the C++ declarations:
+
+class Y;
+class X
+{
+ public:
+ X(int x, Y* y) : m_y(y) {}
+ X(double);
+ private:
+ Y* m_y;
+};
+
+ A corresponding Boost.Python extension class can be created with:
+
+using namespace boost::python;
+
+class_<X>("X", "This is X's docstring.",
+ init<int,char const*>(args("x","y"), "X.__init__'s docstring")[
+ with_custodian_and_ward<1,3>()]
+ )
+ .def(init<double>())
+ ;
+
+ © Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/overloads.html b/doc/v2/overloads.html new file mode 100644 index 00000000..3e931980 --- /dev/null +++ b/doc/v2/overloads.html @@ -0,0 +1,225 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/overloads.hpp>+ |
+
Defines facilities for generating families of overloaded Python + functions and extension class methods from C++ functions and + member functions with default arguments, or from similar families + of C++ overloads
+ ++ An overload-dispatch-expression is used to describe a + family of overloaded methods to be generated for an extension + class. It has the following properties: + +
++ ++
+- docstring: An ntbs + whose value will bound to the methods'
+ +__doc__+ attribute- keywords: A keyword-expression which + will be used to name (a trailing subsequence of) the arguments + to the generated methods.
+ +- call policies: An instance of some type which models CallPolicies.
+ +- minimum arity + The minimum number of arguments to be accepted by a generated + method overload.
+ +- maximum arity + The maximum number of arguments to be accepted by a generated + method overload.
+
X is a class which has a
+ minimum arity and a maximum arity, and for which
+ the following following are valid overload-dispatch-expressions,
+ with the same minimum and maximum arity as the OverloadDispatcher.
+
++X() +X(docstring) +X(docstring, keywords) +X(keywords, docstring) +X()[policies] +X(docstring)[policies] +X(docstring, keywords)[policies] +X(keywords, docstring)[policies] ++ +
policies are supplied, it must be an instance of a
+type which models CallPolicies, and
+will be used as the result's call policies. Otherwise the result's
+call policies will be an instance of default_call_policies.
+
+docstring is supplied it must be an ntbs, and will be used as the result's docstring. Otherwise the result has an empty docstring.
+
+keywords is supplied it must be the result of a keyword-expression
+ whose length is no greater than X's maximum
+ arity, and will be used as the result's keywords. Otherwise
+ the result's keywords will be empty.
+name in the current scope which can be used to
+ generate the following function invocation:
++func_id(a1, a2,...ai); ++ + for all
min_args <= i <= max_args.
+
+ name in the current scope which can be used to
+ generate the following function invocation:
++x.member_name(a1, a2,...ai); ++ + for all
min_args <= i <=
+ max_args, where x is a reference to an
+ object of class type.
+
+
+#include <boost/python/module.hpp>
+#include <boost/python/def.hpp>
+#include <boost/python/args.hpp>
+#include <boost/python/tuple.hpp>
+#include <boost/python/class.hpp>
+#include <boost/python/overloads.hpp>
+#include <boost/python/return_internal_reference.hpp>
+
+using namespace boost::python;
+
+tuple f(int x = 1, double y = 4.25, char const* z = "wow")
+{
+ return make_tuple(x, y, z);
+}
+
+BOOST_PYTHON_FUNCTION_OVERLOADS(f_overloads, f, 0, 3)
+
+stryct Y {};
+struct X
+{
+ Y& f(int x, double y = 4.25, char const* z = "wow")
+ {
+ return inner;
+ }
+ Y inner;
+};
+
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_f_overloads, X::f, 1, 3)
+
+BOOST_PYTHON_MODULE(args_ext)
+{
+ def("f", f, args("x", "y", "z")
+ , "This is f's docstring"
+ );
+
+
+ class_<Y>("Y")
+ ;
+
+ class_<X>("X", "This is X's docstring")
+ .def("f1", &X::f,
+ X_f_overloads(args("x", "y", "z"),
+ "f's docstring"
+ )[return_internal_reference<>()])
+ ;
+}
+
+
+ Revised + + 01 October, 2002 + +
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + +