[pygccxml-commit] SF.net SVN: pygccxml: [948] pyplusplus_dev/pyplusplus/code_creators/ global_varia
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2007-03-05 14:16:01
|
Revision: 948 http://svn.sourceforge.net/pygccxml/?rev=948&view=rev Author: roman_yakovenko Date: 2007-03-05 06:15:56 -0800 (Mon, 05 Mar 2007) Log Message: ----------- improving generated code - global variables will be exposed using object( boost::ref( x ) ) Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/global_variable.py Modified: pyplusplus_dev/pyplusplus/code_creators/global_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2007-03-05 14:14:31 UTC (rev 947) +++ pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2007-03-05 14:15:56 UTC (rev 948) @@ -11,11 +11,8 @@ import registration_based from pygccxml import declarations from pyplusplus import code_repository +from pyplusplus import decl_wrappers -#TODO: mutable global variable -#scope.attr( "x" ) = object( ptr( &x ) ) - -#TODO: if variable is not const, then export it using boost::python::ptr class global_variable_base_t( registration_based.registration_based_t , declaration_based.declaration_based_t ): """ @@ -48,8 +45,15 @@ result = [] result.append( algorithm.create_identifier( self, '::boost::python::scope' ) ) result.append( '().attr("%s")' % self.alias ) - full_name = pygccxml.declarations.full_name( self.declaration ) - result.append( ' = %s;' % algorithm.create_identifier( self, full_name ) ) + dtype = self.declaration.type + if decl_wrappers.python_traits.is_immutable( dtype ) \ + or pygccxml.declarations.is_const( dtype ) \ + or pygccxml.declarations.smart_pointer_traits.is_smart_pointer( dtype ): + result.append( ' = %s;' % self.decl_identifier ) + else: + obj_identifier = algorithm.create_identifier( self, '::boost::python::object' ) + ref_identifier = algorithm.create_identifier( self, '::boost::ref' ) + result.append( ' = %s( %s( %s ) );' % ( obj_identifier, ref_identifier, self.decl_identifier ) ) return ''.join( result ) class array_gv_t( global_variable_base_t ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |