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-09-03 05:38:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-03 05:43:43 +0300
commit7ff1750218bf3c2ef4c57f9ea4a12b738f4b7264 (patch)
tree613c4796c351d6de824bc69716963e21e3817190 /source/blender/python/intern/bpy_interface.c
parent4bb8dba340e0ac570f4a4eb628d0be09c92713b7 (diff)
PyAPI: add optional imports to expression eval API
Avoids having to use `__import__` to access modules.
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 9b685d5ba6e..7ca087e4993 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -588,7 +588,9 @@ void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr)
/**
* \return success
*/
-bool BPY_execute_string_as_number(bContext *C, const char *expr, const bool verbose, double *r_value)
+bool BPY_execute_string_as_number(
+ bContext *C, const char *imports[],
+ const char *expr, const bool verbose, double *r_value)
{
PyGILState_STATE gilstate;
bool ok = true;
@@ -604,7 +606,7 @@ bool BPY_execute_string_as_number(bContext *C, const char *expr, const bool verb
bpy_context_set(C, &gilstate);
- ok = PyC_RunString_AsNumber(expr, "<blender button>", r_value);
+ ok = PyC_RunString_AsNumber(imports, expr, "<expr as number>", r_value);
if (ok == false) {
if (verbose) {
@@ -623,7 +625,9 @@ bool BPY_execute_string_as_number(bContext *C, const char *expr, const bool verb
/**
* \return success
*/
-bool BPY_execute_string_as_string(bContext *C, const char *expr, const bool verbose, char **r_value)
+bool BPY_execute_string_as_string(
+ bContext *C, const char *imports[],
+ const char *expr, const bool verbose, char **r_value)
{
BLI_assert(r_value && expr);
PyGILState_STATE gilstate;
@@ -636,7 +640,7 @@ bool BPY_execute_string_as_string(bContext *C, const char *expr, const bool verb
bpy_context_set(C, &gilstate);
- ok = PyC_RunString_AsString(expr, "<blender button>", r_value);
+ ok = PyC_RunString_AsString(imports, expr, "<expr as str>", r_value);
if (ok == false) {
if (verbose) {
@@ -657,7 +661,9 @@ bool BPY_execute_string_as_string(bContext *C, const char *expr, const bool verb
*
* \return success
*/
-bool BPY_execute_string_as_intptr(bContext *C, const char *expr, const bool verbose, intptr_t *r_value)
+bool BPY_execute_string_as_intptr(
+ bContext *C, const char *imports[],
+ const char *expr, const bool verbose, intptr_t *r_value)
{
BLI_assert(r_value && expr);
PyGILState_STATE gilstate;
@@ -670,7 +676,7 @@ bool BPY_execute_string_as_intptr(bContext *C, const char *expr, const bool verb
bpy_context_set(C, &gilstate);
- ok = PyC_RunString_AsIntPtr(expr, "<blender button>", r_value);
+ ok = PyC_RunString_AsIntPtr(imports, expr, "<expr as intptr>", r_value);
if (ok == false) {
if (verbose) {