diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index f370d47b3f7..f621b7597c1 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -69,7 +69,7 @@ set(DEFSRC rna_sculpt_paint.c rna_sequencer.c rna_shader_fx.c - rna_sound.c + rna_sound.cc rna_space.c rna_speaker.c rna_test.c @@ -123,7 +123,7 @@ set(APISRC rna_workspace_api.c ) -string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}") +string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*)\.(cc?)" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.\\2" GENSRC "${DEFSRC}") list(APPEND GENSRC "${CMAKE_CURRENT_BINARY_DIR}/rna_prototypes_gen.h" "${CMAKE_CURRENT_BINARY_DIR}/../RNA_prototypes.h" diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 3592ecd84c8..9165c015be5 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -18,7 +18,6 @@ #include "BLI_string.h" #include "BLI_system.h" /* for 'BLI_system_backtrace' stub. */ #include "BLI_utildefines.h" - #include "RNA_define.h" #include "RNA_enum_types.h" #include "RNA_types.h" @@ -1902,7 +1901,7 @@ static void rna_set_raw_offset(FILE *f, StructRNA *srna, PropertyRNA *prop) { PropertyDefRNA *dp = rna_find_struct_property_def(srna, prop); - fprintf(f, "\toffsetof(%s, %s), %d", dp->dnastructname, dp->dnaname, prop->rawtype); + fprintf(f, "\toffsetof(%s, %s), RNA_RAWPROPERTYTYPE(%d)", dp->dnastructname, dp->dnaname, prop->rawtype); } static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) @@ -3475,8 +3474,8 @@ static void rna_generate_internal_property_prototypes(BlenderRNA *UNUSED(brna), fprintf(f, "\n"); for (prop = base->cont.properties.first; prop; prop = prop->next) { fprintf(f, - "%s%s rna_%s_%s;\n", - "extern ", + "%s %s rna_%s_%s;\n", + "RNA_EXTERN", rna_property_structname(prop->type), base->identifier, prop->identifier); @@ -3490,7 +3489,8 @@ static void rna_generate_internal_property_prototypes(BlenderRNA *UNUSED(brna), for (prop = srna->cont.properties.first; prop; prop = prop->next) { fprintf(f, - "%s rna_%s_%s;\n", + "%s %s rna_%s_%s;\n", + "RNA_EXTERN", rna_property_structname(prop->type), srna->identifier, prop->identifier); @@ -4052,7 +4052,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_print_c_string(f, prop->translation_context); fprintf(f, ",\n"); fprintf(f, - "\t%s, %s | %s, %s, %u, {%u, %u, %u}, %u,\n", + "\t%s, RNA_SUBTYPE(%s | %s), %s, %u, {%u, %u, %u}, %u,\n", RNA_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), @@ -4077,7 +4077,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_set_raw_offset(f, srna, prop); } else { - fprintf(f, "\t0, -1"); + fprintf(f, "\t0, RNA_RAWPROPERTYTYPE(-1)"); } /* our own type - collections/arrays only */ @@ -4126,7 +4126,9 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_function_string(iprop->getarray_ex), rna_function_string(iprop->setarray_ex), rna_function_string(iprop->range_ex)); + fprintf(f, "RNA_PROPERTYSCALETYPE("); rna_int_print(f, iprop->ui_scale_type); + fprintf(f, ")"); fprintf(f, ", "); rna_int_print(f, iprop->softmin); fprintf(f, ", "); @@ -4189,7 +4191,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr case PROP_STRING: { StringPropertyRNA *sprop = (StringPropertyRNA *)prop; fprintf(f, - "\t%s, %s, %s, %s, %s, %s, %s, %d, %d, ", + "\t%s, %s, %s, %s, %s, %s, %s, RNA_STRINGPROPERTYSEARCHFLAG(%d), %d, ", rna_function_string(sprop->get), rna_function_string(sprop->length), rna_function_string(sprop->set), @@ -4366,7 +4368,6 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE fprintf(f, "};\n"); fprintf(f, "\n"); } - fprintf(f, "StructRNA RNA_%s = {\n", srna->identifier); if (srna->cont.next) { @@ -4548,7 +4549,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_test.c", NULL, RNA_def_test}, {"rna_text.c", "rna_text_api.c", RNA_def_text}, {"rna_timeline.c", NULL, RNA_def_timeline_marker}, - {"rna_sound.c", "rna_sound_api.c", RNA_def_sound}, + {"rna_sound.cc", "rna_sound_api.c", RNA_def_sound}, {"rna_ui.c", "rna_ui_api.c", RNA_def_ui}, {"rna_userdef.c", NULL, RNA_def_userdef}, {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont}, @@ -4599,10 +4600,10 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const fprintf(f, "#include \"RNA_define.h\"\n"); fprintf(f, "#include \"RNA_types.h\"\n"); fprintf(f, "#include \"rna_internal.h\"\n\n"); - + fprintf(f, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n"); /* include the generated prototypes header */ fprintf(f, "#include \"rna_prototypes_gen.h\"\n\n"); - + fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n"); if (filename) { fprintf(f, "#include \"%s\"\n", filename); } @@ -4618,14 +4619,29 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const #endif fprintf(f, "/* Auto-generated Functions. */\n\n"); - + fprintf(f, "#ifdef __cplusplus\n"); + fprintf(f, "# define RNA_EXTERN extern \"C\"\n"); + fprintf(f, "# define RNA_SUBTYPE(x) PropertySubType(x)\n"); + fprintf(f, "# define RNA_RAWPROPERTYTYPE(x) RawPropertyType(x)\n"); + fprintf(f, "# define RNA_PROPERTYSCALETYPE(x) PropertyScaleType(x)\n"); + fprintf(f, "# define RNA_STRINGPROPERTYSEARCHFLAG(x) eStringPropertySearchFlag(x)\n"); + fprintf(f, "#else\n"); + fprintf(f, "# define RNA_EXTERN extern\n"); + fprintf(f, "# define RNA_SUBTYPE(x) x\n"); + fprintf(f, "# define RNA_RAWPROPERTYTYPE(x) x\n"); + fprintf(f, "# define RNA_PROPERTYSCALETYPE(x) x\n"); + fprintf(f, "# define RNA_STRINGPROPERTYSEARCHFLAG(x) x\n"); + fprintf(f, "#endif\n"); + fprintf(f, " // 1!!!\n"); for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { if (!filename || ds->filename == filename) { + fprintf(f, " // 1a!!!\n"); rna_generate_internal_property_prototypes(brna, ds->srna, f); + fprintf(f, " // 1b!!!\n"); rna_generate_function_prototypes(brna, ds->srna, f); } } - + fprintf(f, " // 2!!!\n"); for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { if (!filename || ds->filename == filename) { for (dp = ds->cont.properties.first; dp; dp = dp->next) { @@ -4633,7 +4649,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const } } } - + fprintf(f, " // 3!!!\n"); for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { if (!filename || ds->filename == filename) { for (dp = ds->cont.properties.first; dp; dp = dp->next) { @@ -4648,13 +4664,13 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const rna_generate_static_function_prototypes(brna, ds->srna, f); } } - + fprintf(f, " // 4!!!\n"); for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { if (!filename || ds->filename == filename) { rna_generate_struct(brna, ds->srna, f); } } - + fprintf(f, " // 5!!!\n"); if (filename && STREQ(filename, "rna_ID.c")) { /* this is ugly, but we cannot have c files compiled for both * makesrna and blender with some build systems at the moment */ @@ -5344,8 +5360,18 @@ static int rna_preprocess(const char *outfile, const char *public_header_outfile for (i = 0; PROCESS_ITEMS[i].filename; i++) { strcpy(deffile, outfile); strcat(deffile, PROCESS_ITEMS[i].filename); - deffile[strlen(deffile) - 2] = '\0'; - strcat(deffile, "_gen.c" TMP_EXT); + + const bool is_cpp_file = (deffile[strlen(deffile) - 1] == 'c' && + deffile[strlen(deffile) - 2] == 'c'); + + if (is_cpp_file) { + deffile[strlen(deffile) - 3] = '\0'; + strcat(deffile, "_gen.cc" TMP_EXT); + } + else { + deffile[strlen(deffile) - 2] = '\0'; + strcat(deffile, "_gen.c" TMP_EXT); + } if (status) { make_bad_file(deffile, __LINE__); diff --git a/source/blender/makesrna/intern/rna_sound.cc b/source/blender/makesrna/intern/rna_sound.cc index e38481a845a..0a17adc79da 100644 --- a/source/blender/makesrna/intern/rna_sound.cc +++ b/source/blender/makesrna/intern/rna_sound.cc @@ -14,7 +14,8 @@ #include "BKE_sound.h" -/* Enumeration for Audio Channels, compatible with eSoundChannels */ +#include + /* Enumeration for Audio Channels, compatible with eSoundChannels */ static const EnumPropertyItem rna_enum_audio_channels_items[] = { {SOUND_CHANNELS_INVALID, "INVALID", ICON_NONE, "Invalid", "Invalid"}, {SOUND_CHANNELS_MONO, "MONO", ICON_NONE, "Mono", "Mono"}, diff --git a/source/blender/makesrna/intern/rna_sound_api.c b/source/blender/makesrna/intern/rna_sound_api.c index 5cc7ee29afe..e5af3ce369b 100644 --- a/source/blender/makesrna/intern/rna_sound_api.c +++ b/source/blender/makesrna/intern/rna_sound_api.c @@ -29,7 +29,7 @@ static void rna_Sound_unpack(bSound *sound, Main *bmain, ReportList *reports, in } else { /* reports its own error on failure */ - BKE_packedfile_unpack_sound(bmain, reports, sound, method); + BKE_packedfile_unpack_sound(bmain, reports, sound, static_cast < ePF_FileStatus>(method)); } }