Commit: 0ffc603553bb6a5dd3ce96e88bc9be34356fc0cf
Author: Campbell Barton
Date:   Thu Dec 31 21:15:29 2015 +1100
Branches: master
https://developer.blender.org/rB0ffc603553bb6a5dd3ce96e88bc9be34356fc0cf

Cleanup: Py API naming

Use BPY_execute_* prefix for all Python execution commands

===================================================================

M       source/blender/editors/interface/interface.c
M       source/blender/editors/space_script/script_edit.c
M       source/blender/editors/space_text/text_ops.c
M       source/blender/editors/util/numinput.c
M       source/blender/freestyle/intern/system/PythonInterpreter.h
M       source/blender/python/BPY_extern.h
M       source/blender/python/generic/py_capi_utils.c
M       source/blender/python/generic/py_capi_utils.h
M       source/blender/python/intern/bpy_interface.c
M       source/blender/python/intern/bpy_utils_units.c
M       source/blender/windowmanager/intern/wm_files.c
M       source/creator/creator.c

===================================================================

diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 79a7f4f..95187bb 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2272,7 +2272,7 @@ static bool ui_set_but_string_eval_num_unit(bContext *C, 
uiBut *but, const char
        bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), 
but->drawstr,
                            ui_get_but_scale_unit(but, 1.0), 
but->block->unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type));
 
-       return (BPY_button_exec(C, str_unit_convert, value, true) != -1);
+       return BPY_execute_string_as_number(C, str_unit_convert, value, true);
 }
 
 #endif /* WITH_PYTHON */
