Re: [pygccxml-development] special functions/operators
Brought to you by:
mbaas,
roman_yakovenko
|
From: Matthias B. <ba...@ir...> - 2006-08-28 13:16:12
|
Roman Yakovenko wrote:
>> We can indeed use cdef for this, but it's rather low level. I wonder
>> if we
>> can make a better api for this, maybe something like:
>>
>> add_method (...)
>
> You and Matthias are solving different problems.
> Matthias generates new function from the script and than adds it to the
> class.
Well, not only. In my Maya bindings I'm also doing the same thing as
Neal, i.e. I have manually written C++ functions that I add as methods
to some classes using cdef().
> You already have function declaration, and the only thing you want to
> do is to associate it
> with the class. I think it will take only few hours to implement what
> you are asking for.
>
> cls = mb.class_("X")
> f = mb.free_function( "addAssign" )
> cls.add_method( f )
I think this could be a useful feature, couldn't it?
However, in my case I would have to change my project setup a bit as
Py++ doesn't "see" my manually written functions. I'm not parsing my own
headers so the query for the free function wouldn't work.
> While it is possible to implement this on top of cdef function, I
> think it will be a wrong
> solution. Why? Because next functionality already exists in code creators:
> 1. keyword arguments ( default values )
> 2. introducing function type into generated code
> 3. argument policies ( they will not work on function )
> 4. warnings
> 5. class held type and smart pointers registration
But in the above example f is already a "real" declaration that will get
turned into a "real" code creator, so all the above features could be
used, couldn't they?
- Matthias -
|