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.

----------------------


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



      __________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now at
http://ca.toolbar.yahoo.com.
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to