pyplusplus.decl_wrappers package

Overview

Code generator configuration classes

pygccxml.declarations package contains classes, which describe C++ declarations. This package contains classes that derive from the pygccxml.declarations classes. The classes in this package allow you to configure the code generator.

class pyplusplus.decl_wrappers.dwfactory_t

Bases: pygccxml.declarations.decl_factory.decl_factory_t

declarations factory class

create_casting_operator(*arguments, **keywords)
create_class(*arguments, **keywords)
create_class_declaration(*arguments, **keywords)
create_constructor(*arguments, **keywords)
create_destructor(*arguments, **keywords)
create_enumeration(*arguments, **keywords)
create_free_function(*arguments, **keywords)
create_free_operator(*arguments, **keywords)
create_member_function(*arguments, **keywords)
create_member_operator(*arguments, **keywords)
create_namespace(*arguments, **keywords)
create_typedef(*arguments, **keywords)
create_variable(*arguments, **keywords)

Modules

algorithm

Contains few unrelated algorithms, which works on code creators tree

pyplusplus.decl_wrappers.algorithm.create_identifier(creator, full_name)
Return new full name, which takes into account namespace aliases
pyplusplus.decl_wrappers.algorithm.create_valid_name(name)

creates Python identifier from a string

As input this functions takes valid C++ nameidentifier and replaces all illegal characters.

Illegal characters are introduced by a template instantiation.

pyplusplus.decl_wrappers.algorithm.creators_affect_on_me(me)

find all relevant code creators, which influence on code generated by “me”.

C++ allows to define aliases to namespaces. Py++ allows user to define aliases to the namespace and will take this aliases into account when it generates the code.

Example:

[a b c d e f g]
       |
       + [k l m]
            |
            + [y x] <-- we are here ( x )

return value is: [y,l,k,d,c,b,a]

class pyplusplus.decl_wrappers.algorithm.registration_order

class-namespace, introduce few functions, which deals with functions registration order problem: http://www.language-binding.net/pyplusplus/documentation/functions/registration_order.html

Check whether two typesclasses t1 and t2 could introduce the problem
static select_problematics(calldef)
Return list of problematic functions for function “calldef”

calldef_wrapper

contains classes that allow to configure code generation for freemember functions, operators and etc.

class pyplusplus.decl_wrappers.calldef_wrapper.calldef_t(*arguments, **keywords)

Bases: pyplusplus.decl_wrappers.decl_wrapper.decl_wrapper_t

base class, for code generator configuration, for function declaration classes.

BOOST_PYTHON_MAX_ARITY

Boost.Python configuration macro value.

A function has more than BOOST_PYTHON_MAX_ARITY arguments, will not compile. You should adjust BOOST_PYTHON_MAX_ARITY macro. For more information see: http://mail.python.org/pipermail/c++-sig/2002-June/001554.html

add_transformation(*transformer_creators, **keywd)

add new function transformation.

transformer_creators - list of transformer creators, which should be applied on the function keywd - keyword arguments for function_transformers.function_transformation_t class initialization

