Re: [pygccxml-development] special functions/operators
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2006-08-28 13:22:42
|
On 8/28/06, Matthias Baas <ba...@ir...> wrote:
> 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().
It does not different from what I say. You did not feed the
declarations to Py++.
> > 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?
Yes.
> 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?
I just wanted to save time :-). I can implement the feature, but it
will take some time.
Do you want to try to implement it?
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|