container: wrap STL containers

Wrap C++ STL containers

class pybindgen.container.Container(name, value_type, container_type, outer_class=None, custom_name=None)

Bases: object

Parameters:
  • name – C++ type name of the container, e.g. std::vector<int> or MyIntList
  • value_type – a ReturnValue of the element type: note, for mapping containers, value_type is a tuple with two ReturnValue’s: (key, element).
  • container_type – a string with the type of container, one of ‘list’, ‘deque’, ‘queue’, ‘priority_queue’, ‘vector’, ‘stack’, ‘set’, ‘multiset’, ‘hash_set’, ‘hash_multiset’, ‘map’
  • outer_class (None or L{CppClass}) – if the type is defined inside a class, must be a reference to the outer class
  • custom_name – alternative name to register with in the Python module
generate(code_sink, module, docstring=None)

Generates the class to a code sink

generate_forward_declarations(code_sink, module)

Generates forward declarations for the instance and type structures.

get_iter_pystruct()
get_module()

Get the Module object this type belongs to

get_pystruct()
iter_pystruct
module

Get the Module object this type belongs to

pystruct
python_full_name
python_name
register_alias(alias)

Re-register the class with another base name, in addition to any registrations that might have already been done.

set_module(module)

Set the Module object this type belongs to

class pybindgen.container.ContainerParameter(ctype, name, direction=1, is_const=False, default_value=None)

Bases: pybindgen.container.ContainerParameterBase

Container handlers

ctype – C type, normally ‘MyClass*’ name – parameter name

CTYPES = []
DIRECTIONS = [1]
container_type = <pybindgen.Container None>
convert_c_to_python(wrapper)

Write some code before calling the Python method.

convert_python_to_c(wrapper)

parses python args to get C++ value

class pybindgen.container.ContainerParameterBase(ctype, name, direction=1, is_const=False, default_value=None)

Bases: pybindgen.typehandlers.base.Parameter

Base class for all C++ Class parameter handlers

ctype – C type, normally ‘MyClass*’ name – parameter name

CTYPES = []
DIRECTIONS = [1]
container_type = <pybindgen.Container None>
class pybindgen.container.ContainerPtrParameter(ctype, name, direction=1, is_const=False, default_value=None, transfer_ownership=None)

Bases: pybindgen.container.ContainerParameterBase

Container handlers

CTYPES = []
DIRECTIONS = [1, 2, 3]
container_type = <pybindgen.Container None>
convert_c_to_python(wrapper)

Write some code before calling the Python method.

convert_python_to_c(wrapper)

parses python args to get C++ value

class pybindgen.container.ContainerRefParameter(ctype, name, direction=1, is_const=False, default_value=None)

Bases: pybindgen.container.ContainerParameterBase

Container handlers

ctype – C type, normally ‘MyClass*’ name – parameter name

CTYPES = []
DIRECTIONS = [1, 2, 3]
container_type = <pybindgen.Container None>
convert_c_to_python(wrapper)

Write some code before calling the Python method.

convert_python_to_c(wrapper)

parses python args to get C++ value

class pybindgen.container.ContainerReturnValue(ctype, is_const=False)

Bases: pybindgen.container.ContainerReturnValueBase

Container type return handlers

override to fix the ctype parameter with namespace information

CTYPES = []
container_type = <pybindgen.Container None>
convert_c_to_python(wrapper)

see ReturnValue.convert_c_to_python

convert_python_to_c(wrapper)

see ReturnValue.convert_python_to_c

get_c_error_return()

See ReturnValue.get_c_error_return

class pybindgen.container.ContainerReturnValueBase(ctype)

Bases: pybindgen.typehandlers.base.ReturnValue

Class return handlers – base class

CTYPES = []
container_type = <pybindgen.Container None>
class pybindgen.container.ContainerTraits(add_value_method, is_mapping=False)

Bases: object

class pybindgen.container.IterNextWrapper(container)

Bases: pybindgen.typehandlers.base.ForwardWrapperBase

tp_iternext wrapper

value_type – a ReturnValue object handling the value type; container – the L{Container}

HAVE_RETURN_VALUE = True
generate(code_sink)

code_sink – a CodeSink instance that will receive the generated code

generate_call()
reset_code_generation_state()