Package pyplusplus :: Package decl_wrappers :: Module class_wrapper :: Class class_t

type class_t

source code

                                             object --+    
                                                      |    
                                 class_common_details_t --+
                                                          |
                                         object --+       |
                                                  |       |
                        decl_wrapper.decl_wrapper_t --+   |
                                                      |   |
                            scopedef_wrapper.scopedef_t --+
                                                          |
                                     object --+           |
                                              |           |
pygccxml.declarations.declaration.declaration_t --+       |
                                                  |       |
          pygccxml.declarations.scopedef.scopedef_t --+   |
                                                      |   |
        pygccxml.declarations.class_declaration.class_t --+
                                                          |
                                                         class_t

Nested Classes
EXPOSED_CLASS_TYPE

Inherited from pygccxml.declarations.scopedef.scopedef_t: declaration_not_found_t, multiple_declarations_found_t

Instance Methods
 
__init__(self, *arguments, **keywords)
creates class that describes C++ class definition
source code
 
add_fake_constructors(self, f)
f - reference to a calldef_t object or list of them
source code
 
add_destructor_code(self, code)
adds code to the class-wrapper destructor
source code
 
translate_exception_to_string(self, python_exception_type, to_string)
registers exception translation to string
source code
 
add_declaration_code(self, code)
adds the code to the declaration section
source code
 
add_registration_code(self, code, works_on_instance=True, tail=True)
adds the code to the class registration section
source code
 
add_code(self, code, works_on_instance=True, tail=True)
adds the code to the class registration section
source code
 
add_wrapper_code(self, code)
adds code to the class wrapper class definition
source code
 
set_constructors_body(self, body)
Sets the body for all constructors
source code
 
get_exportable_members(self, sort=None)
returns list of internal declarations that should\could be exported
source code
 
add_property(self, name, fget, fset=None, doc='')
adds new property to the class
source code
 
add_properties(self, recognizer=None, exclude_accessors=False) source code
 
add_static_property(self, name, fget, fset=None, doc='')
adds new static property to the class
source code
 
redefined_funcs(self)
returns list of member functions that should be defined in class wrapper
source code
 
is_wrapper_needed(self)
returns an explanation( list of str ) why wrapper is needed.
source code
 
guess_always_expose_using_scope_value(self) source code

Inherited from scopedef_wrapper.scopedef_t: exclude, include

Inherited from decl_wrapper.decl_wrapper_t: disable_messages, disable_warnings, get_already_exposed, get_exportable, readme, rename, set_already_exposed, set_exportable, why_not_exportable

Inherited from pygccxml.declarations.class_declaration.class_t: __eq__, __str__, adopt_declaration, find_copy_constructor, find_noncopyable_vars, find_out_member_access_type, find_trivial_constructor, get_members, i_depend_on_them, remove_declaration

Inherited from pygccxml.declarations.scopedef.scopedef_t: __getitem__, calldef, calldefs, casting_operator, casting_operators, class_, classes, clear_optimizer, constructor, constructors, decl, decls, enum, enumeration, enumerations, enums, init_optimizer, mem_fun, mem_funs, mem_oper, mem_opers, member_function, member_functions, member_operator, member_operators, operator, operators, typedef, typedefs, var, variable, variables, vars

Inherited from pygccxml.declarations.declaration.declaration_t: __lt__, __ne__, create_decl_string

