[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11406] branches/pyapi_devel/source/ blender: * added a base type for all library data - that can share comparison, common getset's and hash functions.

Campbell Barton cbarton at metavr.com
Sat Jul 28 16:53:04 CEST 2007


Revision: 11406
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11406
Author:   campbellbarton
Date:     2007-07-28 16:53:03 +0200 (Sat, 28 Jul 2007)

Log Message:
-----------
* added a base type for all library data - that can share comparison, common getset's and hash functions.
* looping on Curve nurbs now wont crash is a nurbs removed mid loop, and made nested looping work.
* removed Blender.Types

Modified Paths:
--------------
    branches/pyapi_devel/source/blender/python/api2_2x/Armature.c
    branches/pyapi_devel/source/blender/python/api2_2x/Blender.c
    branches/pyapi_devel/source/blender/python/api2_2x/Camera.c
    branches/pyapi_devel/source/blender/python/api2_2x/Camera.h
    branches/pyapi_devel/source/blender/python/api2_2x/Const.c
    branches/pyapi_devel/source/blender/python/api2_2x/CurNurb.c
    branches/pyapi_devel/source/blender/python/api2_2x/CurNurb.h
    branches/pyapi_devel/source/blender/python/api2_2x/Curve.c
    branches/pyapi_devel/source/blender/python/api2_2x/Curve.h
    branches/pyapi_devel/source/blender/python/api2_2x/CurveText.c
    branches/pyapi_devel/source/blender/python/api2_2x/Font.c
    branches/pyapi_devel/source/blender/python/api2_2x/Font.h
    branches/pyapi_devel/source/blender/python/api2_2x/Group.c
    branches/pyapi_devel/source/blender/python/api2_2x/Group.h
    branches/pyapi_devel/source/blender/python/api2_2x/Image.c
    branches/pyapi_devel/source/blender/python/api2_2x/Ipo.c
    branches/pyapi_devel/source/blender/python/api2_2x/Key.c
    branches/pyapi_devel/source/blender/python/api2_2x/Lamp.c
    branches/pyapi_devel/source/blender/python/api2_2x/Lattice.c
    branches/pyapi_devel/source/blender/python/api2_2x/Material.c
    branches/pyapi_devel/source/blender/python/api2_2x/Mesh.c
    branches/pyapi_devel/source/blender/python/api2_2x/Metaball.c
    branches/pyapi_devel/source/blender/python/api2_2x/NLA.c
    branches/pyapi_devel/source/blender/python/api2_2x/Object.c
    branches/pyapi_devel/source/blender/python/api2_2x/Scene.c
    branches/pyapi_devel/source/blender/python/api2_2x/Sound.c
    branches/pyapi_devel/source/blender/python/api2_2x/SurfNurb.c
    branches/pyapi_devel/source/blender/python/api2_2x/Text.c
    branches/pyapi_devel/source/blender/python/api2_2x/Texture.c
    branches/pyapi_devel/source/blender/python/api2_2x/World.c
    branches/pyapi_devel/source/blender/python/api2_2x/bpy.c
    branches/pyapi_devel/source/blender/python/api2_2x/bpy_types.c
    branches/pyapi_devel/source/blender/python/api2_2x/gen_library.c
    branches/pyapi_devel/source/blender/python/api2_2x/gen_library.h
    branches/pyapi_devel/source/blender/python/api2_2x/sceneObSeq.c
    branches/pyapi_devel/source/blender/src/buttons_editing.c

