diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-06-03 17:10:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-06-03 17:10:44 +0300 |
commit | 7b28a31f2c3a6bd28b465f6a48d9ee064ecb5176 (patch) | |
tree | a20a7e1c1559a9524a63fcfd07f0afcf8a056483 | |
parent | d5f6e573ed43521e497c83eff02f828aea1a35c9 (diff) |
Cleanup: style, use braces in makesrna
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 57 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 78 |
3 files changed, 102 insertions, 51 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 7eee3661074..3b9fa40fcae 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1459,7 +1459,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, item_type = (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType"; if (dp->dnalengthname || dp->dnalengthfixed) { - if (dp->dnalengthname) + if (dp->dnalengthname) { fprintf(f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, " "index);\n", @@ -1467,7 +1467,8 @@ static char *rna_def_property_lookup_int_func(FILE *f, dp->dnaname, dp->dnaname, dp->dnalengthname); - else + } + else { fprintf( f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n", @@ -1475,18 +1476,21 @@ static char *rna_def_property_lookup_int_func(FILE *f, dp->dnaname, dp->dnaname, dp->dnalengthfixed); + } } else { - if (dp->dnapointerlevel == 0) + if (dp->dnapointerlevel == 0) { fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n", item_type, dp->dnaname); - else + } + else { fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n", item_type, dp->dnaname); + } } #endif @@ -2040,12 +2044,15 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property /* disabled for now to avoid msvc compiler error due to large file size */ #if 0 - if (prop->name && prop->description && prop->description[0] != '\0') + if (prop->name && prop->description && prop->description[0] != '\0') { fprintf(f, "\t/* %s: %s */\n", prop->name, prop->description); - else if (prop->name) + } + else if (prop->name) { fprintf(f, "\t/* %s */\n", prop->name); - else + } + else { fprintf(f, "\t/* */\n"); + } #endif switch (prop->type) { @@ -2234,11 +2241,13 @@ static void rna_def_struct_function_prototype_cpp(FILE *f, fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier)); } - if (func->flag & FUNC_USE_MAIN) + if (func->flag & FUNC_USE_MAIN) { WRITE_PARAM("void *main"); + } - if (func->flag & FUNC_USE_CONTEXT) + if (func->flag & FUNC_USE_CONTEXT) { WRITE_PARAM("Context C"); + } for (dp = dfunc->cont.properties.first; dp; dp = dp->next) { int type, flag, flag_parameter, pout; @@ -2416,7 +2425,7 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe #if 0 CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop; - if (cprop->type) + if (cprop->type) { fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->type, @@ -2425,7 +2434,8 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe (cprop->length ? "true" : "false"), (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false")); - else + } + else { fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", @@ -2434,6 +2444,7 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe (cprop->length ? "true" : "false"), (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false")); + } #endif break; } @@ -2458,8 +2469,9 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func dsrna = rna_find_struct_def(srna); - if (func->flag & FUNC_USE_SELF_ID) + if (func->flag & FUNC_USE_SELF_ID) { WRITE_PARAM("(::ID *) ptr.id.data"); + } if ((func->flag & FUNC_NO_SELF) == 0) { WRITE_COMMA; @@ -2478,14 +2490,17 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func fprintf(f, "this->ptr.type"); } - if (func->flag & FUNC_USE_MAIN) + if (func->flag & FUNC_USE_MAIN) { WRITE_PARAM("(::Main *) main"); + } - if (func->flag & FUNC_USE_CONTEXT) + if (func->flag & FUNC_USE_CONTEXT) { WRITE_PARAM("(::bContext *) C.ptr.data"); + } - if (func->flag & FUNC_USE_REPORTS) + if (func->flag & FUNC_USE_REPORTS) { WRITE_PARAM("NULL"); + } dp = dfunc->cont.properties.first; for (; dp; dp = dp->next) { @@ -2630,8 +2645,9 @@ static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, Functio first = 1; - if (func->flag & FUNC_USE_SELF_ID) + if (func->flag & FUNC_USE_SELF_ID) { WRITE_PARAM("_selfid"); + } if ((func->flag & FUNC_NO_SELF) == 0) { WRITE_PARAM("_self"); @@ -2640,14 +2656,17 @@ static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, Functio WRITE_PARAM("_type"); } - if (func->flag & FUNC_USE_MAIN) + if (func->flag & FUNC_USE_MAIN) { WRITE_PARAM("bmain"); + } - if (func->flag & FUNC_USE_CONTEXT) + if (func->flag & FUNC_USE_CONTEXT) { WRITE_PARAM("C"); + } - if (func->flag & FUNC_USE_REPORTS) + if (func->flag & FUNC_USE_REPORTS) { WRITE_PARAM("reports"); + } dparm = dfunc->cont.properties.first; for (; dparm; dparm = dparm->next) { diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 20358ca80fd..a9ba1730216 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4594,20 +4594,23 @@ static int rna_raw_access(ReportList *reports, if (set) { switch (itemtype) { case PROP_BOOLEAN: { - for (j = 0; j < itemlen; j++, a++) + for (j = 0; j < itemlen; j++, a++) { RAW_GET(bool, ((bool *)tmparray)[j], in, a); + } RNA_property_boolean_set_array(&itemptr, iprop, tmparray); break; } case PROP_INT: { - for (j = 0; j < itemlen; j++, a++) + for (j = 0; j < itemlen; j++, a++) { RAW_GET(int, ((int *)tmparray)[j], in, a); + } RNA_property_int_set_array(&itemptr, iprop, tmparray); break; } case PROP_FLOAT: { - for (j = 0; j < itemlen; j++, a++) + for (j = 0; j < itemlen; j++, a++) { RAW_GET(float, ((float *)tmparray)[j], in, a); + } RNA_property_float_set_array(&itemptr, iprop, tmparray); break; } @@ -4619,20 +4622,23 @@ static int rna_raw_access(ReportList *reports, switch (itemtype) { case PROP_BOOLEAN: { RNA_property_boolean_get_array(&itemptr, iprop, tmparray); - for (j = 0; j < itemlen; j++, a++) + for (j = 0; j < itemlen; j++, a++) { RAW_SET(int, in, a, ((bool *)tmparray)[j]); + } break; } case PROP_INT: { RNA_property_int_get_array(&itemptr, iprop, tmparray); - for (j = 0; j < itemlen; j++, a++) + for (j = 0; j < itemlen; j++, a++) { RAW_SET(int, in, a, ((int *)tmparray)[j]); + } break; } case PROP_FLOAT: { RNA_property_float_get_array(&itemptr, iprop, tmparray); - for (j = 0; j < itemlen; j++, a++) + for (j = 0; j < itemlen; j++, a++) { RAW_SET(float, in, a, ((float *)tmparray)[j]); + } break; } default: diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index b1818cae62a..2cb7c62b028 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -263,12 +263,14 @@ static PropertyDefRNA *rna_find_property_def(PropertyRNA *prop) } dprop = rna_find_struct_property_def(DefRNA.laststruct, prop); - if (dprop) + if (dprop) { return dprop; + } dprop = rna_find_parameter_def(prop); - if (dprop) + if (dprop) { return dprop; + } return NULL; } @@ -750,8 +752,9 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) RNA_def_property_free_pointers(prop); - if (prop->flag_internal & PROP_INTERN_RUNTIME) + if (prop->flag_internal & PROP_INTERN_RUNTIME) { rna_freelinkN(&srna->cont.properties, prop); + } } for (func = srna->functions.first; func; func = nextfunc) { @@ -762,14 +765,16 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) RNA_def_property_free_pointers(parm); - if (parm->flag_internal & PROP_INTERN_RUNTIME) + if (parm->flag_internal & PROP_INTERN_RUNTIME) { rna_freelinkN(&func->cont.properties, parm); + } } RNA_def_func_free_pointers(func); - if (func->flag & FUNC_RUNTIME) + if (func->flag & FUNC_RUNTIME) { rna_freelinkN(&srna->functions, func); + } } rna_brna_structs_remove_and_free(brna, srna); @@ -1408,8 +1413,9 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, prop->flag |= PROP_IDPROPERTY; prop->flag_internal |= PROP_INTERN_RUNTIME; #ifdef RNA_RUNTIME - if (cont->prophash) + if (cont->prophash) { BLI_ghash_insert(cont->prophash, (void *)prop->identifier, prop); + } #endif } @@ -3897,15 +3903,17 @@ int rna_parameter_size(PropertyRNA *parm) } case PROP_POINTER: { #ifdef RNA_RUNTIME - if (parm->flag_parameter & PARM_RNAPTR) + if (parm->flag_parameter & PARM_RNAPTR) { if (parm->flag & PROP_THICK_WRAP) { return sizeof(PointerRNA); } else { return sizeof(PointerRNA *); } - else + } + else { return sizeof(void *); + } #else if (parm->flag_parameter & PARM_RNAPTR) { if (parm->flag & PROP_THICK_WRAP) { @@ -4027,10 +4035,12 @@ void RNA_def_struct_free_pointers(BlenderRNA *brna, StructRNA *srna) void RNA_def_func_duplicate_pointers(FunctionRNA *func) { - if (func->identifier) + if (func->identifier) { func->identifier = BLI_strdup(func->identifier); - if (func->description) + } + if (func->description) { func->description = BLI_strdup(func->description); + } func->flag |= FUNC_FREE_POINTERS; } @@ -4038,10 +4048,12 @@ void RNA_def_func_duplicate_pointers(FunctionRNA *func) void RNA_def_func_free_pointers(FunctionRNA *func) { if (func->flag & FUNC_FREE_POINTERS) { - if (func->identifier) + if (func->identifier) { MEM_freeN((void *)func->identifier); - if (func->description) + } + if (func->description) { MEM_freeN((void *)func->description); + } } } @@ -4125,8 +4137,9 @@ void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA } case PROP_STRING: { StringPropertyRNA *sprop = (StringPropertyRNA *)prop; - if (sprop->defaultvalue) + if (sprop->defaultvalue) { sprop->defaultvalue = BLI_strdup(sprop->defaultvalue); + } break; } default: @@ -4141,54 +4154,66 @@ void RNA_def_property_free_pointers(PropertyRNA *prop) if (prop->flag_internal & PROP_INTERN_FREE_POINTERS) { int a; - if (prop->identifier) + if (prop->identifier) { MEM_freeN((void *)prop->identifier); - if (prop->name) + } + if (prop->name) { MEM_freeN((void *)prop->name); - if (prop->description) + } + if (prop->description) { MEM_freeN((void *)prop->description); - if (prop->py_data) + } + if (prop->py_data) { MEM_freeN(prop->py_data); + } switch (prop->type) { case PROP_BOOLEAN: { BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop; - if (bprop->defaultarray) + if (bprop->defaultarray) { MEM_freeN((void *)bprop->defaultarray); + } break; } case PROP_INT: { IntPropertyRNA *iprop = (IntPropertyRNA *)prop; - if (iprop->defaultarray) + if (iprop->defaultarray) { MEM_freeN((void *)iprop->defaultarray); + } break; } case PROP_FLOAT: { FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop; - if (fprop->defaultarray) + if (fprop->defaultarray) { MEM_freeN((void *)fprop->defaultarray); + } break; } case PROP_ENUM: { EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop; for (a = 0; a < eprop->totitem; a++) { - if (eprop->item[a].identifier) + if (eprop->item[a].identifier) { MEM_freeN((void *)eprop->item[a].identifier); - if (eprop->item[a].name) + } + if (eprop->item[a].name) { MEM_freeN((void *)eprop->item[a].name); - if (eprop->item[a].description) + } + if (eprop->item[a].description) { MEM_freeN((void *)eprop->item[a].description); + } } - if (eprop->item) + if (eprop->item) { MEM_freeN((void *)eprop->item); + } break; } case PROP_STRING: { StringPropertyRNA *sprop = (StringPropertyRNA *)prop; - if (sprop->defaultvalue) + if (sprop->defaultvalue) { MEM_freeN((void *)sprop->defaultvalue); + } break; } default: @@ -4202,8 +4227,9 @@ static void rna_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop) ContainerRNA *cont = cont_; if (prop->flag_internal & PROP_INTERN_RUNTIME) { - if (cont->prophash) + if (cont->prophash) { BLI_ghash_remove(cont->prophash, prop->identifier, NULL, NULL); + } RNA_def_property_free_pointers(prop); rna_freelinkN(&cont->properties, prop); |