Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-03-08 17:37:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2007-03-08 17:37:34 +0300
commit5eaf9f90c1acc1b337a3fee38887f5db2a46ac81 (patch)
tree6c2608c7d77487761dfeefc0caf15be68dd64b0b /source/blender/python/api2_2x/Key.c
parent51c16edabc18a13e91bee1a35cbe39eb1e911ea3 (diff)
BPython API
added a function - GenericLib_assignData for assigning blender data, to assign an ipo to a camera or world to a scene for instance. Using this function removed ~300 lines of code. also fixes user count error in some places that didnt check. also made it possible to clear the colorband by setting it to []
Diffstat (limited to 'source/blender/python/api2_2x/Key.c')
-rw-r--r--source/blender/python/api2_2x/Key.c71
1 files changed, 15 insertions, 56 deletions
diff --git a/source/blender/python/api2_2x/Key.c b/source/blender/python/api2_2x/Key.c
index 82b6687f394..87edb8f4e5b 100644
--- a/source/blender/python/api2_2x/Key.c
+++ b/source/blender/python/api2_2x/Key.c
@@ -65,12 +65,12 @@ static void KeyBlock_dealloc( PyObject * self );
static int Key_compare( BPy_Key * a, BPy_Key * b );
static PyObject *Key_repr( BPy_Key * self );
-static PyObject *Key_getBlocks( PyObject * self );
+static PyObject *Key_getBlocks( BPy_Key * self );
static PyObject *Key_getType( BPy_Key * self );
static PyObject *Key_getRelative( BPy_Key * self );
-static PyObject *Key_getIpo( PyObject * self );
-static int Key_setIpo( PyObject * self, PyObject * args );
-static PyObject *Key_getValue( PyObject * self );
+static PyObject *Key_getIpo( BPy_Key * self );
+static int Key_setIpo( BPy_Key * self, PyObject * args );
+static PyObject *Key_getValue( BPy_Key * self );
static int Key_setRelative( BPy_Key * self, PyObject * value );
static struct PyMethodDef Key_methods[] = {
@@ -319,69 +319,30 @@ static PyObject *Key_repr( BPy_Key * self )
return PyString_FromFormat( "[Key \"%s\"]", self->key->id.name + 2 );
}
-static PyObject *Key_getIpo( PyObject * self )
+static PyObject *Key_getIpo( BPy_Key * self )
{
- BPy_Key *k = ( BPy_Key * ) self;
BPy_Ipo *new_ipo;
- if (k->key->ipo) {
+ if (self->key->ipo) {
new_ipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type );
- new_ipo->ipo = k->key->ipo;
+ new_ipo->ipo = self->key->ipo;
return (PyObject *) new_ipo;
} else {
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
}
-static int Key_setIpo( PyObject * self, PyObject * value )
+static int Key_setIpo( BPy_Key * 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_plus(id);
- }
-
- return 0;
+ return GenericLib_assignData(value, (void **) &self->key->ipo, 0, 1, ID_IP, ID_KE);
}
static PyObject *Key_getRelative( BPy_Key * self )
{
if( self->key->type == KEY_RELATIVE )
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
static int Key_setRelative( BPy_Key * self, PyObject * value )
@@ -418,16 +379,14 @@ static PyObject *Key_getType( BPy_Key * self )
return PyInt_FromLong( type );
}
-static PyObject *Key_getBlocks( PyObject * self )
+static PyObject *Key_getBlocks( BPy_Key * self )
{
- BPy_Key *k = ( BPy_Key * ) self;
- Key *key = k->key;
+ Key *key = self->key;
KeyBlock *kb;
PyObject *keyblock_object;
PyObject *l = PyList_New( 0 );
for (kb = key->block.first; kb; kb = kb->next) {
-
keyblock_object = KeyBlock_CreatePyObject( kb, key );
PyList_Append( l, keyblock_object );
}
@@ -435,7 +394,7 @@ static PyObject *Key_getBlocks( PyObject * self )
return l;
}
-static PyObject *Key_getValue( PyObject * self )
+static PyObject *Key_getValue( BPy_Key * self )
{
BPy_Key *k = ( BPy_Key * ) self;