Merge branch 'master' into blender2.8
[blender.git] / source / blender / makesrna / intern / makesrna.c
index 3c2e3ddb30068cda18d9bb7bdc9b4b448c2de15c..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"
 
@@ -82,7 +89,7 @@ static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, F
                fprintf(f, param); \
        } (void)0
 
-static int replace_if_different(char *tmpfile, const char *dep_files[])
+static int replace_if_different(const char *tmpfile, const char *dep_files[])
 {
        /* return 0;  *//* use for testing had edited rna */
 
@@ -177,8 +184,8 @@ static int replace_if_different(char *tmpfile, const char *dep_files[])
 
 
        if (len_new != len_org) {
-               fclose(fp_new);
-               fclose(fp_org);
+               fclose(fp_new); fp_new = NULL;
+               fclose(fp_org); fp_org = NULL;
                REN_IF_DIFF;
        }
 
@@ -191,8 +198,8 @@ static int replace_if_different(char *tmpfile, const char *dep_files[])
        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);
+       fclose(fp_new); fp_new = NULL;
+       fclose(fp_org); fp_org = NULL;
 
        cmp = memcmp(arr_new, arr_org, len_new);
 
@@ -214,12 +221,16 @@ static int replace_if_different(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);
 }
@@ -319,15 +330,15 @@ static void rna_print_c_string(FILE *f, const char *str)
 static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
 {
        if (dp->dnastructfromname && dp->dnastructfromprop)
-               fprintf(f, "    %s *data= (%s*)(((%s*)ptr->data)->%s);\n", dp->dnastructname, dp->dnastructname,
+               fprintf(f, "    %s *data = (%s *)(((%s *)ptr->data)->%s);\n", dp->dnastructname, dp->dnastructname,
                        dp->dnastructfromname, dp->dnastructfromprop);
        else
-               fprintf(f, "    %s *data= (%s*)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
+               fprintf(f, "    %s *data = (%s *)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
 }
 
 static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp))
 {
-       fprintf(f, "    ID *id= ptr->id.data;\n");
+       fprintf(f, "    ID *id = ptr->id.data;\n");
 }
 
 static void rna_construct_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type)
@@ -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);
@@ -646,19 +657,20 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                        if (prop->flag & PROP_DYNAMIC) {
                                                char *lenfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier),
                                                                                        "get_length");
