[pygccxml-commit] SF.net SVN: pygccxml:[1411] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2008-09-05 19:39:54
|
Revision: 1411 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1411&view=rev Author: roman_yakovenko Date: 2008-09-05 19:39:55 +0000 (Fri, 05 Sep 2008) Log Message: ----------- small refactoring to improve no_init handling Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py Modified: pyplusplus_dev/pyplusplus/code_creators/class_declaration.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2008-09-03 12:01:18 UTC (rev 1410) +++ pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2008-09-05 19:39:55 UTC (rev 1411) @@ -217,38 +217,18 @@ if self.documentation: result.append( ', %s' % self.documentation ) used_init = None - inits = filter( lambda x: isinstance( x, calldef.constructor_t ), self.creators ) - has_nonpublic_destructor = declarations.has_destructor( self.declaration ) \ - and not declarations.has_public_destructor( self.declaration ) - - #select all public constructors and exclude copy constructor - cs = self.declaration.constructors( lambda c: not c.is_copy_constructor and c.access_type == 'public' - , recursive=False, allow_empty=True ) - has_suitable_constructor = bool( cs ) - if cs and len(cs) == 1 and cs[0].is_trivial_constructor and self.declaration.find_noncopyable_vars(): - has_suitable_constructor = False + inits = filter( lambda x: isinstance( x, calldef.constructor_t ), self.creators ) trivial_constructor = self.declaration.find_trivial_constructor() - - if has_nonpublic_destructor \ - or ( self.declaration.is_abstract and not self.wrapper ) \ - or not has_suitable_constructor: + + if self.declaration.no_init: result.append( ", " ) result.append( algorithm.create_identifier( self, '::boost::python::no_init' ) ) - elif not trivial_constructor or trivial_constructor.access_type != 'public': + else: if inits: used_init = inits[0] result.append( ", " ) result.append( used_init.create_init_code() ) - elif self.declaration.indexing_suite: - pass #in this case all constructors are exposed by indexing suite - else:#it is possible to class to have public accessed constructor - #that could not be exported by boost.python library - #for example constructor takes as argument pointer to function - result.append( ", " ) - result.append( algorithm.create_identifier( self, '::boost::python::no_init' ) ) - else: - pass result.append( ' )' ) return ( ''.join( result ), used_init ) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-09-03 12:01:18 UTC (rev 1410) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-09-05 19:39:55 UTC (rev 1411) @@ -196,6 +196,7 @@ self._expose_this = None self._expose_sizeof = None self._fake_constructors = [] + self._no_init = None @property def fake_constructors(self): @@ -685,3 +686,38 @@ return False else: return True + + def _get_no_init( self ): + if None is self._no_init and False == bool( self.indexing_suite ): + #select all public constructors and exclude copy constructor + cs = self.constructors( lambda c: not c.is_copy_constructor and c.access_type == 'public' + , recursive=False, allow_empty=True ) + + has_suitable_constructor = bool( cs ) + if cs and len(cs) == 1 and cs[0].is_trivial_constructor and self.find_noncopyable_vars(): + has_suitable_constructor = False + + has_nonpublic_destructor = declarations.has_destructor( self ) \ + and not declarations.has_public_destructor( self ) + + trivial_constructor = self.find_trivial_constructor() + + if has_nonpublic_destructor \ + or ( self.is_abstract and not self.is_wrapper_needed() ) \ + or not has_suitable_constructor: + self._no_init = True + elif not trivial_constructor or trivial_constructor.access_type != 'public': + exportable_cs = filter( lambda c: c.exportable and c.ignore == False + , cs ) + if not exportable_cs: + self._no_init = True + else: + pass + if None is self._no_init: + self._no_init = False + return self._no_init + def _set_no_init( self, value ): + self._no_init = value + + no_init = property( _get_no_init, _set_no_init + , doc="If True, class will be registered with 'boost::python::no_init'" ) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |