[pygccxml-commit] SF.net SVN: pygccxml:[1401] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2008-08-20 20:06:53
|
Revision: 1401
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1401&view=rev
Author: roman_yakovenko
Date: 2008-08-20 20:07:03 +0000 (Wed, 20 Aug 2008)
Log Message:
-----------
fix code generation for pure virtual function, which returns auto_ptr<...> and invoked from C++
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/unittests/return_auto_ptr_tester.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2008-08-20 20:02:25 UTC (rev 1400)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2008-08-20 20:07:03 UTC (rev 1401)
@@ -274,11 +274,11 @@
if keywd_args:
result.append( self.indent( self.param_sep(), 3 ) )
result.append( keywd_args )
-
+
result.append( ' )' ) #make_constructor
-
+
doc = self.create_doc()
- if doc:
+ if doc:
result.append( self.param_sep() )
result.append( doc )
@@ -341,6 +341,7 @@
}
def create_body( self ):
+ auto_ptr_traits = declarations.auto_ptr_traits
if not self.declaration.overridable:
return self.unoverriden_function_body()
template = []
@@ -348,18 +349,28 @@
if precall_code:
template.append( os.linesep.join( precall_code ) )
template.append( '%(override)s func_%(alias)s = this->get_override( "%(alias)s" );' )
- template.append( '%(return_)sfunc_%(alias)s( %(args)s );')
+ if self.declaration.return_type \
+ and auto_ptr_traits.is_smart_pointer( self.declaration.return_type ):
+ template.append( 'boost::python::object %(alias)s_result = func_%(alias)s( %(args)s );' )
+ template.append( 'return boost::python::extract< %(return_type)s >( %(alias)s_result );' )
+ else:
+ template.append( '%(return_)sfunc_%(alias)s( %(args)s );')
template = os.linesep.join( template )
return_ = ''
if not declarations.is_void( self.declaration.return_type ):
return_ = 'return '
+ return_type = ''
+ if self.declaration.return_type:
+ return_type = self.declaration.return_type.decl_string
+
return template % {
'override' : self.override_identifier()
, 'alias' : self.declaration.alias
, 'return_' : return_
, 'args' : self.function_call_args()
+ , 'return_type' : return_type
}
def _create_impl(self):
Modified: pyplusplus_dev/unittests/return_auto_ptr_tester.py
===================================================================
--- pyplusplus_dev/unittests/return_auto_ptr_tester.py 2008-08-20 20:02:25 UTC (rev 1400)
+++ pyplusplus_dev/unittests/return_auto_ptr_tester.py 2008-08-20 20:07:03 UTC (rev 1401)
@@ -20,9 +20,8 @@
, *args )
def customize( self, mb ):
- pass
- #~ r_input = mb.class_( 'r_input_t' )
- #~ r_input.held_type = 'std::auto_ptr< %s >' % r_input.decl_string
+ r_input = mb.class_( 'r_input_t' )
+ r_input.held_type = 'std::auto_ptr< %s >' % r_input.decl_string
def create_py_input( self, module, rows, cols ):
class py_input_t( module.generic_input_t ):
@@ -43,12 +42,8 @@
a = self.create_py_input( module, 3, 7 )
c = a.create_r_input()
self.failUnless( c.rows() == 3 and c.cols() == 7 )
- try:
- b = module.process_input(a)
- self.failUnless( b.rows() == 3 and b.cols() == 7 )
- except TypeError, err:
- print err
-
+ b = module.process_input(a)
+ self.failUnless( b.rows() == 3 and b.cols() == 7 )
c = a.create_r_input_shared()
self.failUnless( c.rows() == 3 and c.cols() == 7 )
b = module.process_input_shared(a)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|