diff options
Diffstat (limited to 'source/blender/python')
28 files changed, 486 insertions, 115 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c index bc14e1ac3a6..f74737ba8f4 100644 --- a/source/blender/python/bmesh/bmesh_py_api.c +++ b/source/blender/python/bmesh/bmesh_py_api.c @@ -108,7 +108,7 @@ PyDoc_STRVAR(bpy_bm_update_edit_mesh_doc, " :type mesh: :class:`bpy.types.Mesh`\n" " :arg tessface: Option to recalculate n-gon tessellation.\n" " :type tessface: boolean\n" -" :arg destructive: Use when grometry has been added or removed.\n" +" :arg destructive: Use when geometry has been added or removed.\n" " :type destructive: boolean\n" ); static PyObject *bpy_bm_update_edit_mesh(PyObject *UNUSED(self), PyObject *args, PyObject *kw) diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c index 84c1031a24a..a4c057acac2 100644 --- a/source/blender/python/bmesh/bmesh_py_ops_call.c +++ b/source/blender/python/bmesh/bmesh_py_ops_call.c @@ -69,9 +69,10 @@ static int bpy_bm_op_as_py_error(BMesh *bm) * \param htype Test \a value matches this type. * \param descr Description text. */ -static int bpy_slot_from_py_elem_check(BPy_BMElem *value, BMesh *bm, const char htype, - /* for error messages */ - const char *opname, const char *slot_name, const char *descr) +static int bpy_slot_from_py_elem_check( + BPy_BMElem *value, BMesh *bm, const char htype, + /* for error messages */ + const char *opname, const char *slot_name, const char *descr) { if (!BPy_BMElem_Check(value) || !(value->ele->head.htype & htype)) @@ -107,10 +108,11 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value, BMesh *bm, const char * \param htype_bmo The type(s) supported by the target slot. * \param descr Description text. */ -static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value, BMesh *bm, - const char htype_py, const char htype_bmo, - /* for error messages */ - const char *opname, const char *slot_name, const char *descr) +static int bpy_slot_from_py_elemseq_check( + BPy_BMGeneric *value, BMesh *bm, + const char htype_py, const char htype_bmo, + /* for error messages */ + const char *opname, const char *slot_name, const char *descr) { if (value->bm == NULL) { PyErr_Format(PyExc_TypeError, @@ -142,9 +144,10 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value, BMesh *bm, /** * Use for giving py args to an operator. */ -static int bpy_slot_from_py(BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObject *value, - /* the are just for exception messages */ - const char *opname, const char *slot_name) +static int bpy_slot_from_py( + BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObject *value, + /* the are just for exception messages */ + const char *opname, const char *slot_name) { switch (slot->slot_type) { case BMO_OP_SLOT_BOOL: diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 20ee872b3be..14fdada66bb 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -3251,17 +3251,17 @@ static PyObject *bpy_bmloop_repr(BPy_BMLoop *self) /* Types * ===== */ -PyTypeObject BPy_BMesh_Type = {{{0}}}; -PyTypeObject BPy_BMVert_Type = {{{0}}}; -PyTypeObject BPy_BMEdge_Type = {{{0}}}; -PyTypeObject BPy_BMFace_Type = {{{0}}}; -PyTypeObject BPy_BMLoop_Type = {{{0}}}; -PyTypeObject BPy_BMElemSeq_Type = {{{0}}}; -PyTypeObject BPy_BMVertSeq_Type = {{{0}}}; -PyTypeObject BPy_BMEdgeSeq_Type = {{{0}}}; -PyTypeObject BPy_BMFaceSeq_Type = {{{0}}}; -PyTypeObject BPy_BMLoopSeq_Type = {{{0}}}; -PyTypeObject BPy_BMIter_Type = {{{0}}}; +PyTypeObject BPy_BMesh_Type; +PyTypeObject BPy_BMVert_Type; +PyTypeObject BPy_BMEdge_Type; +PyTypeObject BPy_BMFace_Type; +PyTypeObject BPy_BMLoop_Type; +PyTypeObject BPy_BMElemSeq_Type; +PyTypeObject BPy_BMVertSeq_Type; +PyTypeObject BPy_BMEdgeSeq_Type; +PyTypeObject BPy_BMFaceSeq_Type; +PyTypeObject BPy_BMLoopSeq_Type; +PyTypeObject BPy_BMIter_Type; @@ -3757,10 +3757,11 @@ void bpy_bm_generic_invalidate(BPy_BMGeneric *self) * * The 'bm_r' value is assigned when empty, and used when set. */ -void *BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_size, - const char htype, - const bool do_unique_check, const bool do_bm_check, - const char *error_prefix) +void *BPy_BMElem_PySeq_As_Array( + BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_size, + const char htype, + const bool do_unique_check, const bool do_bm_check, + const char *error_prefix) { BMesh *bm = (r_bm && *r_bm) ? *r_bm : NULL; PyObject *seq_fast; diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h index 66059a642d1..630afcb32c0 100644 --- a/source/blender/python/bmesh/bmesh_py_types.h +++ b/source/blender/python/bmesh/bmesh_py_types.h @@ -158,10 +158,11 @@ PyObject *BPy_BMIter_CreatePyObject(BMesh *bm); PyObject *BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele); /* just checks type and creates v/e/f/l */ -void *BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_size, - const char htype, - const bool do_unique_check, const bool do_bm_check, - const char *error_prefix); +void *BPy_BMElem_PySeq_As_Array( + BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_size, + const char htype, + const bool do_unique_check, const bool do_bm_check, + const char *error_prefix); PyObject *BPy_BMElem_Array_As_Tuple(BMesh *bm, BMHeader **elem, Py_ssize_t elem_len); PyObject *BPy_BMVert_Array_As_Tuple(BMesh *bm, BMVert **elem, Py_ssize_t elem_len); diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 7fcc3813096..1d5f0d7ac37 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -791,12 +791,12 @@ PyDoc_STRVAR(bpy_bmlayeritem_type_doc, ); -PyTypeObject BPy_BMLayerAccessVert_Type = {{{0}}}; /* bm.verts.layers */ -PyTypeObject BPy_BMLayerAccessEdge_Type = {{{0}}}; /* bm.edges.layers */ -PyTypeObject BPy_BMLayerAccessFace_Type = {{{0}}}; /* bm.faces.layers */ -PyTypeObject BPy_BMLayerAccessLoop_Type = {{{0}}}; /* bm.loops.layers */ -PyTypeObject BPy_BMLayerCollection_Type = {{{0}}}; /* bm.loops.layers.uv */ -PyTypeObject BPy_BMLayerItem_Type = {{{0}}}; /* bm.loops.layers.uv["UVMap"] */ +PyTypeObject BPy_BMLayerAccessVert_Type; /* bm.verts.layers */ +PyTypeObject BPy_BMLayerAccessEdge_Type; /* bm.edges.layers */ +PyTypeObject BPy_BMLayerAccessFace_Type; /* bm.faces.layers */ +PyTypeObject BPy_BMLayerAccessLoop_Type; /* bm.loops.layers */ +PyTypeObject BPy_BMLayerCollection_Type; /* bm.loops.layers.uv */ +PyTypeObject BPy_BMLayerItem_Type; /* bm.loops.layers.uv["UVMap"] */ PyObject *BPy_BMLayerAccess_CreatePyObject(BMesh *bm, const char htype) diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index 94f38ffdec7..92c11a03433 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -99,7 +99,7 @@ static PyGetSetDef bpy_bmtexpoly_getseters[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; -static PyTypeObject BPy_BMTexPoly_Type = {{{0}}}; /* bm.loops.layers.uv.active */ +static PyTypeObject BPy_BMTexPoly_Type; /* bm.loops.layers.uv.active */ static void bm_init_types_bmtexpoly(void) { @@ -212,7 +212,7 @@ static PyGetSetDef bpy_bmloopuv_getseters[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; -PyTypeObject BPy_BMLoopUV_Type = {{{0}}}; /* bm.loops.layers.uv.active */ +PyTypeObject BPy_BMLoopUV_Type; /* bm.loops.layers.uv.active */ static void bm_init_types_bmloopuv(void) { @@ -321,7 +321,7 @@ static PyGetSetDef bpy_bmvertskin_getseters[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; -static PyTypeObject BPy_BMVertSkin_Type = {{{0}}}; /* bm.loops.layers.uv.active */ +static PyTypeObject BPy_BMVertSkin_Type; /* bm.loops.layers.uv.active */ static void bm_init_types_bmvertskin(void) { @@ -750,7 +750,7 @@ static struct PyMethodDef bpy_bmdeformvert_methods[] = { {NULL, NULL, 0, NULL} }; -PyTypeObject BPy_BMDeformVert_Type = {{{0}}}; /* bm.loops.layers.uv.active */ +PyTypeObject BPy_BMDeformVert_Type; /* bm.loops.layers.uv.active */ static void bm_init_types_bmdvert(void) { diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c index 7b792e9f08e..a2dceb2a877 100644 --- a/source/blender/python/bmesh/bmesh_py_types_select.c +++ b/source/blender/python/bmesh/bmesh_py_types_select.c @@ -342,8 +342,8 @@ static PyObject *bpy_bmeditseliter_next(BPy_BMEditSelIter *self) } } -PyTypeObject BPy_BMEditSelSeq_Type = {{{0}}}; -PyTypeObject BPy_BMEditSelIter_Type = {{{0}}}; +PyTypeObject BPy_BMEditSelSeq_Type; +PyTypeObject BPy_BMEditSelIter_Type; PyObject *BPy_BMEditSel_CreatePyObject(BMesh *bm) diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index 2e32a571e3c..b7890926a85 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -84,7 +84,7 @@ static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObjec return NULL; } - if (BM_vert_edge_count(py_vert->v) > 2) { + if (BM_vert_edge_count_is_over(py_vert->v, 2)) { PyErr_SetString(PyExc_ValueError, "vert_collapse_edge(vert, edge): vert has more than 2 connected edges"); return NULL; @@ -150,7 +150,7 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje return NULL; } - if (BM_vert_edge_count(py_vert->v) > 2) { + if (BM_vert_edge_count_is_over(py_vert->v, 2)) { PyErr_SetString(PyExc_ValueError, "vert_collapse_faces(vert, edge): vert has more than 2 connected edges"); return NULL; @@ -253,7 +253,7 @@ static PyObject *bpy_bm_utils_vert_splice(PyObject *UNUSED(self), PyObject *args } /* should always succeed */ - ok = BM_vert_splice(bm, py_vert->v, py_vert_target->v); + ok = BM_vert_splice(bm, py_vert_target->v, py_vert->v); BLI_assert(ok == true); UNUSED_VARS_NDEBUG(ok); @@ -307,7 +307,7 @@ static PyObject *bpy_bm_utils_vert_separate(PyObject *UNUSED(self), PyObject *ar return NULL; } - BM_vert_separate(bm, py_vert->v, &elem, &elem_len, edge_array, edge_array_len); + BM_vert_separate(bm, py_vert->v, edge_array, edge_array_len, false, &elem, &elem_len); /* return collected verts */ ret = BPy_BMVert_Array_As_Tuple(bm, elem, elem_len); MEM_freeN(elem); @@ -670,7 +670,7 @@ PyDoc_STRVAR(bpy_bm_utils_face_vert_separate_doc, " :type face: :class:`bmesh.types.BMFace`\n" " :arg vert: A vertex in the face to separate.\n" " :type vert: :class:`bmesh.types.BMVert`\n" -" :return vert: The newly created vertex or None of failure.\n" +" :return vert: The newly created vertex or None on failure.\n" " :rtype vert: :class:`bmesh.types.BMVert`\n" "\n" " .. note::\n" @@ -749,9 +749,9 @@ PyDoc_STRVAR(bpy_bm_utils_loop_separate_doc, "\n" " Rip a vertex in a face away and add a new vertex.\n" "\n" -" :arg loop: The to separate.\n" -" :type loop: :class:`bmesh.types.BMFace`\n" -" :return vert: The newly created vertex or None of failure.\n" +" :arg loop: The loop to separate.\n" +" :type loop: :class:`bmesh.types.BMLoop`\n" +" :return vert: The newly created vertex or None on failure.\n" " :rtype vert: :class:`bmesh.types.BMVert`\n" ); static PyObject *bpy_bm_utils_loop_separate(PyObject *UNUSED(self), BPy_BMLoop *value) diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 92ac82508e5..6443c65a50a 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -478,6 +478,34 @@ error_cleanup: } #endif +PyObject *PyC_ExceptionBuffer_Simple(void) +{ + PyObject *string_io_buf; + + PyObject *error_type, *error_value, *error_traceback; + + if (!PyErr_Occurred()) + return NULL; + + PyErr_Fetch(&error_type, &error_value, &error_traceback); + + if (error_value == NULL) { + return NULL; + } + + string_io_buf = PyObject_Str(error_value); + /* Python does this too */ + if (UNLIKELY(string_io_buf == NULL)) { + string_io_buf = PyUnicode_FromFormat( + "<unprintable %s object>", Py_TYPE(error_value)->tp_name); + } + + PyErr_Restore(error_type, error_value, error_traceback); + + PyErr_Print(); + PyErr_Clear(); + return string_io_buf; +} /* string conversion, escape non-unicode chars, coerce must be set to NULL */ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index 398d7da9179..ab630d1d203 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -32,6 +32,7 @@ void PyC_ObSpit(const char *name, PyObject *var); void PyC_LineSpit(void); void PyC_StackSpit(void); PyObject * PyC_ExceptionBuffer(void); +PyObject * PyC_ExceptionBuffer_Simple(void); PyObject * PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...); PyObject * PyC_FrozenSetFromStrings(const char **strings); PyObject * PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *format, ...); diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 8296027f044..ed04152182e 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -31,6 +31,7 @@ set(INC ../../blenloader ../../editors/include ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../windowmanager @@ -69,6 +70,7 @@ set(SRC bpy_rna_callback.c bpy_traceback.c bpy_util.c + bpy_utils_previews.c bpy_utils_units.c stubs.c @@ -94,6 +96,7 @@ set(SRC bpy_rna_callback.h bpy_traceback.h bpy_util.h + bpy_utils_previews.h bpy_utils_units.h ../BPY_extern.h ) diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index ec3c017a7ed..9a5e488850e 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -48,6 +48,7 @@ #include "bpy_props.h" #include "bpy_library.h" #include "bpy_operator.h" +#include "bpy_utils_previews.h" #include "bpy_utils_units.h" #include "../generic/py_capi_utils.h" @@ -330,6 +331,7 @@ void BPy_init_modules(void) PyModule_AddObject(mod, "ops", BPY_operator_module()); PyModule_AddObject(mod, "app", BPY_app_struct()); PyModule_AddObject(mod, "_utils_units", BPY_utils_units()); + PyModule_AddObject(mod, "_utils_previews", BPY_utils_previews_module()); /* bpy context */ RNA_pointer_create(NULL, &RNA_Context, (void *)BPy_GetContext(), &ctx_ptr); diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index c8a4971847b..1cf0c44fd87 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -220,6 +220,33 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos return 0; } + + +PyDoc_STRVAR(bpy_app_binary_path_python_doc, +"String, the path to the python executable (read-only)" +); +static PyObject *bpy_app_binary_path_python_get(PyObject *UNUSED(self), void *UNUSED(closure)) +{ + /* refcount is held in BlenderAppType.tp_dict */ + static PyObject *ret = NULL; + + if (ret == NULL) { + /* only run once */ + char fullpath[1024]; + BKE_appdir_program_python_search( + fullpath, sizeof(fullpath), + PY_MAJOR_VERSION, PY_MINOR_VERSION); + ret = PyC_UnicodeFromByte(fullpath); + PyDict_SetItemString(BlenderAppType.tp_dict, "binary_path_python", ret); + } + else { + Py_INCREF(ret); + } + + return ret; + +} + PyDoc_STRVAR(bpy_app_debug_value_doc, "Int, number which can be set to non-zero values for testing purposes" ); @@ -287,6 +314,9 @@ static PyGetSetDef bpy_app_getsets[] = { {(char *)"debug_wm", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_WM}, {(char *)"debug_depsgraph", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_DEPSGRAPH}, {(char *)"debug_simdata", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_SIMDATA}, + {(char *)"debug_gpumem", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_GPU_MEM}, + + {(char *)"binary_path_python", bpy_app_binary_path_python_get, NULL, (char *)bpy_app_binary_path_python_doc, NULL}, {(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL}, {(char *)"tempdir", bpy_app_tempdir_get, NULL, (char *)bpy_app_tempdir_doc, NULL}, diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 123b111f3cb..72133badbbb 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -47,8 +47,7 @@ #include "../generic/python_utildefines.h" -typedef struct -{ +typedef struct { PyObject_HEAD /* The string used to separate context from actual message in PY_TRANSLATE RNA props. */ const char *context_separator; @@ -821,3 +820,12 @@ PyObject *BPY_app_translations_struct(void) return ret; } + +void BPY_app_translations_end(void) +{ + /* Incase the object remains in a module's namespace, see T44127. */ +#ifdef WITH_INTERNATIONAL + _clear_translations_cache(); +#endif +} + diff --git a/source/blender/python/intern/bpy_app_translations.h b/source/blender/python/intern/bpy_app_translations.h index 704307574d0..e04c2484ecc 100644 --- a/source/blender/python/intern/bpy_app_translations.h +++ b/source/blender/python/intern/bpy_app_translations.h @@ -28,5 +28,6 @@ #define __BPY_APP_TRANSLATIONS_H__ PyObject *BPY_app_translations_struct(void); +void BPY_app_translations_end(void); #endif /* __BPY_APP_TRANSLATIONS_H__ */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 5b4db89a41a..4be63042c1e 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -61,6 +61,8 @@ #include "bpy_traceback.h" #include "bpy_intern_string.h" +#include "bpy_app_translations.h" + #include "DNA_text_types.h" #include "BKE_appdir.h" @@ -358,6 +360,9 @@ void BPY_python_end(void) bpy_intern_string_exit(); + /* bpy.app modules that need cleanup */ + BPY_app_translations_end(); + #ifndef WITH_PYTHON_MODULE BPY_atexit_unregister(); /* without this we get recursive calls to WM_exit */ @@ -590,7 +595,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const bool ver if (error_ret) { if (verbose) { - BPy_errors_to_report(CTX_wm_reports(C)); + BPy_errors_to_report_ex(CTX_wm_reports(C), false, false); } else { PyErr_Clear(); @@ -831,7 +836,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy) static void dealloc_obj_dealloc(PyObject *self); -static PyTypeObject dealloc_obj_Type = {{{0}}}; +static PyTypeObject dealloc_obj_Type; /* use our own dealloc so we can free a property if we use one */ static void dealloc_obj_dealloc(PyObject *self) diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index aad47d14b7c..8309938b632 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -100,7 +100,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) char *enum_str = BPy_enum_as_string(operator_context_items); PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s.poll\" error, " - "expected a string enum in (%.200s)", + "expected a string enum in (%s)", opname, enum_str); MEM_freeN(enum_str); return NULL; @@ -186,7 +186,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) char *enum_str = BPy_enum_as_string(operator_context_items); PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s\" error, " - "expected a string enum in (%.200s)", + "expected a string enum in (%s)", opname, enum_str); MEM_freeN(enum_str); return NULL; diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 8370aea4c99..b0fae243182 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -68,7 +68,8 @@ static EnumPropertyItem property_flag_items[] = { {0, NULL, 0, NULL, NULL}}; #define BPY_PROPDEF_OPTIONS_DOC \ -" :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE', 'LIBRARY_EDITABLE', 'PROPORTIONAL'].\n" \ +" :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE', 'LIBRARY_EDITABLE', 'PROPORTIONAL'," \ + "'TEXTEDIT_UPDATE'].\n" \ " :type options: set\n" \ static EnumPropertyItem property_flag_enum_items[] = { @@ -1480,15 +1481,26 @@ static EnumPropertyItem *bpy_prop_enum_itemf_cb(struct bContext *C, PointerRNA * EnumPropertyItem *eitems = NULL; int err = 0; - bpy_context_set(C, &gilstate); + if (C) { + bpy_context_set(C, &gilstate); + } + else { + gilstate = PyGILState_Ensure(); + } args = PyTuple_New(2); self = pyrna_struct_as_instance(ptr); PyTuple_SET_ITEM(args, 0, self); /* now get the context */ - PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module); - Py_INCREF(bpy_context_module); + if (C) { + PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module); + Py_INCREF(bpy_context_module); + } + else { + PyTuple_SET_ITEM(args, 1, Py_None); + Py_INCREF(Py_None); + } items = PyObject_CallObject(py_func, args); @@ -1529,8 +1541,13 @@ static EnumPropertyItem *bpy_prop_enum_itemf_cb(struct bContext *C, PointerRNA * eitems = DummyRNA_NULL_items; } + if (C) { + bpy_context_clear(C, &gilstate); + } + else { + PyGILState_Release(gilstate); + } - bpy_context_clear(C, &gilstate); return eitems; } @@ -2617,7 +2634,7 @@ PyDoc_STRVAR(BPy_EnumProperty_doc, " Note the item is optional.\n" " For dynamic values a callback can be passed which returns a list in\n" " the same format as the static list.\n" -" This function must take 2 arguments (self, context)\n" +" This function must take 2 arguments (self, context), **context may be None**.\n" " WARNING: There is a known bug with using a callback,\n" " Python must keep a reference to the strings returned or Blender will crash.\n" " :type items: sequence of string tuples or a function\n" @@ -2965,9 +2982,10 @@ static struct PyMethodDef props_methods[] = { static struct PyModuleDef props_module = { PyModuleDef_HEAD_INIT, "bpy.props", - "This module defines properties to extend blenders internal data, the result of these functions" - " is used to assign properties to classes registered with blender and can't be used directly.\n" - ".. warning:: All parameters to these functions must be passed as keywords.", + "This module defines properties to extend Blender's internal data. The result of these functions" + " is used to assign properties to classes registered with Blender and can't be used directly.\n" + "\n" + ".. warning:: All parameters to these functions must be passed as keywords.\n", -1, /* multiple "initialization" just copies the module dict. */ props_methods, NULL, NULL, NULL, NULL diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index fadc50e3317..af5ec03c7ed 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -177,7 +177,7 @@ static GHash *id_weakref_pool_get(ID *id) if (weakinfo_hash == NULL) { /* we're using a ghash as a set, could use libHX's HXMAP_SINGULAR but would be an extra dep. */ weakinfo_hash = BLI_ghash_ptr_new("rna_id"); - BLI_ghash_insert(id_weakref_pool, (void *)id, weakinfo_hash); + BLI_ghash_insert(id_weakref_pool, id, weakinfo_hash); } return weakinfo_hash; @@ -203,7 +203,7 @@ static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna) Py_DECREF(weakref_cb_py); /* function owned by the weakref now */ /* important to add at the end, since first removal looks at the end */ - BLI_ghash_insert(weakinfo_hash, (void *)weakref, id); /* using a hash table as a set, all 'id's are the same */ + BLI_ghash_insert(weakinfo_hash, weakref, id); /* using a hash table as a set, all 'id's are the same */ /* weakinfo_hash owns the weakref */ } @@ -1830,25 +1830,23 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb RNA_property_pointer_set(ptr, prop, param->ptr); } else { + raise_error = true; + } + } + + if (raise_error) { + if (pyrna_struct_validity_check(param) == -1) { + /* error set */ + } + else { PointerRNA tmp; RNA_pointer_create(NULL, ptr_type, NULL, &tmp); PyErr_Format(PyExc_TypeError, - "%.200s %.200s.%.200s expected a %.200s type. not %.200s", + "%.200s %.200s.%.200s expected a %.200s type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), RNA_struct_identifier(param->ptr.type)); - Py_XDECREF(value_new); return -1; } - } - - if (raise_error) { - PointerRNA tmp; - RNA_pointer_create(NULL, ptr_type, NULL, &tmp); - PyErr_Format(PyExc_TypeError, - "%.200s %.200s.%.200s expected a %.200s type, not %.200s", - error_prefix, RNA_struct_identifier(ptr->type), - RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), - RNA_struct_identifier(param->ptr.type)); Py_XDECREF(value_new); return -1; } } diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 93183a4f320..e876adfa58e 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -82,14 +82,9 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool } -short BPy_errors_to_report(ReportList *reports) +bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const bool use_location) { PyObject *pystring; - PyObject *pystring_format = NULL; /* workaround, see below */ - const char *cstring; - - const char *filename; - int lineno; if (!PyErr_Occurred()) return 1; @@ -101,31 +96,56 @@ short BPy_errors_to_report(ReportList *reports) return 1; } - pystring = PyC_ExceptionBuffer(); + if (use_full) { + pystring = PyC_ExceptionBuffer(); + } + else { + pystring = PyC_ExceptionBuffer_Simple(); + } if (pystring == NULL) { BKE_report(reports, RPT_ERROR, "Unknown py-exception, could not convert"); return 0; } - - PyC_FileAndNum(&filename, &lineno); - if (filename == NULL) - filename = "<unknown location>"; - - cstring = _PyUnicode_AsString(pystring); + + if (use_location) { + const char *filename; + int lineno; + + PyObject *pystring_format; /* workaround, see below */ + const char *cstring; + + PyC_FileAndNum(&filename, &lineno); + if (filename == NULL) { + filename = "<unknown location>"; + } #if 0 /* ARG!. workaround for a bug in blenders use of vsnprintf */ - BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", cstring, filename, lineno); + BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", _PyUnicode_AsString(pystring), filename, lineno); #else - pystring_format = PyUnicode_FromFormat(TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno); - cstring = _PyUnicode_AsString(pystring_format); - BKE_report(reports, RPT_ERROR, cstring); + pystring_format = PyUnicode_FromFormat( + TIP_("%s\nlocation: %s:%d\n"), + _PyUnicode_AsString(pystring), filename, lineno); + + cstring = _PyUnicode_AsString(pystring_format); + BKE_report(reports, RPT_ERROR, cstring); + + /* not exactly needed. just for testing */ + fprintf(stderr, TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno); + + Py_DECREF(pystring_format); /* workaround */ #endif + } + else { + BKE_report(reports, RPT_ERROR, _PyUnicode_AsString(pystring)); + } - /* not exactly needed. just for testing */ - fprintf(stderr, TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno); Py_DECREF(pystring); - Py_DECREF(pystring_format); /* workaround */ return 1; } + +bool BPy_errors_to_report(ReportList *reports) +{ + return BPy_errors_to_report_ex(reports, true, true); +}
\ No newline at end of file diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h index d19696aa230..1ae00a7fb02 100644 --- a/source/blender/python/intern/bpy_util.h +++ b/source/blender/python/intern/bpy_util.h @@ -40,7 +40,8 @@ char *BPy_enum_as_string(struct EnumPropertyItem *item); /* error reporting */ short BPy_reports_to_error(struct ReportList *reports, PyObject *exception, const bool clear); -short BPy_errors_to_report(struct ReportList *reports); +bool BPy_errors_to_report_ex(struct ReportList *reports, const bool use_full, const bool use_location); +bool BPy_errors_to_report(struct ReportList *reports); /* TODO - find a better solution! */ struct bContext *BPy_GetContext(void); diff --git a/source/blender/python/intern/bpy_utils_previews.c b/source/blender/python/intern/bpy_utils_previews.c new file mode 100644 index 00000000000..fed7c7210de --- /dev/null +++ b/source/blender/python/intern/bpy_utils_previews.c @@ -0,0 +1,188 @@ +/* + * ***** 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): Bastien Montagne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_utils_previews.c + * \ingroup pythonintern + * + * This file defines a singleton py object accessed via 'bpy.utils.previews', + * which exposes low-level API for custom previews/icons. + * It is replaced in final API by an higher-level python wrapper, that handles previews by addon, + * and automatically release them on deletion. + */ + +#include <Python.h> +#include <structmember.h> + +#include "BLI_utildefines.h" + +#include "RNA_types.h" +#include "RNA_access.h" + +#include "BPY_extern.h" +#include "bpy_utils_previews.h" +#include "bpy_rna.h" + +#include "MEM_guardedalloc.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "IMB_thumbs.h" + +#include "BKE_icons.h" + +#include "DNA_ID.h" + +#include "../generic/python_utildefines.h" + +#define STR_SOURCE_TYPES "'IMAGE', 'MOVIE', 'BLEND', 'FONT'" + +PyDoc_STRVAR(bpy_utils_previews_new_doc, +".. method:: new(name)\n" +"\n" +" Generate a new empty preview, or return existing one matching ``name``.\n" +"\n" +" :arg name: The name (unique id) identifying the preview.\n" +" :type name: string\n" +" :return: The Preview matching given name, or a new empty one.\n" +" :rtype: :class:`bpy.types.ImagePreview`\n" +); +static PyObject *bpy_utils_previews_new(PyObject *UNUSED(self), PyObject *args) +{ + char *name; + PreviewImage *prv; + PointerRNA ptr; + + if (!PyArg_ParseTuple(args, "s:new", &name)) { + return NULL; + } + + prv = BKE_previewimg_cached_ensure(name); + RNA_pointer_create(NULL, &RNA_ImagePreview, prv, &ptr); + + return pyrna_struct_CreatePyObject(&ptr); +} + +PyDoc_STRVAR(bpy_utils_previews_load_doc, +".. method:: load(name, filepath, filetype, force_reload=False)\n" +"\n" +" Generate a new preview from given file path, or return existing one matching ``name``.\n" +"\n" +" :arg name: The name (unique id) identifying the preview.\n" +" :type name: string\n" +" :arg filepath: The file path to generate the preview from.\n" +" :type filepath: string\n" +" :arg filetype: The type of file, needed to generate the preview in [" STR_SOURCE_TYPES "].\n" +" :type filetype: string\n" +" :arg force_reload: If True, force running thumbnail manager even if preview already exists in cache.\n" +" :type force_reload: bool\n" +" :return: The Preview matching given name, or a new empty one.\n" +" :rtype: :class:`bpy.types.ImagePreview`\n" +); +static PyObject *bpy_utils_previews_load(PyObject *UNUSED(self), PyObject *args) +{ + char *name, *path, *path_type_s; + int path_type, force_reload = false; + + PreviewImage *prv; + PointerRNA ptr; + + if (!PyArg_ParseTuple( args, "sss|p:load", &name, &path, &path_type_s, &force_reload)) { + return NULL; + } + + if (STREQ(path_type_s, "IMAGE")) { + path_type = THB_SOURCE_IMAGE; + } + else if (STREQ(path_type_s, "MOVIE")) { + path_type = THB_SOURCE_MOVIE; + } + else if (STREQ(path_type_s, "BLEND")) { + path_type = THB_SOURCE_BLEND; + } + else if (STREQ(path_type_s, "FONT")) { + path_type = THB_SOURCE_FONT; + } + else { + PyErr_Format(PyExc_ValueError, + "load: invalid '%s' filetype, only [" STR_SOURCE_TYPES "] " + "are supported", path_type_s); + return NULL; + } + + prv = BKE_previewimg_cached_thumbnail_read(name, path, path_type, force_reload); + RNA_pointer_create(NULL, &RNA_ImagePreview, prv, &ptr); + + return pyrna_struct_CreatePyObject(&ptr); +} + +PyDoc_STRVAR(bpy_utils_previews_release_doc, +".. method:: release(name)\n" +"\n" +" Release (free) a previously created preview.\n" +"\n" +"\n" +" :arg name: The name (unique id) identifying the preview.\n" +" :type name: string\n" +); +static PyObject *bpy_utils_previews_release(PyObject *UNUSED(self), PyObject *args) +{ + char *name; + + if (!PyArg_ParseTuple(args, "s:release", &name)) { + return NULL; + } + + BKE_previewimg_cached_release(name); + + Py_RETURN_NONE; +} + +static struct PyMethodDef bpy_utils_previews_methods[] = { + /* Can't use METH_KEYWORDS alone, see http://bugs.python.org/issue11587 */ + {"new", (PyCFunction)bpy_utils_previews_new, METH_VARARGS, bpy_utils_previews_new_doc}, + {"load", (PyCFunction)bpy_utils_previews_load, METH_VARARGS, bpy_utils_previews_load_doc}, + {"release", (PyCFunction)bpy_utils_previews_release, METH_VARARGS, bpy_utils_previews_release_doc}, + {NULL, NULL, 0, NULL} +}; + +PyDoc_STRVAR(bpy_utils_previews_doc, +"This object contains basic static methods to handle cached (non-ID) previews in Blender\n" +"(low-level API, not exposed to final users)." +); +static struct PyModuleDef bpy_utils_previews_module = { + PyModuleDef_HEAD_INIT, + "bpy._utils_previews", + bpy_utils_previews_doc, + 0, + bpy_utils_previews_methods, + NULL, NULL, NULL, NULL +}; + + +PyObject *BPY_utils_previews_module(void) +{ + PyObject *submodule; + + submodule = PyModule_Create(&bpy_utils_previews_module); + + return submodule; +} diff --git a/source/blender/python/intern/bpy_utils_previews.h b/source/blender/python/intern/bpy_utils_previews.h new file mode 100644 index 00000000000..3d7ade04b9f --- /dev/null +++ b/source/blender/python/intern/bpy_utils_previews.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): Bastien Montagne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_utils_previews.h + * \ingroup pythonintern + */ + +#ifndef __BPY_UTILS_PREVIEWS_H__ +#define __BPY_UTILS_PREVIEWS_H__ + +PyObject *BPY_utils_previews_module(void); + +#endif /* __BPY_UTILS_PREVIEWS_H__ */ diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c index a6df8f54cc3..d40e7e070ac 100644 --- a/source/blender/python/intern/bpy_utils_units.c +++ b/source/blender/python/intern/bpy_utils_units.c @@ -155,18 +155,18 @@ static bool bpyunits_validate(const char *usys_str, const char *ucat_str, int *r } PyDoc_STRVAR(bpyunits_to_value_doc, -".. method:: to_value(unit_system, unit_category, str_input, [str_ref_unit=None])\n" +".. method:: to_value(unit_system, unit_category, str_input, str_ref_unit=None)\n" "\n" " Convert a given input string into a float value.\n" "\n" " :arg unit_system: The unit system, from :attr:`bpy.utils.units.systems`.\n" " :type unit_system: string\n" -" :arg unit_category: The category of data we are converting (length, area, rotation, etc.), " +" :arg unit_category: The category of data we are converting (length, area, rotation, etc.),\n" " from :attr:`bpy.utils.units.categories`.\n" " :type unit_category: string\n" " :arg str_input: The string to convert to a float value.\n" " :type str_input: string\n" -" :arg str_ref_unit: A reference string from which to extract a default unit, if none is found in :arg:`str_input`.\n" +" :arg str_ref_unit: A reference string from which to extract a default unit, if none is found in ``str_input``.\n" " :type str_ref_unit: string or None\n" " :return: The converted/interpreted value.\n" " :rtype: float\n" @@ -221,13 +221,13 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj } PyDoc_STRVAR(bpyunits_to_string_doc, -".. method:: to_string(unit_system, unit_category, value, [precision=3, [split_unit=False, [compatible_unit=False]]])\n" +".. method:: to_string(unit_system, unit_category, value, precision=3, split_unit=False, compatible_unit=False)\n" "\n" " Convert a given input float value into a string with units.\n" "\n" " :arg unit_system: The unit system, from :attr:`bpy.utils.units.systems`.\n" " :type unit_system: string\n" -" :arg unit_category: The category of data we are converting (length, area, rotation, etc.), " +" :arg unit_category: The category of data we are converting (length, area, rotation, etc.),\n" " from :attr:`bpy.utils.units.categories`.\n" " :type unit_category: string\n" " :arg value: The value to convert to a string.\n" diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index e4580e8035b..f933c02390c 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -79,7 +79,17 @@ static PyObject *PyInit_gpu(void) if (m == NULL) return NULL; + /* device constant groups */ + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_MISC); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_LAMP); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_OBJECT); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_SAMPLER); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_MIST); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_WORLD); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_MAT); + /* device constants */ + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_NONE); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWMAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_MAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWIMAT); @@ -92,9 +102,30 @@ static PyObject *PyInit_gpu(void) PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNPERSMAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNENERGY); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNCOL); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_ATT1); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_ATT2); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DISTANCE); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_SPOTBLEND); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_SPOTSIZE); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_SAMPLER_2DBUFFER); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_SAMPLER_2DIMAGE); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_SAMPLER_2DSHADOW); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_ENABLE); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_START); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_DISTANCE); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_INTENSITY); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_TYPE); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_COLOR); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_HORIZON_COLOR); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_AMBIENT_COLOR); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_ALPHA); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_AMB); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_DIFFRGB); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_EMIT); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_HARD); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_REF); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_SPEC); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_SPECRGB); PY_MODULE_ADD_CONSTANT(m, GPU_DATA_1I); PY_MODULE_ADD_CONSTANT(m, GPU_DATA_1F); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 67905f8e340..817173c5bc6 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1858,7 +1858,7 @@ static PyObject *Matrix_zero(MatrixObject *self) if (BaseMath_Prepare_ForWrite(self) == -1) return NULL; - fill_vn_fl(self->matrix, self->num_col * self->num_row, 0.0f); + copy_vn_fl(self->matrix, self->num_col * self->num_row, 0.0f); if (BaseMath_WriteCallback(self) == -1) return NULL; @@ -2757,7 +2757,7 @@ PyDoc_STRVAR(matrix_doc, " matrices from 2x2 up to 4x4.\n" "\n" " :param rows: Sequence of rows.\n" -" When ommitted, a 4x4 identity matrix is constructed.\n" +" When ommitted, a 4x4 identity matrix is constructed.\n" " :type rows: 2d number sequence\n" ); PyTypeObject matrix_Type = { diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index a33b55c35dc..3d7a505eb12 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -76,7 +76,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } - fill_vn_fl(vec, size, 0.0f); + copy_vn_fl(vec, size, 0.0f); break; case 1: if ((size = mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { @@ -142,7 +142,7 @@ static PyObject *C_Vector_Fill(PyObject *cls, PyObject *args) return NULL; } - fill_vn_fl(vec, size, fill); + copy_vn_fl(vec, size, fill); return Vector_CreatePyObject_alloc(vec, size, (PyTypeObject *)cls); } @@ -339,7 +339,7 @@ static PyObject *Vector_zero(VectorObject *self) if (BaseMath_Prepare_ForWrite(self) == -1) return NULL; - fill_vn_fl(self->vec, self->size, 0.0f); + copy_vn_fl(self->vec, self->size, 0.0f); if (BaseMath_WriteCallback(self) == -1) return NULL; @@ -426,7 +426,7 @@ static PyObject *Vector_resize(VectorObject *self, PyObject *value) /* If the vector has increased in length, set all new elements to 0.0f */ if (size > self->size) { - fill_vn_fl(self->vec + self->size, size - self->size, 0.0f); + copy_vn_fl(self->vec + self->size, size - self->size, 0.0f); } self->size = size; @@ -465,7 +465,7 @@ static PyObject *Vector_resized(VectorObject *self, PyObject *value) return NULL; } - fill_vn_fl(vec, size, 0.0f); + copy_vn_fl(vec, size, 0.0f); memcpy(vec, self->vec, self->size * sizeof(float)); return Vector_CreatePyObject_alloc(vec, size, NULL); @@ -2236,7 +2236,7 @@ static int Vector_length_set(VectorObject *self, PyObject *value) return -1; } if (param == 0.0) { - fill_vn_fl(self->vec, self->size, 0.0f); + copy_vn_fl(self->vec, self->size, 0.0f); return 0; } @@ -3030,7 +3030,7 @@ PyObject *Vector_CreatePyObject( memcpy(self->vec, vec, size * sizeof(float)); } else { /* new empty */ - fill_vn_fl(self->vec, size, 0.0f); + copy_vn_fl(self->vec, size, 0.0f); if (size == 4) { /* do the homogeneous thing */ self->vec[3] = 1.0f; } diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index bb4080decef..ae5c058406f 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -850,7 +850,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_quad_2d_doc, "\n" " Takes 5 vectors (using only the x and y coordinates): one is the point and the next 4 define the quad, \n" " only the x and y are used from the vectors. Returns 1 if the point is within the quad, otherwise 0.\n" -" Works only with convex quads without singular edges." +" Works only with convex quads without singular edges.\n" "\n" " :arg pt: Point\n" " :type pt: :class:`mathutils.Vector`\n" |