-                                               fprintf(f, "    int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
-                                               fprintf(f, "    int len= %s(ptr, arraylen);\n\n", lenfunc);
-                                               fprintf(f, "    for (i=0; i < len; i++) {\n");
+                                               fprintf(f, "    unsigned int arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
+                                               fprintf(f, "    unsigned int i;\n");
+                                               fprintf(f, "    unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
+                                               fprintf(f, "    for (i = 0; i < len; i++) {\n");
                                                MEM_freeN(lenfunc);
                                        }
                                        else {
-                                               fprintf(f, "    int i;\n\n");
-                                               fprintf(f, "    for (i=0; i < %u; i++) {\n", prop->totarraylength);
+                                               fprintf(f, "    unsigned int i;\n\n");
+                                               fprintf(f, "    for (i = 0; i < %u; i++) {\n", prop->totarraylength);
                                        }
 
                                        if (dp->dnaarraylength == 1) {
                                                if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
-                                                       fprintf(f, "            values[i] = %s((data->%s & (%d << i)) != 0);\n",
+                                                       fprintf(f, "            values[i] = %s((data->%s & (%du << i)) != 0);\n",
                                                                (dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
                                                }
                                                else {
@@ -674,11 +686,11 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                                        fprintf(f, ") != 0);\n");
                                                }
                                                else if (rna_color_quantize(prop, dp)) {
-                                                       fprintf(f, "            values[i] = (%s)(data->%s[i]*(1.0f / 255.0f));\n",
+                                                       fprintf(f, "            values[i] = (%s)(data->%s[i] * (1.0f / 255.0f));\n",
                                                                rna_type_type(prop), dp->dnaname);
                                                }
                                                else if (dp->dnatype) {
-                                                       fprintf(f, "            values[i] = (%s)%s(((%s*)data->%s)[i]);\n",
+                                                       fprintf(f, "            values[i] = (%s)%s(((%s *)data->%s)[i]);\n",
                                                                rna_type_type(prop), (dp->booleannegative) ? "!" : "", dp->dnatype, dp->dnaname);
                                                }
                                                else {
@@ -744,6 +756,24 @@ static void rna_clamp_value_range(FILE *f, PropertyRNA *prop)
        }
 }
 
+#ifdef USE_RNA_RANGE_CHECK
+static void rna_clamp_value_range_check(
+        FILE *f, PropertyRNA *prop,
+        const char *dnaname_prefix, const char *dnaname)
+{
+       if (prop->type == PROP_INT) {
+               IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
+               fprintf(f,
+                       "       { BLI_STATIC_ASSERT("
+                       "(TYPEOF_MAX(%s%s) >= %d) && "
+                       "(TYPEOF_MIN(%s%s) <= %d), "
+                       "\"invalid limits\"); }\n",
+                       dnaname_prefix, dnaname, iprop->hardmax,
+                       dnaname_prefix, dnaname, iprop->hardmin);
+       }
+}
+#endif  /* USE_RNA_RANGE_CHECK */
+
 static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
 {
        if (prop->type == PROP_INT) {
@@ -896,23 +926,23 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                        if (prop->flag & PROP_DYNAMIC) {
                                                char *lenfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier),
                                                                                        "set_length");
-                                               fprintf(f, "    int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
-                                               fprintf(f, "    int len= %s(ptr, arraylen);\n\n", lenfunc);
+                                               fprintf(f, "    unsigned int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
+                                               fprintf(f, "    unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
                                                rna_clamp_value_range(f, prop);
-                                               fprintf(f, "    for (i=0; i < len; i++) {\n");
+                                               fprintf(f, "    for (i = 0; i < len; i++) {\n");
                                                MEM_freeN(lenfunc);
                                        }
                                        else {
-                                               fprintf(f, "    int i;\n\n");
+                                               fprintf(f, "    unsigned int i;\n\n");
                                                rna_clamp_value_range(f, prop);
-                                               fprintf(f, "    for (i=0; i < %u; i++) {\n", prop->totarraylength);
+                                               fprintf(f, "    for (i = 0; i < %u; i++) {\n", prop->totarraylength);
                                        }
 
                                        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 &= ~(%d << i);\n", dp->dnaname, dp->booleanbit);
+                                                       fprintf(f, "            else data->%s &= ~(%du << i);\n", dp->dnaname, dp->booleanbit);
                                                }
                                                else {
                                                        fprintf(f, "            (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
@@ -934,7 +964,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                                }
                                                else {
                                                        if (dp->dnatype)
-                                                               fprintf(f, "            ((%s*)data->%s)[i] = %s", dp->dnatype, dp->dnaname,
+                                                               fprintf(f, "            ((%s *)data->%s)[i] = %s", dp->dnatype, dp->dnaname,
                                                                        (dp->booleannegative) ? "!" : "");
                                                        else
                                                                fprintf(f, "            (data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
@@ -943,6 +973,18 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                        }
                                        fprintf(f, "    }\n");
                                }
+
+#ifdef USE_RNA_RANGE_CHECK
+                               if (dp->dnaname && manualfunc == NULL) {
+                                       if (dp->dnaarraylength == 1) {
+                                               rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
+                                       }
+                                       else {
+                                               rna_clamp_value_range_check(f, prop, "*data->", dp->dnaname);
+                                       }
+                               }
+#endif
+
                                fprintf(f, "}\n\n");
                        }
                        else {
@@ -974,6 +1016,13 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                                rna_clamp_value(f, prop, 0);
                                        }
                                }
+
+#ifdef USE_RNA_RANGE_CHECK
+                               if (dp->dnaname && manualfunc == NULL) {
+                                       rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
+                               }
+#endif
+
                                fprintf(f, "}\n\n");
                        }
                        break;
@@ -1034,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");
        }
@@ -1072,8 +1128,8 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
                rna_print_data_get(f, dp);
 
        fprintf(f, "\n  memset(iter, 0, sizeof(*iter));\n");
-       fprintf(f, "    iter->parent= *ptr;\n");
-       fprintf(f, "    iter->prop= (PropertyRNA *)&rna_%s_%s;\n", srna->identifier, prop->identifier);
+       fprintf(f, "    iter->parent = *ptr;\n");
+       fprintf(f, "    iter->prop = (PropertyRNA *)&rna_%s_%s;\n", srna->identifier, prop->identifier);
 
        if (dp->dnalengthname || dp->dnalengthfixed) {
                if (manualfunc) {
@@ -1100,7 +1156,7 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
        getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
 
        fprintf(f, "\n  if (iter->valid)\n");
-       fprintf(f, "            iter->ptr= %s(iter);\n", getfunc);
+       fprintf(f, "            iter->ptr = %s(iter);\n", getfunc);
 
        fprintf(f, "}\n\n");
 
@@ -1112,7 +1168,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
                                               const char *manualfunc, const char *nextfunc)
 {
        /* note on indices, this is for external functions and ignores skipped values.
-        * so the the index can only be checked against the length when there is no 'skip' function. */
+        * so the index can only be checked against the length when there is no 'skip' function. */
        char *func;
 
        if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
@@ -1123,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;
        }
 
@@ -1139,14 +1195,14 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
                return func;
        }
 
-       fprintf(f, "    int found= 0;\n");
+       fprintf(f, "    int found = 0;\n");
        fprintf(f, "    CollectionPropertyIterator iter;\n\n");
 
        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) {
-               fprintf(f, "            ArrayIterator *internal= iter.internal;\n");
+       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");
                fprintf(f, "                    printf(\"Array iterator out of range: %%s (index %%d)\\n\", __func__, index);\n");
@@ -1158,25 +1214,25 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
                fprintf(f, "                    while (index-- > 0 && iter.valid) {\n");
                fprintf(f, "                            rna_iterator_array_next(&iter);\n");
                fprintf(f, "                    }\n");
-               fprintf(f, "                    found= (index == -1 && iter.valid);\n");
+               fprintf(f, "                    found = (index == -1 && iter.valid);\n");
                fprintf(f, "            }\n");
                fprintf(f, "            else {\n");
-               fprintf(f, "                    internal->ptr += internal->itemsize*index;\n");
-               fprintf(f, "                    found= 1;\n");
+               fprintf(f, "                    internal->ptr += internal->itemsize * index;\n");
+               fprintf(f, "                    found = 1;\n");
                fprintf(f, "            }\n");
        }
-       else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {
-               fprintf(f, "            ListBaseIterator *internal= iter.internal;\n");
+       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");
                fprintf(f, "                            rna_iterator_listbase_next(&iter);\n");
                fprintf(f, "                    }\n");
-               fprintf(f, "                    found= (index == -1 && iter.valid);\n");
+               fprintf(f, "                    found = (index == -1 && iter.valid);\n");
                fprintf(f, "            }\n");
                fprintf(f, "            else {\n");
                fprintf(f, "                    while (index-- > 0 && internal->link)\n");
-               fprintf(f, "                            internal->link= internal->link->next;\n");
-               fprintf(f, "                    found= (index == -1 && internal->link);\n");
+               fprintf(f, "                            internal->link = internal->link->next;\n");
+               fprintf(f, "                    found = (index == -1 && internal->link);\n");
                fprintf(f, "            }\n");
        }
 
@@ -1256,7 +1312,7 @@ static char *rna_def_property_lookup_string_func(FILE *f, StructRNA *srna, Prope
        fprintf(f, "    extern int %s_%s_length(PointerRNA *);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
        fprintf(f, "    extern void %s_%s_get(PointerRNA *, char *);\n\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
 
-       fprintf(f, "    int found= 0;\n");
+       fprintf(f, "    bool found = false;\n");
        fprintf(f, "    CollectionPropertyIterator iter;\n");
        fprintf(f, "    char namebuf[%d];\n", namebuflen);
        fprintf(f, "    char *name;\n\n");
@@ -1264,26 +1320,29 @@ static char *rna_def_property_lookup_string_func(FILE *f, StructRNA *srna, Prope
        fprintf(f, "    %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
 
        fprintf(f, "    while (iter.valid) {\n");
-       fprintf(f, "            int namelen = %s_%s_length(&iter.ptr);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
-       fprintf(f, "            if (namelen < %d) {\n", namebuflen);
-       fprintf(f, "                    %s_%s_get(&iter.ptr, namebuf);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
-       fprintf(f, "                    if (strcmp(namebuf, key) == 0) {\n");
-       fprintf(f, "                            found = 1;\n");
-       fprintf(f, "                            *r_ptr = iter.ptr;\n");
-       fprintf(f, "                            break;\n");
+       fprintf(f, "            if (iter.ptr.data) {\n");
+       fprintf(f, "                    int namelen = %s_%s_length(&iter.ptr);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
+       fprintf(f, "                    if (namelen < %d) {\n", namebuflen);
+       fprintf(f, "                            %s_%s_get(&iter.ptr, namebuf);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
+       fprintf(f, "                            if (strcmp(namebuf, key) == 0) {\n");
+       fprintf(f, "                                    found = true;\n");
+       fprintf(f, "                                    *r_ptr = iter.ptr;\n");
+       fprintf(f, "                                    break;\n");
+       fprintf(f, "                            }\n");
        fprintf(f, "                    }\n");
-       fprintf(f, "            }\n");
-       fprintf(f, "            else {\n");
-       fprintf(f, "                    name = MEM_mallocN(namelen+1, \"name string\");\n");
-       fprintf(f, "                    %s_%s_get(&iter.ptr, name);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
-       fprintf(f, "                    if (strcmp(name, key) == 0) {\n");
-       fprintf(f, "                            MEM_freeN(name);\n\n");
-       fprintf(f, "                            found = 1;\n");
-       fprintf(f, "                            *r_ptr = iter.ptr;\n");
-       fprintf(f, "                            break;\n");
+       fprintf(f, "                    else {\n");
+       fprintf(f, "                            name = MEM_mallocN(namelen+1, \"name string\");\n");
+       fprintf(f, "                            %s_%s_get(&iter.ptr, name);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
+       fprintf(f, "                            if (strcmp(name, key) == 0) {\n");
+       fprintf(f, "                                    MEM_freeN(name);\n\n");
+       fprintf(f, "                                    found = true;\n");
+       fprintf(f, "                                    *r_ptr = iter.ptr;\n");
+       fprintf(f, "                                    break;\n");
+       fprintf(f, "                            }\n");
+       fprintf(f, "                            else {\n");
+       fprintf(f, "                                    MEM_freeN(name);\n");
+       fprintf(f, "                            }\n");
        fprintf(f, "                    }\n");
-       fprintf(f, "                    else\n");
-       fprintf(f, "                            MEM_freeN(name);\n");
        fprintf(f, "            }\n");
        fprintf(f, "            %s_%s_next(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
        fprintf(f, "    }\n");
@@ -1315,7 +1374,7 @@ static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *p
        getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
 
        fprintf(f, "\n  if (iter->valid)\n");
-       fprintf(f, "            iter->ptr= %s(iter);\n", getfunc);
+       fprintf(f, "            iter->ptr = %s(iter);\n", getfunc);
 
        fprintf(f, "}\n\n");
 
@@ -1348,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;
        }
@@ -1477,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) {
@@ -1487,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;
                                }
@@ -1532,7 +1591,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
 static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
 {
        PropertyRNA *prop;
-       char *func;
+       const char *func;
 
        prop = dp->prop;
 
@@ -1551,7 +1610,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
                        }
                        else if (prop->arraydimension && prop->totarraylength) {
                                fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength);
-                               fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->totarraylength);
+                               fprintf(f, "void %sset(PointerRNA *ptr, const int values[%u]);\n", func, prop->totarraylength);
                        }
                        else {
                                fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func);
@@ -1567,7 +1626,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
                        }
                        else if (prop->arraydimension && prop->totarraylength) {
                                fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength);
-                               fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->totarraylength);
+                               fprintf(f, "void %sset(PointerRNA *ptr, const float values[%u]);\n", func, prop->totarraylength);
                        }
                        else {
                                fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func);
@@ -1580,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++)
@@ -1659,12 +1718,15 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
        if (prop->flag & (PROP_IDPROPERTY | PROP_BUILTIN))
                return;
        
+       /* disabled for now to avoid msvc compiler error due to large file size */
+#if 0
        if (prop->name && prop->description && prop->description[0] != '\0')
                fprintf(f, "\t/* %s: %s */\n", prop->name, prop->description);
        else if (prop->name)
                fprintf(f, "\t/* %s */\n", prop->name);
        else
                fprintf(f, "\t/* */\n");
+#endif
 
        switch (prop->type) {
                case PROP_BOOLEAN:
@@ -1737,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;
                }
@@ -1761,12 +1823,12 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
 
                        if (cprop->item_type)
                                fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, (const char *)cprop->item_type, srna->identifier,
-                                       rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"),
-                                       (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
+                                       rna_safe_id(prop->identifier), (cprop->length ? "true" : "false"),
+                                       (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
                        else
                                fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, "UnknownType", srna->identifier,
-                                       rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"),
-                                       (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
+                                       rna_safe_id(prop->identifier), (cprop->length ? "true" : "false"),
+                                       (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
                        break;
                }
        }
@@ -1826,7 +1888,7 @@ static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *UNUSED(srn
                if (flag & PROP_DYNAMIC)
                        ptrstr = pout ? "**" : "*";
                else if (type == PROP_POINTER)
-                       ptrstr = pout ? "*": "";
+                       ptrstr = pout ? "*" : "";
                else if (dp->prop->arraydimension)
                        ptrstr = "*";
                else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
@@ -1842,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, ")");
@@ -1854,14 +1920,15 @@ static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *UNUSED(srn
 
 static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
 {
-       FunctionRNA *func = dfunc->func;
-
-       if (!dfunc->call)
-               return;
-
-       fprintf(f, "\n\t/* %s */\n", func->description);
+       if (dfunc->call) {
+               /* disabled for now to avoid msvc compiler error due to large file size */
+#if 0
+               FunctionRNA *func = dfunc->func;
+               fprintf(f, "\n\t/* %s */\n", func->description);
+#endif
 
-       rna_def_struct_function_prototype_cpp(f, srna, dfunc, NULL, 1);
+               rna_def_struct_function_prototype_cpp(f, srna, dfunc, NULL, 1);
+       }
 }
 
 static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
@@ -1941,12 +2008,12 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
 
                        if (cprop->type)
                                fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->type, srna->identifier,
-                                       prop->identifier, (cprop->length ? "TRUE" : "FALSE"),
-                                       (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
+                                       prop->identifier, (cprop->length ? "true" : "false"),
+                                       (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
                        else
                                fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", srna->identifier,
-                                       prop->identifier, (cprop->length ? "TRUE" : "FALSE"),
-                                       (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE"));
+                                       prop->identifier, (cprop->length ? "true" : "false"),
+                                       (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
 #endif
                        break;
                }
@@ -1975,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) {
@@ -2148,7 +2216,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
        PropertyType type;
        const char *funcname, *valstr;
        const char *ptrstr;
-       const short has_data = (dfunc->cont.properties.first != NULL);
+       const bool has_data = (dfunc->cont.properties.first != NULL);
        int flag, pout, cptr, first;
 
        srna = dsrna->srna;
@@ -2170,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) {
@@ -2195,7 +2264,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
                else if ((type == PROP_POINTER) && (flag & PROP_RNAPTR) && !(flag & PROP_THICK_WRAP))
                        ptrstr = "*";
                /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
-                * but type name for string props is already char*, so leave empty */
+                * but type name for string props is already (char *), so leave empty */
                else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
                        ptrstr = "";
                else
@@ -2218,19 +2287,20 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
 
        /* assign self */
        if (func->flag & FUNC_USE_SELF_ID) {
-               fprintf(f, "\t_selfid= (struct ID*)_ptr->id.data;\n");
+               fprintf(f, "\t_selfid = (struct ID *)_ptr->id.data;\n");
        }
        
        if ((func->flag & FUNC_NO_SELF) == 0) {
-               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);
+               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) {
-               fprintf(f, "\t_type= _ptr->type;\n");
+               fprintf(f, "\t_type = _ptr->type;\n");
        }
 
        if (has_data) {
-               fprintf(f, "\t_data= (char *)_parms->data;\n");
+               fprintf(f, "\t_data = (char *)_parms->data;\n");
        }
 
        dparm = dfunc->cont.properties.first;
@@ -2241,7 +2311,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
                cptr = ((type == PROP_POINTER) && !(flag & PROP_RNAPTR));
 
                if (dparm->prop == func->c_ret)
-                       fprintf(f, "\t_retdata= _data;\n");
+                       fprintf(f, "\t_retdata = _data;\n");
                else {
                        const char *data_str;
                        if (cptr || (flag & PROP_DYNAMIC)) {
@@ -2265,11 +2335,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
                                valstr = "*";
                        }
 
-                       /* this must be kept in sync with RNA_parameter_length_get_data,
+                       /* this must be kept in sync with RNA_parameter_dynamic_length_get_data and RNA_parameter_get,
                         * we could just call the function directly, but this is faster */
                        if (flag & PROP_DYNAMIC) {
-                               fprintf(f, "\t%s_len= %s((int *)_data);\n", dparm->prop->identifier, pout ? "" : "*");
-                               data_str = "(&(((char *)_data)[sizeof(void *)]))";
+                               fprintf(f, "\t%s_len = %s((ParameterDynAlloc *)_data)->array_tot;\n", dparm->prop->identifier,
+                                                                                                     pout ? "(int *)&" : "(int)");
+                               data_str = "(&(((ParameterDynAlloc *)_data)->array))";
                        }
                        else {
                                data_str = "_data";
@@ -2279,12 +2350,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
                        if (!pout)
                                fprintf(f, "%s", valstr);
 
-                       fprintf(f, "((%s%s%s)%s);\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
+                       fprintf(f, "((%s%s %s)%s);\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
                                ptrstr, data_str);
                }
 
                if (dparm->next)
-                       fprintf(f, "\t_data += %d;\n", rna_parameter_size_alloc(dparm->prop));
+                       fprintf(f, "\t_data += %d;\n", rna_parameter_size(dparm->prop));
        }
 
        if (dfunc->call) {
@@ -2349,7 +2420,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
                        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),
+                       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);
                }
        }
@@ -2366,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) {
@@ -2390,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);
                                }
                        }
@@ -2434,6 +2505,7 @@ static const char *rna_property_subtypename(PropertySubType type)
                case PROP_FILEPATH: return "PROP_FILEPATH";
                case PROP_FILENAME: return "PROP_FILENAME";
                case PROP_DIRPATH: return "PROP_DIRPATH";
+               case PROP_PIXEL: return "PROP_PIXEL";
                case PROP_BYTESTRING: return "PROP_BYTESTRING";
                case PROP_UNSIGNED: return "PROP_UNSIGNED";
                case PROP_PERCENTAGE: return "PROP_PERCENTAGE";
@@ -2621,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;
        }
@@ -2683,7 +2756,11 @@ static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, F
 
        }
 
+       /* ensure func(void) if there are no args */
+       if (first) fprintf(f, "void");
+
        fprintf(f, ")");
+
        if (close_prototype)
                fprintf(f, ";\n");
 }
@@ -2728,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;
                                                        }
@@ -2755,7 +2832,7 @@ static void rna_generate_struct_prototypes(FILE *f)
 
 static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, PropertyRNA *prop)
 {
-       char *strnest = "", *errnest = "";
+       char *strnest = (char *)"", *errnest = (char *)"";
        int len, freenest = 0;
        
        if (nest != NULL) {
@@ -2908,9 +2985,9 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
        fprintf(f, ", %d, ", prop->flag);
        rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
        rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
-       fprintf(f, "%d,\n", prop->icon);
-       rna_print_c_string(f, prop->translation_context); fprintf(f, ",\n\t");
-       fprintf(f, "\t%s, %s|%s, %s, %u, {%u, %u, %u}, %u,\n",
+       fprintf(f, "%d, ", prop->icon);
+       rna_print_c_string(f, prop->translation_context); fprintf(f, ",\n");
+       fprintf(f, "\t%s, %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),
@@ -3148,14 +3225,14 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE
        else fprintf(f, "NULL}},\n");
        fprintf(f, "\t");
        rna_print_c_string(f, srna->identifier);
-       fprintf(f, "\t, NULL,NULL\n"); /* PyType - Cant initialize here */
+       fprintf(f, ", NULL, NULL"); /* PyType - Cant initialize here */
        fprintf(f, ", %d, ", srna->flag);
        rna_print_c_string(f, srna->name);
-       fprintf(f, ", ");
+       fprintf(f, ",\n\t");
        rna_print_c_string(f, srna->description);
-       fprintf(f, ", ");
+       fprintf(f, ",\n\t");
        rna_print_c_string(f, srna->translation_context);
-       fprintf(f, ",\n\t%d,\n", srna->icon);
+       fprintf(f, ", %d,\n", srna->icon);
 
        prop = srna->nameproperty;
        if (prop) {
@@ -3222,15 +3299,16 @@ 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},
        {"rna_constraint.c", NULL, RNA_def_constraint},
        {"rna_context.c", NULL, RNA_def_context},
        {"rna_controller.c", "rna_controller_api.c", RNA_def_controller},
-       {"rna_curve.c", NULL, RNA_def_curve},
+       {"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},
@@ -3239,7 +3317,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_image.c", "rna_image_api.c", RNA_def_image},
        {"rna_key.c", NULL, RNA_def_key},
        {"rna_lamp.c", NULL, RNA_def_lamp},
-       {"rna_lattice.c", NULL, RNA_def_lattice},
+       {"rna_lattice.c", "rna_lattice_api.c", RNA_def_lattice},
        {"rna_linestyle.c", NULL, RNA_def_linestyle},
        {"rna_main.c", "rna_main_api.c", RNA_def_main},
        {"rna_material.c", "rna_material_api.c", RNA_def_material},
@@ -3251,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},
@@ -3262,15 +3340,15 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_sensor.c", "rna_sensor_api.c", RNA_def_sensor},
        {"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer},
        {"rna_smoke.c", NULL, RNA_def_smoke},
-       {"rna_space.c", NULL, RNA_def_space},
+       {"rna_space.c", "rna_space_api.c", RNA_def_space},
        {"rna_speaker.c", NULL, RNA_def_speaker},
        {"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},
@@ -3314,13 +3392,21 @@ 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)
                fprintf(f, "#include \"%s\"\n", api_filename);
        fprintf(f, "\n");
 
+       /* we want the included C files to have warnings enabled but for the generated code
+        * ignore unused-parameter warnings which are hard to prevent */
+#ifdef __GNUC__
+       fprintf(f, "#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n\n");
+#endif
+
        fprintf(f, "/* Autogenerated Functions */\n\n");
 
        for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
@@ -3353,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");
@@ -3385,7 +3471,7 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f)
        fprintf(f, "            CollectionPropertyIterator rna_macro_iter; \\\n");
        fprintf(f, "            for (property##_begin(&rna_macro_iter, sptr); rna_macro_iter.valid; "
                "property##_next(&rna_macro_iter)) { \\\n");
-       fprintf(f, "                    itemptr= rna_macro_iter.ptr;\n\n");
+       fprintf(f, "                    itemptr = rna_macro_iter.ptr;\n\n");
 
        fprintf(f, "#define FOREACH_END(property) \\\n");
        fprintf(f, "            } \\\n");
@@ -3427,7 +3513,7 @@ static const char *cpp_classes = ""
 "      inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
 "\n"
 "#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-"      inline Array<int,size> sname::identifier(void) \\\n"
+"      inline Array<int, size> sname::identifier(void) \\\n"
 "              { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
 "      inline void sname::identifier(int values[size]) \\\n"
 "              { sname##_##identifier##_set(&ptr, values); } \\\n"
@@ -3447,7 +3533,7 @@ static const char *cpp_classes = ""
 "      inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
 "\n"
 "#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-"      inline Array<int,size> sname::identifier(void) \\\n"
+"      inline Array<int, size> sname::identifier(void) \\\n"
 "              { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
 "      inline void sname::identifier(int values[size]) \\\n"
 "              { sname##_##identifier##_set(&ptr, values); } \\\n"
@@ -3467,7 +3553,7 @@ static const char *cpp_classes = ""
 "      inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n"
 "\n"
 "#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
-"      inline Array<float,size> sname::identifier(void) \\\n"
+"      inline Array<float, size> sname::identifier(void) \\\n"
 "              { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
 "      inline void sname::identifier(float values[size]) \\\n"
 "              { sname##_##identifier##_set(&ptr, values); } \\\n"
@@ -3488,7 +3574,7 @@ static const char *cpp_classes = ""
 "\n"
 "#define STRING_PROPERTY(sname, identifier) \\\n"
 "      inline std::string sname::identifier(void) { \\\n"
-"              int len= sname##_##identifier##_length(&ptr); \\\n"
+"              int len = sname##_##identifier##_length(&ptr); \\\n"
 "              std::string str; str.resize(len); \\\n"
 "              sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n"
 "      inline void sname::identifier(const std::string& value) { \\\n"
@@ -3497,7 +3583,7 @@ static const char *cpp_classes = ""
 "#define POINTER_PROPERTY(type, sname, identifier) \\\n"
 "      inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
 "\n"
-"#define COLLECTION_PROPERTY_LENGTH_FALSE(sname, identifier) \\\n"
+"#define COLLECTION_PROPERTY_LENGTH_false(sname, identifier) \\\n"
 "      inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
 "      { \\\n"
 "              CollectionPropertyIterator iter; \\\n"
@@ -3510,11 +3596,11 @@ static const char *cpp_classes = ""
 "              sname##_##identifier##_end(&iter); \\\n"
 "              return length; \\\n"
 "      } \n"
-"#define COLLECTION_PROPERTY_LENGTH_TRUE(sname, identifier) \\\n"
+"#define COLLECTION_PROPERTY_LENGTH_true(sname, identifier) \\\n"
 "      inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
 "      { return sname##_##identifier##_length(ptr); } \n"
 "\n"
-"#define COLLECTION_PROPERTY_LOOKUP_INT_FALSE(sname, identifier) \\\n"
+"#define COLLECTION_PROPERTY_LOOKUP_INT_false(sname, identifier) \\\n"
 "      inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n"
 "      { \\\n"
 "              CollectionPropertyIterator iter; \\\n"
@@ -3534,11 +3620,15 @@ static const char *cpp_classes = ""
 "                      memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
 "              return found; \\\n"
 "      } \n"
-"#define COLLECTION_PROPERTY_LOOKUP_INT_TRUE(sname, identifier) \\\n"
+"#define COLLECTION_PROPERTY_LOOKUP_INT_true(sname, identifier) \\\n"
 "      inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n"
-"      { return sname##_##identifier##_lookup_int(ptr, key, r_ptr); } \n"
-"\n"
-"#define COLLECTION_PROPERTY_LOOKUP_STRING_FALSE(sname, identifier) \\\n"
+"      { \\\n"
+"              int found = sname##_##identifier##_lookup_int(ptr, key, r_ptr); \\\n"
+"              if (!found) \\\n"
+"                      memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
+"              return found; \\\n"
+"      } \n"
+"#define COLLECTION_PROPERTY_LOOKUP_STRING_false(sname, identifier) \\\n"
 "      inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n"
 "      { \\\n"
 "              CollectionPropertyIterator iter; \\\n"
@@ -3563,10 +3653,14 @@ static const char *cpp_classes = ""
 "                      memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
 "              return found; \\\n"
 "      } \n"
-"#define COLLECTION_PROPERTY_LOOKUP_STRING_TRUE(sname, identifier) \\\n"
+"#define COLLECTION_PROPERTY_LOOKUP_STRING_true(sname, identifier) \\\n"
 "      inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n"
-"      { return sname##_##identifier##_lookup_string(ptr, key, r_ptr); } \n"
-"\n"
+"      { \\\n"
+"              int found = sname##_##identifier##_lookup_string(ptr, key, r_ptr); \\\n"
+"              if (!found) \\\n"
+"                      memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
+"              return found; \\\n"
+"      } \n"
 "#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, has_lookup_int, has_lookup_string) \\\n"
 "      typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n"
 "              sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n"
@@ -3597,10 +3691,11 @@ static const char *cpp_classes = ""
 "\n"
 "      Array() {}\n"
 "      Array(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n"
-"      const Array<T, Tsize>& operator=(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); "
+"      const Array<T, Tsize>& operator = (const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); "
 "return *this; }\n"
 "\n"
 "      operator T*() { return data; }\n"
+"      operator const T*() const { return data; }\n"
 "};\n"
 "\n"
 "template<typename T>\n"
@@ -3610,9 +3705,9 @@ 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"
+"      const DynamicArray<T>& operator = (const DynamicArray<T>& other) { copy_from(other); return *this; }\n"
 "\n"
 "      ~DynamicArray() { if (data) free(data); }\n"
 "\n"
@@ -3621,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"
@@ -3637,7 +3732,7 @@ static const char *cpp_classes = ""
 "template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
 "class CollectionIterator {\n"
 "public:\n"
-"      CollectionIterator() : t(iter.ptr), init(false) { iter.valid= false; }\n"
+"      CollectionIterator() : t(iter.ptr), init(false) { iter.valid = false; }\n"
 "      ~CollectionIterator(void) { if (init) Tend(&iter); };\n"
 "\n"
 "      operator bool(void)\n"
@@ -3646,7 +3741,7 @@ static const char *cpp_classes = ""
 "\n"
 "      T& operator*(void) { return t; }\n"
 "      T* operator->(void) { return &t; }\n"
-"      bool operator==(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
+"      bool operator == (const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
 "{ return iter.valid == other.iter.valid; }\n"
 "      bool operator!=(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
 "{ return iter.valid != other.iter.valid; }\n"
@@ -3655,7 +3750,7 @@ static const char *cpp_classes = ""
 "      { if (init) Tend(&iter); Tbegin(&iter, (PointerRNA *)&ptr.ptr); t = T(iter.ptr); init = true; }\n"
 "\n"
 "private:\n"
-"      const CollectionIterator<T, Tbegin, Tnext, Tend>& operator="
+"      const CollectionIterator<T, Tbegin, Tnext, Tend>& operator = "
 "(const CollectionIterator<T, Tbegin, Tnext, Tend>& copy) {}\n"
 ""
 "      CollectionPropertyIterator iter;\n"
@@ -3668,7 +3763,7 @@ static const char *cpp_classes = ""
 "         typename Tcollection_funcs>\n"
 "class Collection : public Tcollection_funcs {\n"
 "public:\n"
-"      Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p)  {}\n"
+"      Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n"
 "\n"
 "      void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n"
 "      { iter.begin(ptr); }\n"
@@ -3688,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";
@@ -3707,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;
                }
@@ -3808,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;
 
@@ -3895,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);