Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-21 02:04:29 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-21 02:04:29 +0400
commitc4e7cc3287170dd6860f7b3d6d8628531d807136 (patch)
treeb7d7758f4a58382186ee761129ab045254e9b6b0 /source/blender/python/generic
parentd31e1533a38f9560ee91c75116fcc877006ed771 (diff)
fix for leak in gpu.export_shader(), wasnt freeing the function.
also change the bmesh iterator so its possible to initialize without stepping.
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r--source/blender/python/generic/py_capi_utils.c36
-rw-r--r--source/blender/python/generic/py_capi_utils.h2
2 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index ebc9a61f604..e79bad57ee0 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -646,3 +646,39 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
PyGILState_Release(gilstate);
}
}
+
+/* generic function to avoid depending on RNA */
+void *PyC_RNA_AsPointer(PyObject *value, const char *type_name)
+{
+ PyObject* as_pointer;
+ PyObject* pointer;
+
+ if (!strcmp(Py_TYPE(value)->tp_name, type_name) &&
+ (as_pointer = PyObject_GetAttrString(value, "as_pointer")) != NULL &&
+ PyCallable_Check(as_pointer))
+ {
+ void *result = NULL;
+
+ /* must be a 'type_name' object */
+ pointer = PyObject_CallObject(as_pointer, NULL);
+ Py_DECREF(as_pointer);
+
+ if (!pointer) {
+ PyErr_SetString(PyExc_SystemError, "value.as_pointer() failed");
+ return NULL;
+ }
+ result = PyLong_AsVoidPtr(pointer);
+ Py_DECREF(pointer);
+ if (!result) {
+ PyErr_SetString(PyExc_SystemError, "value.as_pointer() failed");
+ }
+
+ return result;
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "expected '%.200s' type found '%.200s' instead",
+ type_name, Py_TYPE(value)->tp_name);
+ return NULL;
+ }
+}
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index a71a2821c9a..18eac6d42f8 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -54,4 +54,6 @@ void PyC_SetHomePath(const char *py_path_bundle);
#define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL)
+void *PyC_RNA_AsPointer(PyObject *value, const char *type_name);
+
#endif // __PY_CAPI_UTILS_H__