remove unused rna includes
[blender.git] / source / blender / makesrna / intern / makesrna.c
index 96953cefa2e9b926cb6a5eaaa4daaf06d3bda994..c9db05c30b13fee31c6d02470a23816cfce213db 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * Contributor(s): Blender Foundation (2008).
  *
@@ -30,9 +30,7 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "RNA_access.h"
 #include "RNA_define.h"
-#include "RNA_types.h"
 
 #include "rna_internal.h"
 
 #endif
 #endif
 
+/* Replace if different */
+#define TMP_EXT ".tmp"
+
+static int replace_if_different(char *tmpfile)
+{
+
+#define REN_IF_DIFF \
+       remove(orgfile); \
+       if(rename(tmpfile, orgfile) != 0) { \
+               fprintf(stderr, "%s:%d, rename error: \"%s\" -> \"%s\"\n", __FILE__, __LINE__, tmpfile, orgfile); \
+               return -1; \
+       } \
+       remove(tmpfile); \
+       return 1; \
+/* end REN_IF_DIFF */
+
+
+       FILE *fp_new, *fp_org;
+       int len_new, len_org;
+       char *arr_new, *arr_org;
+       int cmp;
+
+       char orgfile[4096];
+
+       strcpy(orgfile, tmpfile);
+       orgfile[strlen(orgfile) - strlen(TMP_EXT)] = '\0'; /* strip '.tmp' */
+
+       fp_org= fopen(orgfile, "rb");
+
+       if(fp_org==NULL) {
+               REN_IF_DIFF;
+       }
+
+       fp_new= fopen(tmpfile, "rb");
+
+       if(fp_new==NULL) {
+               /* shouldn't happen, just to be safe */
+               fprintf(stderr, "%s:%d, open error: \"%s\"\n", __FILE__, __LINE__, tmpfile);
+               return -1;
+       }
+
+       fseek(fp_new, 0L, SEEK_END); len_new = ftell(fp_new); fseek(fp_new, 0L, SEEK_SET);
+       fseek(fp_org, 0L, SEEK_END); len_org = ftell(fp_org); fseek(fp_org, 0L, SEEK_SET);
+
+
+       if(len_new != len_org) {
+               fclose(fp_new);
+               fclose(fp_org);
+               REN_IF_DIFF;
+       }
+
+       /* now compare the files... */
+       arr_new= MEM_mallocN(sizeof(char)*len_new, "rna_cmp_file_new");
+       arr_org= MEM_mallocN(sizeof(char)*len_org, "rna_cmp_file_org");
+
+       if(fread(arr_new, sizeof(char), len_new, fp_new) != len_new)
+               fprintf(stderr, "%s:%d, error reading file %s for comparison.\n", __FILE__, __LINE__, tmpfile);
+       if(fread(arr_org, sizeof(char), len_org, fp_org) != len_org)
+               fprintf(stderr, "%s:%d, error reading file %s for comparison.\n", __FILE__, __LINE__, orgfile);
+
+       fclose(fp_new);
+       fclose(fp_org);
+
+       cmp= memcmp(arr_new, arr_org, len_new);
+
+       MEM_freeN(arr_new);
+       MEM_freeN(arr_org);
+
+       if(cmp) {
+               REN_IF_DIFF;
+       }
+       else {
+               remove(tmpfile);
+               return 0;
+       }
+
+#undef REN_IF_DIFF
+}
+
+
+
 /* Sorting */
 
 static int cmp_struct(const void *a, const void *b)
@@ -765,6 +844,98 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
        return func;
 }
 
