[Bf-python] short term goals

Joseph Gilbert jgilbert at TIGR.org
Tue Jul 19 16:00:25 CEST 2005


Well its up to you but:

#define MTEXGET(x) \
        static PyObject *MTex_get##x( BPy_MTex *self, void *closure );
#define MTEXSET(x) \
        static int MTex_set##x( BPy_MTex *self, PyObject *value, void 
*closure);#define MTEXGETSET(x) \
        MTEXGET(x) \
        MTEXSET(x)

Is Ugly with a capital U. lol but whatever peeps decide.

Ken Hughes wrote:

> Damn... wrong button.  Let me try again.
>
> Stephen Swaney wrote:
>
>> 2) start to migrate our attribute handling code to use the tp_getset
>> interface.
>>
>> Right now our attribute access is done thru the tp_getattr and
>> tp_setattr slots in our PyTypeObjects where we lookup string names for
>> attributes and call the appropriate method.  Since the programmatic
>> interface here is similar to method calls we have duplicated all
>> our attribute access with  x.getStuff() / x.setStuff() methods
>>
>> The difference between tp_getset style and the x.setStuff() is the way
>> arguments are passed and the return types.  For tp_getset, the
>> argument is a PyObject pointer.  For the setStuff() style,
>> that same pyObject argument is wrapped in a tuple.
>>
>> Since tp_getset is the wave of the future, what we would like to do
>> here is have the setStuff() methods parse out the pyobject and then
>> call the appropriate method from the PyGetSetDef table ( the one for
>> the tp_getset slot ).  Both getStuff() and setStuff() wrappers will
>> also need to fix up the return type.
>>
>> This is mostly grunt work, but happily we have a willing victim, errr,
>> I mean volunteer.  Thanks, Ken!
>>
>> Right now, for backward compatibility, we will keep the getStuff() 
>> setStuff() methods unchanged.
>
>
> So the naming convention for method x.getStuff()/x.setStuff() would be 
> to have an attribute named x.stuff (whether stuff exists now or not).
> Similarly x.getOtherStuff()/x.setOtherStuff() would be x.otherStuff,
> etc.  And I'll ignore methods which are not attribute-related (ex,
> curve.update() ) ?
>
> And should I be using the style that sapir is using in his MTex.c 
> changes for declaring the getset procedures?
>
> #define MTEXGET(x) \
>         static PyObject *MTex_get##x( BPy_MTex *self, void *closure );
> #define MTEXSET(x) \
>         static int MTex_set##x( BPy_MTex *self, PyObject *value, void 
> *closure);#define MTEXGETSET(x) \
>         MTEXGET(x) \
>         MTEXSET(x)
>
> MTEXGETSET(Tex)
> MTEXGETSET(TexCo)
> MTEXGETSET(Object)
>
> ....
>
> /*****************************************************************************/ 
>
> /* Python get/set methods table                                       */
> /*****************************************************************************/ 
>
>
> static PyGetSetDef MTex_getseters[] = {
>         { "tex", (getter) MTex_getTex, (setter) MTex_setTex,
>                 "Texture whose mapping this MTex describes", NULL },
>         { "texco", (getter) MTex_getTexCo, (setter) MTex_setTexCo,
> ...
>
>
> Ken
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python





More information about the Bf-python mailing list