Class Variables
  FAKE_CONSTRUCTOR_TYPES = (<class 'pygccxml.declarations.callde...
  FAKE_CONSTRUCTOR_TYPE_NAMES = 'member and free functions'

Inherited from decl_wrapper.decl_wrapper_t: SPECIAL_TYPEDEF_PICK_ANY

Inherited from pygccxml.declarations.class_declaration.class_t: USE_DEMANGLED_AS_NAME

Inherited from pygccxml.declarations.scopedef.scopedef_t: ALLOW_EMPTY_MDECL_WRAPPER, RECURSIVE_DEFAULT

Properties
  fake_constructors
list of fake constructors
  redefine_operators
tells Py++ to redefine operators from base class in this class, False by default
  exposed_class_type
set this value to CLASS_TYPE.WRAPPER, if you need to transfer ownership ofpolymorphic class
  held_type
string, this property tells Py++ what HeldType this class hasDefault value is calculated, based on information presented in exposed declarations
  noncopyable
True if the class is noncopyable, False otherwiesDefault value is calculated, based on information presented in the declarations tree
  wrapper_alias
class-wrapper name
  declaration_code
List of strings, that contains valid C++ code, that will be added to the class declaration section
  registration_code_head
List of strings, that contains valid C++ code, that will be added to the head of the class registration section
  registration_code_tail
List of strings, that contains valid C++ code, that will be added to the tail of the class registration section
  registration_code
List of strings, that contains all C++ code, that will be added to the class registration section
  wrapper_code
List of strings, that contains valid C++ code, that will be added to the class wrapper.
  null_constructor_body
null constructor code, that will be added as is to the null constructor of class-wrapper
  copy_constructor_body
copy constructor code, that will be added as is to the copy constructor of class-wrapper
  destructor_code
list of code to be added to wrapper destructor
  exception_argument_name
exception argument name for translate exception function
  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.
  properties
list of properties
  require_self_reference
boolean, if True the first argument to the constructor will be reference to self object
  expose_this
boolean, if True an object address( this pointer ) will be exposed to Python as integer.
  expose_sizeof
boolean, if True the sizeof(obj) will be exposed to Python as integer.
  introduces_new_scope
returns True, if during exposing this class, new scope will be created
  no_init
If True, class will be registered with 'boost::python::no_init'

Inherited from class_common_details_t: always_expose_using_scope, class_var_name, equality_comparable, indexing_suite, indexing_suite_version, less_than_comparable, opaque

Inherited from decl_wrapper.decl_wrapper_t: alias, already_exposed, disabled_messages, documentation, exportable, ignore, include_files, logger

Inherited from pygccxml.declarations.class_declaration.class_t: aliases, bases, byte_align, byte_size, class_type, container_traits, derived, is_abstract, private_members, protected_members, public_members, recursive_bases, recursive_derived

Inherited from pygccxml.declarations.scopedef.scopedef_t: declarations

Inherited from pygccxml.declarations.declaration.declaration_t: attributes, cache, compiler, decl_string, demangled, is_artificial, location, mangled, name, parent, partial_decl_string, partial_name, top_parent

Method Details

__init__(self, *arguments, **keywords)
(Constructor)

source code 

creates class that describes C++ class definition

Overrides: pygccxml.declarations.declaration.declaration_t.__init__

add_fake_constructors(self, f)

source code 

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.

translate_exception_to_string(self, python_exception_type, to_string)

source code 

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*.

add_registration_code(self, code, works_on_instance=True, tail=True)

source code 

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.

add_code(self, code, works_on_instance=True, tail=True)

source code 

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.

add_property(self, name, fget, fset=None, doc='')

source code 

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

redefined_funcs(self)

source code 
returns list of member functions that should be defined in 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(){}
};

derived_wrapper should define do_nothing function, otherwise the generated
code will not compile

is_wrapper_needed(self)

source code 

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

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

guess_always_expose_using_scope_value(self)

source code 
Overrides: class_common_details_t.guess_always_expose_using_scope_value

Class Variable Details

FAKE_CONSTRUCTOR_TYPES

Value:
(<class 'pygccxml.declarations.calldef.member_function_t'>,
 <class 'pygccxml.declarations.calldef.free_function_t'>)

Property Details

fake_constructors

list of fake constructors

redefine_operators

tells Py++ to redefine operators from base class in this class, False by default

Get Method:
_get_redefine_operators(self)
Set Method:
_set_redefine_operators(self, new_value)

exposed_class_type

set this value to CLASS_TYPE.WRAPPER, if you need to transfer ownership ofpolymorphic class

Get Method:
_get_exposed_class_type(self)
Set Method:
_set_exposed_class_type(self, class_type)

held_type

string, this property tells Py++ what HeldType this class hasDefault value is calculated, based on information presented in exposed declarations

Get Method:
_get_held_type(self)
Set Method:
_set_held_type(self, held_type)

noncopyable

True if the class is noncopyable, False otherwiesDefault value is calculated, based on information presented in the declarations tree

Get Method:
_get_noncopyable(self)
Set Method:
_set_noncopyable(self, noncopyable)

wrapper_alias

class-wrapper name

Get Method:
_get_wrapper_alias(self)
Set Method:
_set_wrapper_alias(self, walias)

declaration_code

List of strings, that contains valid C++ code, that will be added to the class declaration section

registration_code_head

List of strings, that contains valid C++ code, that will be added to the head of the class registration section

registration_code_tail

List of strings, that contains valid C++ code, that will be added to the tail of the class registration section

registration_code

List of strings, that contains all C++ code, that will be added to the class registration section

wrapper_code

List of strings, that contains valid C++ code, that will be added to the class wrapper.

null_constructor_body

null constructor code, that will be added as is to the null constructor of class-wrapper

Get Method:
_get_null_constructor_body(self)
Set Method:
_set_null_constructor_body(self, body)

copy_constructor_body

copy constructor code, that will be added as is to the copy constructor of class-wrapper

Get Method:
_get_copy_constructor_body(self)
Set Method:
_set_copy_constructor_body(self, body)

destructor_code

list of code to be added to wrapper destructor

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

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.

Get Method:
_get_exception_translation_code(self)
Set Method:
_set_exception_translation_code(self, code)

properties

list of properties

require_self_reference

boolean, if True the first argument to the constructor will be reference to self object

Get Method:
_get_require_self_reference(self)
Set Method:
_set_require_self_reference(self, require_self_reference)

expose_this

boolean, if True an object address( this pointer ) will be exposed to Python as integer.

Get Method:
_get_expose_this(self)
Set Method:
_set_expose_this(self, new_value)

expose_sizeof

boolean, if True the sizeof(obj) will be exposed to Python as integer.

Get Method:
_get_expose_sizeof(self)
Set Method:
_set_expose_sizeof(self, new_value)

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.

no_init

If True, class will be registered with 'boost::python::no_init'

Get Method:
_get_no_init(self)
Set Method:
_set_no_init(self, value)