[C++-sig] boost::python constructing object from PyObject *
Hans Meine
hans_meine at gmx.net
Wed Oct 29 22:07:16 CET 2008
On Mittwoch 29 Oktober 2008, David Abrahams wrote:
> The above should be a complete guide. Any questions?
Great, thanks a lot for the write-up. I think my second question is still
left, at least from your post and the docs at
http://www.boost.org/doc/libs/1_36_0/libs/python/doc/v2/handle.html
I have the impression that a handle<> can only be created from PyObject-style
pointers. So, let's say I have exported a class Foo, and I write a wrapper
for a factory function that creates a new Foo, and wants to convert it to
python in order to manually add some attributes (cf. my deep_copy
implementation). Is there a better way than the following for creating
result from new_foo?
Foo *new_foo = new Foo(...);
bp::object result =
bp::detail::new_reference(
typename manage_new_object::apply<Foo *>::type()(new_foo);
result.attr("bar") = 42;
return result;
--
Ciao, / / .o.
/--/ ..o
/ / ANS ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081029/1be7d746/attachment.pgp>
More information about the Cplusplus-sig
mailing list