Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-03-10 10:18:03 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-03-10 10:18:03 +0400
commitf9f707033665dc737f1011e82406a12fafa78326 (patch)
treef1c69f7f99ec010b529be0f0724b39e80d1303ce /source/blender/python
parentf99be71850f6f40715f6b8f6fe9058fb66470dfa (diff)
add STREQ macro (commonly used macro like CLAMP, MAX2, STRINGIFY). Use for some areas of the python api, bmesh.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c2
-rw-r--r--source/blender/python/generic/py_capi_utils.c4
-rw-r--r--source/blender/python/intern/bpy.c14
-rw-r--r--source/blender/python/intern/bpy_props.c8
-rw-r--r--source/blender/python/intern/bpy_rna.c14
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c10
6 files changed, 28 insertions, 24 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/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 6fba12903b7..a0e7c4332e1 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -153,10 +153,10 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
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;
@@ -197,9 +197,9 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
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;
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 d8842256c22..bdb2f8fcc12 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -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, \
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];
}