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
This commit is contained in:
Ray Molenkamp 2020-03-17 13:45:35 -06:00
parent e09f0caff3
commit a7c660fe61
8 changed files with 33 additions and 4 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -427,6 +427,7 @@ typedef struct EnumPropertyRNA {
int totitem;
int defaultvalue;
const char *native_enum_type;
} EnumPropertyRNA;
typedef struct PointerPropertyRNA {

View File

@ -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 */

View File

@ -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

View File

@ -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");