PrevUpHomeNext

Chapter 4. Function Invocation and Creation

Table of Contents

boost/python/args.hpp
Introduction
Class arg
Class arg constructor
Class arg operator=
Keyword-expression operator,
Example
boost/python/call.hpp
Introduction
Function call
Example
boost/python/call_method.hpp
Introduction
Function call_method
Example
boost/python/data_members.hpp
Introduction
Functions
Example
boost/python/make_function.hpp
Introduction
Functions
Example
boost/python/overloads.hpp
Introduction
OverloadDispatcher Concept
Macros
Example
boost/python/ptr.hpp
Introduction
Functions
Class template pointer_wrapper
Class template pointer_wrapper types
Class template pointer_wrapper constructors and destructor
Class template pointer_wrapper observer functions
Metafunctions
Example
boost/python/raw_function.hpp
Introduction
Function raw_function
Example
Function documentation
boost/python/function_doc_signature.hpp
boost/python/pytype_function.hpp
Models of CallPolicies
boost/python/default_call_policies.hpp
boost/python/return_arg.hpp
boost/python/return_internal_reference.hpp
boost/python/return_value_policy.hpp
boost/python/with_custodian_and_ward.hpp
Models of ResultConverter
boost/python/to_python_indirect.hpp
boost/python/to_python_value.hpp
Models of ResultConverterGenerator
boost/python/copy_const_reference.hpp
boost/python/copy_non_const_reference.hpp
boost/python/manage_new_object.hpp
boost/python/reference_existing_object.hpp
boost/python/return_by_value.hpp
boost/python/return_opaque_pointer.hpp

Supplies a family of overloaded functions for specifying argument keywords for wrapped C++ functions.

A keyword-expression results in an object which holds a sequence of ntbses, and whose type encodes the number of keywords specified. The keyword-expression may contain default values for some or all of the keywords it holds

The objects of class arg are keyword-expressions holding one keyword ( size one )

namespace boost { namespace python
{
        struct arg
        {
          template <class T>
                  arg &operator = (T const &value);
          explicit arg (char const *name){elements[0].name = name;}
        };

}}
arg(char const* name);

Requires

The argument must be a ntbs.

Effects

Constructs an arg object holding a keyword with name name.

template <class T> arg &operator = (T const &value);

Requires

The argument must convertible to python.

Effects

Assigns default value for the keyword.

Returns

Reference to this.

keyword-expression operator , (keyword-expression, const arg &kw) const
keyword-expression operator , (keyword-expression, const char *name) const;

Requires

The argument name must be a ntbs.

Effects

Extends the keyword-expression argument with one more keyword.

Returns

The extended keyword-expression.

#include <boost/python/def.hpp>
using namespace boost::python;

int f(double x, double y, double z=0.0, double w=1.0);

BOOST_PYTHON_MODULE(xxx)
{
  def("f", f, (arg("x"), "y", arg("z")=0.0, arg("w")=1.0));
}

PrevUpHomeNext