[Bf-blender-cvs] [775c8ce3327] master: Cleanup: style, use braces for makesdna, makesrna

Campbell Barton noreply at git.blender.org
Mon Apr 22 13:15:30 CEST 2019


Commit: 775c8ce3327975ea98c18e29012bc03268753385
Author: Campbell Barton
Date:   Mon Apr 22 09:16:18 2019 +1000
Branches: master
https://developer.blender.org/rB775c8ce3327975ea98c18e29012bc03268753385

Cleanup: style, use braces for makesdna, makesrna

===================================================================

M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_animation.c
M	source/blender/makesrna/intern/rna_armature.c
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_main.c
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_mesh.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/makesrna/intern/rna_rna.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_sequencer.c

===================================================================

diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 163165283dd..0ea1ca9c018 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -587,8 +587,9 @@ static int preprocess_include(char *maindata, const int maindata_len)
     else if (*cp == '\n') {
       comment = 0;
     }
-    if (comment || *cp < 32 || *cp > 128)
+    if (comment || *cp < 32 || *cp > 128) {
       *cp = 32;
+    }
     cp++;
   }
 
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 2e7277606da..94fa06452be 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -73,10 +73,12 @@ static int file_older(const char *file1, const char *file2)
     printf("compare: %s %s\n", file1, file2);
   }
 
-  if (stat(file1, &st1))
+  if (stat(file1, &st1)) {
     return 0;
-  if (stat(file2, &st2))
+  }
+  if (stat(file2, &st2)) {
     return 0;
+  }
 
   return (st1.st_mtime < st2.st_mtime);
 }