+static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc, char *nextfunc)
+{
+       char *func;
+
+       if(prop->flag & PROP_IDPROPERTY)
+               return NULL;
+
+       if(!manualfunc) {
+               if(!dp->dnastructname || !dp->dnaname)
+                       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);
+               else return NULL;
+       }
+
+       func= rna_alloc_function_name(srna->identifier, prop->identifier, "lookup_int");
+
+       fprintf(f, "PointerRNA %s(PointerRNA *ptr, int index)\n", func);
+       fprintf(f, "{\n");
+
+       if(manualfunc) {
+               fprintf(f, "\n  return %s(ptr, index);\n", manualfunc);
+               fprintf(f, "}\n\n");
+               return func;
+       }
+
+       fprintf(f, "    PointerRNA r_ptr;\n");
+       fprintf(f, "    CollectionPropertyIterator iter;\n\n");
+
+       fprintf(f, "    %s_%s_begin(&iter, ptr);\n\n", srna->identifier, prop->identifier);
+       fprintf(f, "    {\n");
+
+       if(strcmp(nextfunc, "rna_iterator_array_next") == 0) {
+               fprintf(f, "            ArrayIterator *internal= iter.internal;\n");
+               fprintf(f, "            if(internal->skip) {\n");
+               fprintf(f, "                    while(index-- > 0) {\n");
+               fprintf(f, "                            do {\n");
+               fprintf(f, "                                    internal->ptr += internal->itemsize;\n");
+               fprintf(f, "                            } while(internal->skip(&iter, internal->ptr));\n");
+               fprintf(f, "                    }\n");
+               fprintf(f, "            }\n");
+               fprintf(f, "            else {\n");
+               fprintf(f, "                    internal->ptr += internal->itemsize*index;\n");
+               fprintf(f, "            }\n");
+       }
+       else if(strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {
+               fprintf(f, "            ListBaseIterator *internal= iter.internal;\n");
+               fprintf(f, "            if(internal->skip) {\n");
+               fprintf(f, "                    while(index-- > 0) {\n");
+               fprintf(f, "                            do {\n");
+               fprintf(f, "                                    internal->link= internal->link->next;\n");
+               fprintf(f, "                            } while(internal->skip(&iter, internal->link));\n");
+               fprintf(f, "                    }\n");
+               fprintf(f, "            }\n");
+               fprintf(f, "            else {\n");
+               fprintf(f, "                    while(index-- > 0)\n");
+               fprintf(f, "                            internal->link= internal->link->next;\n");
+               fprintf(f, "            }\n");
+       }
+
+       fprintf(f, "    }\n\n");
+
+       fprintf(f, "    r_ptr = %s_%s_get(&iter);\n", srna->identifier, prop->identifier);
+       fprintf(f, "    %s_%s_end(&iter);\n\n", srna->identifier, prop->identifier);
+
+       fprintf(f, "    return r_ptr;\n");
+
+#if 0
+       rna_print_data_get(f, dp);
+       item_type= (cprop->item_type)? (char*)cprop->item_type: "UnknownType";
+
+       if(dp->dnalengthname || dp->dnalengthfixed) {
+               if(dp->dnalengthname)
+                       fprintf(f, "\n  rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, index);\n", item_type, dp->dnaname, dp->dnaname, dp->dnalengthname);
+               else
+                       fprintf(f, "\n  rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n", item_type, dp->dnaname, dp->dnaname, dp->dnalengthfixed);
+       }
+       else {
+               if(dp->dnapointerlevel == 0)
+                       fprintf(f, "\n  return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n", item_type, dp->dnaname);
+               else
+                       fprintf(f, "\n  return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n", item_type, dp->dnaname);
+       }
+#endif
+
+       fprintf(f, "}\n\n");
+
+       return func;
+}
+
 static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc)
 {
        char *func, *getfunc;
@@ -934,6 +1105,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
                }
                case PROP_COLLECTION: {
                        CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+                       char *nextfunc= (char*)cprop->next;
 
                        if(dp->dnatype && strcmp(dp->dnatype, "ListBase")==0);
                        else if(dp->dnalengthname || dp->dnalengthfixed)
@@ -950,6 +1122,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
                        cprop->begin= (void*)rna_def_property_begin_func(f, srna, prop, dp, (char*)cprop->begin);
                        cprop->next= (void*)rna_def_property_next_func(f, srna, prop, dp, (char*)cprop->next);
                        cprop->end= (void*)rna_def_property_end_func(f, srna, prop, dp, (char*)cprop->end);
+                       cprop->lookupint= (void*)rna_def_property_lookup_int_func(f, srna, prop, dp, (char*)cprop->lookupint, nextfunc);
 
                        if(!(prop->flag & PROP_IDPROPERTY)) {
                                if(!cprop->begin) {
@@ -1211,13 +1384,14 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
        StructRNA *srna;
        FunctionRNA *func;
        PropertyDefRNA *dparm;
-       char *funcname, *ptrstr;
-       int first;
+       PropertyType type;
+       char *funcname, *ptrstr, *valstr;
+       int flag, pout, cptr, first;
 
        srna= dsrna->srna;
        func= dfunc->func;
 
-       if(func->flag & FUNC_REGISTER)
+       if(!dfunc->call)
                return;
 
        funcname= rna_alloc_function_name(srna->identifier, func->identifier, "call");
@@ -1228,29 +1402,51 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
 
        /* variable definitions */
        if((func->flag & FUNC_NO_SELF)==0) {
+               if(func->flag & FUNC_USE_SELF_ID)
+                       fprintf(f, "\tstruct ID *_selfid;\n");
+
                if(dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
                else fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
        }
 
        dparm= dfunc->cont.properties.first;
        for(; dparm; dparm= dparm->next) {
-               if(dparm->prop->arraydimension)
+               type = dparm->prop->type;
+               flag = dparm->prop->flag;
+               pout = (flag & PROP_OUTPUT);
+               cptr = ((type == PROP_POINTER) && !(flag & PROP_RNAPTR));
+
+               if(dparm->prop==func->c_ret)
+                       ptrstr= cptr || dparm->prop->arraydimension ? "*" : "";
+               /* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
+               else if (cptr || (flag & PROP_DYNAMIC))
+                       ptrstr= pout ? "**" : "*";
+               /* fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack, pass a pointer to it */
+               else if (type == PROP_POINTER || dparm->prop->arraydimension)
                        ptrstr= "*";
-               else if(dparm->prop==func->ret)
-                       ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "*": "";
+               /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack, but type name for string props is already char*, so leave empty */
+               else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
+                       ptrstr= "";
                else
-                       ptrstr= (dparm->prop->type == PROP_POINTER)? "*": "";
-                        
+                       ptrstr= pout ? "*" : "";
+
                fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier);
+
+               /* for dynamic parameters we pass an additional int for the length of the parameter */
+               if (flag & PROP_DYNAMIC)
+                       fprintf(f, "\tint %s%s_len;\n", pout ? "*" : "", dparm->prop->identifier);
        }
 
        fprintf(f, "\tchar *_data");
-       if(func->ret) fprintf(f, ", *_retdata");
+       if(func->c_ret) fprintf(f, ", *_retdata");
        fprintf(f, ";\n");
        fprintf(f, "\t\n");
 
        /* assign self */
        if((func->flag & FUNC_NO_SELF)==0) {
+               if(func->flag & FUNC_USE_SELF_ID)
+                       fprintf(f, "\t_selfid= (struct ID*)_ptr->id.data;\n");
+
                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);
        }
@@ -1259,32 +1455,59 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
 
        dparm= dfunc->cont.properties.first;
        for(; dparm; dparm= dparm->next) {
-               if(dparm->prop==func->ret) 
+               type = dparm->prop->type;
+               flag = dparm->prop->flag;
+               pout = (flag & PROP_OUTPUT);
+               cptr = ((type == PROP_POINTER) && !(flag & PROP_RNAPTR));
+
+               if(dparm->prop==func->c_ret)
                        fprintf(f, "\t_retdata= _data;\n");
-               else if(dparm->prop->arraydimension)
-                       fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
-               else if(dparm->prop->type == PROP_POINTER) {
-                       if(dparm->prop->flag & PROP_RNAPTR)
-                               fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
-                       else
-                               fprintf(f, "\t%s= *((%s%s**)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
+               else  {
+                       if (cptr || (flag & PROP_DYNAMIC)) {
+                               ptrstr= "**";
+                               valstr= "*";
+                       }
+                       else if (type == PROP_POINTER || dparm->prop->arraydimension) {
+                               ptrstr= "*";
+                               valstr= "";
+                       }
+                       else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
+                               ptrstr= "";
+                               valstr= "";
+                       }
+                       else {
+                               ptrstr= "*";
+                               valstr= "*";
+                       }
+
+                       fprintf(f, "\t%s= ", dparm->prop->identifier);
+
+                       if (!pout)
+                               fprintf(f, "%s", valstr);
+
+                       fprintf(f, "((%s%s%s)_data);\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr);
+
+                       /* this must be kept in sync with RNA_parameter_length_get_data, we could just call the function directly, but this is faster */
+                       if (flag & PROP_DYNAMIC)
+                               fprintf(f, "\t%s_len= %s((int *)(_data+%d));\n", dparm->prop->identifier, pout ? "" : "*", rna_parameter_size(dparm->prop));
                }
-               else
-                       fprintf(f, "\t%s= *((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
 
                if(dparm->next)
-                       fprintf(f, "\t_data+= %d;\n", rna_parameter_size(dparm->prop));
+                       fprintf(f, "\t_data+= %d;\n", rna_parameter_size_alloc(dparm->prop));
        }
 
        if(dfunc->call) {
                fprintf(f, "\t\n");
                fprintf(f, "\t");
-               if(func->ret) fprintf(f, "%s= ", func->ret->identifier);
+               if(func->c_ret) fprintf(f, "%s= ", func->c_ret->identifier);
                fprintf(f, "%s(", dfunc->call);
 
                first= 1;
 
                if((func->flag & FUNC_NO_SELF)==0) {
+                       if(func->flag & FUNC_USE_SELF_ID)
+                               fprintf(f, "_selfid, ");
+
                        fprintf(f, "_self");
                        first= 0;
                }
@@ -1303,21 +1526,24 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
 
                dparm= dfunc->cont.properties.first;
                for(; dparm; dparm= dparm->next) {
-                       if(dparm->prop==func->ret)
+                       if(dparm->prop==func->c_ret)
                                continue;
 
                        if(!first) fprintf(f, ", ");
                        first= 0;
 
                        fprintf(f, "%s", dparm->prop->identifier);
+
+                       if (dparm->prop->flag & PROP_DYNAMIC)
+                               fprintf(f, ", %s_len", dparm->prop->identifier);
                }
 
                fprintf(f, ");\n");
 
-               if(func->ret) {
-                       dparm= rna_find_parameter_def(func->ret);
+               if(func->c_ret) {
+                       dparm= rna_find_parameter_def(func->c_ret);
                        ptrstr= (((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR)) || (dparm->prop->arraydimension))? "*": "";
-                       fprintf(f, "\t*((%s%s%s*)_retdata)= %s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, func->ret->identifier);
+                       fprintf(f, "\t*((%s%s%s*)_retdata)= %s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, func->c_ret->identifier);
                }
        }
 
@@ -1413,6 +1639,7 @@ static const char *rna_property_subtypename(PropertyType type)
        switch(type) {
                case PROP_NONE: return "PROP_NONE";
                case PROP_FILEPATH: return "PROP_FILEPATH";
+               case PROP_FILENAME: return "PROP_FILENAME";
                case PROP_DIRPATH: return "PROP_DIRPATH";
                case PROP_UNSIGNED: return "PROP_UNSIGNED";
                case PROP_PERCENTAGE: return "PROP_PERCENTAGE";
@@ -1551,14 +1778,16 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA
        FunctionRNA *func;
        PropertyDefRNA *dparm;
        StructDefRNA *dsrna;
-       int first;
+       PropertyType type;
+       int flag, pout, cptr, first;
+       char *ptrstr;
 
        dsrna= rna_find_struct_def(srna);
        func= dfunc->func;
 
        /* return type */
        for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) {
-               if(dparm->prop==func->ret) {
+               if(dparm->prop==func->c_ret) {
                        if(dparm->prop->arraydimension)
                                fprintf(f, "XXX no array return types yet"); /* XXX not supported */
                        else if(dparm->prop->type == PROP_POINTER && !(dparm->prop->flag & PROP_RNAPTR))
@@ -1581,6 +1810,9 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA
 
        /* self, context and reports parameters */
        if((func->flag & FUNC_NO_SELF)==0) {
+               if(func->flag & FUNC_USE_SELF_ID)
+                       fprintf(f, "struct ID *_selfid, ");
+
                if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
                else fprintf(f, "struct %s *_self", srna->identifier);
                first= 0;
@@ -1600,18 +1832,33 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA
 
        /* defined parameters */
        for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) {
-               if(dparm->prop==func->ret)
+               type = dparm->prop->type;
+               flag = dparm->prop->flag;
+               pout = (flag & PROP_OUTPUT);
+               cptr = ((type == PROP_POINTER) && !(flag & PROP_RNAPTR));
+
+               if(dparm->prop==func->c_ret)
                        continue;
 
+               if (cptr || (flag & PROP_DYNAMIC))
+                       ptrstr= pout ? "**" : "*";
+               else if (type == PROP_POINTER || dparm->prop->arraydimension)
+                       ptrstr= "*";
+               else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
+                       ptrstr= "";
+               else
+                       ptrstr= pout ? "*" : "";
+
                if(!first) fprintf(f, ", ");
                first= 0;
 
-               if(dparm->prop->arraydimension)
+               if(!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension)
                        fprintf(f, "%s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->totarraylength);
-               else if(dparm->prop->type == PROP_POINTER)
-                       fprintf(f, "%s%s *%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier);
                else
-                       fprintf(f, "%s%s %s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier);
+                       fprintf(f, "%s%s %s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier);
+
+               if (flag & PROP_DYNAMIC)
+                       fprintf(f, ", int %s%s_len", pout ? "*" : "", dparm->prop->identifier);
        }
 
        fprintf(f, ");\n");
@@ -1621,16 +1868,19 @@ static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA
 {
        FunctionRNA *func;
        FunctionDefRNA *dfunc;
-
-       fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
+       int first= 1;
 
        for(func= srna->functions.first; func; func= func->cont.next) {
-               if(func->flag & FUNC_REGISTER)
-                       continue;
-
                dfunc= rna_find_function_def(func);
-               if(dfunc->call)
+
+               if(dfunc->call) {
+                       if(first) {
+                               fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
+                               first= 0;
+                       }
+
                        rna_generate_static_parameter_prototypes(brna, srna, dfunc, f);
+               }
        }
 
        fprintf(f, "\n");
@@ -1766,7 +2016,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
        fprintf(f, "\t%s%s, %d, %s, %s,\n", (prop->flag & PROP_CONTEXT_UPDATE)? "(UpdateFunc)": "", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable), rna_function_string(prop->itemeditable));
 
        if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop);
-       else fprintf(f, "\t0, 0");
+       else fprintf(f, "\t0, -1");
 
        /* our own type - collections/arrays only */
        if(prop->srna) fprintf(f, ", &RNA_%s", (char*)prop->srna);
@@ -1890,8 +2140,8 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
                dfunc= rna_find_function_def(func);
                if(dfunc->gencall) fprintf(f, "\t%s,\n", dfunc->gencall);
                else fprintf(f, "\tNULL,\n");
-       
-               if(func->ret) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->ret->identifier);
+
+               if(func->c_ret) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->c_ret->identifier);
                else fprintf(f, "\tNULL\n");
 
                fprintf(f, "};\n");
@@ -1983,6 +2233,7 @@ RNAProcessItem PROCESS_ITEMS[]= {
        {"rna_texture.c", NULL, RNA_def_texture},
        {"rna_action.c", "rna_action_api.c", RNA_def_action},
        {"rna_animation.c", "rna_animation_api.c", RNA_def_animation},
+       {"rna_animviz.c", NULL, RNA_def_animviz},
        {"rna_actuator.c", NULL, RNA_def_actuator},
        {"rna_armature.c", "rna_armature_api.c", RNA_def_armature},
        {"rna_boid.c", NULL, RNA_def_boid},
@@ -2020,7 +2271,7 @@ RNAProcessItem PROCESS_ITEMS[]= {
        {"rna_screen.c", NULL, RNA_def_screen},
        {"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint},
        {"rna_sensor.c", NULL, RNA_def_sensor},
-       {"rna_sequence.c", NULL, RNA_def_sequence},
+       {"rna_sequencer.c", NULL, RNA_def_sequencer},
        {"rna_smoke.c", NULL, RNA_def_smoke},
        {"rna_space.c", NULL, RNA_def_space},
        {"rna_test.c", NULL, RNA_def_test},
@@ -2041,8 +2292,8 @@ static void rna_generate(BlenderRNA *brna, FILE *f, char *filename, char *api_fi
        FunctionDefRNA *dfunc;
        
        fprintf(f, "\n/* Automatically generated struct definitions for the Data API.\n"
-                    "   Do not edit manually, changes will be overwritten.           */\n\n"
-                     "#define RNA_RUNTIME\n\n");
+                                "   Do not edit manually, changes will be overwritten.           */\n\n"
+                                 "#define RNA_RUNTIME\n\n");
 
        fprintf(f, "#include <float.h>\n");
        fprintf(f, "#include <limits.h>\n");
@@ -2117,7 +2368,7 @@ static void rna_generate_header(BlenderRNA *brna, FILE *f)
        fprintf(f, "#define __RNA_BLENDER_H__\n\n");
 
        fprintf(f, "/* Automatically generated function declarations for the Data API.\n"
-                    "   Do not edit manually, changes will be overwritten.              */\n\n");
+                                "   Do not edit manually, changes will be overwritten.              */\n\n");
 
        fprintf(f, "#include \"RNA_types.h\"\n\n");
 
@@ -2272,7 +2523,7 @@ static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f)
        fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n");
 
        fprintf(f, "/* Automatically generated classes for the Data API.\n"
-                    "   Do not edit manually, changes will be overwritten. */\n\n");
+                                "   Do not edit manually, changes will be overwritten. */\n\n");
 
        fprintf(f, "#include \"RNA_blender.h\"\n");
        fprintf(f, "#include \"RNA_types.h\"\n");
@@ -2317,10 +2568,10 @@ static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f)
        fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n");
 }
 
-static void make_bad_file(char *file)
+static void make_bad_file(char *file, int line)
 {
        FILE *fp= fopen(file, "w");
-       fprintf(fp, "ERROR! Cannot make correct RNA file, STUPID!\n");
+       fprintf(fp, "#error \"Error! can't make correct RNA file from %s:%d, STUPID!\"\n", __FILE__, line);
        fclose(fp);
 }
 
@@ -2350,12 +2601,12 @@ static int rna_preprocess(char *outfile)
 
        /* create RNA_blender_cpp.h */
        strcpy(deffile, outfile);
-       strcat(deffile, "RNA_blender_cpp.h");
+       strcat(deffile, "RNA_blender_cpp.h" TMP_EXT);
 
        status= (DefRNA.error != 0);
 
        if(status) {
-               make_bad_file(deffile);
+               make_bad_file(deffile, __LINE__);
        }
        else {
                file = fopen(deffile, "w");
@@ -2367,11 +2618,12 @@ static int rna_preprocess(char *outfile)
                else {
                        rna_generate_header_cpp(brna, file);
                        fclose(file);
-
                        status= (DefRNA.error != 0);
                }
        }
 
+       replace_if_different(deffile);
+
        rna_sort(brna);
 
        /* create rna_gen_*.c files */
@@ -2379,10 +2631,10 @@ static int rna_preprocess(char *outfile)
                strcpy(deffile, outfile);
                strcat(deffile, PROCESS_ITEMS[i].filename);
                deffile[strlen(deffile)-2] = '\0';
-               strcat(deffile, "_gen.c");
+               strcat(deffile, "_gen.c" TMP_EXT);
 
                if(status) {
-                       make_bad_file(deffile);
+                       make_bad_file(deffile, __LINE__);
                }
                else {
                        file = fopen(deffile, "w");
@@ -2394,18 +2646,19 @@ static int rna_preprocess(char *outfile)
                        else {
                                rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename);
                                fclose(file);
-
                                status= (DefRNA.error != 0);
                        }
                }
+
+               replace_if_different(deffile);
        }
 
        /* create RNA_blender.h */
        strcpy(deffile, outfile);
-       strcat(deffile, "RNA_blender.h");
+       strcat(deffile, "RNA_blender.h" TMP_EXT);
 
        if(status) {
-               make_bad_file(deffile);
+               make_bad_file(deffile, __LINE__);
        }
        else {
                file = fopen(deffile, "w");
@@ -2417,11 +2670,12 @@ static int rna_preprocess(char *outfile)
                else {
                        rna_generate_header(brna, file);
                        fclose(file);
-
                        status= (DefRNA.error != 0);
                }
        }
 
+       replace_if_different(deffile);
+
        /* free RNA */
        RNA_define_free(brna);
        RNA_free(brna);
@@ -2429,7 +2683,7 @@ static int rna_preprocess(char *outfile)
        return status;
 }
 
-static void mem_error_cb(char *errorStr)
+static void mem_error_cb(const char *errorStr)
 {
        fprintf(stderr, "%s", errorStr);
        fflush(stderr);