Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r--source/blender/makesrna/intern/makesrna.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 3ea7f8e0df6..f19bab6870a 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3304,7 +3304,7 @@ static const char *rna_property_subtype_unit(PropertySubType type)
}
}
-static void rna_generate_prototypes(BlenderRNA *brna, FILE *f)
+static void rna_generate_internal_struct_prototypes(BlenderRNA *brna, FILE *f)
{
StructRNA *srna;
@@ -3343,7 +3343,19 @@ static void rna_generate_blender(BlenderRNA *brna, FILE *f)
"};\n\n");
}
-static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
+static void rna_generate_external_property_prototypes(BlenderRNA *brna, FILE *f)
+{
+ for (StructRNA *srna = brna->structs.first; srna; srna = srna->cont.next) {
+ for (PropertyRNA *prop = srna->cont.properties.first; prop; prop = prop->next) {
+ fprintf(f, "extern struct PropertyRNA rna_%s_%s;\n", srna->identifier, prop->identifier);
+ }
+ fprintf(f, "\n");
+ }
+}
+
+static void rna_generate_internal_property_prototypes(BlenderRNA *UNUSED(brna),
+ StructRNA *srna,
+ FILE *f)
{
PropertyRNA *prop;
StructRNA *base;
@@ -4499,7 +4511,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
if (!filename || ds->filename == filename) {
- rna_generate_property_prototypes(brna, ds->srna, f);
+ rna_generate_internal_property_prototypes(brna, ds->srna, f);
rna_generate_function_prototypes(brna, ds->srna, f);
}
}
@@ -5128,7 +5140,11 @@ static void make_bad_file(const char *file, int line)
fclose(fp);
}
-static int rna_preprocess(const char *outfile)
+/**
+ * \param extern_outfile: Directory to put public headers into. Can be NULL, in which case
+ * everything is put into \a outfile.
+ */
+static int rna_preprocess(const char *outfile, const char *public_header_outfile)
{
BlenderRNA *brna;
StructDefRNA *ds;
@@ -5137,6 +5153,10 @@ static int rna_preprocess(const char *outfile)
int i, status;
const char *deps[3]; /* expand as needed */
+ if (!public_header_outfile) {
+ public_header_outfile = outfile;
+ }
+
/* define rna */
brna = RNA_create();
@@ -5161,7 +5181,36 @@ static int rna_preprocess(const char *outfile)
status = (DefRNA.error != 0);
- /* create rna prototype header file */
+ /* Create external rna struct prototype header file RNA_prototypes.h. */
+ strcpy(deffile, public_header_outfile);
+ strcat(deffile, "RNA_prototypes.h" TMP_EXT);
+ if (status) {
+ make_bad_file(deffile, __LINE__);
+ }
+ file = fopen(deffile, "w");
+ if (!file) {
+ fprintf(stderr, "Unable to open file: %s\n", deffile);
+ status = 1;
+ }
+ else {
+ fprintf(file,
+ "/* Automatically generated RNA property declarations, to statically reference \n"
+ " * properties as `rna_[struct-name]_[property-name]`.\n"
+ " *\n"
+ " * DO NOT EDIT MANUALLY, changes will be overwritten.\n"
+ " */\n\n");
+
+ fprintf(file, "#pragma once\n\n");
+ fprintf(file, "#ifdef __cplusplus\n extern \"C\" {\n#endif\n\n");
+ rna_generate_external_property_prototypes(brna, file);
+ fprintf(file, "#ifdef __cplusplus\n }\n#endif\n");
+ fclose(file);
+ status = (DefRNA.error != 0);
+
+ replace_if_different(deffile, NULL);
+ }
+
+ /* create internal rna struct prototype header file */
strcpy(deffile, outfile);
strcat(deffile, "rna_prototypes_gen.h");
if (status) {
@@ -5176,7 +5225,7 @@ static int rna_preprocess(const char *outfile)
fprintf(file,
"/* Automatically generated function declarations for the Data API.\n"
" * Do not edit manually, changes will be overwritten. */\n\n");
- rna_generate_prototypes(brna, file);
+ rna_generate_internal_struct_prototypes(brna, file);
fclose(file);
status = (DefRNA.error != 0);
}
@@ -5288,7 +5337,7 @@ int main(int argc, char **argv)
CLG_level_set(debugSRNA);
if (argc < 2) {
- fprintf(stderr, "Usage: %s outdirectory/\n", argv[0]);
+ fprintf(stderr, "Usage: %s outdirectory [public header outdirectory]/\n", argv[0]);
return_status = 1;
}
else {
@@ -5296,7 +5345,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Running makesrna\n");
}
makesrna_path = argv[0];
- return_status = rna_preprocess(argv[1]);
+ return_status = rna_preprocess(argv[1], (argc > 2) ? argv[2] : NULL);
}
CLG_exit();