@@ -243,12 +245,15 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[])
 
 static const char *rna_safe_id(const char *id)
 {
-  if (STREQ(id, "default"))
+  if (STREQ(id, "default")) {
     return "default_value";
-  else if (STREQ(id, "operator"))
+  }
+  else if (STREQ(id, "operator")) {
     return "operator_value";
-  else if (STREQ(id, "new"))
+  }
+  else if (STREQ(id, "new")) {
     return "create";
+  }
   else if (STREQ(id, "co_return")) {
     /* MSVC2015, C++ uses for coroutines */
     return "coord_return";
@@ -272,15 +277,19 @@ static int cmp_property(const void *a, const void *b)
   const PropertyRNA *propa = *(const PropertyRNA **)a;
   const PropertyRNA *propb = *(const PropertyRNA **)b;
 
-  if (STREQ(propa->identifier, "rna_type"))
+  if (STREQ(propa->identifier, "rna_type")) {
     return -1;
-  else if (STREQ(propb->identifier, "rna_type"))
+  }
+  else if (STREQ(propb->identifier, "rna_type")) {
     return 1;
+  }
 
-  if (STREQ(propa->identifier, "name"))
+  if (STREQ(propa->identifier, "name")) {
     return -1;
-  else if (STREQ(propb->identifier, "name"))
+  }
+  else if (STREQ(propb->identifier, "name")) {
     return 1;
+  }
 
   return strcmp(propa->name, propb->name);
 }
@@ -307,15 +316,18 @@ static void rna_sortlist(ListBase *listbase, int (*cmp)(const void *, const void
   void **array;
   int a, size;
 
-  if (listbase->first == listbase->last)
+  if (listbase->first == listbase->last) {
     return;
+  }
 
-  for (size = 0, link = listbase->first; link; link = link->next)
+  for (size = 0, link = listbase->first; link; link = link->next) {
     size++;
+  }
 
   array = MEM_mallocN(sizeof(void *) * size, "rna_sortlist");
-  for (a = 0, link = listbase->first; link; link = link->next, a++)
+  for (a = 0, link = listbase->first; link; link = link->next, a++) {
     array[a] = link;
+  }
 
   qsort(array, size, sizeof(void *), cmp);
 
@@ -344,29 +356,35 @@ static void rna_print_c_string(FILE *f, const char *str)
 
   fprintf(f, "\"");
   for (i = 0; str[i]; i++) {
-    for (j = 0; escape[j]; j++)
-      if (str[i] == escape[j][0])
+    for (j = 0; escape[j]; j++) {
+      if (str[i] == escape[j][0]) {
         break;
+      }
+    }
 
-    if (escape[j])
+    if (escape[j]) {
       fprintf(f, "\\%c", escape[j][1]);
-    else
+    }
+    else {
       fprintf(f, "%c", str[i]);
+    }
   }
   fprintf(f, "\"");
 }
 
 static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
 {
-  if (dp->dnastructfromname && dp->dnastructfromprop)
+  if (dp->dnastructfromname && dp->dnastructfromprop) {
     fprintf(f,
             "    %s *data = (%s *)(((%s *)ptr->data)->%s);\n",
             dp->dnastructname,
             dp->dnastructname,
             dp->dnastructfromname,
             dp->dnastructfromprop);
-  else
+  }
+  else {
     fprintf(f, "    %s *data = (%s *)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
+  }
 }
 
 static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp))
@@ -383,10 +401,12 @@ static void rna_construct_function_name(
 static void rna_construct_wrapper_function_name(
     char *buffer, int size, const char *structname, const char *propname, const char *type)
 {
-  if (type == NULL || type[0] == '\0')
+  if (type == NULL || type[0] == '\0') {
     snprintf(buffer, size, "%s_%s", structname, propname);
-  else
+  }
+  else {
     snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
+  }
 }
 
 static char *rna_alloc_function_name(const char *structname,
@@ -412,9 +432,11 @@ static StructRNA *rna_find_struct(const char *identifier)
 {
   StructDefRNA *ds;
 
-  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
-    if (STREQ(ds->srna->identifier, identifier))
+  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+    if (STREQ(ds->srna->identifier, identifier)) {
       return ds->srna;
+    }
+  }
 
   return NULL;
 }
@@ -423,9 +445,11 @@ static const char *rna_find_type(const char *type)
 {
   StructDefRNA *ds;
 
-  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
-    if (ds->dnaname && STREQ(ds->dnaname, type))
+  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+    if (ds->dnaname && STREQ(ds->dnaname, type)) {
       return ds->srna->identifier;
+    }
+  }
 
   return NULL;
 }
@@ -434,9 +458,11 @@ static const char *rna_find_dna_type(const char *type)
 {
   StructDefRNA *ds;
 
-  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
-    if (STREQ(ds->srna->identifier, type))
+  for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+    if (STREQ(ds->srna->identifier, type)) {
       return ds->dnaname;
+    }
+  }
 
   return NULL;
 }
@@ -469,8 +495,9 @@ static const char *rna_type_type(PropertyRNA *prop)
 
   type = rna_type_type_name(prop);
 
-  if (type)
+  if (type) {
     return type;
+  }
 
   return "PointerRNA";
 }
@@ -481,8 +508,9 @@ static const char *rna_type_struct(PropertyRNA *prop)
 
   type = rna_type_type_name(prop);
 
-  if (type)
+  if (type) {
     return "";
+  }
 
   return "struct ";
 }
@@ -493,17 +521,20 @@ static const char *rna_parameter_type_name(PropertyRNA *parm)
 
   type = rna_type_type_name(parm);
 
