[C++-sig] pybindgen add_function_as_constructor

Gustavo Carneiro gjcarneiro at gmail.com
Mon Apr 27 12:21:19 CEST 2009


2009/4/27 Robin Gilks <robin.gilks at tait.co.nz>

> Robin Gilks wrote:
>
>> I've found the pybindgen commit for revision 628 and that fixes the
>> PyObject problem - got a new one now!! I can't work out the syntax to return
>> any sort of pointer for example
>>   mod.add_method('methodA', ReturnValue.new('uint8_t *'), [])
>> This is probably me again not understanding the Python side of things -
>> how would I return a string otherwise?
>>
>>
>> I see that some of the fixes are in the NS-3 project as
>> pybindgen-0.10.0.630 (I assume this means up to and including commit 630)
>> but there is no waf included in this project so I can't build it :-(
>>
>>
> Sorry about constantly replying to myself but the further I get into the
> pybindgen code, the more I get lost!! I've temporarily solved my 'uint8_t *'
> problem by using 'char *' but since I'll be using strings that may have
> embedded nulls I'm moving everything across to std::string types so that
> problem goes away:-)


Sounds good.

Sorry I wasn't online to help with the other questions.  I assume those
problems are solved, if not please ask again the questions.


> Where I've got to now is I can't find how to declare a docstring for a
> function or method.


Doesn't this work?

     module.add_function(..., docstring="this is a docstring")

OK, looking at the code I found two bugs in pybindgen wrt docstrings:

     1. there is a bug with handling docstrings with overloaded functions;
they will only work if the function is not overloaded with another function
with the same name;

     2. I forgot to add a docstring parameter to method objects.  But it's a
simple workaround, just:

        method = MyClass.add_method(...)
        method.docstring = "this is a docstring"

    Again, only works if the method is not overloaded.

Regards,

-- 
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/20090427/d271a309/attachment.htm>


More information about the Cplusplus-sig mailing list