Trees | Indices | Help |
|
---|
|
1 # Copyright 2004-2008 Roman Yakovenko. 2 # Distributed under the Boost Software License, Version 1.0. (See 3 # accompanying file LICENSE_1_0.txt or copy at 4 # http://www.boost.org/LICENSE_1_0.txt) 5 6 import os 7 import algorithm 8 import declaration_based 9 import registration_based 10 from pygccxml import declarations 11 12 templates = declarations.templates 1315 """ Helper class that can hold name of smart_ptr type and create 16 identifier for held type from that given a creator. 17 """3619 """ smart_ptr: string of ptr type. Ex: 'boost::shared_ptr' """ 20 object.__init__( self ) 21 self._smart_ptr = smart_ptr22 27 smart_ptr = property( _get_smart_ptr, _set_smart_ptr ) 2830 """ Return string of type to use for held type. 31 Ex: boost::shared_ptr<Class> 32 """ 33 smart_ptr = algorithm.create_identifier( creator, self.smart_ptr ) 34 arg = algorithm.create_identifier( creator, creator.declaration.decl_string ) 35 return templates.join( smart_ptr, [ arg ] )37 -class smart_pointer_registrator_t( registration_based.registration_based_t 38 , declaration_based.declaration_based_t ):39 """ Convertor for boost::python::register_ptr_to_python<PTR>. 40 Lets boost python know that it can use smart_ptr to hold a an object. 41 See: http://www.boost.org/libs/python/doc/v2/register_ptr_to_python.html 42 """76 7944 """ smart_ptr: string of ptr type. Ex: 'boost::shared_ptr' """ 45 registration_based.registration_based_t.__init__( self ) 46 declaration_based.declaration_based_t.__init__( self, class_creator.declaration ) 47 self._smart_ptr = smart_ptr 48 self._class_creator = class_creator 49 self.works_on_instance = False50 55 smart_ptr = property( _get_smart_ptr, _set_smart_ptr ) 56 61 class_creator = property( _get_class_creator, _set_class_creator ) 62 64 if self.declaration.already_exposed: 65 return '' 66 if self.class_creator \ 67 and self.class_creator.held_type \ 68 and isinstance( self.class_creator.held_type, held_type_t ) \ 69 and self.class_creator.held_type.smart_ptr == self.smart_ptr \ 70 and self.target_configuration.boost_python_has_wrapper_held_type \ 71 and not self.class_creator.declaration.require_self_reference: 72 return '' #boost.python does it automaticly 73 rptp = algorithm.create_identifier( self, '::boost::python::register_ptr_to_python' ) 74 held_type = held_type_t(self.smart_ptr).create( self ) 75 return templates.join( rptp, [ held_type ] ) + '();'80 -class smart_pointers_converter_t( registration_based.registration_based_t 81 , declaration_based.declaration_based_t ):82 """ creator for boost::python::implicitly_convertible. 83 This creates a statemnt that allows the usage of C++ implicit 84 conversion from source to target. 85 See: http://www.boost.org/libs/python/doc/v2/implicit.html 86 """117 12088 registration_based.registration_based_t.__init__( self ) 89 declaration_based.declaration_based_t.__init__( self, source ) 90 self._target = target 91 self._smart_ptr = smart_ptr 92 self.works_on_instance = False93 96 target = property( _get_target ) 9799 return self.declaration100 source = property( _get_source ) 101 106 smart_ptr = property( _get_smart_ptr, _set_smart_ptr ) 107109 identifier = algorithm.create_identifier( self, decl.partial_decl_string ) 110 return templates.join( self.smart_ptr, [identifier] )111 113 implicitly_convertible = algorithm.create_identifier( self, '::boost::python::implicitly_convertible' ) 114 from_arg = self._instantiate_smart_ptr( self.source ) 115 to_arg = self._instantiate_smart_ptr( self.target ) 116 return templates.join(implicitly_convertible, [ from_arg, to_arg ] ) + '();'
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Oct 20 08:51:20 2008 | http://epydoc.sourceforge.net |