Revision: 225
Author: roman_yakovenko
Date: 2006-06-17 23:44:26 -0700 (Sat, 17 Jun 2006)
ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=225&view=rev
Log Message:
-----------
integrating constructor body patch from Niall
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/pyplusplus/module_creator/creator.py
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2006-06-18 05:44:03 UTC (rev 224)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2006-06-18 06:44:26 UTC (rev 225)
@@ -68,8 +68,8 @@
from calldef import casting_constructor_t
from calldef import constructor_wrapper_t
from calldef import casting_member_operator_t
-from calldef import special_constructor_wrapper_t
-from calldef import trivial_constructor_wrapper_t
+from calldef import copy_constructor_wrapper_t
+from calldef import null_constructor_wrapper_t
from global_variable import global_variable_base_t
from global_variable import global_variable_t
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-06-18 05:44:03 UTC (rev 224)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-06-18 06:44:26 UTC (rev 225)
@@ -957,14 +957,16 @@
answer = [ self._create_declaration() ]
answer.append( ': ' + self._create_constructor_call() )
answer.append( ' , ' + self.parent.boost_wrapper_identifier + '()' )
- answer.append( '{}' )
+ answer.append( '{ // Normal constructor' )
+ answer.append( self.declaration.body )
+ answer.append( '}' )
return os.linesep.join( answer )
#There is something I don't understand
#There are usecases when boost.python requeres
#constructor for wrapper class from exposed class
#I should understand this more
-class special_constructor_wrapper_t( declaration_based.declaration_based_t ):
+class copy_constructor_wrapper_t( declaration_based.declaration_based_t ):
"""
Creates wrapper class constructor from wrapped class instance.
"""
@@ -995,13 +997,16 @@
def _create_impl(self):
answer = [ self._create_declaration() ]
answer.append( ': ' + self._create_constructor_call() )
- answer.append( ' , ' + self.parent.boost_wrapper_identifier + '()' )
- answer.append( '{}' )
+ answer.append( ' , ' + self.parent.boost_wrapper_identifier + '(){' )
+ answer.append( self.indent( '// copy constructor' ) )
+ answer.append( self.indent( self.declaration.copy_constructor_body ) )
+ answer.append( '}' )
return os.linesep.join( answer )
-class trivial_constructor_wrapper_t( declaration_based.declaration_based_t ):
+
+class null_constructor_wrapper_t( declaration_based.declaration_based_t ):
"""
- Creates trivial wrapper class constructor.
+ Creates wrapper for compiler generated null constructor.
"""
def __init__( self, class_inst, parent=None ):
declaration_based.declaration_based_t.__init__( self
@@ -1017,8 +1022,10 @@
answer[0] = answer[0] + 'PyObject*'
answer[0] = answer[0] + ')'
answer.append( ': ' + self._create_constructor_call() )
- answer.append( ' , ' + self.parent.boost_wrapper_identifier + '()' )
- answer.append( '{}' )
+ answer.append( ' , ' + self.parent.boost_wrapper_identifier + '(){' )
+ answer.append( self.indent( '// null constructor' ) )
+ answer.append( self.indent( self.declaration.null_constructor_body ) )
+ answer.append( '}' )
return os.linesep.join( answer )
#in python all operators are members of class, while in C++
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-06-18 05:44:03 UTC (rev 224)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-06-18 06:44:26 UTC (rev 225)
@@ -155,7 +155,14 @@
def __init__(self, *arguments, **keywords):
declarations.constructor_t.__init__( self, *arguments, **keywords )
calldef_t.__init__( self )
+ self._body = ''
+ def _get_body(self):
+ return self._body
+ def _set_body(self, body):
+ self._body = body
+ body = property( _get_body, _set_body )
+
def _exportable_impl_derived( self ):
if self.is_artificial:
return 'pyplusplus does not exports compiler generated constructors'
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-06-18 05:44:03 UTC (rev 224)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-06-18 06:44:26 UTC (rev 225)
@@ -47,7 +47,9 @@
self._user_code = []
self._wrapper_user_code = []
self._indexing_suite = None
-
+ self._null_constructor_body = ''
+ self._copy_constructor_body = ''
+
def _get_always_expose_using_scope( self ):
return self._always_expose_using_scope
def _set_always_expose_using_scope( self, value ):
@@ -108,6 +110,18 @@
return self._indexing_suite
indexing_suite = property( _get_indexing_suite )
+ def _get_null_constructor_body(self):
+ return self._null_constructor_body
+ def _set_null_constructor_body(self, body):
+ self._null_constructor_body = body
+ null_constructor_body = property( _get_null_constructor_body, _set_null_constructor_body )
+
+ def _get_copy_constructor_body(self):
+ return self._copy_constructor_body
+ def _set_copy_constructor_body(self, body):
+ self._copy_constructor_body = body
+ copy_constructor_body = property( _get_copy_constructor_body, _set_copy_constructor_body )
+
def add_code( self, code, works_on_instance=True ):
"""works_on_instance: If true, the custom code can be applied directly to obj inst.
Ex: ObjInst."CustomCode"
@@ -116,6 +130,12 @@
def add_wrapper_code( self, code ):
self.wrapper_user_code.append( user_text.user_text_t( code ) )
+
+ def set_constructors_body( self, body ):
+ """Sets the body for all constructors"""
+ self.constructors().body = body
+ self.null_constructor_body = body
+ self.copy_constructor_body = body
def _exportable_impl( self ):
if not self.name:
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-06-18 05:44:03 UTC (rev 224)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-06-18 06:44:26 UTC (rev 225)
@@ -579,12 +579,12 @@
#I don't know but sometimes boost.python requieres
#to construct wrapper from wrapped classe
if not self.curr_decl.noncopyable:
- scons = code_creators.special_constructor_wrapper_t( class_inst=self.curr_decl )
- wrapper.adopt_creator( scons )
- trivial_constr = declarations.find_trivial_constructor(self.curr_decl)
- if trivial_constr and trivial_constr.is_artificial:
+ copy_constr = code_creators.copy_constructor_wrapper_t( class_inst=self.curr_decl )
+ wrapper.adopt_creator( copy_constr )
+ 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.trivial_constructor_wrapper_t( class_inst=self.curr_decl )
+ tcons = code_creators.null_constructor_wrapper_t( class_inst=self.curr_decl )
wrapper.adopt_creator( tcons )
self.curr_code_creator.adopt_creator( class_inst )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|