Using SVN HEAD, I've encountered AttributeError exceptions during the
usual call to mb.build_code_creator(). It seems to involve member
function declaration objects.
The relevant Py++ code is pretty simple:
def force_no_init(class_):
for c in [ c for c in class_.constructors() if not
c.is_copy_constructor ]:
class_.remove_declaration( c )
TestNS = builder.namespace('TestNS')
TestNS.exclude()
TestClass = builder.class_('TestClass') # C++ is TestNS::TestClass
TestClass.include()
TestClass.decls().exclude()
force_no_init(TestClass)
TestClass.member_function('getValue').include()
builder.build_code_creator(module_name='test')
This worked with version 0.8.1
The first traceback was:
File "generate_code.py", line 19, in <module>
builder.build_code_creator(module_name='test')
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_builder\builder.py",
line 247, in build_code_creator
self.__code_creator = creator.create()
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_creator\creator.py",
line 524, in create
declarations.apply_visitor( self, decl )
File "C:\Program
Files\Python\Lib\site-packages\pygccxml\declarations\algorithm.py", line
263, in apply_visitor
getattr( visitor, fname )()
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_creator\creator.py",
line 717, in visit_class
if self._is_wrapper_needed( self.curr_decl, exportable_members ):
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_creator\creator.py",
line 318, in _is_wrapper_needed
if member.function_transformers:
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\decl_wrappers\calldef_wrapper.py",
line 124, in _get_function_transformers
if None is self._function_transformers:
AttributeError: 'member_function_t' object has no attribute
'_function_transformers'
Just to experiment I changed line 124 of
decl_wrappers\calldef_wrapper.py to:
if not hasattr(self, '_function_transformers' ) or None is
self._function_transformers:
... although this is just a hack; I don't understand why the attribute
is missing, so this is probably the wrong thing to do. It did eliminate
the exception.
Patching that exposed a second AttributeError:
File "generate_code.py", line 19, in <module>
builder.build_code_creator(module_name='test')
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_builder\builder.py",
line 247, in build_code_creator
self.__code_creator = creator.create()
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_creator\creator.py",
line 524, in create
declarations.apply_visitor( self, decl )
File "C:\Program
Files\Python\Lib\site-packages\pygccxml\declarations\algorithm.py", line
263, in apply_visitor
getattr( visitor, fname )()
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_creator\creator.py",
line 740, in visit_class
exposed = self.expose_overloaded_mem_fun_using_macro( cls_decl, cls_cc )
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_creator\creator.py",
line 687, in expose_overloaded_mem_fun_using_macro
overloads = filter( lambda decl: decl.use_overload_macro, overloads )
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\module_creator\creator.py",
line 687, in <lambda>
overloads = filter( lambda decl: decl.use_overload_macro, overloads )
File "C:\Program
Files\Python\lib\site-packages\pyplusplus\decl_wrappers\calldef_wrapper.py",
line 205, in get_use_overload_macro
return self._use_overload_macro
AttributeError: 'member_function_t' object has no attribute
'_use_overload_macro'
_use_overload_macro is assigned to False in
calldef_wrapper.member_function_t.__init__(), so the only thing I can
think of is that apply_visitor() is working with a class object rather
than an instance.
Now that there's two errors I don't really understand, I thought I'd
better just report them.
Thanks,
--- Kevin
|