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>.
Roman Yakovenko wrote:
> Here is a relevant list of links:
> Examples of exposing boost::optional class
> http://mail.python.org/pipermail/c++-sig/2004-September/thread.html#8070
> http://mail.python.org/pipermail/c++-sig/2004-July/thread.html#7849
>
These must be the discussions that lead to the development of the
boost::optional wrapper code that I'm using, since that code is written
by Ralf Grosse-Kunstleve.
> You can tell Py++ that your class is already exposed:
> http://language-binding.net/pyplusplus/documentation/multi_module_development.html
>
>
I have only written wrappers by hand for a couple of boost::optional
members. Those work (since I'm using .add_property and specifying the
return_by_value policy).
> 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?
> 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?
> 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.
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.
Thank you again.
Roger
|