[pygccxml-commit] SF.net SVN: pygccxml: [1133] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2007-11-10 22:37:09
|
Revision: 1133
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1133&view=rev
Author: roman_yakovenko
Date: 2007-11-10 14:37:12 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
adding treatment to trivial [copy] constructors
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/pyplusplus/code_creators/declaration_based.py
pyplusplus_dev/pyplusplus/module_creator/creator.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-11-10 22:29:29 UTC (rev 1132)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-11-10 22:37:12 UTC (rev 1133)
@@ -932,18 +932,18 @@
"""
Creates wrapper class constructor from wrapped class instance.
"""
- def __init__( self, constructor ):
+ def __init__( self, class_ ):
code_creator.code_creator_t.__init__( self )
- declaration_based.declaration_based_t.__init__( self, declaration=constructor )
+ declaration_based.declaration_based_t.__init__( self, declaration=class_ )
def _create_declaration(self):
result = []
- result.append( self.parent.declaration.wrapper_alias )
+ result.append( self.declaration.wrapper_alias )
result.append( '(' )
if not self.target_configuration.boost_python_has_wrapper_held_type \
- or self.declaration.parent.require_self_reference:
+ or self.declaration.require_self_reference:
result.append( 'PyObject* self, ' )
- declarated = declarations.declarated_t( self.declaration.parent )
+ declarated = declarations.declarated_t( self.declaration )
const_decl = declarations.const_t( declarated )
const_ref_decl = declarations.reference_t( const_decl )
identifier = algorithm.create_identifier( self, const_ref_decl.decl_string )
@@ -952,7 +952,7 @@
return ''.join( result )
def _create_constructor_call( self ):
- answer = [ algorithm.create_identifier( self, self.parent.declaration.decl_string ) ]
+ answer = [ algorithm.create_identifier( self, self.declaration.decl_string ) ]
answer.append( '( arg )' )
return ''.join( answer )
@@ -961,7 +961,7 @@
answer.append( ': ' + self._create_constructor_call() )
answer.append( ' , ' + self.parent.boost_wrapper_identifier + '(){' )
answer.append( self.indent( '// copy constructor' ) )
- answer.append( self.indent( self.parent.declaration.copy_constructor_body ) )
+ answer.append( self.indent( self.declaration.copy_constructor_body ) )
answer.append( '}' )
return os.linesep.join( answer )
@@ -973,23 +973,23 @@
"""
Creates wrapper for compiler generated null constructor.
"""
- def __init__( self, constructor ):
+ def __init__( self, class_ ):
code_creator.code_creator_t.__init__( self )
- declaration_based.declaration_based_t.__init__( self, declaration=constructor )
+ declaration_based.declaration_based_t.__init__( self, declaration=class_ )
def _create_constructor_call( self ):
- return algorithm.create_identifier( self, self.parent.declaration.decl_string ) + '()'
+ return algorithm.create_identifier( self, self.declaration.decl_string ) + '()'
def _create_impl(self):
- answer = [ self.parent.declaration.wrapper_alias + '(' ]
+ answer = [ self.declaration.wrapper_alias + '(' ]
if not self.target_configuration.boost_python_has_wrapper_held_type \
- or self.declaration.parent.require_self_reference:
+ or self.declaration.require_self_reference:
answer[0] = answer[0] + 'PyObject* self'
answer[0] = answer[0] + ')'
answer.append( ': ' + self._create_constructor_call() )
answer.append( ' , ' + self.parent.boost_wrapper_identifier + '(){' )
answer.append( self.indent( '// null constructor' ) )
- answer.append( self.indent( self.parent.declaration.null_constructor_body ) )
+ answer.append( self.indent( self.declaration.null_constructor_body ) )
answer.append( '}' )
return os.linesep.join( answer )
Modified: pyplusplus_dev/pyplusplus/code_creators/declaration_based.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2007-11-10 22:29:29 UTC (rev 1132)
+++ pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2007-11-10 22:37:12 UTC (rev 1133)
@@ -41,9 +41,9 @@
self.declaration.alias = alias
alias = property( _get_alias, _set_alias )
- def _get_decl_identifier( self ):
+ @property
+ def decl_identifier( self ):
return algorithm.create_identifier( self, self.declaration.decl_string )
- decl_identifier = property( _get_decl_identifier )
@property
def documentation( self ):
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-11-10 22:29:29 UTC (rev 1132)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-11-10 22:37:12 UTC (rev 1133)
@@ -571,18 +571,32 @@
else:
self.__extmodule.adopt_declaration_creator( wrapper )
if declarations.has_trivial_copy( self.curr_decl ):
- #~ #I don't know but sometimes boost.python requieres
- #~ #to construct wrapper from wrapped classe
- copy_constr = self.curr_decl.constructor( lambda c: c.is_copy_constructor, recursive=False )
- if not self.curr_decl.noncopyable and copy_constr.is_artificial:
- cccc = code_creators.copy_constructor_wrapper_t( constructor=copy_constr )
- wrapper.adopt_creator( cccc )
- null_constr = declarations.find_trivial_constructor(self.curr_decl)
- if null_constr and null_constr.is_artificial:
- #this constructor is not going to be exposed
- tcons = code_creators.null_constructor_wrapper_t( constructor=null_constr )
- wrapper.adopt_creator( tcons )
-
+ #next constructors are not present in code, but compiler generated
+ #Boost.Python requiers them to be declared in the wrapper class
+ if '0.9' in self.curr_decl.compiler:
+ copy_constr = self.curr_decl.constructors( lambda c: c.is_copy_constructor
+ , recursive=False
+ , allow_empty=True)
+ if not copy_constr:
+ cccc = code_creators.copy_constructor_wrapper_t( class_=self.curr_decl)
+ wrapper.adopt_creator( cccc )
+ trivial_constr = self.curr_decl.constructors( lambda c: c.is_trivial_constructor
+ , recursive=False
+ , allow_empty=True)
+ if not trivial_constr:
+ tcons = code_creators.null_constructor_wrapper_t( class_=self.curr_decl )
+ wrapper.adopt_creator( tcons )
+ else:
+ copy_constr = self.curr_decl.constructor( lambda c: c.is_copy_constructor, recursive=False )
+ if not self.curr_decl.noncopyable and copy_constr.is_artificial:
+ cccc = code_creators.copy_constructor_wrapper_t( class_=self.curr_decl)
+ wrapper.adopt_creator( cccc )
+ null_constr = declarations.find_trivial_constructor(self.curr_decl)
+ if null_constr and null_constr.is_artificial:
+ #this constructor is not going to be exposed
+ tcons = code_creators.null_constructor_wrapper_t( class_=self.curr_decl )
+ wrapper.adopt_creator( tcons )
+
exposed = self.expose_overloaded_mem_fun_using_macro( cls_decl, cls_cc )
cls_parent_cc.adopt_creator( cls_cc )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|