diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-13 14:10:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-13 14:10:29 +0300 |
commit | 5a322bd67cf1f99b4d8fc26e50edb22904f58b9e (patch) | |
tree | 4739ef0abd2ce0dd110f93742e3faf9e7543fba7 /source/blender | |
parent | b17964af11a1acab393ac2d51b2b0bd55a8c127c (diff) |
F8 reload works again, script errors are printed but dont stop loading every other script
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_edit.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_ops.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 18 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator_wrap.c | 6 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_ui.c | 2 |
7 files changed, 16 insertions, 46 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 0df7b326834..f90c1513116 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3704,7 +3704,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", F7KEY, KM_PRESS, 0, 0)->ptr, "path", "test.py"); - WM_keymap_verify_item(keymap, "SCRIPT_OT_python_run_ui_scripts", F8KEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "WM_OT_reload_scripts", F8KEY, KM_PRESS, 0, 0); /* files */ WM_keymap_add_item(keymap, "FILE_OT_execute", RETKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 630ea752f22..355095ea290 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -89,34 +89,3 @@ void SCRIPT_OT_python_file_run(wmOperatorType *ot) RNA_def_string_file_path(ot->srna, "path", "", 512, "Path", ""); } -static int run_ui_scripts_exec(bContext *C, wmOperator *op) -{ -#ifndef DISABLE_PYTHON -// TODO -#endif - return OPERATOR_FINISHED; -} - -static int run_ui_scripts_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret= run_ui_scripts_exec(C, op); - - if(ret==OPERATOR_FINISHED) - WM_event_add_notifier(C, NC_WINDOW, NULL); - - return ret; -} - - -void SCRIPT_OT_python_run_ui_scripts(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Reload Python Interface"; - ot->description= "Reload Python interface."; - ot->idname= "SCRIPT_OT_python_run_ui_scripts"; - - /* api callbacks */ - ot->exec= run_ui_scripts_exec; - ot->invoke= run_ui_scripts_invoke; - ot->poll= ED_operator_areaactive; -} diff --git a/source/blender/editors/space_script/script_intern.h b/source/blender/editors/space_script/script_intern.h index 7534fc98de1..08ec8ea289a 100644 --- a/source/blender/editors/space_script/script_intern.h +++ b/source/blender/editors/space_script/script_intern.h @@ -40,7 +40,6 @@ void script_keymap(struct wmKeyConfig *keyconf); /* script_edit.c */ void SCRIPT_OT_python_file_run(struct wmOperatorType *ot); -void SCRIPT_OT_python_run_ui_scripts(struct wmOperatorType *ot); #endif /* ED_SCRIPT_INTERN_H */ diff --git a/source/blender/editors/space_script/script_ops.c b/source/blender/editors/space_script/script_ops.c index fd87705648f..4ac90e852fb 100644 --- a/source/blender/editors/space_script/script_ops.c +++ b/source/blender/editors/space_script/script_ops.c @@ -60,7 +60,6 @@ void script_operatortypes(void) { WM_operatortype_append(SCRIPT_OT_python_file_run); - WM_operatortype_append(SCRIPT_OT_python_run_ui_scripts); } void script_keymap(wmKeyConfig *keyconf) @@ -69,6 +68,5 @@ void script_keymap(wmKeyConfig *keyconf) /* TODO - this is just while we have no way to load a text datablock */ RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0)->ptr, "path", "test.py"); - WM_keymap_add_item(keymap, "SCRIPT_OT_python_run_ui_scripts", PKEY, KM_PRESS, KM_SHIFT, 0); } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index b1577969a22..409afee7d7d 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -57,13 +57,13 @@ static PyObject *pyop_call( PyObject * self, PyObject * args) // XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it... bContext *C = BPy_GetContext(); - if (!PyArg_ParseTuple(args, "sO|O!i:bpy.__ops__.call", &opname, &context_dict, &PyDict_Type, &kw, &context)) + if (!PyArg_ParseTuple(args, "sO|O!i:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context)) return NULL; ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format( PyExc_SystemError, "bpy.__ops__.call: operator \"%s\"could not be found", opname); + PyErr_Format( PyExc_SystemError, "_bpy.ops.call: operator \"%s\"could not be found", opname); return NULL; } @@ -76,7 +76,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args) Py_XINCREF(context_dict); /* so we done loose it */ if(WM_operator_poll((bContext*)C, ot) == FALSE) { - PyErr_SetString( PyExc_SystemError, "bpy.__ops__.call: operator poll() function failed, context is incorrect"); + PyErr_SetString( PyExc_SystemError, "_bpy.ops.call: operator poll() function failed, context is incorrect"); error_val= -1; } else { @@ -158,13 +158,13 @@ static PyObject *pyop_as_string( PyObject * self, PyObject * args) bContext *C = BPy_GetContext(); - if (!PyArg_ParseTuple(args, "s|O!i:bpy.__ops__.as_string", &opname, &PyDict_Type, &kw, &all_args)) + if (!PyArg_ParseTuple(args, "s|O!i:_bpy.ops.as_string", &opname, &PyDict_Type, &kw, &all_args)) return NULL; ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format( PyExc_SystemError, "bpy.__ops__.as_string: operator \"%s\"could not be found", opname); + PyErr_Format( PyExc_SystemError, "_bpy.ops.as_string: operator \"%s\"could not be found", opname); return NULL; } @@ -217,12 +217,12 @@ static PyObject *pyop_getrna(PyObject *self, PyObject *value) BPy_StructRNA *pyrna= NULL; if(opname==NULL) { - PyErr_SetString(PyExc_TypeError, "bpy.__ops__.get_rna() expects a string argument"); + PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_rna() expects a string argument"); return NULL; } ot= WM_operatortype_find(opname, TRUE); if(ot==NULL) { - PyErr_Format(PyExc_KeyError, "bpy.__ops__.get_rna(\"%s\") not found", opname); + PyErr_Format(PyExc_KeyError, "_bpy.ops.get_rna(\"%s\") not found", opname); return NULL; } @@ -245,8 +245,8 @@ PyObject *BPY_operator_module( void ) static PyMethodDef pyop_add_meth = {"add", (PyCFunction) PYOP_wrap_add, METH_O, NULL}; static PyMethodDef pyop_remove_meth = {"remove", (PyCFunction) PYOP_wrap_remove, METH_O, NULL}; - PyObject *submodule = PyModule_New("bpy.__ops__"); - PyDict_SetItemString(PySys_GetObject("modules"), "bpy.__ops__", submodule); + PyObject *submodule = PyModule_New("_bpy.ops"); + PyDict_SetItemString(PySys_GetObject("modules"), "_bpy.ops", submodule); PyModule_AddObject( submodule, "call", PyCFunction_New(&pyop_call_meth, NULL) ); PyModule_AddObject( submodule, "as_string",PyCFunction_New(&pyop_as_string_meth,NULL) ); diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 95ffd3e1121..0aa6d8b6e6e 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -341,7 +341,11 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class) // in python would be... //PyObject *optype = PyObject_GetAttrString(PyObject_GetAttrString(PyDict_GetItemString(PyEval_GetGlobals(), "bpy"), "types"), "Operator"); - base_class = PyObject_GetAttrStringArgs(PyDict_GetItemString(PyEval_GetGlobals(), "bpy"), 2, "types", "Operator"); + + //PyObject bpy_mod= PyDict_GetItemString(PyEval_GetGlobals(), "bpy"); + PyObject *bpy_mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0); + base_class = PyObject_GetAttrStringArgs(bpy_mod, 2, "types", "Operator"); + Py_DECREF(bpy_mod); if(BPY_class_validate("Operator", py_class, base_class, pyop_class_attr_values, NULL) < 0) { return NULL; /* BPY_class_validate sets the error */ diff --git a/source/blender/python/intern/bpy_ui.c b/source/blender/python/intern/bpy_ui.c index f03a83bee9c..ab50ebd8bd5 100644 --- a/source/blender/python/intern/bpy_ui.c +++ b/source/blender/python/intern/bpy_ui.c @@ -48,7 +48,7 @@ static struct PyMethodDef ui_methods[] = { static struct PyModuleDef ui_module = { PyModuleDef_HEAD_INIT, - "bpy.ui", + "_bpy.ui", "", -1,/* multiple "initialization" just copies the module dict. */ ui_methods, |