[Bf-blender-cvs] [a7c660fe615] master: Cleanup: Fix warnings about function signature of register pass

Ray Molenkamp noreply at git.blender.org
Tue Mar 17 20:45:40 CET 2020


Commit: a7c660fe615030b41128a20e0bd2676ff4c2a196
Author: Ray Molenkamp
Date:   Tue Mar 17 13:45:35 2020 -0600
Branches: master
https://developer.blender.org/rBa7c660fe615030b41128a20e0bd2676ff4c2a196

Cleanup: Fix warnings about function signature of register pass

RE_engine_register_pass is sometimes in the headers with type
as an integer parameter, sometimes as eNodeSocketDatatype.

This caused warnings, the root cause was makesrna was not able
to generate the proper type for enums and defaulted to int.

makesrna has been extended with the RNA_def_property_enum_native_type
that allows telling makesrna the native type of an enum, if set it
will be used otherwise it will still fall back to int.

Differential Revision: https://developer.blender.org/D7117

Reviewed By: brecht

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

M	source/blender/blenkernel/BKE_node.h
M	source/blender/makesrna/RNA_define.h
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_internal_types.h
M	source/blender/makesrna/intern/rna_render.c
M	source/blender/nodes/composite/nodes/node_composite_image.c
M	source/blender/render/intern/source/render_result.c

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

diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index ed36d3892ac..dc06f56861a 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1195,7 +1195,7 @@ void ntreeCompositRegisterPass(struct bNodeTree *ntree,
                                struct Scene *scene,
                                struct ViewLayer *view_layer,
                                const char *name,
-                               int type);
+                               eNodeSocketDatatype type);
 void ntreeCompositClearTags(struct bNodeTree *ntree);
 
 struct bNodeSocket *ntreeCompositOutputFileAddSocket(struct bNodeTree *ntree,
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 026043cd7c5..d2cc9fb95f1 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -369,6 +369,7 @@ void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int le
 void RNA_def_property_range(PropertyRNA *prop, double min, double max);
 
 void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item);
+void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type);
 void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength);
 void RNA_def_property_struct_type(PropertyRNA *prop, const char *type);
 void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type);
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index ae414489f52..0f69adf6298 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -482,8 +482,14 @@ static const char *rna_type_type_name(PropertyRNA *prop)
     case PROP_BOOLEAN:
       return "bool";
     case PROP_INT:
-    case PROP_ENUM:
       return "int";
+    case PROP_ENUM: {
+      EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
+      if (eprop->native_enum_type) {
+        return eprop->native_enum_type;
+      }
+      return "int";
+    }
     case PROP_FLOAT:
       return "float";
     case PROP_STRING:
@@ -4331,6 +4337,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
 
   fprintf(f, "#include \"DNA_ID.h\"\n");
   fprintf(f, "#include \"DNA_scene_types.h\"\n");
+  fprintf(f, "#include \"DNA_node_types.h\"\n");
 
   fprintf(f, "#include \"BLI_blenlib.h\"\n\n");
   fprintf(f, "#include \"BLI_utildefines.h\"\n\n");
@@ -4423,6 +4430,7 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f)
           " * Do not edit manually, changes will be overwritten.              */\n\n");
 
   fprintf(f, "#include \"RNA_types.h\"\n\n");
+  fprintf(f, "#include \"DNA_node_types.h\"\n\n");
 
   fprintf(f, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
 
@@ -4857,6 +4865,7 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
   fprintf(f, "#include \"RNA_blender.h\"\n");
   fprintf(f, "#include \"RNA_types.h\"\n");
   fprintf(f, "#include \"RNA_access.h\"\n");
+  fprintf(f, "#include \"DNA_node_types.h\"\n");
 
   fprintf(f, "%s", cpp_classes);
 
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 55c97672958..8932639d1ac 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -1819,6 +1819,23 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
   }
 }
 
+void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type)
+{
+  StructRNA *srna = DefRNA.laststruct;
+  switch (prop->type) {
+    case PROP_ENUM: {
+      EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
+      eprop->native_enum_type = native_enum_type;
+      break;
+    }
+    default:
+      CLOG_ERROR(
+          &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier);
+      DefRNA.error = 1;
+      break;
+  }
+}
+
 void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
 {
   StructRNA *srna = DefRNA.laststruct;
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 7c6a471b1d7..0e3fc851a9b 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -427,6 +427,7 @@ typedef struct EnumPropertyRNA {
   int totitem;
 
   int defaultvalue;
+  const char *native_enum_type;
 } EnumPropertyRNA;
 
 typedef struct PointerPropertyRNA {
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 2f64740830b..eeaa8f78438 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -833,6 +833,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
   parm = RNA_def_string(func, "chanid", NULL, 8, "Channel IDs", "");
   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
   parm = RNA_def_enum(func, "type", render_pass_type_items, SOCK_FLOAT, "Type", "");
+  RNA_def_property_enum_native_type(parm, "eNodeSocketDatatype");
   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
 
   /* registration */
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 74f18c2e5ae..6b380bfb5af 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -283,7 +283,7 @@ static void cmp_node_rlayer_create_outputs_cb(void *UNUSED(userdata),
                                               const char *name,
                                               int UNUSED(channels),
                                               const char *UNUSED(chanid),
-                                              int type)
+                                              eNodeSocketDatatype type)
 {
   /* Register the pass in all scenes that have a render layer node for this layer.
    * Since multiple scenes can be used in the compositor, the code must loop over all scenes
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 4e20dd51122..0f39073c693 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -1206,7 +1206,7 @@ static void templates_register_pass_cb(void *userdata,
                                        const char *name,
                                        int channels,
                                        const char *chan_id,
-                                       int UNUSED(type))
+                                       eNodeSocketDatatype UNUSED(type))
 {
   ListBase *templates = userdata;
   RenderPass *pass = MEM_callocN(sizeof(RenderPass), "RenderPassTemplate");



More information about the Bf-blender-cvs mailing list