[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60229] trunk/blender/source/blender/ python: replace macro PYC_INTERPRETER_ACTIVE for PyC_IsInterpreterActive() function call,

Campbell Barton ideasman42 at gmail.com
Thu Sep 19 01:21:24 CEST 2013


Revision: 60229
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60229
Author:   campbellbarton
Date:     2013-09-18 23:21:24 +0000 (Wed, 18 Sep 2013)
Log Message:
-----------
replace macro PYC_INTERPRETER_ACTIVE for PyC_IsInterpreterActive() function call,
(indirectly referenced Python define of ~30 lines, most were optimized out but still caused some code bloat).

Modified Paths:
--------------
    trunk/blender/source/blender/python/generic/idprop_py_api.c
    trunk/blender/source/blender/python/generic/py_capi_utils.c
    trunk/blender/source/blender/python/generic/py_capi_utils.h
    trunk/blender/source/blender/python/intern/bpy_driver.c
    trunk/blender/source/blender/python/intern/bpy_interface.c
    trunk/blender/source/blender/python/intern/bpy_props.c

Modified: trunk/blender/source/blender/python/generic/idprop_py_api.c
===================================================================
--- trunk/blender/source/blender/python/generic/idprop_py_api.c	2013-09-18 23:08:23 UTC (rev 60228)
+++ trunk/blender/source/blender/python/generic/idprop_py_api.c	2013-09-18 23:21:24 UTC (rev 60229)
@@ -1518,7 +1518,7 @@
 {
 	if (prop) {
 		PyGILState_STATE gilstate;
-		int use_gil = TRUE; /* !PYC_INTERPRETER_ACTIVE; */
+		int use_gil = TRUE; /* !PyC_IsInterpreterActive(); */
 		PyObject *ret_dict;
 		PyObject *ret_str;
 

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c	2013-09-18 23:08:23 UTC (rev 60228)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c	2013-09-18 23:21:24 UTC (rev 60229)
@@ -191,7 +191,7 @@
 	int lineno;
 
 	/* Note, allow calling from outside python (RNA) */
-	if (!PYC_INTERPRETER_ACTIVE) {
+	if (!PyC_IsInterpreterActive()) {
 		fprintf(stderr, "python line lookup failed, interpreter inactive\n");
 		return;
 	}
@@ -205,7 +205,7 @@
 void PyC_StackSpit(void)
 {
 	/* Note, allow calling from outside python (RNA) */
-	if (!PYC_INTERPRETER_ACTIVE) {
+	if (!PyC_IsInterpreterActive()) {
 		fprintf(stderr, "python line lookup failed, interpreter inactive\n");
 		return;
 	}
@@ -258,7 +258,7 @@
 
 void PyC_FileAndNum_Safe(const char **filename, int *lineno)
 {
-	if (!PYC_INTERPRETER_ACTIVE) {
+	if (!PyC_IsInterpreterActive()) {
 		return;
 	}
 
@@ -599,6 +599,11 @@
 	}
 }
 
+bool PyC_IsInterpreterActive(void)
+{
+	return (((PyThreadState *)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL);
+}
+
 /* Would be nice if python had this built in
  * See: http://wiki.blender.org/index.php/Dev:Doc/Tools/Debugging/PyFromC
  */

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.h
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.h	2013-09-18 23:08:23 UTC (rev 60228)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.h	2013-09-18 23:21:24 UTC (rev 60229)
@@ -56,7 +56,7 @@
 
 void PyC_SetHomePath(const char *py_path_bundle);
 
-#define PYC_INTERPRETER_ACTIVE (((PyThreadState *)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL)
+bool PyC_IsInterpreterActive(void);
 
 void *PyC_RNA_AsPointer(PyObject *value, const char *type_name);
 

Modified: trunk/blender/source/blender/python/intern/bpy_driver.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_driver.c	2013-09-18 23:08:23 UTC (rev 60228)
+++ trunk/blender/source/blender/python/intern/bpy_driver.c	2013-09-18 23:21:24 UTC (rev 60229)
@@ -123,7 +123,7 @@
 void BPY_driver_reset(void)
 {
 	PyGILState_STATE gilstate;
-	bool use_gil = true; /* !PYC_INTERPRETER_ACTIVE; */
+	bool use_gil = true; /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -162,7 +162,7 @@
  *
  * (old)note: PyGILState_Ensure() isn't always called because python can call
  * the bake operator which intern starts a thread which calls scene update
- * which does a driver update. to avoid a deadlock check PYC_INTERPRETER_ACTIVE
+ * which does a driver update. to avoid a deadlock check PyC_IsInterpreterActive()
  * if PyGILState_Ensure() is needed - see [#27683]
  *
  * (new)note: checking if python is running is not threadsafe [#28114]
@@ -199,7 +199,7 @@
 		return 0.0f;
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c	2013-09-18 23:08:23 UTC (rev 60228)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2013-09-18 23:21:24 UTC (rev 60229)
@@ -166,7 +166,7 @@
 {
 	if (text->compiled) {
 		PyGILState_STATE gilstate;
-		bool use_gil = !PYC_INTERPRETER_ACTIVE;
+		bool use_gil = !PyC_IsInterpreterActive();
 
 		if (use_gil)
 			gilstate = PyGILState_Ensure();
@@ -760,7 +760,7 @@
 int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result)
 {
 	PyGILState_STATE gilstate;
-	bool use_gil = !PYC_INTERPRETER_ACTIVE;
+	bool use_gil = !PyC_IsInterpreterActive();
 
 	PyObject *pyctx;
 	PyObject *item;

Modified: trunk/blender/source/blender/python/intern/bpy_props.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_props.c	2013-09-18 23:08:23 UTC (rev 60228)
+++ trunk/blender/source/blender/python/intern/bpy_props.c	2013-09-18 23:21:24 UTC (rev 60229)
@@ -256,7 +256,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -313,7 +313,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -368,7 +368,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -430,7 +430,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -490,7 +490,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -547,7 +547,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -602,7 +602,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -664,7 +664,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -724,7 +724,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -781,7 +781,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -836,7 +836,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -898,7 +898,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -957,7 +957,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -1017,7 +1017,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -1079,7 +1079,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -1140,7 +1140,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
@@ -1197,7 +1197,7 @@
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();




More information about the Bf-blender-cvs mailing list