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/intern | |
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/intern')
-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 |
10 files changed, 51 insertions, 41 deletions
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" |