call_policies
reference to decl_wrappers.call_policy_t class.Default value is calculated at runtime, based on return value.
create_with_signature
boolean, if True Py++ will generate next code: def( ..., function type( function ref )Thus, the generated code is safe, when a user creates function overloading.Default value is computed, based on information from the declarations tree
get_call_policies()
get_overridable()
Check if the method can be overridden.
has_wrapper()

returns True, if function - wrapper is needed

The functionality by this function is incomplete. So please don’t use it in your code.

mark_as_non_overridable(reason)

mark this function as final - user will not be able to override it from Python

Not all functions could be overridden from Python, for example virtual function that returns non const reference to a member variable. Py++ allows you to mark these functions and provide and explanation to the user.

non_overridable_reason
returns the reason the function could not be overridden
overridable
Check if the method can be overridden.
set_call_policies(call_policies)
set_overridable(overridable)
transformations
return list of function transformations that should be applied on the function
use_default_arguments
boolean, if True Py++ will generate code that will set default argumentsDefault value is True.
use_keywords
boolean, if True, allows to call function from Python using keyword arguments.Default value is True.
class pyplusplus.decl_wrappers.calldef_wrapper.casting_operator_t(*arguments, **keywords)

Bases: pygccxml.declarations.calldef.casting_operator_t, pyplusplus.decl_wrappers.calldef_wrapper.calldef_t

defines a set of properties, that will instruct Py++ how to expose the casting operator

alias
Gives right alias for casting operators: __int__, __long__, __str__.If there is no built-in type, creates as_xxx alias
prepare_special_cases()
Creates a map of special cases ( aliases ) for casting operator.
class pyplusplus.decl_wrappers.calldef_wrapper.constructor_t(*arguments, **keywords)

Bases: pygccxml.declarations.calldef.constructor_t, pyplusplus.decl_wrappers.calldef_wrapper.calldef_t

defines a set of properties, that will instruct Py++ how to expose the constructor

allow_implicit_conversion
boolean, indicates whether Py++ should generate implicitly_convertible code or notDefault value is calculated from the constructor type.
body
string, class-wrapper constructor body
does_define_implicit_conversion()

returns true if the constructor can take part in implicit conversions.

For more information see:

class pyplusplus.decl_wrappers.calldef_wrapper.destructor_t(*arguments, **keywords)

Bases: pygccxml.declarations.calldef.destructor_t, pyplusplus.decl_wrappers.calldef_wrapper.calldef_t

you may ignore this class for he time being.

In future it will contain “body” property, that will allow to insert user code to class-wrapper destructor.

class pyplusplus.decl_wrappers.calldef_wrapper.free_function_t(*arguments, **keywords)

Bases: pygccxml.declarations.calldef.free_function_t, pyplusplus.decl_wrappers.calldef_wrapper.calldef_t

defines a set of properties, that will instruct Py++ how to expose the free function

adaptor
string, if contains value Py++ will generate code the following code: def(<name>, <adaptor>(<function reference>), <other args> )
add_declaration_code(code)
adds the code to the declaration section
declaration_code
List of strings, that contains valid C++ code, that will be added to the same file in which the registration code for the function will be generated
get_use_overload_macro()
set_use_overload_macro(use_macro)
use_overload_macro
boolean, if True, will use BOOST_PYTHON_FUNCTION_OVERLOADS macro to expose declarationsDefault value is False.
class pyplusplus.decl_wrappers.calldef_wrapper.free_operator_t(*arguments, **keywords)

Bases: pygccxml.declarations.calldef.free_operator_t, pyplusplus.decl_wrappers.calldef_wrapper.calldef_t

defines a set of properties, that will instruct Py++ how to expose the free operator

get_target_class()
set_target_class(class_)
target_class
reference to class_t or class_declaration_t object. There are use cases, where Py++ doesn’t guess right, in what scope free operator should be registered( exposed ). If this is your use case than setting the class will allow you to quickly fix the situation.
class pyplusplus.decl_wrappers.calldef_wrapper.member_function_t(*arguments, **keywords)

Bases: pygccxml.declarations.calldef.member_function_t, pyplusplus.decl_wrappers.calldef_wrapper.calldef_t

defines a set of properties, that will instruct Py++ how to expose the member function

adaptor
string, if contains value Py++ will generate code the following code: .def(<name>, <adaptor>(<function reference>), <other args> ) . The property is relevant for public, non virtual member functions.
add_default_precall_code(code)
add code, which should be executed, before this member function call
add_override_native_precall_code(code)
add code, which should be executed, before native member function call
add_override_precall_code(code)
add code, which should be executed, before overridden member function call
default_precall_code
code, which should be executed, before this member function call
get_use_overload_macro()
override_native_precall_code
code, which should be executed, before overrided member function call
override_precall_code
code, which should be executed, before overrided member function call
set_use_overload_macro(use_macro)
use_overload_macro
boolean, if True, will use BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro to expose declarationsDefault value is False.
class pyplusplus.decl_wrappers.calldef_wrapper.member_operator_t(*arguments, **keywords)

Bases: pygccxml.declarations.calldef.member_operator_t, pyplusplus.decl_wrappers.calldef_wrapper.calldef_t

defines a set of properties, that will instruct Py++ how to expose the member operator

add_default_precall_code(code)
add_override_native_precall_code(code)
add code, which should be executed, before native member function call
add_override_precall_code(code)
alias
Gives right alias for operator()( __call__ ) and operator[]( __getitem__ )
default_precall_code
override_native_precall_code
code, which should be executed, before overrided member function call
override_precall_code
target_class
class pyplusplus.decl_wrappers.calldef_wrapper.operators_helper

helps Py++ to deal with C++ operators

static exportable(oper)
returns True if Boost.Python or Py++ know how to export the operator
static is_supported(oper)
returns True if Boost.Python support the operator
static target_class(oper)
this functions returns reference to class/class declaration in scope of which, the operator should be exposed.

call_policies

Contains definition of call policies classes

class pyplusplus.decl_wrappers.call_policies.CREATION_POLICY
Implementation details
class pyplusplus.decl_wrappers.call_policies.call_policy_t

Bases: object

base class for all classes, which generate “call policies” code

create(function_creator, creation_policy='as instance')

Creates code from the call policies class instance. :param function_creator: parent code creator :type function_creator: code_creators.function_t or code_creators.constructor_t

Parameter:creation_policy (decl_wrappers.CREATION_POLICY) – indicates whether we this call policy used as template argument or as an instance
create_template_arg(function_creator)
return call policies class declaration as string
create_type()
return call policies class declaration as string
header_file
return a name of the header file the call policy is defined in
is_default()
return True is self is instance of decl_wrappers.default_call_policies_t class
is_predefined()
return True if call policy is defined in Boost.Python library, False otherwise
class pyplusplus.decl_wrappers.call_policies.compound_policy_t(base=None)

Bases: pyplusplus.decl_wrappers.call_policies.call_policy_t

base class for all call policies, except the default one

base_policy
base call policy, by default is reference to decl_wrappers.default_call_policies_t call policy
pyplusplus.decl_wrappers.call_policies.convert_array_to_tuple(array_size, memory_manager, make_object_call_policies=None, base=None)
create boost::python::return_value_policy< py++::as_tuple > call policies code generator
class pyplusplus.decl_wrappers.call_policies.convert_array_to_tuple_t(array_size, memory_manager, make_object_call_policies=None, base=None)

Bases: pyplusplus.decl_wrappers.call_policies.compound_policy_t

implements code generation for Py++ defined “as_tuple” value policy

For complete documentation and usage example see “Call policies” document.

array_size
header_file
Return name of the header file to be included
is_predefined()
Returns True if call policy is defined in Boost.Python library, False otherwise
make_objec_call_policies
memory_manager
pyplusplus.decl_wrappers.call_policies.custom_call_policies(call_policies, header_file=None)
create customuser defined call policies code generator
class pyplusplus.decl_wrappers.call_policies.custom_call_policies_t(call_policies, header_file=None)

Bases: pyplusplus.decl_wrappers.call_policies.call_policy_t

implements code generation for user defined call policies

get_header_file()
header_file
Return name of the header file to be included
set_header_file(header_file_name)
pyplusplus.decl_wrappers.call_policies.default_call_policies()
create ::boost::python::default_call_policies call policies code generator
class pyplusplus.decl_wrappers.call_policies.default_call_policies_t

Bases: pyplusplus.decl_wrappers.call_policies.call_policy_t

implements code generation for boost::python::default_call_policies

is_default()
pyplusplus.decl_wrappers.call_policies.is_return_opaque_pointer_policy(policy)
returns True is policy represents return_value_policy<return_opaque_pointer>, False otherwise
class pyplusplus.decl_wrappers.call_policies.memory_managers

implements code generation for Py++ defined memory managers

For complete documentation and usage example see “Call policies” document.

static create(manager, function_creator=None)
pyplusplus.decl_wrappers.call_policies.return_arg(arg_pos, base=None)
create boost::python::return_arg call policies code generator
class pyplusplus.decl_wrappers.call_policies.return_argument_t(position=1, base=None)

Bases: pyplusplus.decl_wrappers.call_policies.compound_policy_t

implements code generation for boost::python::return_argument call policies

position
pyplusplus.decl_wrappers.call_policies.return_internal_reference(arg_pos=1, base=None)
create boost::python::return_internal_reference call policies code generator
class pyplusplus.decl_wrappers.call_policies.return_internal_reference_t(position=1, base=None)

Bases: pyplusplus.decl_wrappers.call_policies.compound_policy_t

implements code generation for boost::python::return_internal_reference call policies

position
pyplusplus.decl_wrappers.call_policies.return_range(function, get_size_class, value_policies=None)
create Py++ defined return_range call policies code generator
class pyplusplus.decl_wrappers.call_policies.return_range_t(get_size_class, value_type, value_policies)

Bases: pyplusplus.decl_wrappers.call_policies.call_policy_t

implements code generation for Py++ defined “return_range” call policies

For complete documentation and usage example see “Call policies” document.

get_size_class
header_file
Return name of the header file to be included
is_predefined()
Returns True if call policy is defined in Boost.Python library, False otherwise
value_policies
value_type
pyplusplus.decl_wrappers.call_policies.return_self(base=None)
create boost::python::return_self call policies code generator
pyplusplus.decl_wrappers.call_policies.return_value_policy(result_converter_generator, base=None)
create boost::python::return_value_policy call policies code generator
class pyplusplus.decl_wrappers.call_policies.return_value_policy_t(result_converter_generator, base=None)

Bases: pyplusplus.decl_wrappers.call_policies.compound_policy_t

implements code generation for boost::python::return_value_policy call policies

header_file
Return name of the header file to be included
is_predefined()
Returns True if call policy is defined in Boost.Python library, False otherwise
result_converter_generator
pyplusplus.decl_wrappers.call_policies.with_custodian_and_ward(custodian, ward, base=None)
create boost::python::with_custodian_and_ward call policies code generator
pyplusplus.decl_wrappers.call_policies.with_custodian_and_ward_postcall(custodian, ward, base=None)
create boost::python::with_custodian_and_ward_postcall call policies code generator
class pyplusplus.decl_wrappers.call_policies.with_custodian_and_ward_postcall_t(custodian, ward, base=None)

Bases: pyplusplus.decl_wrappers.call_policies.with_custodian_and_ward_t

implements code generation for boost::python::with_custodian_and_ward_postcall call policies

class pyplusplus.decl_wrappers.call_policies.with_custodian_and_ward_t(custodian, ward, base=None)

Bases: pyplusplus.decl_wrappers.call_policies.compound_policy_t

implements code generation for boost::python::with_custodian_and_ward call policies

custodian
ward

class_wrapper

defines class that configure class definition and class declaration exposing

class pyplusplus.decl_wrappers.class_wrapper.class_common_details_t

Bases: object

defines pygccxml.declarations.class_declaration_t and pygccxml.declarations.class_t classes common properties

always_expose_using_scope
please see class_wrapper.always_expose_using_scope_documentation variable for documentation.
class_var_name
equality_comparable
indicates existence of public operator=Default value is calculated, based on information presented in the declarations tree
guess_always_expose_using_scope_value()
indexing_suite

reference to indexing suite configuration class.

If the class is not STD container, this property will contain None”

indexing_suite_version
indexing suite version
less_than_comparable
indicates existence of public operator<. Default value is calculated, based on information presented in the declarations tree
opaque
If True, Py++ will treat return types and arguments T* as opaque types. nFor Boost.Python code generator it means that macro BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID everywhere it needed. For ctypes code generator it means that the class will be introduced, but without fields. For both code generators it means: you will only be able to get and pass pointers around. Other functionality will not be available.
class pyplusplus.decl_wrappers.class_wrapper.class_declaration_t(*arguments, **keywords)
Bases: pyplusplus.decl_wrappers.class_wrapper.class_common_details_t, pyplusplus.decl_wrappers.decl_wrapper.decl_wrapper_t, pygccxml.declarations.class_declaration.class_declaration_t
class pyplusplus.decl_wrappers.class_wrapper.class_t(*arguments, **keywords)

Bases: pyplusplus.decl_wrappers.class_wrapper.class_common_details_t, pyplusplus.decl_wrappers.scopedef_wrapper.scopedef_t, pygccxml.declarations.class_declaration.class_t

class EXPOSED_CLASS_TYPE
class_t.add_code(code, works_on_instance=True, tail=True)

adds the code to the class registration section

Parameters:
  • works_on_instance (bool) – If true, the custom code can be applied directly to obj inst. Example: ObjInst.code
  • tail (bool) – if True, the custom code is appended to the end of the class registration code.
class_t.add_declaration_code(code)
adds the code to the declaration section
class_t.add_destructor_code(code)
adds code to the class-wrapper destructor
class_t.add_fake_constructors(f)

f - reference to a calldef_t object or list of them

boost::python::make_constructor allows to register a C++ function, as a class constructor.

class_t.add_properties(recognizer=None, exclude_accessors=False)
class_t.add_property(name, fget, fset=None, doc='')

adds new property to the class

Parameters:
  • name (str) – name of the property
  • fget – reference to the class member function
  • fset – reference to the class member function, could be None
  • doc – documentation string
class_t.add_registration_code(code, works_on_instance=True, tail=True)

adds the code to the class registration section

Parameters:
  • works_on_instance (bool) – If true, the custom code can be applied directly to obj inst. Example: ObjInst.code
  • tail (bool) – if True, the custom code is appended to the end of the class registration code.
class_t.add_static_property(name, fget, fset=None, doc='')
adds new static property to the class
class_t.add_wrapper_code(code)
adds code to the class wrapper class definition
class_t.copy_constructor_body
copy constructor code, that will be added as is to the copy constructor of class-wrapper
class_t.declaration_code
List of strings, that contains valid C++ code, that will be added to the class declaration section
class_t.destructor_code
list of code to be added to wrapper destructor
class_t.exception_argument_name

exception argument name for translate exception function

If you don’t understand what this argument is, please take a look on Boost.Python documentation: http://www.boost.org/libs/python/doc/v2/exception_translator.html

class_t.exception_translation_code
C++ exception to Python exception translation code Example: PyErr_SetString(PyExc_RuntimeError, exc.what()); Py++ will generate the rest of the code. Pay attention: the exception variable name is exc.
class_t.expose_sizeof
boolean, if True the sizeof(obj) will be exposed to Python as integer.
class_t.expose_this
boolean, if True an object address( this pointer ) will be exposed to Python as integer.
class_t.exposed_class_type
set this value to CLASS_TYPE.WRAPPER, if you need to transfer ownership ofpolymorphic class
class_t.fake_constructors
list of fake constructors
class_t.get_exportable_members(sort=None)
returns list of internal declarations that shouldcould be exported
class_t.guess_always_expose_using_scope_value()
class_t.held_type
string, this property tells Py++ what HeldType this class hasDefault value is calculated, based on information presented in exposed declarations
class_t.introduces_new_scope

returns True, if during exposing this class, new scope will be created

For example, anonymous structs will be exposed in a parent scope.

class_t.is_wrapper_needed()

returns an explanation( list of str ) why wrapper is needed.

If wrapper is not needed than [] will be returned.

class_t.no_init
If True, class will be registered with ‘boost::python::no_init’
class_t.noncopyable
True if the class is noncopyable, False otherwiesDefault value is calculated, based on information presented in the declarations tree
class_t.null_constructor_body
null constructor code, that will be added as is to the null constructor of class-wrapper
class_t.properties
list of properties
class_t.redefine_operators
tells Py++ to redefine operators from base class in this class, False by default
class_t.redefined_funcs()

returns list of member functions that should be defined in the class wrapper

It comes useful in 3 tier hierarchy:

struct base{
    virtual void do_nothing() = 0;
};

struct derived{
    virtual void do_something() = 0;
};

struct concrete{
    virtual void do_nothing(){}
    virtual void do_something(){}
};

The wrapper for class derived, should define do_nothing function, otherwise the generated code will not compile

class_t.registration_code
List of strings, that contains all C++ code, that will be added to the class registration section
class_t.registration_code_head
List of strings, that contains valid C++ code, that will be added to the head of the class registration section
class_t.registration_code_tail
List of strings, that contains valid C++ code, that will be added to the tail of the class registration section
class_t.require_self_reference
boolean, if True the first argument to the constructor will be reference to self object
class_t.set_constructors_body(body)
Sets the body for all constructors
class_t.translate_exception_to_string(python_exception_type, to_string)

registers exception translation to string

Parameters:
  • python_exception_type (str) – Python exception type, for example PyExc_RuntimeError
  • to_string (str) – C++ expression that extracts information from exception. The type of expression should be char*.
class_t.wrapper_alias
class-wrapper name
class_t.wrapper_code
List of strings, that contains valid C++ code, that will be added to the class wrapper.
class pyplusplus.decl_wrappers.class_wrapper.impl_details
class GUESS_VALUES

decl_wrapper

defines base class for all code generator configuration classes

class pyplusplus.decl_wrappers.decl_wrapper.CODE_GENERATOR_TYPES
class pyplusplus.decl_wrappers.decl_wrapper.decl_wrapper_t

Bases: object

code generator declaration configuration base class

This class contains configuration that could be applied to all declarations.

alias
The name under which, Python will know the declaration. Code generators: ctypes, Boost.Python
already_exposed
boolean flag, which says whether the declaration is already exposed or not
code_generator
code generator type, could be Boost.Python or ctypes
disable_messages(*args)

disable messages - Py++ will not report the disabled messages Usage example:

decl.disable_messages( messages.W1001, messages.W1040 )
disable_warnings(*args)

disable messages - Py++ will not report the disabled messages Usage example:

decl.disable_messages( messages.W1001, messages.W1040 )
disabled_messaged
list of messages to ignore
disabled_messages
list of messages to ignore
documentation
exposed declaration Python documentation string
exclude(compilation_errors=False)

exclude “self” and child declarations from being exposed.

If compile_time_errors is True, than only declarations, which will cause compilation error will be excluded

Code generators: ctypes, Boost.Python

exportable
Returns True if declaration could be exported to Python, otherwise False
get_already_exposed()
get_exportable()
return True if declaration could be exposed to Python, False otherwise
ignore
Boolean flag, which says whether to export declaration to Python or not. Code generators: ctypes, Boost.Python
include(already_exposed=False)

include “self” and child declarations to be exposed.

Code generators: ctypes, Boost.Python.

include_files
list of header files, to be included from the file, the generated code will be placed-in
logger
reference to _logging_.loggers.declarations
readme(skip_ignored=True)

return important information( hints/tips/warning message ) Py++ has about this declaration.

skip_ignored argument allows you to control the information reported to you. For more information please read: http://www.language-binding.net/pyplusplus/documentation/warnings.html

rename(new_name)

give new name to the declaration, under which Python will know the declaration

Code generators: ctypes, Boost.Python

set_already_exposed(value)
set_exportable(exportable)

change “exportable” status

This function should be use in case Py++ made a mistake and signed the declaration as non-exportable.

why_not_exportable()

return the reason( string ) that explains why this declaration could not be exported

If declaration could be exported, than method will return None

decl_wrapper_printer

defines class that will print in a user friendly format declarations tree and declarations Py++ configuration instructions

class pyplusplus.decl_wrappers.decl_wrapper_printer.decl_wrapper_printer_t(level=0, print_details=True, recursive=True, writer=None)

Bases: pygccxml.declarations.decl_printer.decl_printer_t

Helper class for printing declarations tree and Py++ configuration instructions

clone(increment_level=True)
print_calldef_wrapper()
print_decl_header()
visit_casting_operator()
visit_class()
visit_class_declaration()
visit_constructor()
visit_destructor()
visit_enumeration()
visit_free_function()
visit_free_operator()
visit_member_function()
visit_member_operator()
visit_namespace()
visit_typedef()
visit_variable()
pyplusplus.decl_wrappers.decl_wrapper_printer.print_declarations(decls, detailed=True, recursive=True, writer=<built-in method write of file object at 0x7ff9091f4140>)

print declarations tree

Parameter:decls – could be single pygccxml.declarations.declaration_t object or list of them

doc_extractor

defines documentation extractor class interface

class pyplusplus.decl_wrappers.doc_extractor.doc_extractor_i(encoding='ascii')

Bases: object

defines documentation extractor interface

static escape_doc(doc)
converts a text to be valid C++ string literals
extract(decl)

returns documentation text for the declaration

This function should be implemented in derived class.

Using decl.location.file_name and decl.location.line variables you can find out the location of declaration within source file

enumeration_wrapper

defines class that configure enumeration declaration exposing

class pyplusplus.decl_wrappers.enumeration_wrapper.enumeration_t(*arguments, **keywords)

Bases: pyplusplus.decl_wrappers.decl_wrapper.decl_wrapper_t, pygccxml.declarations.enumeration.enumeration_t

defines a set of properties, that will instruct Py++ how to expose the enumeration

By default, Py++ will export all enumeration values.

export_values
A list of (C++) enumeration names that should be exported. @type: list
no_export_values
A list of (C++) enumeration names that should not be exported. @type: list
value_aliases
A translation table from C++ enumeration value names to desired Python names. @type: dict

indexing_suite1

defines interface for exposing STD containers, using current version of indexing suite

class pyplusplus.decl_wrappers.indexing_suite1.indexing_suite1_t(container_class, no_proxy=None, derived_policies=None)

Bases: object

This class helps user to export STD containers, using built-in Boost.Python indexing suite.

container_class
reference to the parent( STD container ) class
container_traits
reference to container traits. See pygccxml documentation for more information.
derived_policies
This proprty contains DerivedPolicies string. It will be added as is to the generated code.
element_type
reference to container value_type( mapped_type ) type
include_files
Return list of header files to be included in generated code
no_proxy
NoProxy value, the initial value depends on container element_type( mapped_type ) type. In most cases, Py++ is able to guess this value, right. If you are not lucky, you will have to set the property value.

indexing_suite2

defines interface for exposing STD containers, using next version of indexing suite

class pyplusplus.decl_wrappers.indexing_suite2.indexing_suite2_t(container_class)

Bases: object

This class helps user to export STD containers, using Boost.Python indexing suite V2.

call_policies
container_class
reference to the parent( STD container ) class
container_traits
reference to container traits. See pygccxml documentation for more information.
disable_method(method_name)
Disable method from being exposed
disable_methods
list of all disabled methods
disable_methods_group(group_name)
Disable methods group from being exposed
disabled_methods_groups
list of all disabled methods group
element_type
reference to container value_type( mapped_type ) type
enable_method(method_name)
Enable method to be exposed
enable_methods_group(group_name)
Enable methods group to be exposed
get_use_container_suite()
include_files
Return list of header files to be included in generated code
set_use_container_suite(value)
use_container_suite

namespace_wrapper

defines class that configure namespace exposing.

class pyplusplus.decl_wrappers.namespace_wrapper.namespace_t(*arguments, **keywords)

Bases: pyplusplus.decl_wrappers.scopedef_wrapper.scopedef_t, pygccxml.declarations.namespace.namespace_t

defines a set of properties, that will instruct Py++ how to expose the namespace

Today, Py++ does not exposes namespaces, but this could be changed in future. The future direction I see here, is to expose every namespace as sub-module of the main one.

properties

defines property_t helper class

pyplusplus.decl_wrappers.properties.find_properties(cls, recognizer=None, exclude_accessors=False)
class pyplusplus.decl_wrappers.properties.name_based_recognizer_t

Bases: pyplusplus.decl_wrappers.properties.property_recognizer_i

check_name_compatibility(gname, sname, gprefix, sprefix)
check_prefix(name, prefix)
check_type_compatibility(fget, fset)
create_property(fget, fset)
create_read_only_property(fget)
find_out_prefixes(gname, sname)
find_out_property_name(fget, prefix)
find_out_ro_prefixes(gname)
make_l_camel_convention(gprefix, sprefix)
make_std_convention(gprefix, sprefix)
make_u_camel_convention(gprefix, sprefix)
prefixes()
class pyplusplus.decl_wrappers.properties.properties_finder_t(cls, recognizer=None, exclude_accessors=False)
find_properties(getters, setters, used_getters, used_setters)
class pyplusplus.decl_wrappers.properties.property_recognizer_i

Bases: object

base_classes(cls)
class_accessors(cls)
create_property(fget, fset)
create_read_only_property(sefl, fget)
inherited_accessors(cls)
is_accessor(mem_fun)
is_getter(mem_fun)
is_setter(mem_fun)
class pyplusplus.decl_wrappers.properties.property_t(name, fget, fset=None, doc=None, is_static=False)

Bases: object

This class describes a “property”.

It keeps

doc
fget
fset
is_static
name

python_traits

defines few “type traits” functions related to C++ Python bindings

pyplusplus.decl_wrappers.python_traits.call_traits(type_)
http://boost.org/libs/utility/call_traits.htm
pyplusplus.decl_wrappers.python_traits.is_immutable(type_)
returns True, if type_ represents Python immutable type

scopedef_wrapper

defines base class for decl_wrappers.class_t and decl_wrappers.namespace_t classes

class pyplusplus.decl_wrappers.scopedef_wrapper.scopedef_t

Bases: pyplusplus.decl_wrappers.decl_wrapper.decl_wrapper_t

base class for decl_wrappers.class_t and decl_wrappers.namespace_t classes

It provides convenience functionality: includeexclude all internal declarations (not) to be exported.

exclude(compilation_errors=False)

exclude “self” and child declarations from being exposed.

If compile_time_errors is True, than only declarations, which will cause compilation error will be excluded

include(already_exposed=False)
Include “self” and child declarations to be exposed.

typedef_wrapper

defines class that configure typedef exposing

class pyplusplus.decl_wrappers.typedef_wrapper.typedef_t(*arguments, **keywords)

Bases: pyplusplus.decl_wrappers.decl_wrapper.decl_wrapper_t, pygccxml.declarations.typedef.typedef_t

defines a set of properties, that will instruct Py++ how to expose the typedef

Today, Py++ does not exposes typedefs, but this could be changed in future. In C++, it is a common practices to give an aliases to the class. May be in future, Py++ will generate code, that will register all those aliases.

is_directive

user_text

defines few classes, used by decl_wrapper.class_t class to keep user code

class pyplusplus.decl_wrappers.user_text.class_user_text_t(text, works_on_instance=True)

Bases: pyplusplus.decl_wrappers.user_text.user_text_t

keeps reference to user code that belongs to registration section

works_on_instance: If true, the custom code can be applied directly to obj inst. Ex: ObjInst.”CustomCode”

class pyplusplus.decl_wrappers.user_text.user_text_t(text)

Bases: object

keeps reference to user code that belongs to declaration section

variable_wrapper

defines class that configure global and member variable exposing

class pyplusplus.decl_wrappers.variable_wrapper.variable_t(*arguments, **keywords)

Bases: pyplusplus.decl_wrappers.decl_wrapper.decl_wrapper_t, pygccxml.declarations.variable.variable_t

defines a set of properties, that will instruct Py++ how to expose the variable

apply_smart_ptr_wa

Generate code using make_getter and make_setter functions

Basically you don’t need to use this, untill you have one of the following use-cases:

  • member variable is smart pointer - in this case Boost.Python has small problem to expose it right. Using get/set functions is a work-around.
  • member variable defined custom r-value converter - may be you don’t know but the conversion is applied only on functions arguments. So you need to use make_getter/make_setter functions, allow users to enjoy from the conversion.

Setting apply_smart_ptr_wa and/or use_make_functions to “True” will tell Py++ to generate such code.

expose_address

There are some cases when Boost.Python doesn’t provide a convenient way to expose the variable to Python. For example:

double* x[10]; //or char* buffer; //in case you want to modify the buffer in place

In this cases Py++ doesn’t help too. In these cases it is possible to expose the actual address of the variable. After that, you can use built-in “ctypes” package to edit the content of the variable.

expose_value

Boost.Python is not able to expose unions. Using ctypes module it is possible to get access to the data stored in a variable, which has some union type.

This property controls whether Py++ should expose the variable value or not. In case, this variable has type union, this property will be False.

get_apply_smart_ptr_wa()
get_expose_address()
get_expose_value()
get_getter_call_policies()
get_is_read_only()
get_setter_call_policies()
get_use_make_functions()
getter_call_policies
There are usecase, when exporting member variable forces Py++ to create accessors functions. Sometime, those functions requires call policies. To be more specific: when you export member variable that has reference or pointer type, you need to tell Boost.Python library how to manage object life-time. In all cases, Py++ will give reasonable default value. I am sure, that there are use cases, when you will have to change it. You should use this property to change it.
is_read_only
is_wrapper_needed()

returns an explanation( list of str ) why wrapper is needed.

If wrapper is not needed than [] will be returned.

set_apply_smart_ptr_wa(value)
set_expose_address(value)
set_expose_value(value)
set_getter_call_policies(call_policies)
set_is_read_only(v)
set_setter_call_policies(call_policies)
set_use_make_functions(value)
setter_call_policies
There are usecase, when exporting member variable forces Py++ to create accessors functions. Sometime, those functions requires call policies. To be more specific: when you export member variable that has reference or pointer type, you need to tell Boost.Python library how to manage object life-time. In all cases, Py++ will give reasonable default value. I am sure, that there are use cases, when you will have to change it. You should use this property to change it.
use_make_functions

Generate code using make_getter and make_setter functions

Basically you don’t need to use this, untill you have one of the following use-cases:

  • member variable is smart pointer - in this case Boost.Python has small problem to expose it right. Using get/set functions is a work-around.
  • member variable defined custom r-value converter - may be you don’t know but the conversion is applied only on functions arguments. So you need to use make_getter/make_setter functions, allow users to enjoy from the conversion.

Setting apply_smart_ptr_wa and/or use_make_functions to “True” will tell Py++ to generate such code.

blog comments powered by Disqus

Table Of Contents

Previous topic

pyplusplus.module_builder package

Next topic

pyplusplus.function_transformers package

This Page