Re: [pygccxml-development] Basic Py++ questions
Brought to you by:
mbaas,
roman_yakovenko
From: Paul M. <pa...@sc...> - 2008-10-29 09:39:09
|
Hi Roman, Roman Yakovenko wrote: > On Tue, Oct 28, 2008 at 3:27 PM, Paul Melis <pa...@sc...> wrote: > > >> I.e. I can >> write for example class_('::mynamespace::C'), class_('mynamespace::C') >> or class_('C'). Will these match different classes? >> > > The first and the last examples could match the different classes. > This depends on flags you pass to the method. If you use class_ > method, you will get exception. I am not sure about the second > example. I guess it will not match any class, but I could be wrong. > > I suggest you to take a look on the following document: > http://language-binding.net/pygccxml/query_interface.html > Surprisingly you say that class_('mynamespace::C') might not match any class, as the following example line is in the query interface docs: do_smth = my_class.member_function( 'my_namespace::my_class::do_smth' ) I suppose that this form should match something as it is basically the most used form in C++ code. I haven't seen much code that consistently uses an absolute namespace path, like ::mynamespace::C, to refer to classes. >> - I get warnings (W1005) during code generation about methods/functions >> using instances of non-public classes, with the message that the >> generated code will not compile :) Is there a way to automatically >> disable generation of method wrappers that use non-public classes? >> > > Yes. Py++ warnings are explained here: > http://language-binding.net/pyplusplus/documentation/warnings.html > > Basically you can check why declarations is not exportable : > > <<untested>> > > from pyplusplus import messages > > f = <<<some function>>> > if not f.exportable and f.why_not_exportable().identifier == messages.W1005: > f.exclude() > > Right, I did notice the docs about this and saw a quote from you somewhere that it allows you to exclude items based on warnings they generate. The above indeed shows that, but the warnings API doesn't allow you to find WHICH items generated a certain warning so this would mean iterating over ALL items being exported and checking them for a certain warning? >> - Finally, if I .exclude() a certain class it seems that this doesn't >> propagate into excluding all methods/functions using that class (related >> to the previous question)? >> > > You mean you have class A{}; and some function f( A& ) and excluding > A, doesn't exclude f, right? > Yes. I'm not certain how the generated wrapper would behave when class A is excluded, but f(A&) WOULD be wrapped. If there was a class B derived from A that would be included in the wrappers then I could still call f(B)? > If so, Py++ doesn't do it for performance\memory reasons. > > Now, when I think about it, it should be easy to add to the class_t > new function - "exclude_me_and_references_to_me" ( better name is > needed ) which will does exactly what you want. We can use > "i_depend_on_them" functionality. > It would be a nice addition to give users a choice of how exclusion of a class is treated. The current option is simply excluding only the wrapper for the class, but another variant would then be to exclude the class and all its uses. Regards, Paul PS Why did you choose to name classes with the "_t" postfix, e.g. declaration_matcher_t versus the more common/pythonic DeclarationMatcher? And could a statement like "if not None is self.decl_type:" not also be written as "if self.decl_type is not None:"? |