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>2018-08-31 07:25:42 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-08-31 07:25:42 +0300
commit39ee0f01e3b340e9c39c9d95df6acdba27694337 (patch)
tree2b195359ab17302b538bcaf0f61f9d8cde19b2e6 /source/blender/python/generic
parent7c6136b35ca18da5a36b6030ade3b45dc5cb483d (diff)
parent98800aa4e0f7b4aa169e799e804b1ba658be6e69 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r--source/blender/python/generic/py_capi_utils.c34
-rw-r--r--source/blender/python/generic/py_capi_utils.h1
2 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 6517cc271cc..d8d6b5c7ce7 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -1140,6 +1140,40 @@ bool PyC_RunString_AsNumber(const char *expr, const char *filename, double *r_va
return ok;
}
+bool PyC_RunString_AsIntPtr(const char *expr, const char *filename, intptr_t *r_value)
+{
+ PyObject *py_dict, *retval;
+ bool ok = true;
+ PyObject *main_mod = NULL;
+
+ PyC_MainModule_Backup(&main_mod);
+
+ py_dict = PyC_DefaultNameSpace(filename);
+
+ retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict);
+
+ if (retval == NULL) {
+ ok = false;
+ }
+ else {
+ intptr_t val;
+
+ val = (intptr_t)PyLong_AsVoidPtr(retval);
+ if (val == 0 && PyErr_Occurred()) {
+ ok = false;
+ }
+ else {
+ *r_value = val;
+ }
+
+ Py_DECREF(retval);
+ }
+
+ PyC_MainModule_Restore(main_mod);
+
+ return ok;
+}
+
bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_value)
{
PyObject *py_dict, *retval;
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index fef9171b4d4..b962f40c180 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -102,6 +102,7 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_val
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
bool PyC_RunString_AsNumber(const char *expr, const char *filename, double *r_value);
+bool PyC_RunString_AsIntPtr(const char *expr, const char *filename, intptr_t *r_value);
bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_value);
int PyC_ParseBool(PyObject *o, void *p);