On 7/19/07, Roger Dahl <rd...@da...> wrote:
> Hello Roman,
>
> Thank you for Py++. It's awesome.
>
> Also thank you for the links. I think all the information is there, but
> unfortunately, I'm still floundering. I can't seem to knit it all
> together to a solution.
>
> I guess what I am really trying to do is to tell Py++ that all member
> variables and members that return a boost::optional need to be using
> return_value_policy<return_by_value>.
pseudo code, which is very closed to real one
from pygccxml import declarations
from pyplusplus import call_policies
def is_optional( decl ):
if isinstance( decl, declarations.variable_t ):
t = decl.type
return type.decl_string.startswith( '::boost::optional<' )
elif isinstance( decl, declarations.calldef_t ):
return decl.return_type and
decl.return_type.decl_string.startswith( .... )
vars = mb.variables( is_optional )
#do something with every variable
funcs = mb.calldefs( is_optional )
funcs.call_policies = call_policies.return_value_policy(
call_policies.return_by_value )
> > Here you can find information about adding "hand-written" code to the
> > generated one
> > http://language-binding.net/pyplusplus/documentation/inserting_code.html
> >
>
> It looks like I would be able to use this to iterate over all classes
> and all of their members and insert code kind of like in the "Insert
> code to class wrapper" example, but would that be the best way to go? If
> so, how do I iterate over class members and pick out only the ones of
> boost::optional values?
See the example of code I gave + be sure to read this part of documentation:
http://language-binding.net/pygccxml/query_interface.html
> > Properties:
> > http://language-binding.net/pyplusplus/documentation/properties.html
> >
>
> It looks like this describes mainly how to generate getter and setter
> functions, while I'm trying to export public class members directly.
> Since my class members are getting exposed automatically (though not in
> the way that I need them to be), I don't think I will need to use the
> add_properties algorithm?
I guess you don't need it.
> > You can still instruct Py++ to generate "add_property":
> > http://language-binding.net/pyplusplus/documentation/apidocs/pyplusplus.decl_wrappers.variable_wrapper.variable_t-class.html#use_make_functions
> >
> >
>
> This is the one that I initially mentioned. It looked to me like maybe
> this is the best way to go? But unfortunately, I can't find out how to
> use it. The Py++ documentation seems to have a gap between the basic
> tutorial section and the reference information. An example is the
> variable_t page. It contains only sparse reference information on what
> variable_t can be used for, but no information on how to actually use
> it. Going two steps up the tree, I get to the decl_wrappers page which
> says that these classes are used for configuring the code generator, but
> nothing about how or where to do that. I think only someone already very
> familiar with Py++ (and maybe also Python and this method of
> automatically generating documentation from the source) would see where
> variable_t fits into the big picture and (for instance) how to apply the
> settings there to a specific type of class members.
I think I don't completely understand you, except the fact that Py++
documentation should be much better and I agree with you. What section
is missing? Where can I improve it? Can you propose something
concrete?
> So I'm still coming back to the question on how to tell Py++ to use
> return_by_value for all boost::optional class members. I would much
> appreciate any further help or pointers you might be able to provide.
Hope, this time I've got you right.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|