Removed Paths:
-------------
    branches/pyapi_devel/source/blender/python/api2_2x/Types.c
    branches/pyapi_devel/source/blender/python/api2_2x/Types.h

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Armature.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Armature.c	2007-07-28 14:51:22 UTC (rev 11405)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Armature.c	2007-07-28 14:53:03 UTC (rev 11406)
@@ -952,7 +952,6 @@
 //------------------------tp_getset
 //This contains methods for attributes that require checking
 static PyGetSetDef BPyArmature_getset[] = {
-	GENERIC_LIB_GETSETATTR,
 	{"bones", (getter)Armature_getBoneDict, (setter)Armature_setBoneDict, 
 		"The armature's Bone dictionary", NULL},
 	{"vertexGroups", (getter)Armature_getVertexGroups, (setter)Armature_setVertexGroups, 
@@ -982,19 +981,6 @@
 	{NULL}
 };
 
-/*****************************************************************************/
-/* Function:	Armature_compare						 */
-/* Description: This is a callback function for the BPyArmatureObject type. It	 */
-/*		compares two BPyArmature_Type objects. Only the "==" and "!="  */
-/*		comparisons are meaninful. Returns 0 for equality and -1 if  */
-/*		they don't point to the same Blender Object struct.	 */
-/*		In Python it becomes 1 if they are equal, 0 otherwise.	 */
-/*****************************************************************************/
-static int Armature_compare( BPyArmatureObject * a, BPyArmatureObject * b )
-{
-	return ( a->armature == b->armature ) ? 0 : -1;
-}
-
 //------------------------tp_repr
 //This is the string representation of the object
 static PyObject *Armature_repr(BPyArmatureObject *self)
@@ -1044,18 +1030,18 @@
 	0,								//tp_print
 	0,								//tp_getattr
 	0,								//tp_setattr
-	(cmpfunc) Armature_compare,		//tp_compare
+	0,								//tp_compare
 	(reprfunc) Armature_repr,		//tp_repr
 	0,								//tp_as_number
 	0,								//tp_as_sequence
 	0,								//tp_as_mapping
-	( hashfunc ) GenericLib_hash,	//tp_hash
+	0,								//tp_hash
 	0,								//tp_call
 	0,								//tp_str
 	0,								//tp_getattro
 	0,								//tp_setattro
 	0,								//tp_as_buffer
-	Py_TPFLAGS_DEFAULT| Py_TPFLAGS_HAVE_WEAKREFS,				//tp_flags
+	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS | Py_TPFLAGS_BASETYPE,				//tp_flags
 	BPyArmature_doc,				//tp_doc
 	0,								//tp_traverse
 	0,								//tp_clear
@@ -1065,8 +1051,8 @@
 	0,								//tp_iternext
 	BPyArmature_methods,			//tp_methods
 	0,								//tp_members
-	BPyArmature_getset,			//tp_getset
-	0,								//tp_base
+	BPyArmature_getset,				//tp_getset
+	&BPyGenericLib_Type,			//tp_base
 	0,								//tp_dict
 	0,								//tp_descr_get
 	0,								//tp_descr_set

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Blender.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Blender.c	2007-07-28 14:51:22 UTC (rev 11405)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Blender.c	2007-07-28 14:53:03 UTC (rev 11406)
@@ -92,7 +92,6 @@
 #include "Texture.h"
 #include "Window.h"
 #include "World.h"
-#include "Types.h"
 #include "bpy_list.h"
 #include "layer_set.h"
 #include "color.h"
@@ -911,8 +910,6 @@
 	module = Py_InitModule3("Blender", Blender_methods,
 		"The main Blender module");
 
-	types_InitAll();	/* set all our pytypes to &PyType_Type */
-
 	/* constants for packed files*/
 	//UnpackModes = Blender_UnpackModesDict(  );
 	//if( UnpackModes )
@@ -943,13 +940,12 @@
 	PyDict_SetItemString(dict, "BGL", BGL_Init());
 	PyDict_SetItemString(dict, "CurNurb", CurNurb_Init());
 	Constraint_Init();
-	/*PyDict_SetItemString(dict, "Curve", Curve_Init());*/
-	Camera_Init(); /*PyDict_SetItemString(dict, "Camera", Camera_Init());*/
+	
 	PyDict_SetItemString(dict, "Draw", Draw_Init());
 	Effect_Init();
 	/*Ipo_Init(); - removed */
 	IpoCurve_Init();
-	Image_Init();
+	
 	/*Key_Init(); - removed */
 	/*Lamp_Init(); - removed */
 	Lattice_Init();
@@ -962,13 +958,11 @@
 	Modifier_Init();
 	/*PyDict_SetItemString(dict, "Noise", Noise_Init()); - moved to bpy */
 	PyDict_SetItemString(dict, "Object", Object_Init());
-	Group_Init();
 	PyDict_SetItemString(dict, "Registry", Registry_Init());
 	PyDict_SetItemString(dict, "Scene", Scene_Init());
 	PyDict_SetItemString(dict, "Sound", Sound_Init());
 	PyDict_SetItemString(dict, "SurfNurb", SurfNurb_Init());
 	PyDict_SetItemString(dict, "sys", sys_Init());
-	PyDict_SetItemString(dict, "Types", Types_Init());
 	PyDict_SetItemString(dict, "Text", Text_Init());
 	//CurveText_Init();
 	Texture_Init();

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Camera.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Camera.c	2007-07-28 14:51:22 UTC (rev 11405)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Camera.c	2007-07-28 14:53:03 UTC (rev 11406)
@@ -183,13 +183,12 @@
 /*****************************************************************************/
 /* Python BPyCamera_Type callback function prototypes:                          */
 /*****************************************************************************/
-static int Camera_compare( BPyCameraObject * a, BPyCameraObject * b );
 static PyObject *Camera_repr( BPyCameraObject * self );
 
-void Camera_Init( void )
+PyObject * CameraType_Init( void )
 {	
 	PyType_Ready( &BPyCamera_Type );
-	/* no Blender.Camera anymore */
+	return (PyObject *) &BPyCamera_Type;
 }
 
 /* Three Python BPyCamera_Type helper functions needed by the Object module: */
@@ -389,7 +388,6 @@
 /* Python attributes get/set structure:                                      */
 /*****************************************************************************/
 static PyGetSetDef BPyCamera_getset[] = {
-	GENERIC_LIB_GETSETATTR,
 	GENERIC_LIB_GETSETATTR_SCRIPTLINK,
 	{"orthographic",
 	 (getter)Camera_getOrtho, (setter)Camera_setOrtho, "\
@@ -530,7 +528,7 @@
 	NULL,                       /* printfunc tp_print; */
 	NULL,                       /* getattrfunc tp_getattr; */
 	NULL,                       /* setattrfunc tp_setattr; */
-	( cmpfunc ) Camera_compare, /* cmpfunc tp_compare; */
+	NULL,						/* cmpfunc tp_compare; */
 	( reprfunc ) Camera_repr,   /* reprfunc tp_repr; */
 
 	/* Method suites for standard classes */
@@ -541,7 +539,7 @@
 
 	/* More standard operations (here for binary compatibility) */
 
-	( hashfunc ) GenericLib_hash,	/* hashfunc tp_hash; */
+	NULL,						/* hashfunc tp_hash; */
 	NULL,                       /* ternaryfunc tp_call; */
 	NULL,                       /* reprfunc tp_str; */
 	NULL,                       /* getattrofunc tp_getattro; */
@@ -551,7 +549,7 @@
 	NULL,                       /* PyBufferProcs *tp_as_buffer; */
 
   /*** Flags to define presence of optional/expanded features ***/
-	Py_TPFLAGS_DEFAULT,         /* long tp_flags; */
+	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,         /* long tp_flags; */
 
 	BPyCamera_Type_doc,                       /*  char *tp_doc;  Documentation string */
   /*** Assigned meaning in release 2.0 ***/
@@ -575,9 +573,9 @@
 
   /*** Attribute descriptor and subclassing stuff ***/
 	BPyCamera_methods,       /* struct PyMethodDef *tp_methods; */
-	NULL,                       /* struct PyMemberDef *tp_members; */
-	BPyCamera_getset,                       /* struct PyGetSetDef *tp_getset; */
-	NULL,                       /* struct _typeobject *tp_base; */
+	NULL,						/* struct PyMemberDef *tp_members; */
+	BPyCamera_getset,			/* struct PyGetSetDef *tp_getset; */
+	&BPyGenericLib_Type,		/* struct _typeobject *tp_base; */
 	NULL,                       /* PyObject *tp_dict; */
 	NULL,                       /* descrgetfunc tp_descr_get; */
 	NULL,                       /* descrsetfunc tp_descr_set; */
@@ -598,13 +596,6 @@
 	NULL
 };
 
-
-static int Camera_compare( BPyCameraObject * a, BPyCameraObject * b )
-{
-	Camera *pa = a->camera, *pb = b->camera;
-	return ( pa == pb ) ? 0 : -1;
-}
-
 static PyObject *Camera_repr( BPyCameraObject * self )
 {
 	return PyString_FromFormat( "[Camera \"%s\"]",

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Camera.h
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Camera.h	2007-07-28 14:51:22 UTC (rev 11405)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Camera.h	2007-07-28 14:53:03 UTC (rev 11406)
@@ -73,7 +73,7 @@
 #define EXPP_CAM_DRAWSIZE_MIN     0.1f
 #define EXPP_CAM_DRAWSIZE_MAX    10.0
 
-void Camera_Init( void );
+PyObject *CameraType_Init( void );
 PyObject *Camera_CreatePyObject( Camera * cam );
 
 #define Camera_FromPyObject( py_obj ) (((BPyCameraObject *)py_obj)->camera)

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Const.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Const.c	2007-07-28 14:51:22 UTC (rev 11405)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Const.c	2007-07-28 14:53:03 UTC (rev 11406)
@@ -365,7 +365,7 @@
 
 	/* More standard operations (here for binary compatibility) */
 
-	( hashfunc ) GenericLib_hash,	/* hashfunc tp_hash; */
+	NULL,						/* hashfunc tp_hash; */
 	NULL,                       /* ternaryfunc tp_call; */
 	NULL,                       /* reprfunc tp_str; */
 	NULL,                       /* getattrofunc tp_getattro; */

Modified: branches/pyapi_devel/source/blender/python/api2_2x/CurNurb.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/CurNurb.c	2007-07-28 14:51:22 UTC (rev 11405)
+++ branches/pyapi_devel/source/blender/python/api2_2x/CurNurb.c	2007-07-28 14:53:03 UTC (rev 11406)
@@ -400,13 +400,7 @@
 
 static PyObject *CurNurb_getPoints( BPyCurNurbObject * self )
 {
-	PyObject *attr = PyInt_FromLong( ( long ) self->nurb->pntsu );
-
-	if( attr )
-		return attr;
-
-	return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-			"could not get number of points" );
+	return PyInt_FromLong( ( long ) self->nurb->pntsu );
 }
 
 /*
@@ -415,11 +409,11 @@
  * arg is BezTriple or list of xyzw floats 
  */
 
-PyObject *CurNurb_append( BPyCurNurbObject * self, PyObject * args )
+PyObject *CurNurb_append( BPyCurNurbObject * self, PyObject * value )
 {
 	Nurb *nurb = self->nurb;
 
-	return CurNurb_appendPointToNurb( nurb, args );
+	return CurNurb_appendPointToNurb( nurb, value );
 }
 
 
@@ -429,29 +423,17 @@
  * notice the first arg is Nurb*.
  */
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list