[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12923] trunk/blender: rename WITH_PYAPI_V24X to WITH_BPYAPI_V24X (because its blender' s api version number not pythons), made 24x api use its own armature weakref list since pyobject types are different .

Campbell Barton ideasman42 at gmail.com
Mon Dec 17 12:32:53 CET 2007


Revision: 12923
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12923
Author:   campbellbarton
Date:     2007-12-17 12:32:52 +0100 (Mon, 17 Dec 2007)

Log Message:
-----------
rename WITH_PYAPI_V24X to WITH_BPYAPI_V24X (because its blender's api version number not pythons), made 24x api use its own armature weakref list since pyobject types are different.

Modified Paths:
--------------
    trunk/blender/source/blender/python/BPY_interface.c
    trunk/blender/source/blender/python/Makefile
    trunk/blender/source/blender/python/SConscript
    trunk/blender/source/blender/python/api2_4x/Armature.c
    trunk/blender/source/blender/python/api2_4x/Window.c
    trunk/blender/source/blender/python/api2_4x/gen_utils.h
    trunk/blender/source/nan_definitions.mk
    trunk/blender/tools/btools.py

Modified: trunk/blender/source/blender/python/BPY_interface.c
===================================================================
--- trunk/blender/source/blender/python/BPY_interface.c	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/source/blender/python/BPY_interface.c	2007-12-17 11:32:52 UTC (rev 12923)
@@ -66,7 +66,6 @@
 #include "api2_5x/gen_utils.h"
 #include "api2_5x/gen_library.h" /* GetPyObjectFromID */
 #include "api2_5x/bpy_gl.h" 
-#include "api2_5x/bpy.h"
 #include "api2_5x/bpy_state.h"
 #include "api2_5x/Camera.h"
 #include "api2_5x/Draw.h"
@@ -76,14 +75,14 @@
 #include "api2_5x/bpy.h" /* for the new "bpy" module */
 
 /* old 2.4x api */
-#ifdef WITH_PYAPI_V24X
+#ifdef WITH_BPYAPI_V24X
 #include "api2_4x/Blender.h"
+#include "api2_4x/gen_utils.h"
 #endif
 
 /*these next two are for pyconstraints*/
 #include "api2_5x/IDProp.h"
 #include "api2_5x/matrix.h"
-
 #include "api2_5x/gen_utils.h"
 #include "api2_5x/gen_library.h"
 #include "blendef.h"
@@ -267,16 +266,25 @@
 	 * inside scriptlinks, so this is ok) */
 	if( sc->script->py_event ) {
 		int pass_ascii = 0;
+		PyObject *pyval;
 		if (ascii > 31 && ascii != 127) {
 			pass_ascii = 1;
-			EXPP_dict_set_item_str(g_bpystatedict, "event",
-					PyInt_FromLong((long)ascii));
+			pyval = PyInt_FromLong((long)ascii);
+#ifdef WITH_BPYAPI_V24X
+			EXPP_dict_set_item_str(V24_g_blenderdict, "event", pyval);
+#endif
 		}
+		
 		exec_callback( sc, sc->script->py_event,
 			Py_BuildValue( "(ii)", event, val ) );
-		if (pass_ascii)
-			EXPP_dict_set_item_str(g_bpystatedict, "event",
-					PyString_FromString(""));
+		
+		if (pass_ascii) {
+			pyval = PyString_FromString("");
+			EXPP_dict_set_item_str(g_bpystatedict, "event", pyval);
+#ifdef WITH_BPYAPI_V24X
+			EXPP_dict_set_item_str(V24_g_blenderdict, "event", pyval);
+#endif
+		}
 	}
 }
 
@@ -285,12 +293,10 @@
  * set up a weakref list for Armatures
  *    creates list in __main__ module dict 
  */
