Thread: [pygccxml-development] problem with private classes
Brought to you by:
mbaas,
roman_yakovenko
From: Gordon W. <gor...@gm...> - 2008-07-08 02:03:29
|
I think I found another bug, but I'm not sure who's bug it is. This: class Alpha { private: class Omega { <snip> } public: Omega *pOmega; } produces: static ::Alpha::Omega * get_pOmega(Alpha const & inst ){ return inst.pOmega; } which leads to: extending.cpp(634) : error C2248: 'Alpha::Omega' : cannot access private class declared in class 'Alpha' c:\program files\boost\boost_1_35_0\libs\python\example\bobit.h(1458) : see declaration of 'Alpha::Omega' c:\program files\boost\boost_1_35_0\libs\python\example\bobit.h(1223) : see declaration of 'Alpha' On Tue, Jul 8, 2008 at 11:47 AM, Gordon Wrigley <gor...@gm...> wrote: > This is about the size right? If so is it going to complain about every > pointer variable I have? and if that is the case then why doesn't it just > produce a warning and then assume that if it's not null then the length is > 1, that at least will work for regular pointers. > Or is this just about the combination of the pointer and the array? > > > On Tue, Jul 8, 2008 at 11:31 AM, Gordon Wrigley <gor...@gm...> > wrote: > >> OK, that seems to make some sense, but leads to a few lil feature >> requests. >> >> First the py++ code on that page is overly verbose, it would be nice if >> this could be handled in one line. So for this C++ code: >> >> class tom >> { >> public: >> double *data; >> double dataLen; >> >> you might have something like: >> >> mb.class_( "tom" ).variable( "data" ).size("tom.dataLen") >> >> I realise it's probably not going to be quite that simple, I'm just trying >> to convey the direction of the idea. Also if you had a standard policy of >> always having a xLen variable for every x pointer variable (or xLen function >> for every function returning a pointer) then it'd be nice to be able to >> capture that in a single line. >> >> And of course this would all have to be extended somehow to work with my >> array of pointers example and the documentations width*heigh example. >> >> Also that warning that py++ should give when it runs into one of these >> should include an example of the sort of line required to fix it. >> >> :) >> >> Gordon. >> >> >> On Mon, Jul 7, 2008 at 6:51 PM, Roman Yakovenko < >> rom...@gm...> wrote: >> >>> On Mon, Jul 7, 2008 at 10:28 AM, Gordon Wrigley >>> <gor...@gm...> wrote: >>> > Disclaimer: I have no idea what I'm doing and C++ is not one of my >>> strong >>> > skills. I'm having a problem with py++, boost, msvc and a third party >>> > library I need to bridge to python. I would greatly appreciate any help >>> I >>> > can get with this. >>> >>> :-) >>> >>> > I don't have the various version information handy but I downloaded all >>> of >>> > the boost/py++/msvc stuff from the relevant websites last week. After I >>> > installed everything I made it compile and run the quick start example >>> > correctly. >>> > >>> > I ran the library header through the py++ gui, grabbed the py++ code >>> that >>> > generated, put it in a .py file, ran that and then copied the resulting >>> > files into the quick start example. >>> > >>> > The header for the library includes this snippet (details obscured to >>> > protect the guilty): >>> > >>> > class bob >>> > { >>> > public: >>> > double *fred[4]; >>> >>> This is a bug in Py++. >>> >>> The code generated for "double* fred[4]" caused the compilation error. >>> It is not possible to generate code for "fred" without knowing >>> additional details. In this case Py++ has to exclude this variable >>> from being exposed and give some warning. >>> >>> Now, how can you improve the situation: >>> * exclude variable by your own >>> * take a look on "return_range" ( >>> >>> http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#return-range >>> ) call policies. >>> >>> HTH >>> >>> -- >>> Roman Yakovenko >>> C++ Python language binding >>> http://www.language-binding.net/ >>> >> >> > |
From: Roman Y. <rom...@gm...> - 2008-07-08 04:55:39
|
On Tue, Jul 8, 2008 at 5:03 AM, Gordon Wrigley <gor...@gm...> wrote: > I think I found another bug, but I'm not sure who's bug it is. This: > > class Alpha > { > private: > class Omega > { > <snip> > } > > public: > Omega *pOmega; > } > > produces: > > static ::Alpha::Omega * get_pOmega(Alpha const & inst ){ > return inst.pOmega; > } > > which leads to: > > extending.cpp(634) : error C2248: 'Alpha::Omega' : cannot access private > class declared in class 'Alpha' > c:\program > files\boost\boost_1_35_0\libs\python\example\bobit.h(1458) : see declaration > of 'Alpha::Omega' > c:\program > files\boost\boost_1_35_0\libs\python\example\bobit.h(1223) : see declaration > of 'Alpha' The example you posted could not be compiled with gccxml: The error is: Error occured during code generation process! Error: Error occured while running GCC-XML: d:\tmp\yyy.h: In function 'Alpha::Omega* get_pOmega(const Alpha&)': d:\tmp\yyy.h:5: error: 'class Alpha::Omega' is private d:\tmp\yyy.h:11: error: within this context I guess the actual code looks like: class Alpha { private: class Omega {}; public: typedef Omega Om; public: Omega *pOmega; }; static ::Alpha::Om * get_pOmega(Alpha const & inst ){ return inst.pOmega; } Now these are the warning I've got during the code generation process: > warning W1025: Py++ will generate class wrapper - class contains > "pOmega" - T* member variable WARNING: Alpha::Omega * get_pOmega(Alpha const & inst) [free function] > compilation error W1005: Py++ cannot expose function that takes as > argument/returns instance of non-public class. Generated code will not > compile. WARNING: Alpha::Omega * get_pOmega(Alpha const & inst) [free function] > compilation error W1050: The function returns "Alpha::Omega *" type. > You have to specify a call policies.Be sure to take a look on Py++ > defined call policies: http://language- > binding.net/pyplusplus/documentation/functions/call_policies.html#py- > defined-call-policies WARNING: Alpha::Omega [class] > execution error W1040: The declaration is unexposed, but there are > other declarations, which refer to it. This could cause "no to_python > converter found" run time error. Declarations: Alpha::pOmega > [variable] The last warning warns you about that. Now you can decide what you want to do. In my opinion this is just a mistake in the code, but I could be wrong. Anyway if you want to exclude declarations, based on warnings they produce, you can do this too: http://language-binding.net/pyplusplus/documentation/warnings.html HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |