Bases: object
A CppClass object takes care of generating the code for wrapping a C++ class
Parameters: |
|
---|
Add support for a C++ binary comparison operator, such as == or <.
The binary operator is assumed to operate with both operands of the type of the class, either by reference or by value.
Parameters: | operator – string indicating the name of the operator to support, e.g. ‘==’ |
---|
Add support for a C++ binary numeric operator, such as +, -, *, or /.
Parameters: |
|
---|
Add a nested class. See L{CppClass} for information about accepted parameters.
Add a constructor to the class. See the documentation for L{CppConstructor.__init__} for information on accepted parameters.
Utility method to add a ‘copy constructor’ method to this class.
Adds a custom method wrapper. See L{CustomCppMethodWrapper} for more information.
Add a nested enum. See L{Enum} for information about accepted parameters.
Wrap a function that behaves as a constructor to the class. See the documentation for L{CppFunctionAsConstructor.__init__} for information on accepted parameters.
Add a function as method of the class. See the documentation for L{Function.__init__} for information on accepted parameters. TODO: explain the implicit first function parameter
Add a hook function to be called just prior to a helper class being generated. The hook function applies to this class and all subclasses. The hook function is called like this:
hook_function(helper_class)
Add support for a C++ inplace numeric operator, such as +=, -=, *=, or /=.
Parameters: |
|
---|
Parameters: |
|
---|
Add a method to the class. See the documentation for L{CppMethod.__init__} for information on accepted parameters.
Add str() support based on C++ output stream operator.
Calling this method enables wrapping of an assumed to be defined operator function:
std::ostream & operator << (std::ostream &, MyClass const &);
The wrapper will be registered as an str() python operator, and will call the C++ operator function to convert the value to a string.
Parameters: |
|
---|
Add support for a C++ unary numeric operators, currently only -.
Parameters: |
|
---|
Generates the class to a code sink
Generates forward declarations for the instance and type structures.
Generates the appropriate Module code to register the class with a new name in that module (typedef alias).
Gets a new list of all other classes whose value can be implicitly converted to a value of this class.
>>> Foo = CppClass("Foo")
>>> Bar = CppClass("Bar")
>>> Zbr = CppClass("Zbr")
>>> Bar.implicitly_converts_to(Foo)
>>> Zbr.implicitly_converts_to(Bar)
>>> l = Foo.get_all_implicit_conversions()
>>> l.sort(lambda cls1, cls2: cmp(cls1.name, cls2.name))
>>> [cls.name for cls in l]
['Bar']
Returns an iterator to iterate over all methods of the class
Get a name usable for new %s construction, or raise CodeGenerationError if none found
Returns True if the class has pure virtual methods with no implementation (which would mean the type is not instantiable directly, only through a helper class).
gets the “helper class” for this class wrapper, creating it if necessary
Get the Module object this class belongs to
Get the method resolution order (MRO) of this class.
Returns: | an iterator that gives CppClass objects, from leaf to root class |
---|
Find the root CppClass along the subtree of all parent classes that have automatic_type_narrowing=True Note: multiple inheritance not implemented
Returns True if the class has pure virtual methods with no implementation (which would mean the type is not instantiable directly, only through a helper class).
Determine if this object has sequence methods registered.
Declares that values of this class can be implicitly converted to another class; corresponds to a operator AnotherClass(); special method.
inherit the default constructors from the parentclass according to C++ language rules
Return True if this CppClass instance represents a class that is a subclass of another class represented by the CppClasss object `other’.
Get the Module object this class belongs to
Re-register the class with another base name, in addition to any registrations that might have already been done.
Set a custom function to be called to create instances of this class and its subclasses.
Parameters: | instance_creation_function – instance creation function; see default_instance_creation_function() for signature and example. |
---|
Set the Module object this class belongs to
Set a custom function to be called to add code after an instance is created (usually by the “instance creation function”) and registered with the Python runtime.
Parameters: | post_instance_creation_function – post instance creation function |
---|
Bases: object
Generates code for a C++ proxy subclass that takes care of forwarding virtual methods from C++ to Python.
Parameters: | class – original CppClass wrapper object |
---|
Add a custom method to the helper class, given by a declaration line and a body. The body can be None, in case the whole method definition is included in the declaration itself.
Add custom code to be included right after the helper class is generated.
Add a new CppVirtualMethodParentCaller object to this helper class
Add a new CppVirtualMethodProxy object to this class
Generate the proxy class (virtual method bodies only) to a given code sink. returns pymethodef list of parent callers
Generate the proxy class (declaration only) to a given code sink
Bases: pybindgen.cppclass.MemoryPolicy
Bases: object
memory management policy for a C++ class or C/C++ struct
Return a code statement to free an underlying C/C++ object.
Bases: pybindgen.cppclass.ReferenceCountingPolicy
Bases: pybindgen.cppclass.ReferenceCountingPolicy
Bases: pybindgen.cppclass.MemoryPolicy
Write code to decrease the reference code of an object of this class (the real C++ class, not the wrapper). Should only be called if the class supports reference counting, as reported by the attribute CppClass.has_reference_counting.
Write code to increase the reference code of an object of this class (the real C++ class, not the wrapper). Should only be called if the class supports reference counting, as reported by the attribute CppClass.has_reference_counting.
Default “instance creation function”; it is called whenever a new C++ class instance needs to be created; this default implementation uses a standard C++ new allocator.
Parameters: |
|
---|