Page MenuHome

patch-lamp

Authored By
Ken Hughes (khughes)
Nov 13 2013, 1:07 PM
Size
5 KB
Subscribers
None

patch-lamp

Index: source/blender/python/api2_2x/Lamp.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Lamp.c,v
retrieving revision 1.36
diff -u -r1.36 Lamp.c
--- source/blender/python/api2_2x/Lamp.c 27 Aug 2005 18:44:56 -0000 1.36
+++ source/blender/python/api2_2x/Lamp.c 10 Sep 2005 21:31:27 -0000
@@ -1241,14 +1241,7 @@
static int Lamp_setCol( BPy_Lamp * self, PyObject * args )
{
- PyObject *error;
-
- error = rgbTuple_setCol( self->color, args );
- if ( error ) {
- Py_DECREF ( error );
- return 0;
- }
- return -1;
+ return rgbTuple_setCol( self->color, args );
}
/* lamp.addScriptLink */
@@ -1580,6 +1573,11 @@
return Lamp_setterWrapper ( self, args, Lamp_setIpo );
}
+static PyObject *Lamp_oldsetCol( BPy_Lamp * self, PyObject * args )
+{
+ return EXPP_setterWrapper ( (void *)self, args, (void *)Lamp_setCol );
+}
+
/*
* the "not-well-behaved" methods which require more processing than
* just the simple wrapper
@@ -1700,14 +1698,3 @@
return error;
}
-/*
- * This one isn't changed at all since rgbTuple_setCol() hasn't changed
- * either, and the new attribute setter expects a tuple with a single
- * argument. It's valid to do "lamp.setCol(r,g,b)", which passes three-
- * argument tuple.
- */
-
-static PyObject *Lamp_oldsetCol( BPy_Lamp * self, PyObject * args )
-{
- return rgbTuple_setCol( self->color, args );
-}
Index: source/blender/python/api2_2x/rgbTuple.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/rgbTuple.c,v
retrieving revision 1.9
diff -u -r1.9 rgbTuple.c
--- source/blender/python/api2_2x/rgbTuple.c 18 Jul 2005 03:50:37 -0000 1.9
+++ source/blender/python/api2_2x/rgbTuple.c 10 Sep 2005 21:31:27 -0000
@@ -45,7 +45,7 @@
static int rgbTuple_setAttr( BPy_rgbTuple * self, char *name, PyObject * v );
static PyObject *rgbTuple_repr( BPy_rgbTuple * self );
-static int rgbTupleLength( BPy_rgbTuple * self );
+static int rgbTupleLength( void );
static PyObject *rgbTupleSubscript( BPy_rgbTuple * self, PyObject * key );
static int rgbTupleAssSubscript( BPy_rgbTuple * self, PyObject * who,
@@ -138,39 +138,47 @@
/*****************************************************************************/
PyObject *rgbTuple_getCol( BPy_rgbTuple * self )
{
- PyObject *list = PyList_New( 3 );
-
- if( !list )
+ PyObject *attr = Py_BuildValue( "[fff]", *(self->rgb[0]),
+ *(self->rgb[1]), *(self->rgb[2]));
+ if( !attr )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
-
- PyList_SET_ITEM( list, 0, Py_BuildValue( "f", *( self->rgb[0] ) ) );
- PyList_SET_ITEM( list, 1, Py_BuildValue( "f", *( self->rgb[1] ) ) );
- PyList_SET_ITEM( list, 2, Py_BuildValue( "f", *( self->rgb[2] ) ) );
-
- return list;
+ "Py_BuildValue() failed" );
+ return attr;
}
-PyObject *rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
+int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
{
- int ok;
+ int ok = 0;
float r = 0, g = 0, b = 0;
- if( PyObject_Length( args ) == 3 )
- ok = PyArg_ParseTuple( args, "fff", &r, &g, &b );
-
- else
+ /*
+ * since rgbTuple_getCol() returns a list, be sure we accept a list
+ * as valid input
+ */
+
+ if( PyObject_Length( args ) == 3 ) {
+ if ( PyList_Check ( args ) &&
+ PyFloat_CheckExact( PySequence_Fast_GET_ITEM( args, 0 ) ) &&
+ PyFloat_CheckExact( PySequence_Fast_GET_ITEM( args, 1 ) ) &&
+ PyFloat_CheckExact( PySequence_Fast_GET_ITEM( args, 2 ) ) ) {
+ r = PyFloat_AS_DOUBLE( PySequence_Fast_GET_ITEM( args, 0 ) );
+ g = PyFloat_AS_DOUBLE( PySequence_Fast_GET_ITEM( args, 1 ) );
+ b = PyFloat_AS_DOUBLE( PySequence_Fast_GET_ITEM( args, 2 ) );
+ ok = 1;
+ } else
+ ok = PyArg_ParseTuple( args, "fff", &r, &g, &b );
+ } else
ok = PyArg_ParseTuple( args, "|(fff)", &r, &g, &b );
if( !ok )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected [f,f,f] or f,f,f as arguments (or nothing)" );
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected [f,f,f], (f,f,f) or f,f,f as arguments (or nothing)" );
*( self->rgb[0] ) = EXPP_ClampFloat( r, 0.0, 1.0 );
*( self->rgb[1] ) = EXPP_ClampFloat( g, 0.0, 1.0 );
*( self->rgb[2] ) = EXPP_ClampFloat( b, 0.0, 1.0 );
- return EXPP_incr_ret( Py_None );
+ return 0;
}
/*****************************************************************************/
@@ -245,7 +253,7 @@
/* These functions provide code to access rgbTuple objects as */
/* mappings. */
/*****************************************************************************/
-static int rgbTupleLength( BPy_rgbTuple * self )
+static int rgbTupleLength( void )
{
return 3;
}
Index: source/blender/python/api2_2x/rgbTuple.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/rgbTuple.h,v
retrieving revision 1.5
diff -u -r1.5 rgbTuple.h
--- source/blender/python/api2_2x/rgbTuple.h 19 Jul 2005 04:05:30 -0000 1.5
+++ source/blender/python/api2_2x/rgbTuple.h 10 Sep 2005 21:31:27 -0000
@@ -51,6 +51,6 @@
/*****************************************************************************/
PyObject *rgbTuple_New( float *rgb[3] );
PyObject *rgbTuple_getCol( BPy_rgbTuple * self );
-PyObject *rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args );
+int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args );
#endif /* EXPP_rgbTuple_H */

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
65/b0/e8fa2d1f4829d80a3e7b9ae71259

Event Timeline