diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-18 04:48:59 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-18 04:48:59 +0400 |
commit | c1ceab1281ccf061f03f8000bf190a082a5385d8 (patch) | |
tree | 01b9a9cfca80432d316bdad6c18c74eb025e9eb0 /source/blender/python | |
parent | 0d9c98c4bbfbc8c70c4772086dd09a51d01921ef (diff) | |
parent | 66a35e089a64d27bfc09c2225a530069eca05875 (diff) |
Merged changes in the trunk up to revision 55357.
Resolved conflicts:
release/datafiles/startup.blend
source/blender/editors/space_nla/nla_buttons.c
Also updated source/blender/blenkernel/intern/linestyle.c as a follow-up of
recent changes for the use of bool.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_ops.c | 2 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_ops_call.c | 2 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types.h | 2 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types_meshdata.h | 3 | ||||
-rw-r--r-- | source/blender/python/generic/idprop_py_api.c | 4 | ||||
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy.c | 38 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 3 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_translations.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 8 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_library.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator_wrap.c | 10 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 8 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 18 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_traceback.c | 1 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 10 |
17 files changed, 64 insertions, 55 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c index 0a2091af5df..cc87d34d769 100644 --- a/source/blender/python/bmesh/bmesh_py_ops.c +++ b/source/blender/python/bmesh/bmesh_py_ops.c @@ -159,7 +159,7 @@ static PyObject *bpy_bmesh_ops_fakemod_getattro(PyObject *UNUSED(self), PyObject const char *opname = _PyUnicode_AsString(pyname); for (i = 0; i < tot; i++) { - if (strcmp(bmo_opdefines[i]->opname, opname) == 0) { + if (STREQ(bmo_opdefines[i]->opname, opname)) { return bpy_bmesh_op_CreatePyObject(opname); } } diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c index fad3e4a35cd..4d728b76707 100644 --- a/source/blender/python/bmesh/bmesh_py_ops_call.c +++ b/source/blender/python/bmesh/bmesh_py_ops_call.c @@ -727,7 +727,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) return NULL; } - slot = BMO_slot_get(bmop.slots_in, slot_name); + slot = BMO_slot_get(bmop.slots_in, slot_name); /* now assign the value */ if (bpy_slot_from_py(bm, &bmop, slot, value, diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h index 8e6d04ec9ba..f02b94be526 100644 --- a/source/blender/python/bmesh/bmesh_py_types.h +++ b/source/blender/python/bmesh/bmesh_py_types.h @@ -168,7 +168,7 @@ int BPy_BMElem_CheckHType(PyTypeObject *type, const char htype); char *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32]); char *BPy_BMElem_StringFromHType(const char htype); -void bpy_bm_generic_invalidate(BPy_BMGeneric *self); +// void bpy_bm_generic_invalidate(BPy_BMGeneric *self); int bpy_bm_generic_valid_check(BPy_BMGeneric *self); int bpy_bm_generic_valid_check_source(BPy_BMGeneric *self, BMesh *bm_source, const char *error_prefix); diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.h b/source/blender/python/bmesh/bmesh_py_types_meshdata.h index c9e8dce97a0..8280e5c3bc5 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.h +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.h @@ -51,9 +51,6 @@ PyObject *BPy_BMTexPoly_CreatePyObject(struct MTexPoly *mloopuv); int BPy_BMLoopUV_AssignPyObject(struct MLoopUV *data, PyObject *value); PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *data); -int BPy_BMLoopUV_AssignPyObject(struct MLoopUV *data, PyObject *value); -PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *data); - int BPy_BMLoopColor_AssignPyObject(struct MLoopCol *data, PyObject *value); PyObject *BPy_BMLoopColor_CreatePyObject(struct MLoopCol *data); diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index a0e2f1a0854..85bb8125a3a 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -470,7 +470,9 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty Py_XDECREF(keys); Py_XDECREF(vals); } - else return "invalid property value"; + else { + return "invalid property value"; + } if (group->type == IDP_IDPARRAY) { IDP_AppendArray(group, prop); diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 56d9e2ac0dd..2876d7666f4 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -751,7 +751,7 @@ void *PyC_RNA_AsPointer(PyObject *value, const char *type_name) PyObject *as_pointer; PyObject *pointer; - if (!strcmp(Py_TYPE(value)->tp_name, type_name) && + if (STREQ(Py_TYPE(value)->tp_name, type_name) && (as_pointer = PyObject_GetAttrString(value, "as_pointer")) != NULL && PyCallable_Check(as_pointer)) { @@ -804,7 +804,7 @@ char *PyC_FlagSet_AsString(PyC_FlagSet *item) int PyC_FlagSet_ValueFromID_int(PyC_FlagSet *item, const char *identifier, int *value) { for ( ; item->identifier; item++) { - if (strcmp(item->identifier, identifier) == 0) { + if (STREQ(item->identifier, identifier)) { *value = item->value; return 1; } diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 1f8385288bd..01567a87fdf 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -32,13 +32,17 @@ #include <Python.h> -#include "RNA_types.h" -#include "RNA_access.h" - +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "BLI_string.h" + +#include "BKE_main.h" +#include "BKE_global.h" /* XXX, G.main only */ +#include "BKE_blender.h" #include "BKE_bpath.h" -#include "BLI_utildefines.h" + +#include "RNA_types.h" +#include "RNA_access.h" #include "bpy.h" #include "bpy_util.h" @@ -48,10 +52,6 @@ #include "bpy_library.h" #include "bpy_operator.h" -#include "BKE_main.h" -#include "BKE_global.h" /* XXX, G.main only */ -#include "BKE_blender.h" - #include "MEM_guardedalloc.h" /* external util modules */ @@ -78,7 +78,7 @@ static PyObject *bpy_script_paths(PyObject *UNUSED(self)) { PyObject *ret = PyTuple_New(2); PyObject *item; - char *path; + const char *path; path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL); item = PyUnicode_DecodeFSDefault(path ? path : ""); @@ -151,16 +151,16 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj int folder_id; static const char *kwlist[] = {"type", "subdir", NULL}; - char *path; + const char *path; if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s:user_resource", (char **)kwlist, &type, &subdir)) return NULL; /* stupid string compare */ - if (!strcmp(type, "DATAFILES")) folder_id = BLENDER_USER_DATAFILES; - else if (!strcmp(type, "CONFIG")) folder_id = BLENDER_USER_CONFIG; - else if (!strcmp(type, "SCRIPTS")) folder_id = BLENDER_USER_SCRIPTS; - else if (!strcmp(type, "AUTOSAVE")) folder_id = BLENDER_USER_AUTOSAVE; + if (STREQ(type, "DATAFILES")) folder_id = BLENDER_USER_DATAFILES; + else if (STREQ(type, "CONFIG")) folder_id = BLENDER_USER_CONFIG; + else if (STREQ(type, "SCRIPTS")) folder_id = BLENDER_USER_SCRIPTS; + else if (STREQ(type, "AUTOSAVE")) folder_id = BLENDER_USER_AUTOSAVE; else { PyErr_SetString(PyExc_ValueError, "invalid resource argument"); return NULL; @@ -195,15 +195,15 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100; static const char *kwlist[] = {"type", "major", "minor", NULL}; int folder_id; - char *path; + const char *path; if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ii:resource_path", (char **)kwlist, &type, &major, &minor)) return NULL; /* stupid string compare */ - if (!strcmp(type, "USER")) folder_id = BLENDER_RESOURCE_PATH_USER; - else if (!strcmp(type, "LOCAL")) folder_id = BLENDER_RESOURCE_PATH_LOCAL; - else if (!strcmp(type, "SYSTEM")) folder_id = BLENDER_RESOURCE_PATH_SYSTEM; + if (STREQ(type, "USER")) folder_id = BLENDER_RESOURCE_PATH_USER; + else if (STREQ(type, "LOCAL")) folder_id = BLENDER_RESOURCE_PATH_LOCAL; + else if (STREQ(type, "SYSTEM")) folder_id = BLENDER_RESOURCE_PATH_SYSTEM; else { PyErr_SetString(PyExc_ValueError, "invalid resource argument"); return NULL; @@ -249,7 +249,7 @@ void BPy_init_modules(void) PyObject *mod; /* Needs to be first since this dir is needed for future modules */ - char *modpath = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "modules"); + const char * const modpath = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "modules"); if (modpath) { // printf("bpy: found module path '%s'.\n", modpath); PyObject *sys_path = PySys_GetObject("path"); /* borrow */ diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 7889b9a7f0b..e5180c58d56 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -41,9 +41,8 @@ #include "bpy_app_handlers.h" #include "bpy_driver.h" -#include "BLI_path_util.h" #include "BLI_utildefines.h" - +#include "BLI_path_util.h" #include "BKE_blender.h" #include "BKE_global.h" diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 7c89972b486..35c39814124 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -32,9 +32,9 @@ /* XXX Why bloody hell isn't that included in Python.h???? */ #include <structmember.h> +#include "BLI_utildefines.h" #include "BLI_string.h" #include "BLI_ghash.h" -#include "BLI_utildefines.h" #include "BPY_extern.h" #include "bpy_app_translations.h" diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 90199a403dc..552df561bbd 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -39,13 +39,13 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #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" -#include "BLI_utildefines.h" #include "BLI_threads.h" #include "RNA_types.h" @@ -931,11 +931,7 @@ static void bpy_module_free(void *UNUSED(mod)) /* EVIL, define text.c functions here... */ -extern int text_check_identifier_unicode(const unsigned int ch); -extern int text_check_identifier_nodigit_unicode(const unsigned int ch); -extern int text_check_identifier(const char ch); -extern int text_check_identifier_nodigit(const char ch); - +/* BKE_text.h */ int text_check_identifier_unicode(const unsigned int ch) { return (ch < 255 && text_check_identifier((char)ch)) || Py_UNICODE_ISALNUM(ch); diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index ec6322a1a11..3f66fb7b337 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -411,7 +411,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) /* append, rather than linking */ if ((self->flag & FILE_LINK) == 0) { - BKE_library_make_local(bmain, lib, 1); + BKE_library_make_local(bmain, lib, true); } } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index ee885684e03..26c043f796f 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -369,7 +369,7 @@ static PyObject *pyop_dir(PyObject *UNUSED(self)) GHashIterator *iter = WM_operatortype_iter(); PyObject *list = PyList_New(0), *name; - for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for ( ; BLI_ghashIterator_notDone(iter); BLI_ghashIterator_step(iter)) { wmOperatorType *ot = BLI_ghashIterator_getValue(iter); name = PyUnicode_FromString(ot->idname); diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 9d92ff51213..1c722243424 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -127,6 +127,11 @@ void operator_wrapper(wmOperatorType *ot, void *userdata) *ot = *((wmOperatorType *)userdata); ot->srna = srna; /* restore */ + /* Use i18n context from ext.srna if possible (py operators). */ + if (ot->ext.srna) { + RNA_def_struct_translation_context(ot->srna, RNA_struct_translation_context(ot->ext.srna)); + } + operator_properties_init(ot); } @@ -143,6 +148,11 @@ void macro_wrapper(wmOperatorType *ot, void *userdata) ot->ui = data->ui; ot->ext = data->ext; + /* Use i18n context from ext.srna if possible (py operators). */ + if (ot->ext.srna) { + RNA_def_struct_translation_context(ot->srna, RNA_struct_translation_context(ot->ext.srna)); + } + operator_properties_init(ot); } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 830c2c8de3a..c330eb1549d 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1265,9 +1265,11 @@ static int icon_id_from_name(const char *name) int id; if (name[0]) { - for (item = icon_items, id = 0; item->identifier; item++, id++) - if (strcmp(item->name, name) == 0) + for (item = icon_items, id = 0; item->identifier; item++, id++) { + if (STREQ(item->name, name)) { return item->value; + } + } } return 0; @@ -1353,7 +1355,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i tmp.value = i; } - if (def && def_used == 0 && strcmp(def_cmp, tmp.identifier) == 0) { + if (def && def_used == 0 && STREQ(def_cmp, tmp.identifier)) { *defvalue = tmp.value; def_used++; /* only ever 1 */ } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index cef4e23242d..0adb5e2e90e 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -250,7 +250,7 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash) fprintf(stdout, "id_release_weakref: '%s', %d items\n", id->name, BLI_ghash_size(weakinfo_hash)); #endif - while (!BLI_ghashIterator_isDone(&weakinfo_hash_iter)) { + while (BLI_ghashIterator_notDone(&weakinfo_hash_iter)) { PyObject *weakref = (PyObject *)BLI_ghashIterator_getKey(&weakinfo_hash_iter); PyObject *item = PyWeakref_GET_OBJECT(weakref); if (item != Py_None) { @@ -1427,7 +1427,9 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha { arg_name = RNA_property_identifier(prop); - if (strcmp(arg_name, "rna_type") == 0) continue; + if (STREQ(arg_name, "rna_type")) { + continue; + } if (kw == NULL) { PyErr_Format(PyExc_TypeError, @@ -2223,7 +2225,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) { ID *id = itemptr.data; /* always an ID */ - if (id->lib == lib && (strncmp(keyname, id->name + 2, sizeof(id->name) - 2) == 0)) { + if (id->lib == lib && (STREQLEN(keyname, id->name + 2, sizeof(id->name) - 2))) { found = true; if (r_ptr) { *r_ptr = itemptr; @@ -3463,7 +3465,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) } else if (name[0] == '_') { /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */ /* annoying exception, maybe we need to have different types for this... */ - if ((strcmp(name, "__getitem__") == 0 || strcmp(name, "__setitem__") == 0) && !RNA_struct_idprops_check(self->ptr.type)) { + if ((STREQ(name, "__getitem__") || STREQ(name, "__setitem__")) && !RNA_struct_idprops_check(self->ptr.type)) { PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type"); ret = NULL; } @@ -4939,7 +4941,7 @@ static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_look while (PyDict_Next(dict, &pos, &key, &value)) { if (PyUnicode_Check(key)) { - if (strcmp(key_lookup, _PyUnicode_AsString(key)) == 0) { + if (STREQ(key_lookup, _PyUnicode_AsString(key))) { return value; } } @@ -5139,7 +5141,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject RNA_parameter_list_begin(&parms, &iter); for (; iter.valid; RNA_parameter_list_next(&iter)) { parm = iter.parm; - if (strcmp(arg_name, RNA_property_identifier(parm)) == 0) { + if (STREQ(arg_name, RNA_property_identifier(parm))) { found = true; break; } @@ -6937,7 +6939,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v /* Sneaky workaround to use the class name as the bl_idname */ #define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ - (strcmp(identifier, rna_attr) == 0) { \ + (STREQ(identifier, rna_attr)) { \ item = PyObject_GetAttr(py_class, py_attr); \ if (item && item != Py_None) { \ if (pyrna_py_to_prop(dummyptr, prop, NULL, \ @@ -6948,7 +6950,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v } \ } \ Py_XDECREF(item); \ - } /* intendionally allow else here */ + } /* intentionally allow else here */ if BPY_REPLACEMENT_STRING("bl_idname", bpy_intern_str___name__) else if BPY_REPLACEMENT_STRING("bl_description", bpy_intern_str___doc__) diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index 48bf65a841b..81d12e9d9a6 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -29,6 +29,7 @@ #include <Python.h> #include <frameobject.h> +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "BLI_string.h" diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index da2888045d0..1fcebf29f28 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -829,10 +829,10 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) mat[0] = 1.0f; mat[3] = 1.0f; - if (strcmp(plane, "X") == 0) { + if (STREQ(plane, "X")) { mat[2] = factor; } - else if (strcmp(plane, "Y") == 0) { + else if (STREQ(plane, "Y")) { mat[1] = factor; } else { @@ -855,15 +855,15 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) mat[4] = 1.0f; mat[8] = 1.0f; - if (strcmp(plane, "XY") == 0) { + if (STREQ(plane, "XY")) { mat[6] = factor[0]; mat[7] = factor[1]; } - else if (strcmp(plane, "XZ") == 0) { + else if (STREQ(plane, "XZ")) { mat[3] = factor[0]; mat[5] = factor[1]; } - else if (strcmp(plane, "YZ") == 0) { + else if (STREQ(plane, "YZ")) { mat[1] = factor[0]; mat[2] = factor[1]; } |