Re: [pygccxml-development] Basic Py++ questions
Brought to you by:
mbaas,
roman_yakovenko
From: Paul M. <pa...@sc...> - 2008-10-31 15:05:37
|
Roman Yakovenko wrote: > On Wed, Oct 29, 2008 at 10:31 PM, Paul Melis > <pyp...@as...> wrote: > >> Roman Yakovenko wrote: >> >>>>> Why do you want to exclude such declarations: >>>>> * to get "clean" build - without warnings. If so, in this specific >>>>> case you can decide that you trust Py++ and suppress the warning. >>>>> * other reasons - please explain. >>>>> >>>>> >>>>> >>>> The reason is quite practical. Up till now I have not been able to even >>>> compile my generated wrappers because of W1005 warnings. >>>> I simply want to get some version of my wrappers working that I can get >>>> started with. From there I can work on replacing/handling the issues w.r.t. >>>> use of non-public classes. >>>> >>>> >>> It sounds like a bug. Can you send me simple test case. I would like >>> to improve the situation. >>> >>> >> After some digging it seems to be caused by the following pattern: >> - the code I'm wrapping uses its own smart pointer class, say smart_ptr<T> >> - the code contains a class, say C, with a protected inner class, say I >> - the smart_ptr class has one or more methods that either return or use >> a pointer to C::I >> >> In the gccxml I see lines <Class ... artificial="1" >> demangled="smart_ptr<C::I>;" mangled="..." name="smart_ptr<C::I>" />, >> which probably make Py++ generate wrappers for the smart_ptr methods. >> > > No, it doesn't help. I don't understand why Py++ still generates them. > Are the functions [pure] virtual? > > Also, I suggest you to read the following link: > http://language-binding.net/pyplusplus/troubleshooting_guide/smart_ptrs/smart_ptrs.html > I thought I had found what was going on. Take, for example, the following class: class Outer { protected: struct Inner { Inner() {} Inner(const Inner& obj) { field = obj.field; } Inner& operator = (const Inner& obj) { field = obj.field; return *this; } int field; }; }; When I run the Python script at the end of this mail I get INFO Parsing source file "all.h" ... INFO gccxml cmd: /home/paul/local/bin/gccxml -I"." "all.h" -fxml="/tmp/tmpQ34w-p.xml" INFO GCCXML version - 0.9 WARNING: Outer::Inner::Inner(Outer::Inner const & obj) [copy constructor] > compilation error W1005: Py++ cannot expose function that takes as > argument/returns instance of non-public class. Generated code will not > compile. WARNING: Outer::Inner & Outer::Inner::operator=(Outer::Inner const & obj) [member operator] > compilation error W1005: Py++ cannot expose function that takes as > argument/returns instance of non-public class. Generated code will not > compile. INFO: file "generated.cpp" - updated( 0.000000 seconds ) So it LOOKS like Py++ is trying to wrap the constructors of the protected inner class, which is obviously not going to work. However, when I look in the generated code there's no wrappers for Outer::Inner, so the warning message's claim "Generated code will not compile." is misleading... All the W1005 warnings I get might, however, still contain legimate ones that cause my compile problems. I'll need to dig further. Regards, Paul The script: #! /usr/bin/python import os import sys import pygccxml from pyplusplus import module_builder mb = module_builder.module_builder_t( files=['all.h'], gccxml_path='/home/paul/local/bin/gccxml') #path to gccxml executable mb.global_ns.include() #Now it is the time to give a name to our module mb.build_code_creator( module_name='doh' ) #I don't want absolute includes within code mb.code_creator.user_defined_directories.append( os.path.abspath('.') ) #And finally we can write code to the disk mb.write_module( os.path.join( os.path.abspath('.'), 'generated.cpp' ) ) |