Merge branch 'master' into blender2.8
[blender.git] / source / blender / makesrna / intern / makesrna.c
index 9b33e1f5c286d6300bfd515a845e832bc52964d8..94290828e46890f0f8ae4a50cec0723e32690d0d 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "BLI_utildefines.h"
 
-#include "RNA_access.h"
 #include "RNA_define.h"
 #include "RNA_types.h"
 
 #  endif
 #endif
 
+/* stub for BLI_abort() */
+#ifndef NDEBUG
+void BLI_system_backtrace(FILE *fp)
+{
+       (void)fp;
+}
+#endif
+
 /* Replace if different */
 #define TMP_EXT ".tmp"
 
@@ -214,12 +221,16 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[])
 
 static const char *rna_safe_id(const char *id)
 {
-       if (strcmp(id, "default") == 0)
+       if (STREQ(id, "default"))
                return "default_value";
-       else if (strcmp(id, "operator") == 0)
+       else if (STREQ(id, "operator"))
                return "operator_value";
-       else if (strcmp(id, "new") == 0)
+       else if (STREQ(id, "new"))
                return "create";
+       else if (STREQ(id, "co_return")) {
+               /* MSVC2015, C++ uses for coroutines */
+               return "coord_return";
+       }
 
        return id;
 }
@@ -239,11 +250,11 @@ static int cmp_property(const void *a, const void *b)
        const PropertyRNA *propa = *(const PropertyRNA **)a;
        const PropertyRNA *propb = *(const PropertyRNA **)b;
 
-       if (strcmp(propa->identifier, "rna_type") == 0) return -1;
-       else if (strcmp(propb->identifier, "rna_type") == 0) return 1;
+       if (STREQ(propa->identifier, "rna_type")) return -1;
+       else if (STREQ(propb->identifier, "rna_type")) return 1;
 
-       if (strcmp(propa->identifier, "name") == 0) return -1;
-       else if (strcmp(propb->identifier, "name") == 0) return 1;
+       if (STREQ(propa->identifier, "name")) return -1;
+       else if (STREQ(propb->identifier, "name")) return 1;
 
        return strcmp(propa->name, propb->name);
 }
@@ -365,7 +376,7 @@ static StructRNA *rna_find_struct(const char *identifier)
        StructDefRNA *ds;
 
        for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
-               if (strcmp(ds->srna->identifier, identifier) == 0)
+               if (STREQ(ds->srna->identifier, identifier))
                        return ds->srna;
 
        return NULL;
@@ -376,7 +387,7 @@ static const char *rna_find_type(const char *type)
        StructDefRNA *ds;
 
        for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
-               if (ds->dnaname && strcmp(ds->dnaname, type) == 0)
+               if (ds->dnaname && STREQ(ds->dnaname, type))
                        return ds->srna->identifier;
 
        return NULL;
@@ -387,7 +398,7 @@ static const char *rna_find_dna_type(const char *type)
        StructDefRNA *ds;
 
        for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
-               if (strcmp(ds->srna->identifier, type) == 0)
+               if (STREQ(ds->srna->identifier, type))
                        return ds->dnaname;
 
        return NULL;
@@ -459,7 +470,7 @@ static const char *rna_parameter_type_name(PropertyRNA *parm)
                }
                case PROP_COLLECTION:
                {
-                       return "ListBase";
+                       return "CollectionListBase";
                }
                default:
                        return "<error, no type specified>";
@@ -496,7 +507,7 @@ static void rna_float_print(FILE *f, float num)
 {
        if (num == -FLT_MAX) fprintf(f, "-FLT_MAX");
        else if (num == FLT_MAX) fprintf(f, "FLT_MAX");
-       else if ((int)num == num) fprintf(f, "%.1ff", num);
+       else if ((int64_t)num == num) fprintf(f, "%.1ff", num);
        else fprintf(f, "%.10ff", num);
 }
 
