On 7/19/07, Roger Dahl <rd...@da...> wrote:
> Hello everyone,
>
> I'm having trouble exporting boost::optional<wstring> member variables
> and I was wondering if someone here might be able to help. I have
> boost::optional to_python and from_python converters that I can manually
> invoke like so:
>
> typedef return_value_policy<return_by_value> rbv;
> typedef default_call_policies dcp;
> ...
> .add_property("membervar", make_getter(&myclass::membervar, rbv()),
> make_setter(&myclass::membervar, dcp()))
>
> When I try to use Py++ to export this member variable, it generates code
> like this:
>
> .def_readwrite("membervar", &myclass::membervar)
>
> I have hundreds of these boost::optional<wstring> member variables. Is
> there a way to make Py++ generate code like the .add_property example? I
> have searched in the documentation and have found the variable_wrapper
> module. It looks like it might do the trick, but I can't tell how to use it.
>
> Any help would be much appreciated.
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
You can tell Py++ that your class is already exposed:
http://language-binding.net/pyplusplus/documentation/multi_module_development.html
Here you can find information about adding "hand-written" code to the
generated one
http://language-binding.net/pyplusplus/documentation/inserting_code.html
Properties:
http://language-binding.net/pyplusplus/documentation/properties.html
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
HTH
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|