diff options
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/python/intern/bpy.c | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy.h | 5 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_ffmpeg.c | 9 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_handlers.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 27 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface_atexit.c | 1 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_library.c | 3 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_library.h | 32 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 18 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.h | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna_anim.c | 3 | ||||
-rw-r--r-- | source/blender/python/intern/gpu.c | 3 | ||||
-rw-r--r-- | source/blender/python/intern/stubs.c | 11 |
14 files changed, 93 insertions, 30 deletions
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 4b397ee1870..15aa5164c86 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -72,6 +72,7 @@ set(SRC bpy_app_handlers.h bpy_driver.h bpy_intern_string.h + bpy_library.h bpy_operator.h bpy_operator_wrap.h bpy_props.h diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 38d082346d8..360e041270f 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -37,6 +37,7 @@ #include "bpy_rna.h" #include "bpy_app.h" #include "bpy_props.h" +#include "bpy_library.h" #include "bpy_operator.h" #include "BLI_path_util.h" @@ -240,7 +241,6 @@ static PyObject *bpy_import_test(const char *modname) void BPy_init_modules(void) { extern BPy_StructRNA *bpy_context_module; - extern int bpy_lib_init(PyObject *); PointerRNA ctx_ptr; PyObject *mod; @@ -276,7 +276,7 @@ void BPy_init_modules(void) PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type); /* needs to be first so bpy_types can run */ - bpy_lib_init(mod); + BPY_library_module(mod); bpy_import_test("bpy_types"); PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */ diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h index 2412d65aa21..fe877d161ff 100644 --- a/source/blender/python/intern/bpy.h +++ b/source/blender/python/intern/bpy.h @@ -23,10 +23,13 @@ * \ingroup pythonintern */ - +#ifndef __BPY_H__ + void BPy_init_modules(void); extern PyObject *bpy_package_py; /* bpy_interface_atexit.c */ void BPY_atexit_register(void); void BPY_atexit_unregister(void); + +#endif /* __BPY_H__ */ diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c index 44bba4c098f..5ae2a11710a 100644 --- a/source/blender/python/intern/bpy_app_ffmpeg.c +++ b/source/blender/python/intern/bpy_app_ffmpeg.c @@ -26,11 +26,8 @@ #include <Python.h> #include "BLI_utildefines.h" -#include "BLI_callbacks.h" -#include "RNA_types.h" -#include "RNA_access.h" -#include "bpy_rna.h" +#include "bpy_app_ffmpeg.h" #ifdef WITH_FFMPEG #include <libavcodec/avcodec.h> @@ -80,8 +77,10 @@ static PyObject *make_ffmpeg_info(void) return NULL; } +#if 0 // UNUSED #define SetIntItem(flag) \ PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyLong_FromLong(flag)) +#endif #define SetStrItem(str) \ PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyUnicode_FromString(str)) #define SetObjItem(obj) \ @@ -121,7 +120,7 @@ static PyObject *make_ffmpeg_info(void) return NULL; } -#undef SetIntItem +// #undef SetIntItem #undef SetStrItem #undef SetObjItem diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index bab5a83a6ed..4d7f2080bbc 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -37,6 +37,8 @@ #include "bpy_rna.h" #include "bpy_app_handlers.h" +#include "BPY_extern.h" + void bpy_app_generic_callback(struct Main *main, struct ID *id, void *arg); static PyTypeObject BlenderAppCbType; diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 9cd0bdd090a..85f6163c721 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -53,6 +53,7 @@ #include "BLI_path_util.h" #include "BLI_fileops.h" +#include "BLI_listbase.h" #include "BLI_math_base.h" #include "BLI_string.h" #include "BLI_string_utf8.h" @@ -383,6 +384,7 @@ typedef struct { static int python_script_exec(bContext *C, const char *fn, struct Text *text, struct ReportList *reports, const short do_jump) { + Main *bmain_old = CTX_data_main(C); PyObject *main_mod = NULL; PyObject *py_dict = NULL, *py_result = NULL; PyGILState_STATE gilstate; @@ -461,7 +463,11 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, if (!py_result) { if (text) { if (do_jump) { - python_script_error_jump_text(text); + /* ensure text is valid before use, the script may have freed its self */ + Main *bmain_new = CTX_data_main(C); + if ((bmain_old == bmain_new) && (BLI_findindex(&bmain_new->text, text) != -1)) { + python_script_error_jump_text(text); + } } } BPy_errors_to_report(reports); @@ -680,11 +686,20 @@ void BPY_modules_load_user(bContext *C) int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result) { - PyObject *pyctx = (PyObject *)CTX_py_dict_get(C); - PyObject *item = PyDict_GetItemString(pyctx, member); + PyGILState_STATE gilstate; + int use_gil = !PYC_INTERPRETER_ACTIVE; + + PyObject *pyctx; + PyObject *item; PointerRNA *ptr = NULL; int done = FALSE; + if (use_gil) + gilstate = PyGILState_Ensure(); + + pyctx = (PyObject *)CTX_py_dict_get(C); + item = PyDict_GetItemString(pyctx, member); + if (item == NULL) { /* pass */ } @@ -720,7 +735,8 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data); } else { - printf("List item not a valid type\n"); + printf("PyContext: '%s' list item not a valid type in sequece type '%s'\n", + member, Py_TYPE(item)->tp_name); } } @@ -740,6 +756,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * } } + if (use_gil) + PyGILState_Release(gilstate); + return done; } diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c index db97d361c73..13d8cedf907 100644 --- a/source/blender/python/intern/bpy_interface_atexit.c +++ b/source/blender/python/intern/bpy_interface_atexit.c @@ -32,6 +32,7 @@ #include <Python.h> #include "bpy_util.h" +#include "bpy.h" /* own include */ #include "WM_api.h" diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 40ec8136eb7..7571fe0f75e 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -55,6 +55,7 @@ #include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */ #include "bpy_util.h" +#include "bpy_library.h" #ifdef USE_RNA_DATABLOCKS # include "bpy_rna.h" @@ -426,7 +427,7 @@ static PyObject *bpy_lib_dir(BPy_Library *self) } -int bpy_lib_init(PyObject *mod_par) +int BPY_library_module(PyObject *mod_par) { static PyMethodDef load_meth = {"load", (PyCFunction)bpy_lib_load, METH_STATIC | METH_VARARGS | METH_KEYWORDS, diff --git a/source/blender/python/intern/bpy_library.h b/source/blender/python/intern/bpy_library.h new file mode 100644 index 00000000000..1b68007b704 --- /dev/null +++ b/source/blender/python/intern/bpy_library.h @@ -0,0 +1,32 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_library.h + * \ingroup pythonintern + */ + +#ifndef __BPY_LIBRARY_H__ +#define __BPY_LIBRARY_H__ + +int BPY_library_module(PyObject *); + +#endif /* __BPY_LIBRARY_H__ */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4ae8e821298..8ec8c4c41ba 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -37,6 +37,8 @@ #include "RNA_types.h" +#include "BPY_extern.h" + #include "bpy_rna.h" #include "bpy_rna_anim.h" #include "bpy_props.h" @@ -45,7 +47,7 @@ #include "bpy_intern_string.h" #ifdef USE_PYRNA_INVALIDATE_WEAKREF -#include "MEM_guardedalloc.h" +# include "MEM_guardedalloc.h" #endif #include "BLI_dynstr.h" @@ -55,7 +57,7 @@ #include "BLI_utildefines.h" #ifdef USE_PYRNA_INVALIDATE_WEAKREF -#include "BLI_ghash.h" +# include "BLI_ghash.h" #endif #include "RNA_enum_types.h" @@ -78,7 +80,7 @@ #include "../generic/py_capi_utils.h" #ifdef WITH_INTERNATIONAL -#include "BLF_translation.h" +# include "BLF_translation.h" #endif #define USE_PEDANTIC_WRITE @@ -2150,10 +2152,10 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons * -1: exception set * 0: not found * 1: found */ -int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyObject *key, - const char *err_prefix, const short err_not_found, - PointerRNA *r_ptr - ) +static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyObject *key, + const char *err_prefix, const short err_not_found, + PointerRNA *r_ptr + ) { char *keyname; @@ -5908,7 +5910,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = { NULL }; -PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop) +static PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop) { BPy_PropertyCollectionIterRNA *self = PyObject_New(BPy_PropertyCollectionIterRNA, &pyrna_prop_collection_iter_Type); diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 113367788b6..1fb4b116872 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -175,6 +175,10 @@ PyObject *BPY_rna_types(void); PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr); PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop); +/* extern'd by other modules which don't deal closely with RNA */ +PyObject *pyrna_id_CreatePyObject(struct ID *id); +int pyrna_id_FromPyObject(PyObject *obj, struct ID **id); + /* operators also need this to set args */ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const char *error_prefix); PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop); diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index b7a45897668..69839514a12 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -52,9 +52,6 @@ #include "bpy_util.h" #include "bpy_rna_anim.h" -#define TRUE 1 -#define FALSE 0 - /* for keyframes and drivers */ static int pyrna_struct_anim_args_parse( PointerRNA *ptr, const char *error_prefix, const char *path, diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index 7e2da5b1818..69fe0c48a41 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -74,8 +74,7 @@ static struct PyModuleDef gpumodule = { NULL, NULL, NULL, NULL, NULL }; -PyMODINIT_FUNC -PyInit_gpu(void) +static PyObject *PyInit_gpu(void) { PyObject *m; diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c index 50d2e88f210..e0508359e13 100644 --- a/source/blender/python/intern/stubs.c +++ b/source/blender/python/intern/stubs.c @@ -28,12 +28,15 @@ * \ingroup pythonintern */ +#include "BLI_utildefines.h" + +#include "BPY_extern.h" /* python, will come back */ //void BPY_script_exec(void) {} //void BPY_python_start(void) {} //void BPY_text_free_code(void) {} -void BPY_pyconstraint_exec(void) {} -void BPY_pyconstraint_target(void) {} -int BPY_is_pyconstraint(void) { return 0;} -void BPY_pyconstraint_update(void) {} +void BPY_pyconstraint_exec(struct bPythonConstraint *UNUSED(con), struct bConstraintOb *UNUSED(cob), struct ListBase *UNUSED(targets)) {} +void BPY_pyconstraint_target(struct bPythonConstraint *UNUSED(con), struct bConstraintTarget *UNUSED(ct)) {} +int BPY_is_pyconstraint(struct Text *UNUSED(text)) { return 0;} +void BPY_pyconstraint_update(struct Object *UNUSED(owner), struct bConstraint *UNUSED(con)) {} |