-  if (type)
+  if (type) {
     return type;
+  }
 
   switch (parm->type) {
     case PROP_POINTER: {
       PointerPropertyRNA *pparm = (PointerPropertyRNA *)parm;
 
-      if (parm->flag_parameter & PARM_RNAPTR)
+      if (parm->flag_parameter & PARM_RNAPTR) {
         return "PointerRNA";
-      else
+      }
+      else {
         return rna_find_dna_type((const char *)pparm->type);
+      }
     }
     case PROP_COLLECTION: {
       return "CollectionListBase";
@@ -519,9 +550,11 @@ static int rna_enum_bitmask(PropertyRNA *prop)
   int a, mask = 0;
 
   if (eprop->item) {
-    for (a = 0; a < eprop->totitem; a++)
-      if (eprop->item[a].identifier[0])
+    for (a = 0; a < eprop->totitem; a++) {
+      if (eprop->item[a].identifier[0]) {
         mask |= eprop->item[a].value;
+      }
+    }
   }
 
   return mask;
@@ -541,24 +574,31 @@ static const char *rna_function_string(void *func)
 
 static void rna_float_print(FILE *f, float num)
 {
-  if (num == -FLT_MAX)
+  if (num == -FLT_MAX) {
     fprintf(f, "-FLT_MAX");
-  else if (num == FLT_MAX)
+  }
+  else if (num == FLT_MAX) {
     fprintf(f, "FLT_MAX");
-  else if ((ABS(num) < INT64_MAX) && ((int64_t)num == num))
+  }
+  else if ((ABS(num) < INT64_MAX) && ((int64_t)num == num)) {
     fprintf(f, "%.1ff", num);
-  else
+  }
+  else {
     fprintf(f, "%.10ff", num);
+  }
 }
 
 static void rna_int_print(FILE *f, int num)
 {
-  if (num == INT_MIN)
+  if (num == INT_MIN) {
     fprintf(f, "INT_MIN");
-  else if (num == INT_MAX)
+  }
+  else if (num == INT_MAX) {
     fprintf(f, "INT_MAX");
-  else
+  }
+  else {
     fprintf(f, "%d", num);
+  }
 }
 
 static char *rna_def_property_get_func(
@@ -566,8 +606,9 @@ static char *rna_def_property_get_func(
 {
   char *func;
 
-  if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+  if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
     return NULL;
+  }
 
   if (!manualfunc) {
     if (!dp->dnastructname || !dp->dnaname) {
@@ -635,18 +676,20 @@ static char *rna_def_property_get_func(
           fprintf(f, "    }\n");
         }
 
-        if (sprop->maxlength)
+        if (sprop->maxlength) {
           fprintf(f,
                   "    %s(value, data->%s, %d);\n",
                   string_copy_func,
                   dp->dnaname,
                   sprop->maxlength);
-        else
+        }
+        else {
           fprintf(f,
                   "    %s(value, data->%s, sizeof(data->%s));\n",
                   string_copy_func,
                   dp->dnaname,
                   dp->dnaname);
+        }
       }
       fprintf(f, "}\n\n");
       break;
@@ -660,16 +703,18 @@ static char *rna_def_property_get_func(
       else {
         PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
         rna_print_data_get(f, dp);
-        if (dp->dnapointerlevel == 0)
+        if (dp->dnapointerlevel == 0) {
           fprintf(f,
                   "    return rna_pointer_inherit_refine(ptr, &RNA_%s, &data->%s);\n",
                   (const char *)pprop->type,
                   dp->dnaname);
-        else
+        }
+        else {
           fprintf(f,
                   "    return rna_pointer_inherit_refine(ptr, &RNA_%s, data->%s);\n",
                   (const char *)pprop->type,
                   dp->dnaname);
+        }
       }
       fprintf(f, "}\n\n");
       break;
@@ -697,14 +742,16 @@ static char *rna_def_property_get_func(
     }
     default:
       if (prop->arraydimension) {
-        if (prop->flag & PROP_DYNAMIC)
+        if (prop->flag & PROP_DYNAMIC) {
           fprintf(f, "void %s(PointerRNA *ptr, %s values[])\n", func, rna_type_type(prop));
-        else
+        }
+        else {
           fprintf(f,
                   "void %s(PointerRNA *ptr, %s values[%u])\n",
                   func,
                   rna_type_type(prop),
                   prop->totarraylength);
+        }
         fprintf(f, "{\n");
 
         if (manualfunc) {
@@ -798,12 +845,13 @@ static char *rna_def_property_get

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list