kanarip / rpms / blender

Forked from rpms/blender 5 years ago
Clone
Blob Blame History Raw
commit 4dd7d4110a06422b5a86a609b7cc7687bd570fef
Author: Campbell Barton <ideasman42@gmail.com>
Date:   Wed Sep 18 23:21:24 2013 +0000

    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).

diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index fc4b78b5c05..f7ed5fec891 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -1518,7 +1518,7 @@ void IDP_spit(IDProperty *prop)
 {
 	if (prop) {
 		PyGILState_STATE gilstate;
-		int use_gil = TRUE; /* !PYC_INTERPRETER_ACTIVE; */
+		int use_gil = TRUE; /* !PyC_IsInterpreterActive(); */
 		PyObject *ret_dict;
 		PyObject *ret_str;
 
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 2876d7666f4..63f66afd8a8 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -191,7 +191,7 @@ void PyC_LineSpit(void)
 	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_LineSpit(void)
 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(const char **filename, int *lineno)
 
 void PyC_FileAndNum_Safe(const char **filename, int *lineno)
 {
-	if (!PYC_INTERPRETER_ACTIVE) {
+	if (!PyC_IsInterpreterActive()) {
 		return;
 	}
 
@@ -599,6 +599,11 @@ void PyC_SetHomePath(const char *py_path_bundle)
 	}
 }
 
+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
  */
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 239858032de..8928642bc3e 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -56,7 +56,7 @@ void PyC_MainModule_Restore(PyObject *main_mod);
 
 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);
 
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 481758db252..7141db7352a 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -123,7 +123,7 @@ static void bpy_pydriver_update_dict(const float evaltime)
 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 @@ static void pydriver_error(ChannelDriver *driver)
  *
  * (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 @@ float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
 		return 0.0f;
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index dc1f5828c15..cc1dd369f8b 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -166,7 +166,7 @@ void BPY_text_free_code(Text *text)
 {
 	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 @@ void BPY_modules_load_user(bContext *C)
 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;
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 9bd9d33a36c..bfa4954d4bc 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -256,7 +256,7 @@ static int bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
 		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 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
 		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 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
 		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 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
 		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 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
 		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 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
 		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 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
 		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 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
 		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 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
 		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 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
 		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 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
 		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 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
 		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 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
 		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 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
 		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 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
 		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 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
 		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 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
 		pyrna_write_set(true);
 	}
 
-	use_gil = true;  /* !PYC_INTERPRETER_ACTIVE; */
+	use_gil = true;  /* !PyC_IsInterpreterActive(); */
 
 	if (use_gil)
 		gilstate = PyGILState_Ensure();