diff options
author | Johnny Matthews <johnny.matthews@gmail.com> | 2005-10-31 18:53:21 +0300 |
---|---|---|
committer | Johnny Matthews <johnny.matthews@gmail.com> | 2005-10-31 18:53:21 +0300 |
commit | 15707394d174f412f8e0e3ee4c085e633487caf3 (patch) | |
tree | 13c17f2255f2de563b8f37dbc63660a04b2cc527 /source/blender/python/api2_2x/Key.c | |
parent | 54659d4a7d7d3cfdcf43b352bef1e19dd793fc86 (diff) |
Adding Key.ipo as access to ipo data both get and set
Diffstat (limited to 'source/blender/python/api2_2x/Key.c')
-rw-r--r-- | source/blender/python/api2_2x/Key.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Key.c b/source/blender/python/api2_2x/Key.c index c0d5cd19b15..f1b8c5e2388 100644 --- a/source/blender/python/api2_2x/Key.c +++ b/source/blender/python/api2_2x/Key.c @@ -63,6 +63,7 @@ static PyObject *Key_repr( BPy_Key * self ); static PyObject *Key_getBlocks( PyObject * self ); static PyObject *Key_getType( PyObject * self ); static PyObject *Key_getIpo( PyObject * self ); +static int Key_setIpo( PyObject * self, PyObject * args ); static PyObject *Key_getValue( PyObject * self ); static struct PyMethodDef Key_methods[] = { @@ -76,6 +77,8 @@ static PyGetSetDef BPy_Key_getsetters[] = { "Key Type",NULL}, {"value",(getter)Key_getValue, (setter)NULL, "Key value",NULL}, + {"ipo",(getter)Key_getIpo, (setter)Key_setIpo, + "ipo linked to key",NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; @@ -319,6 +322,50 @@ static PyObject *Key_getIpo( PyObject * self ) } } +static int Key_setIpo( PyObject * self, PyObject * value ) +{ + Ipo *ipo = NULL; + Ipo *oldipo = (( BPy_Key * )self)->key->ipo; + ID *id; + + /* if parameter is not None, check for valid Ipo */ + + if ( value != Py_None ) { + if ( !Ipo_CheckPyObject( value ) ) + return EXPP_ReturnIntError( PyExc_RuntimeError, + "expected an Ipo object" ); + + ipo = Ipo_FromPyObject( value ); + + if( !ipo ) + return EXPP_ReturnIntError( PyExc_RuntimeError, + "null ipo!" ); + + if( ipo->blocktype != ID_KE ) + return EXPP_ReturnIntError( PyExc_TypeError, + "Ipo is not a key data Ipo" ); + } + + /* if already linked to Ipo, delete link */ + + if ( oldipo ) { + id = &oldipo->id; + if( id->us > 0 ) + id->us--; + } + + /* assign new Ipo and increment user count, or set to NULL if deleting */ + + (( BPy_Key * )self)->key->ipo = ipo; + if ( ipo ) { + id = &ipo->id; + id->us++; + } + + return 0; +} + + static PyObject *Key_getType( PyObject * self ) { BPy_Key *k = ( BPy_Key * ) self; |