Another problem with split_module
Hi Roman, as you may remember I'm generating function wrappers for functions expecting pointers to callback functions along with an instance pointer of type void. How do I make sure these wrappers are generated to the same file as the registration of the wrapper? Consider the following test: In single file mode this produces a working test module. In split file mode the WRAPPER_CODE is generated to test_wrapper.main.cpp whereas the registration is generated to test_wrapper_free_functions.pypp.cpp. test.hpp --- 8>< ------ ><8 --- void test (void *instance, void (*callback)(void *)); --- 8>< ------ ><8 --- test.py --- 8>< ------ ><8 --- # # Wrapper code for void test (void (*test)(void *)); # WRAPPER_CODE = """ void wrap_test_callback (void *instance) { boost::python::call<void> (reinterpret_cast<PyObject *> (instance)); static void test_wrapper (PyObject *callback) { test ( callback && (callback != Py_None)? wrap_test_callback: 0, callback); } """ import os from pyplusplus import \ module_builder from pygccxml.declarations.calldef import \ argument_t from pygccxml.declarations.cpptypes import \ dummy_type_t, \ pointer_t # PyObject * pyobject_type = pointer_t (dummy_type_t ("PyObject")) mb = module_builder.module_builder_t( ["test.hpp"] ) test = mb.free_function (name = "test") test.arguments = [ argument_t (name = "callback", type = pyobject_type) ] test.name = "test_wrapper" test.rename ("test") # this goes to the wrong source file :-( mb.add_declaration_code (WRAPPER_CODE) mb.build_code_creator( module_name='test_wrapper' ) mb.split_module( '.' ) --- 8>< ------ ><8 --- Cheers, Gottfried
On 9/26/06, Ganssauge, Gottfried <Gottfried.Ganssauge@haufe.de> wrote:
Hi Roman,
as you may remember I'm generating function wrappers for functions expecting pointers to callback functions along with an instance pointer of type void. How do I make sure these wrappers are generated to the same file as the registration of the wrapper?
The short answer is: you can not. The long answer: I made some refactoring in order to introduce the "register opaque type" functionality and it should be very easy to implement what you want to do. I will let you know when this functionality will be ready ( 3 -4 days ). -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
On 9/26/06, Roman Yakovenko <roman.yakovenko@gmail.com> wrote:
On 9/26/06, Ganssauge, Gottfried <Gottfried.Ganssauge@haufe.de> wrote:
Hi Roman,
as you may remember I'm generating function wrappers for functions expecting pointers to callback functions along with an instance pointer of type void. How do I make sure these wrappers are generated to the same file as the registration of the wrapper?
The short answer is: you can not. The long answer: I made some refactoring in order to introduce the "register opaque type" functionality and it should be very easy to implement what you want to do.
I will let you know when this functionality will be ready ( 3 -4 days ).
Well, it took me less time than I thought. The functionality is ready. mb = module_builder_t( ... ) mb.free_function( name of the function ).add_declaration_code( your code here ) Enjoy. P.S. This time svn contains a lot of changes, also I tested them pretty well I expect few bugs here and their. It could be nice if you can test the latest code. Thank you. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
-----Original Message----- From: c++-sig-bounces@python.org [mailto:c++-sig-bounces@python.org] On Behalf Of Roman Yakovenko Sent: Thursday, September 28, 2006 10:26 PM To: Development of Python/C++ integration Subject: Re: [C++-sig] Another problem with split_module
On 9/26/06, Roman Yakovenko <roman.yakovenko@gmail.com> wrote:
On 9/26/06, Ganssauge, Gottfried <Gottfried.Ganssauge@haufe.de> wrote:
Hi Roman,
as you may remember I'm generating function wrappers for functions expecting pointers to callback functions along with an instance pointer of type void. How do I make sure these wrappers are generated to the same file as the registration of the wrapper?
The short answer is: you can not. The long answer: I made some refactoring in order to introduce the "register opaque type" functionality and it should be very easy to implement what you want to do.
I will let you know when this functionality will be ready ( 3 -4 days ).
Well, it took me less time than I thought. The functionality is ready. Great.
mb = module_builder_t( ... ) mb.free_function( name of the function ).add_declaration_code( your code here )
Is there a reason you omitted the 'tail' argument from this variant of the function? I certainly would need it e.g. - to make sure includes appear at the head of the generated module - to make sure forward declarations appear before their use - ... (you name it :-)
Enjoy.
I do :-)
P.S. This time svn contains a lot of changes, also I tested them pretty well I expect few bugs here and their. It could be nice if you can test the latest code.
When running my build script I get the following error: build.py:346: DeprecationWarning: create_casting_constructor argument is deprecated and should not be used. If you still want Py++ to generate implicitly_convertible code, consider to use allow_implicit_conversion constructor property mb = module_builder_t(...) mb.constructors().allow_implicit_conversion = True doc_extractor = \ Traceback (most recent call last): File "build.py", line 557, in ? main (args, of) File "build.py", line 535, in main mb.build_code_creator () File "build.py", line 346, in build_code_creator doc_extractor = \ File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 246, in build_code_creator , doc_extractor) File "/usr/lib/python2.4/site-packages/pyplusplus/module_creator/creator.py", line 126, in __init__ prepared_decls = self._prepare_decls( decls, doc_extractor ) File "/usr/lib/python2.4/site-packages/pyplusplus/module_creator/creator.py", line 160, in _prepare_decls readme = filter( lambda msg: msg not in DO_NOT_REPORT_MSGS, decl.readme() ) File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/decl_wrapper. py", line 125, in readme text.extend( self._readme_impl() ) File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/class_wrapper .py", line 456, in _readme_impl return self.is_wrapper_needed() File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/class_wrapper .py", line 427, in is_wrapper_needed if self.redefined_funcs(): File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/class_wrapper .py", line 385, in redefined_funcs is_same_function = declarations.is_same_function AttributeError: 'module' object has no attribute 'is_same_function' The call in line 346 of build.py is: module_builder.module_builder_t.build_code_creator ( self, module_name = self.module_name, doc_extractor = \ lambda decl, extractor = doc_extractor(): \ make_cstring (extractor (decl)) Self is an instance derived from module_builder.module_builder_t. I don't understand the DeprecationWarning - there is nothing like a create_casting_constructor argument being used ... Cheers, Gottfried
Thank you.
-- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ _______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
On 9/29/06, Ganssauge, Gottfried <Gottfried.Ganssauge@haufe.de> wrote:
P.S. This time svn contains a lot of changes, also I tested them pretty well I expect few bugs here and their. It could be nice if you can test the latest code. When running my build script I get the following error: build.py:346: DeprecationWarning: create_casting_constructor argument is deprecated and should not be used. If you still want Py++ to generate implicitly_convertible code, consider to use allow_implicit_conversion constructor property mb = module_builder_t(...) mb.constructors().allow_implicit_conversion = True doc_extractor = \ Traceback (most recent call last): File "build.py", line 557, in ? main (args, of) File "build.py", line 535, in main mb.build_code_creator () File "build.py", line 346, in build_code_creator doc_extractor = \ File "/usr/lib/python2.4/site-packages/pyplusplus/module_builder/builder.py", line 246, in build_code_creator , doc_extractor) File "/usr/lib/python2.4/site-packages/pyplusplus/module_creator/creator.py", line 126, in __init__ prepared_decls = self._prepare_decls( decls, doc_extractor ) File "/usr/lib/python2.4/site-packages/pyplusplus/module_creator/creator.py", line 160, in _prepare_decls readme = filter( lambda msg: msg not in DO_NOT_REPORT_MSGS, decl.readme() ) File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/decl_wrapper. py", line 125, in readme text.extend( self._readme_impl() ) File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/class_wrapper .py", line 456, in _readme_impl return self.is_wrapper_needed() File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/class_wrapper .py", line 427, in is_wrapper_needed if self.redefined_funcs(): File "/usr/lib/python2.4/site-packages/pyplusplus/decl_wrappers/class_wrapper .py", line 385, in redefined_funcs is_same_function = declarations.is_same_function AttributeError: 'module' object has no attribute 'is_same_function'
The call in line 346 of build.py is: module_builder.module_builder_t.build_code_creator ( self, module_name = self.module_name, doc_extractor = \ lambda decl, extractor = doc_extractor(): \ make_cstring (extractor (decl))
Self is an instance derived from module_builder.module_builder_t.
I don't understand the DeprecationWarning - there is nothing like a create_casting_constructor argument being used ...
I am going to deprecate some feature. So you can safety ignore the warning. The error is my fault. I forgot to mention that you need to update pygccxml too. Sorry for inconvenience. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
participants (2)
-
Ganssauge, Gottfried -
Roman Yakovenko