@@ -614,9 +625,9 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                        fprintf(f, "static PointerRNA %s(CollectionPropertyIterator *iter)\n", func);
                        fprintf(f, "{\n");
                        if (manualfunc) {
-                               if (strcmp(manualfunc, "rna_iterator_listbase_get") == 0 ||
-                                   strcmp(manualfunc, "rna_iterator_array_get") == 0 ||
-                                   strcmp(manualfunc, "rna_iterator_array_dereference_get") == 0)
+                               if (STREQ(manualfunc, "rna_iterator_listbase_get") ||
+                                   STREQ(manualfunc, "rna_iterator_array_get") ||
+                                   STREQ(manualfunc, "rna_iterator_array_dereference_get"))
                                {
                                        fprintf(f, "    return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n",
                                                (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType", manualfunc);
@@ -929,7 +940,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
 
                                        if (dp->dnaarraylength == 1) {
                                                if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
-                                                       fprintf(f, "            if (%svalues[i]) data->%s |= (%d<<i);\n",
+                                                       fprintf(f, "            if (%svalues[i]) data->%s |= (%du << i);\n",
                                                                (dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
                                                        fprintf(f, "            else data->%s &= ~(%du << i);\n", dp->dnaname, dp->booleanbit);
                                                }
@@ -1072,11 +1083,18 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
                        fprintf(f, "    return %s(ptr);\n", manualfunc);
                }
                else {
-                       rna_print_data_get(f, dp);
+                       if (dp->dnaarraylength <= 1 || dp->dnalengthname)
+                               rna_print_data_get(f, dp);
+
+                       if (dp->dnaarraylength > 1)
+                               fprintf(f, "    return ");
+                       else
+                               fprintf(f, "    return (data->%s == NULL) ? 0 : ", dp->dnaname);
+
                        if (dp->dnalengthname)
-                               fprintf(f, "    return (data->%s == NULL) ? 0 : data->%s;\n", dp->dnaname, dp->dnalengthname);
+                               fprintf(f, "data->%s;\n", dp->dnalengthname);
                        else
-                               fprintf(f, "    return (data->%s == NULL) ? 0 : %d;\n", dp->dnaname, dp->dnalengthfixed);
+                               fprintf(f, "%d;\n", dp->dnalengthfixed);
                }
                fprintf(f, "}\n\n");
        }
@@ -1161,8 +1179,8 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
                        return NULL;
 
                /* only supported in case of standard next functions */
-               if (strcmp(nextfunc, "rna_iterator_array_next") == 0) {}
-               else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {}
+               if (STREQ(nextfunc, "rna_iterator_array_next")) {}
+               else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {}
                else return NULL;
        }
 
@@ -1183,7 +1201,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
        fprintf(f, "    %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
        fprintf(f, "    if (iter.valid) {\n");
 
-       if (strcmp(nextfunc, "rna_iterator_array_next") == 0) {
+       if (STREQ(nextfunc, "rna_iterator_array_next")) {
                fprintf(f, "            ArrayIterator *internal = &iter.internal.array;\n");
                fprintf(f, "            if (index < 0 || index >= internal->length) {\n");
                fprintf(f, "#ifdef __GNUC__\n");
@@ -1203,7 +1221,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
                fprintf(f, "                    found = 1;\n");
                fprintf(f, "            }\n");
        }
-       else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {
+       else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {
                fprintf(f, "            ListBaseIterator *internal = &iter.internal.listbase;\n");
                fprintf(f, "            if (internal->skip) {\n");
                fprintf(f, "                    while (index-- > 0 && iter.valid) {\n");
@@ -1389,23 +1407,23 @@ static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
        if (!dp->dnatype || !dp->dnaname || !dp->dnastructname)
                return;
        
-       if (strcmp(dp->dnatype, "char") == 0) {
+       if (STREQ(dp->dnatype, "char")) {
                prop->rawtype = PROP_RAW_CHAR;
                prop->flag |= PROP_RAW_ACCESS;
        }
-       else if (strcmp(dp->dnatype, "short") == 0) {
+       else if (STREQ(dp->dnatype, "short")) {
                prop->rawtype = PROP_RAW_SHORT;
                prop->flag |= PROP_RAW_ACCESS;
        }
-       else if (strcmp(dp->dnatype, "int") == 0) {
+       else if (STREQ(dp->dnatype, "int")) {
                prop->rawtype = PROP_RAW_INT;
                prop->flag |= PROP_RAW_ACCESS;
        }
-       else if (strcmp(dp->dnatype, "float") == 0) {
+       else if (STREQ(dp->dnatype, "float")) {
                prop->rawtype = PROP_RAW_FLOAT;
                prop->flag |= PROP_RAW_ACCESS;
        }
-       else if (strcmp(dp->dnatype, "double") == 0) {
+       else if (STREQ(dp->dnatype, "double")) {
                prop->rawtype = PROP_RAW_DOUBLE;
                prop->flag |= PROP_RAW_ACCESS;
        }
@@ -1518,7 +1536,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
                        const char *nextfunc = (const char *)cprop->next;
                        const char *item_type = (const char *)cprop->item_type;
 
-                       if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) {
+                       if (dp->dnatype && STREQ(dp->dnatype, "ListBase")) {
                                /* pass */
                        }
                        else if (dp->dnalengthname || dp->dnalengthfixed) {
@@ -1528,8 +1546,8 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
                        /* test if we can allow raw array access, if it is using our standard
                         * array get/next function, we can be sure it is an actual array */
                        if (cprop->next && cprop->get)
-                               if (strcmp((const char *)cprop->next, "rna_iterator_array_next") == 0 &&
-                                   strcmp((const char *)cprop->get, "rna_iterator_array_get") == 0)
+                               if (STREQ((const char *)cprop->next, "rna_iterator_array_next") &&
+                                   STREQ((const char *)cprop->get, "rna_iterator_array_get"))
                                {
                                        prop->flag |= PROP_RAW_ARRAY;
                                }
@@ -1621,7 +1639,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
                        EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
                        int i;
 
-                       if (eprop->item) {
+                       if (eprop->item && eprop->totitem) {
                                fprintf(f, "enum {\n");
 
                                for (i = 0; i < eprop->totitem; i++)
@@ -1781,7 +1799,7 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
                }
                case PROP_STRING:
                {
-                       fprintf(f, "\tinline std::string %s(void);", rna_safe_id(prop->identifier));
+                       fprintf(f, "\tinline std::string %s(void);\n", rna_safe_id(prop->identifier));
                        fprintf(f, "\tinline void %s(const std::string& value);", rna_safe_id(prop->identifier));
                        break;
                }
@@ -1886,9 +1904,13 @@ static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *UNUSED(srn
                if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension)
                        fprintf(f, "%s %s[%u]", rna_parameter_type_cpp_name(dp->prop),
                                rna_safe_id(dp->prop->identifier), dp->prop->totarraylength);
-               else
-                       fprintf(f, "%s %s%s", rna_parameter_type_cpp_name(dp->prop),
-                               ptrstr, rna_safe_id(dp->prop->identifier));
+               else {
+                       fprintf(f, "%s%s%s%s",
+                               rna_parameter_type_cpp_name(dp->prop),
+                               (dp->prop->type == PROP_POINTER && ptrstr[0] == '\0') ? "& " : " ",
+                               ptrstr,
+                               rna_safe_id(dp->prop->identifier));
+               }
        }
 
        fprintf(f, ")");
@@ -2020,7 +2042,8 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func
 
        if ((func->flag & FUNC_NO_SELF) == 0) {
                WRITE_COMMA;
-               if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnafromname);
+               else if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
                else fprintf(f, "(::%s *) this->ptr.data", srna->identifier);
        }
        else if (func->flag & FUNC_USE_SELF_TYPE) {
@@ -2215,7 +2238,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
        }
 
        if ((func->flag & FUNC_NO_SELF) == 0) {
-               if (dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnafromname);
+               else if (dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
                else fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
        }
        else if (func->flag & FUNC_USE_SELF_TYPE) {
@@ -2267,7 +2291,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
        }
        
        if ((func->flag & FUNC_NO_SELF) == 0) {
-               if (dsrna->dnaname) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnafromname);
+               else if (dsrna->dnaname) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
                else fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", srna->identifier);
        }
        else if (func->flag & FUNC_USE_SELF_TYPE) {
@@ -2412,11 +2437,11 @@ static void rna_auto_types(void)
 
        for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
                /* DNA name for Screen is patched in 2.5, we do the reverse here .. */
-               if (ds->dnaname && strcmp(ds->dnaname, "Screen") == 0)
+               if (ds->dnaname && STREQ(ds->dnaname, "Screen"))
                        ds->dnaname = "bScreen";
 
                for (dp = ds->cont.properties.first; dp; dp = dp->next) {
-                       if (dp->dnastructname && strcmp(dp->dnastructname, "Screen") == 0)
+                       if (dp->dnastructname && STREQ(dp->dnastructname, "Screen"))
                                dp->dnastructname = "bScreen";
 
                        if (dp->dnatype) {
@@ -2436,7 +2461,7 @@ static void rna_auto_types(void)
                                else if (dp->prop->type == PROP_COLLECTION) {
                                        CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
 
-                                       if (!cprop->item_type && !cprop->get && strcmp(dp->dnatype, "ListBase") == 0)
+                                       if (!cprop->item_type && !cprop->get && STREQ(dp->dnatype, "ListBase"))
                                                cprop->item_type = (StructRNA *)rna_find_type(dp->dnatype);
                                }
                        }
@@ -2668,7 +2693,8 @@ static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, F
 
        if ((func->flag & FUNC_NO_SELF) == 0) {
                if (!first) fprintf(f, ", ");
-               if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "struct %s *_self", dsrna->dnafromname);
+               else if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
                else fprintf(f, "struct %s *_self", srna->identifier);
                first = 0;
        }
@@ -2779,7 +2805,7 @@ static void rna_generate_struct_prototypes(FILE *f)
                                                const char *struct_name = rna_parameter_type_name(dp->prop);
 
                                                for (a = 0; a < all_structures; a++) {
-                                                       if (strcmp(struct_name, structures[a]) == 0) {
+                                                       if (STREQ(struct_name, structures[a])) {
                                                                found = 1;
                                                                break;
                                                        }
@@ -3273,8 +3299,8 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_animviz.c", NULL, RNA_def_animviz},
        {"rna_actuator.c", "rna_actuator_api.c", RNA_def_actuator},
        {"rna_armature.c", "rna_armature_api.c", RNA_def_armature},
-       {"rna_boid.c", NULL, RNA_def_boid},
        {"rna_brush.c", NULL, RNA_def_brush},
+       {"rna_cachefile.c", NULL, RNA_def_cachefile},
        {"rna_camera.c", "rna_camera_api.c", RNA_def_camera},
        {"rna_cloth.c", NULL, RNA_def_cloth},
        {"rna_color.c", NULL, RNA_def_color},
@@ -3282,6 +3308,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_context.c", NULL, RNA_def_context},
        {"rna_controller.c", "rna_controller_api.c", RNA_def_controller},
        {"rna_curve.c", "rna_curve_api.c", RNA_def_curve},
+       {"rna_depsgraph.c", NULL, RNA_def_depsgraph},
        {"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint},
        {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve},
        {"rna_fluidsim.c", NULL, RNA_def_fluidsim},
@@ -3302,7 +3329,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_object.c", "rna_object_api.c", RNA_def_object},
        {"rna_object_force.c", NULL, RNA_def_object_force},
        {"rna_packedfile.c", NULL, RNA_def_packedfile},
-       {"rna_particle.c", NULL, RNA_def_particle},
+       {"rna_palette.c", NULL, RNA_def_palette},
        {"rna_pose.c", "rna_pose_api.c", RNA_def_pose},
        {"rna_property.c", NULL, RNA_def_gameproperty},
        {"rna_render.c", NULL, RNA_def_render},
@@ -3318,10 +3345,10 @@ 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", NULL, RNA_def_sound},
+       {"rna_sound.c", "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", NULL, RNA_def_vfont},
+       {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont},
        {"rna_wm.c", "rna_wm_api.c", RNA_def_wm},
        {"rna_world.c", NULL, RNA_def_world},
        {"rna_movieclip.c", NULL, RNA_def_movieclip},
@@ -3365,7 +3392,9 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
        fprintf(f, "#include \"RNA_types.h\"\n");
        fprintf(f, "#include \"rna_internal.h\"\n\n");
 
-       rna_generate_prototypes(brna, f);
+
+       /* include the generated prototypes header */
+       fprintf(f, "#include \"rna_prototypes_gen.h\"\n\n");
 
        fprintf(f, "#include \"%s\"\n", filename);
        if (api_filename)
@@ -3410,7 +3439,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
                if (!filename || ds->filename == filename)
                        rna_generate_struct(brna, ds->srna, f);
 
-       if (strcmp(filename, "rna_ID.c") == 0) {
+       if (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 */
                fprintf(f, "#include \"rna_define.c\"\n\n");
@@ -3666,6 +3695,7 @@ static const char *cpp_classes = ""
 "return *this; }\n"
 "\n"
 "      operator T*() { return data; }\n"
+"      operator const T*() const { return data; }\n"
 "};\n"
 "\n"
 "template<typename T>\n"
@@ -3675,7 +3705,7 @@ static const char *cpp_classes = ""
 "      int length;\n"
 "\n"
 "      DynamicArray() : data(NULL), length(0) {}\n"
-"      DynamicArray(int new_length) : data(NULL), length(new_length) { data = (float *)malloc(sizeof(T) * new_length); }\n"
+"      DynamicArray(int new_length) : data(NULL), length(new_length) { data = (T *)malloc(sizeof(T) * new_length); }\n"
 "      DynamicArray(const DynamicArray<T>& other) { copy_from(other); }\n"
 "      const DynamicArray<T>& operator = (const DynamicArray<T>& other) { copy_from(other); return *this; }\n"
 "\n"
@@ -3686,7 +3716,7 @@ static const char *cpp_classes = ""
 "protected:\n"
 "      void copy_from(const DynamicArray<T>& other) {\n"
 "              if (data) free(data);\n"
-"              data = (float *)malloc(sizeof(T) * other.length);\n"
+"              data = (T *)malloc(sizeof(T) * other.length);\n"
 "              memcpy(data, other.data, sizeof(T) * other.length);\n"
 "              length = other.length;\n"
 "      }\n"
@@ -3753,7 +3783,7 @@ static const char *cpp_classes = ""
 "\n"
 "class DefaultCollectionFunctions {\n"
 "public:\n"
-"      DefaultCollectionFunctions(const PointerRNA &p) {}\n"
+"      DefaultCollectionFunctions(const PointerRNA & /*p*/) {}\n"
 "};\n"
 "\n"
 "\n";
@@ -3772,7 +3802,7 @@ static int rna_is_collection_functions_struct(const char **collection_structs, c
        int a = 0, found = 0;
 
        while (collection_structs[a]) {
-               if (!strcmp(collection_structs[a], struct_name)) {
+               if (STREQ(collection_structs[a], struct_name)) {
                        found = 1;
                        break;
                }
@@ -3873,7 +3903,7 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
        for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
                srna = ds->srna;
 
-               if (!strcmp(srna->identifier, first_collection_func_struct)) {
+               if (STREQ(srna->identifier, first_collection_func_struct)) {
                        StructDefRNA *ds2;
                        StructRNA *srna2;
 
@@ -3960,6 +3990,26 @@ static int rna_preprocess(const char *outfile)
 
        status = (DefRNA.error != 0);
 
+       /* create rna prototype header file */
+       strcpy(deffile, outfile);
+       strcat(deffile, "rna_prototypes_gen.h");
+       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 function declarations for the Data API.\n"
+                   " * Do not edit manually, changes will be overwritten.              */\n\n");
+               rna_generate_prototypes(brna, file);
+               fclose(file);
+               status = (DefRNA.error != 0);
+       }
+
        /* create rna_gen_*.c files */
        for (i = 0; PROCESS_ITEMS[i].filename; i++) {
                strcpy(deffile, outfile);