@@ -2287,7 +2287,7 @@ bool ui_but_string_set_eval_num(bContext *C, uiBut *but, 
const char *str, double
        if (str[0] != '\0') {
                bool is_unit_but = (ui_but_is_float(but) && 
ui_but_is_unit(but));
                /* only enable verbose if we won't run again with units */
-               if (BPY_button_exec(C, str, value, is_unit_but == false) != -1) 
{
+               if (BPY_execute_string_as_number(C, str, value, is_unit_but == 
false)) {
                        /* if the value parsed ok without unit conversion this 
button may still need a unit multiplier */
                        if (is_unit_but) {
                                char str_new[128];
diff --git a/source/blender/editors/space_script/script_edit.c 
b/source/blender/editors/space_script/script_edit.c
index d265ae6..6bfb51d 100644
--- a/source/blender/editors/space_script/script_edit.c
+++ b/source/blender/editors/space_script/script_edit.c
@@ -59,7 +59,7 @@ static int run_pyfile_exec(bContext *C, wmOperator *op)
        char path[512];
        RNA_string_get(op->ptr, "filepath", path);
 #ifdef WITH_PYTHON
-       if (BPY_filepath_exec(C, path, op->reports)) {
+       if (BPY_execute_filepath(C, path, op->reports)) {
                ARegion *ar = CTX_wm_region(C);
                ED_region_tag_redraw(ar);
                return OPERATOR_FINISHED;
@@ -125,7 +125,7 @@ static int script_reload_exec(bContext *C, wmOperator *op)
        /* TODO, this crashes on netrender and keying sets, need to look into 
why
         * disable for now unless running in debug mode */
        WM_cursor_wait(1);
-       BPY_string_exec(C, 
"__import__('bpy').utils.load_scripts(reload_scripts=True)");
+       BPY_execute_string(C, 
"__import__('bpy').utils.load_scripts(reload_scripts=True)");
        WM_cursor_wait(0);
        WM_event_add_notifier(C, NC_WINDOW, NULL);
        return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_text/text_ops.c 
b/source/blender/editors/space_text/text_ops.c
index 948293d..4ded3e9 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -598,7 +598,7 @@ static int text_run_script(bContext *C, ReportList *reports)
        void *curl_prev = text->curl;
        int curc_prev = text->curc;
 
-       if (BPY_text_exec(C, text, reports, !is_live)) {
+       if (BPY_execute_text(C, text, reports, !is_live)) {
                if (is_live) {
                        /* for nice live updates */
                        WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
diff --git a/source/blender/editors/util/numinput.c 
b/source/blender/editors/util/numinput.c
index d2bc8bc..9bb4e05 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -496,7 +496,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent 
*event)
                                    n->unit_sys, n->unit_type[idx]);
 
                /* Note: with angles, we always get values as radians here... */
-               if (BPY_button_exec(C, str_unit_convert, &val, false) != -1) {
+               if (BPY_execute_string_as_number(C, str_unit_convert, &val, 
false)) {
                        n->val[idx] = (float)val;
                        n->val_flag[idx] &= ~NUM_INVALID;
                }
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h 
b/source/blender/freestyle/intern/system/PythonInterpreter.h
index ddb79b2..5403ec6 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -78,22 +78,22 @@ public:
                BKE_reports_clear(reports);
                char *fn = const_cast<char*>(filename.c_str());
 #if 0
-               int status = BPY_filepath_exec(_context, fn, reports);
+               bool ok = BPY_execute_filepath(_context, fn, reports);
 #else
-               int status;
+               bool ok;
                Text *text = BKE_text_load(&_freestyle_bmain, fn, G.main->name);
                if (text) {
-                       status = BPY_text_exec(_context, text, reports, false);
+                       ok = BPY_execute_text(_context, text, reports, false);
                        BKE_text_unlink(&_freestyle_bmain, text);
                        BKE_libblock_free(&_freestyle_bmain, text);
                }
                else {
                        BKE_reportf(reports, RPT_ERROR, "Cannot open file: %s", 
fn);
-                       status = 0;
+                       ok = false;
                }
 #endif
 
-               if (status != 1) {
+               if (ok == false) {
                        cerr << "\nError executing Python script from 
PythonInterpreter::interpretFile" << endl;
                        cerr << "File: " << fn << endl;
                        cerr << "Errors: " << endl;
@@ -113,7 +113,7 @@ public:
 
                BKE_reports_clear(reports);
 
-               if (BPY_string_exec(_context, str.c_str()) != 0) {
+               if (!BPY_execute_string(_context, str.c_str())) {
                        BPy_errors_to_report(reports);
                        cerr << "\nError executing Python script from 
PythonInterpreter::interpretString" << endl;
                        cerr << "Name: " << name << endl;
@@ -133,7 +133,7 @@ public:
 
                BKE_reports_clear(reports);
 
-               if (!BPY_text_exec(_context, text, reports, false)) {
+               if (!BPY_execute_text(_context, text, reports, false)) {
                        cerr << "\nError executing Python script from 
PythonInterpreter::interpretText" << endl;
                        cerr << "Name: " << name << endl;
                        cerr << "Errors: " << endl;
diff --git a/source/blender/python/BPY_extern.h 
b/source/blender/python/BPY_extern.h
index 815beeb..d3be599 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -72,10 +72,12 @@ void BPY_thread_restore(BPy_ThreadStatePtr tstate);
 #define BPy_BEGIN_ALLOW_THREADS { BPy_ThreadStatePtr _bpy_saved_tstate = 
BPY_thread_save(); (void)0
 #define BPy_END_ALLOW_THREADS BPY_thread_restore(_bpy_saved_tstate); } (void)0
 
+bool   BPY_execute_filepath(struct bContext *C, const char *filepath, struct 
ReportList *reports);
+bool   BPY_execute_text(struct bContext *C, struct Text *text, struct 
ReportList *reports, const bool do_jump);
+bool   BPY_execute_string_as_number(struct bContext *C, const char *expr, 
double *value, const bool verbose);
+bool   BPY_execute_string_ex(struct bContext *C, const char *expr, bool 
use_eval);
+bool   BPY_execute_string(struct bContext *C, const char *expr);
 
-/* 2.5 UI Scripts */
-int            BPY_filepath_exec(struct bContext *C, const char *filepath, 
struct ReportList *reports);
-int            BPY_text_exec(struct bContext *C, struct Text *text, struct 
ReportList *reports, const bool do_jump);
 void   BPY_text_free_code(struct Text *text);
 void   BPY_modules_update(struct bContext *C); // XXX - annoying, need this 
for pointers that get out of date
 void   BPY_modules_load_user(struct bContext *C);
@@ -85,10 +87,6 @@ void BPY_app_handlers_reset(const short do_all);
 void   BPY_driver_reset(void);
 float  BPY_driver_exec(struct ChannelDriver *driver, const float evaltime);
 
-int            BPY_button_exec(struct bContext *C, const char *expr, double 
*value, const bool verbose);
-int            BPY_string_exec_ex(struct bContext *C, const char *expr, bool 
use_eval);
-int            BPY_string_exec(struct bContext *C, const char *expr);
-
 void   BPY_DECREF(void *pyob_ptr);     /* Py_DECREF() */
 void   BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr);
 int            BPY_context_member_get(struct bContext *C, const char *member, 
struct bContextDataResult *result);
diff --git a/source/blender/python/generic/py_capi_utils.c 
b/source/blender/python/generic/py_capi_utils.c
index 89c3ed2..dd32c91 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -971,14 +971,14 @@ PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, 
int flag)
 
 
 /**
- * \return -1 on error, else 0
+ * \return success
  *
  * \note it is caller's responsibility to acquire & release GIL!
  */
-int PyC_RunString_AsNumber(const char *expr, double *value, const char 
*filename)
+bool PyC_RunString_AsNumber(const char *expr, double *value, const char 
*filename)
 {
        PyObject *py_dict, *mod, *retval;
-       int error_ret = 0;
+       bool ok = true;
        PyObject *main_mod = NULL;
 
        PyC_MainModule_Backup(&main_mod);
@@ -998,7 +998,7 @@ int PyC_RunString_AsNumber(const char *expr, double *value, 
const char *filename
        retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict);
 
        if (retval == NULL) {
-               error_ret = -1;
+               ok = false;
        }
        else {
                double val;
@@ -1024,7 +1024,7 @@ int PyC_RunString_AsNumber(const char *expr, double 
*value, const char *filename
                Py_DECREF(retval);
 
                if (val == -1 && PyErr_Occurred()) {
-                       error_ret = -1;
+                       ok = false;
                }
                else if (!finite(val)) {
                        *value = 0.0;
@@ -1036,7 +1036,7 @@ int PyC_RunString_AsNumber(const char *expr, double 
*value, const char *filename
 
        PyC_MainModule_Restore(main_mod);
 
-       return error_ret;
+       return ok;
 }
 
 #endif  /* #ifndef MATH_STANDALONE */
diff --git a/source/blender/python/generic/py_capi_utils.h 
b/source/blender/python/generic/py_capi_utils.h
index 0ebc06c..a06a717 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -79,7 +79,7 @@ int       PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const 
char *identifier, int
 int       PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int 
*r_value, const char *error_prefix);
 PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
 
-int PyC_RunString_AsNumber(const char *expr, double *value, const char 
*filename);
+bool PyC_RunString_AsNumber(const char *expr, double *value, const char 
*filename);
 
 int PyC_ParseBool(PyObject *o, void *p);
 
diff --git a/source/blender/python/intern/bpy_interface.c 
b/source/blender/python/intern/bpy_interface.c
index d10816b..0c3048d 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -424,8 +424,9 @@ typedef struct {
 } PyModuleObject;
 #endif
 
-static int python_script_exec(bContext *C, const char *fn, struct Text *text,
-                              struct ReportList *reports, const bool do_jump)
+static bool python_script_exec(
+        bContext *C, const char *fn, struct Text *text,
+        struct Re

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to