Merge branch 'master' into blender2.8
[blender.git] / source / blender / makesrna / intern / makesrna.c
index dfd0f13ec1aa2dcc3c59d547cc959b751eedd7c7..94290828e46890f0f8ae4a50cec0723e32690d0d 100644 (file)
@@ -227,6 +227,10 @@ static const char *rna_safe_id(const char *id)
                return "operator_value";
        else if (STREQ(id, "new"))
                return "create";
+       else if (STREQ(id, "co_return")) {
+               /* MSVC2015, C++ uses for coroutines */
+               return "coord_return";
+       }
 
        return id;
 }
@@ -466,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>";
@@ -503,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);
 }
 
@@ -1079,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");
        }
@@ -1788,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;
                }
@@ -1893,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, ")");
@@ -3284,8 +3299,8 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_animviz.c", NULL, RNA_def_animviz},
        {"rna_actuator.c", "rna_actuator_api.c", RNA_def_actuator},
        {"rna_armature.c", "rna_armature_api.c", RNA_def_armature},
-       {"rna_boid.c", NULL, RNA_def_boid},
        {"rna_brush.c", NULL, RNA_def_brush},
+       {"rna_cachefile.c", NULL, RNA_def_cachefile},
        {"rna_camera.c", "rna_camera_api.c", RNA_def_camera},
        {"rna_cloth.c", NULL, RNA_def_cloth},
        {"rna_color.c", NULL, RNA_def_color},
@@ -3315,7 +3330,6 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_object_force.c", NULL, RNA_def_object_force},
        {"rna_packedfile.c", NULL, RNA_def_packedfile},
        {"rna_palette.c", NULL, RNA_def_palette},
-       {"rna_particle.c", NULL, RNA_def_particle},
        {"rna_pose.c", "rna_pose_api.c", RNA_def_pose},
        {"rna_property.c", NULL, RNA_def_gameproperty},
        {"rna_render.c", NULL, RNA_def_render},
@@ -3681,6 +3695,7 @@ static const char *cpp_classes = ""
 "return *this; }\n"
 "\n"
 "      operator T*() { return data; }\n"
+"      operator const T*() const { return data; }\n"
 "};\n"
 "\n"
 "template<typename T>\n"