[C++-sig] [pybindgen] references?

Gustavo Carneiro gjcarneiro at gmail.com
Tue Nov 4 15:18:52 CET 2008


2008/11/4 Alan Baljeu <alanbaljeu at yahoo.com>

> Glad to read this here.  I agree with you about the dislike thing.  I can't
> stand auto_ptr, and if I had to give an object control over the life of
> another object I would generally choose a shared_ptr protocol.  I mean, the
> object existed fine before passing it in.  Why can't it survive independent
> of its new owner?
>
> On the binding side of things, it's good to know pybindgen supports this.
> I really think the documentation needs an overhaul.  I find reference
> manuals too hard to use for learning an API.  The front page of the
> reference (which I nearly overlooked) has a good tutorial but it's quite
> incomplete.  In fact, if I wasn't aesthetically predisposed to choosing this
> solution, or if you didn't answer my questions all timely-like, I would have
> given up. Yet it's looking more and more like it's a nearly comprehensive
> (and elegant) solution so I'm glad to stick with it.
>

Well, I'm sure you'll find a pybindgen limitation sooner or later :-)  As
you would with any other tool...  But I have developed pybindgen mostly
oriented to the features I needed to bind NS-3[1].

Regarding documentation, you are right.  I would never condemn anyone for
not using pybindgen due to lack of documentation, but I'm afraid I don't
have time or predisposition for writing good documentation.  The little
tutorial documentation there is not even written by me, Mathieu Lacage wrote
it (or most of it).  Otherwise, pybindgen can still be useful for
programmers with enough patience  to work with incomplete documentation, and
that's why I make it available anyway.  If you find it useful, good for you,
if not, I understand.

[1] http://www.nsnam.org/



>
>
> ----------------------
>
> I know that you're thinking about the custodian_and_ward policy of
> boost.python, but pybindgen also supports it.  For example:
>
> class SomeObject
> {
> [...]
>     Foobar* get_foobar_with_self_as_custodian ();
>     Foobar* get_foobar_with_other_as_custodian (const SomeObject *other);
>     void set_foobar_with_self_as_custodian (Foobar *foobar);
> };
>
>
> Is wrapped by pybindgen code:
>
>     SomeObject = mod.add_class('SomeObject', allow_subclassing=True)
>    [...]
>     SomeObject.add_method('get_foobar_with_self_as_custodian',
>                           retval('Foobar*', custodian=0), [])
>     SomeObject.add_method('get_foobar_with_other_as_custodian',
>                           retval('Foobar*', custodian=1),
>                           [param('SomeObject*', 'other',
> transfer_ownership=False)])
>     SomeObject.add_method('set_foobar_with_self_as_custodian',
> retval('void'),
>                           [param('Foobar*', 'foobar', custodian=0)])
>
> [excerpt from the pybindgen unit tests]
>
> Although I personally dislike this sort of practice; I would hate working
> with APIs this complicated even in C++.
>
> --
> Gustavo J. A. M. Carneiro
> INESC Porto, Telecommunications and Multimedia Unit
> "The universe is always one step beyond logic." -- Frank Herbert
>
> ------------------------------
> Instant message from any web browser! Try the new * Yahoo! Canada
> Messenger for the Web BETA*<http://ca.messenger.yahoo.com/webmessengerpromo.php>
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>



-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081104/bb1952c9/attachment-0001.htm>


More information about the Cplusplus-sig mailing list