-  
-int setup_armature_weakrefs()
+static int setup_armature_weakrefs__internal(char *list_name)
 {
 	PyObject *maindict;
 	PyObject *main_module;
-	char *list_name = ARM_WEAKREF_LIST_NAME;
 
 	main_module = PyImport_AddModule( "__main__");
 	if(main_module){
@@ -317,13 +323,25 @@
 	return 1;
 }
 
+/* This just accounts for there being 2 weakref armature lists */
+int setup_armature_weakrefs( void )
+{
+	if (!setup_armature_weakrefs__internal(ARM_WEAKREF_LIST_NAME))
+		return 0;
+#ifdef WITH_BPYAPI_V24X
+	if (!setup_armature_weakrefs__internal(V24_ARM_WEAKREF_LIST_NAME))
+		return 0;
+#endif
+	return 1;
+}
+
 /* Declares the modules and their initialization functions
  * These are TOP-LEVEL modules e.g. import `module` - there is no
  * support for packages here e.g. import `package.module` */
 
 static struct _inittab BPyInittab_Modules[] = {
 	{"bpy", m_bpy_init},
-#ifdef WITH_PYAPI_V24X
+#ifdef WITH_BPYAPI_V24X
 	{"Blender", V24_M_Blender_Init},
 #endif
 	{NULL, NULL}
@@ -490,11 +508,13 @@
 	init_ourImport(  );
 	init_ourReload(  );
 
-	//init a global dictionary
+	/*init a global dictionary and module*/
 	g_bpystatedict = NULL;
-	
-	/* Init the module here! */
 	m_bpy_init();
+#ifdef WITH_BPYAPI_V24X
+	V24_g_blenderdict = NULL;
+	V24_M_Blender_Init();
+#endif
 	
 	//Look for a python installation
 	init_syspath( first_time ); /* not first_time: some msgs are suppressed */

Modified: trunk/blender/source/blender/python/Makefile
===================================================================
--- trunk/blender/source/blender/python/Makefile	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/source/blender/python/Makefile	2007-12-17 11:32:52 UTC (rev 12923)
@@ -35,7 +35,7 @@
 
 DIRS = api2_5x
 
-ifeq ($(WITH_PYAPI_V24X), true)
+ifeq ($(WITH_BPYAPI_V24X), true)
 	DIRS += api2_4x
 endif
 

Modified: trunk/blender/source/blender/python/SConscript
===================================================================
--- trunk/blender/source/blender/python/SConscript	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/source/blender/python/SConscript	2007-12-17 11:32:52 UTC (rev 12923)
@@ -3,7 +3,7 @@
 
 sources = Split('BPY_interface.c BPY_menus.c') + env.Glob('api2_5x/*.c')
 
-if env['WITH_BF_PYAPI_V24X']==1:
+if env['WITH_BF_BPYAPI_V24X']==1:
 	sources += env.Glob('api2_4x/*.c')
 
 if env['BF_SPLIT_SRC'] == 1:
@@ -16,7 +16,7 @@
 	subsources = [] 	 
 	 
 	if (env['OURPLATFORM'] == 'win32-mingw'): 	 
-		for i in range(numlibs - 1): 	 
+		for i in range(numlibs - 1):
 			subsources.append(sources[i*maxobj:(i+1)*maxobj]) 	 
 		subsources.append(sources[(numlibs-1)*maxobj:])
 
@@ -40,8 +40,8 @@
 if env['WITH_BF_FFMPEG'] == 1:
     defs.append('WITH_FFMPEG')
 	
-if env['WITH_BF_PYAPI_V24X']==1:
-	defs.append('WITH_PYAPI_V24X')
+if env['WITH_BF_BPYAPI_V24X']==1:
+	defs.append('WITH_BPYAPI_V24X')
 	incs += ' api2_4x'
 
 

Modified: trunk/blender/source/blender/python/api2_4x/Armature.c
===================================================================
--- trunk/blender/source/blender/python/api2_4x/Armature.c	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/source/blender/python/api2_4x/Armature.c	2007-12-17 11:32:52 UTC (rev 12923)
@@ -1328,7 +1328,7 @@
 /* internal func to remove weakref from weakref list */
 PyObject * V24_arm_weakref_callback_weakref_dealloc(PyObject *self, PyObject *weakref)
 {
-	char *list_name = ARM_WEAKREF_LIST_NAME;
+	char *list_name = V24_ARM_WEAKREF_LIST_NAME;
 	PyObject *maindict = NULL, *armlist = NULL;
 	int i;
 	
@@ -1356,7 +1356,7 @@
 	V24_BPy_Armature *py_armature = NULL;
 	PyObject *maindict = NULL, *weakref = NULL;
 	PyObject *armlist = NULL;  /* list of armature weak refs */
-	char *list_name = ARM_WEAKREF_LIST_NAME;
+	char *list_name = V24_ARM_WEAKREF_LIST_NAME;
 	int i;
 
 	//put a weakreference in __main__

Modified: trunk/blender/source/blender/python/api2_4x/Window.c
===================================================================
--- trunk/blender/source/blender/python/api2_4x/Window.c	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/source/blender/python/api2_4x/Window.c	2007-12-17 11:32:52 UTC (rev 12923)
@@ -921,7 +921,7 @@
 static int update_armature_weakrefs()
 {
 	/* stuff for armature weak refs */
-	char *list_name = ARM_WEAKREF_LIST_NAME;
+	char *list_name = V24_ARM_WEAKREF_LIST_NAME;
 	PyObject *maindict = NULL, *armlist = NULL;
 	PyObject *pyarmature = NULL;
 	int x;

Modified: trunk/blender/source/blender/python/api2_4x/gen_utils.h
===================================================================
--- trunk/blender/source/blender/python/api2_4x/gen_utils.h	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/source/blender/python/api2_4x/gen_utils.h	2007-12-17 11:32:52 UTC (rev 12923)
@@ -77,7 +77,7 @@
 #endif
 
 /* name of list of Armature weak refs built into __main__ */
-#define ARM_WEAKREF_LIST_NAME "__arm_weakrefs"
+#define V24_ARM_WEAKREF_LIST_NAME "__V24_arm_weakrefs"
 
 int V24_EXPP_FloatsAreEqual(float A, float B, int floatSteps);
 int V24_EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);

Modified: trunk/blender/source/nan_definitions.mk
===================================================================
--- trunk/blender/source/nan_definitions.mk	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/source/nan_definitions.mk	2007-12-17 11:32:52 UTC (rev 12923)
@@ -112,7 +112,7 @@
 
     export WITH_OPENEXR ?= true
     export WITH_DDS ?= true
-	export WITH_PYAPI_V24X ?= true
+	export WITH_BPYAPI_V24X ?= true
 	
     ifeq ($(OS),windows)
 	export NAN_WINTAB ?= $(LCGDIR)/wintab

Modified: trunk/blender/tools/btools.py
===================================================================
--- trunk/blender/tools/btools.py	2007-12-17 11:20:51 UTC (rev 12922)
+++ trunk/blender/tools/btools.py	2007-12-17 11:32:52 UTC (rev 12923)
@@ -46,7 +46,7 @@
             'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
             'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC', 'BF_OPENGL_LINKFLAGS',
             'WITH_BF_FTGL', 'BF_FTGL', 'BF_FTGL_INC', 'BF_FTGL_LIB',
-            'WITH_BF_PYAPI_V24X',
+            'WITH_BF_BPYAPI_V24X',
             'WITH_BF_PLAYER',
             'CFLAGS', 'CCFLAGS', 'CPPFLAGS', 
             'REL_CFLAGS', 'REL_CCFLAGS',
@@ -173,7 +173,7 @@
         ('BF_FFMPEG_INC', 'FFMPEG includes', ''),
         ('BF_FFMPEG_LIBPATH', 'FFMPEG library path', ''),
         
-        (BoolOption('WITH_BF_PYAPI_V24X', 'Compile Blender 2.4x python api if true', 'true')),
+        (BoolOption('WITH_BF_BPYAPI_V24X', 'Compile Blender 2.4x python api if true', 'true')),
 
         (BoolOption('WITH_BF_JPEG', 'Use JPEG if true', 'true')),
         ('BF_JPEG', 'JPEG base path', ''),





More information about the Bf-blender-cvs mailing list