60
62
/* macro from blenkernel/intern/key.c:98 */
61
63
#define GS(a) (*((short *)(a)))
63
static void Key_dealloc( PyObject * self );
64
static void KeyBlock_dealloc( PyObject * self );
65
65
static int Key_compare( BPy_Key * a, BPy_Key * b );
66
66
static PyObject *Key_repr( BPy_Key * self );
68
static PyObject *Key_getBlocks( PyObject * self );
68
static PyObject *Key_getBlocks( BPy_Key * self );
69
69
static PyObject *Key_getType( BPy_Key * self );
70
70
static PyObject *Key_getRelative( BPy_Key * self );
71
static PyObject *Key_getIpo( PyObject * self );
72
static int Key_setIpo( PyObject * self, PyObject * args );
73
static PyObject *Key_getValue( PyObject * self );
71
static PyObject *Key_getIpo( BPy_Key * self );
72
static int Key_setIpo( BPy_Key * self, PyObject * args );
73
static PyObject *Key_getValue( BPy_Key * self );
74
74
static int Key_setRelative( BPy_Key * self, PyObject * value );
76
76
static struct PyMethodDef Key_methods[] = {
136
136
sizeof( BPy_Key ), /*tp_basicsize */
137
137
0, /*tp_itemsize */
139
( destructor ) Key_dealloc, /*tp_dealloc */
139
NULL, /*tp_dealloc */
140
140
( printfunc ) 0, /*tp_print */
141
141
( getattrfunc ) 0, /*tp_getattr */
142
142
( setattrfunc ) 0, /*tp_setattr */
151
151
/* More standard operations (here for binary compatibility) */
153
NULL, /* hashfunc tp_hash; */
153
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
154
154
NULL, /* ternaryfunc tp_call; */
155
155
NULL, /* reprfunc tp_str; */
156
156
NULL, /* getattrofunc tp_getattro; */
319
314
return PyString_FromFormat( "[Key \"%s\"]", self->key->id.name + 2 );
322
static PyObject *Key_getIpo( PyObject * self )
317
static PyObject *Key_getIpo( BPy_Key * self )
324
BPy_Key *k = ( BPy_Key * ) self;
325
319
BPy_Ipo *new_ipo;
321
if (self->key->ipo) {
328
322
new_ipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type );
329
new_ipo->ipo = k->key->ipo;
323
new_ipo->ipo = self->key->ipo;
330
324
return (PyObject *) new_ipo;
332
return EXPP_incr_ret( Py_None );
336
static int Key_setIpo( PyObject * self, PyObject * value )
330
static int Key_setIpo( BPy_Key * self, PyObject * value )
339
Ipo *oldipo = (( BPy_Key * )self)->key->ipo;
342
/* if parameter is not None, check for valid Ipo */
344
if ( value != Py_None ) {
345
if ( !Ipo_CheckPyObject( value ) )
346
return EXPP_ReturnIntError( PyExc_RuntimeError,
347
"expected an Ipo object" );
349
ipo = Ipo_FromPyObject( value );
352
return EXPP_ReturnIntError( PyExc_RuntimeError,
355
if( ipo->blocktype != ID_KE )
356
return EXPP_ReturnIntError( PyExc_TypeError,
357
"Ipo is not a key data Ipo" );
360
/* if already linked to Ipo, delete link */
368
/* assign new Ipo and increment user count, or set to NULL if deleting */
370
(( BPy_Key * )self)->key->ipo = ipo;
332
return GenericLib_assignData(value, (void **) &self->key->ipo, 0, 1, ID_IP, ID_KE);
379
335
static PyObject *Key_getRelative( BPy_Key * self )
381
337
if( self->key->type == KEY_RELATIVE )
382
return EXPP_incr_ret(Py_True);
384
return EXPP_incr_ret(Py_False);
387
343
static int Key_setRelative( BPy_Key * self, PyObject * value )
418
374
return PyInt_FromLong( type );
421
static PyObject *Key_getBlocks( PyObject * self )
377
static PyObject *Key_getBlocks( BPy_Key * self )
423
BPy_Key *k = ( BPy_Key * ) self;
379
Key *key = self->key;
426
381
PyObject *keyblock_object;
427
382
PyObject *l = PyList_New( 0 );
429
384
for (kb = key->block.first; kb; kb = kb->next) {
431
385
keyblock_object = KeyBlock_CreatePyObject( kb, key );
432
386
PyList_Append( l, keyblock_object );
445
399
/* ------------ Key Block Functions -------------- */
447
static void KeyBlock_dealloc( PyObject * self )
449
PyObject_DEL( self );
452
401
static PyObject *new_KeyBlock( KeyBlock * oldkeyBlock, Key *parentKey)
454
403
BPy_KeyBlock *kb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type );