diff options
author | Julian Eisel <julian@blender.org> | 2020-03-26 23:03:42 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-03-26 23:18:45 +0300 |
commit | c94b6209861ca7cc3985b53474feed7d94c0221a (patch) | |
tree | 752054f0dca1338cda5cf8ad4f6d18573fcca3b9 /source/blender/makesrna/intern/makesrna.c | |
parent | 357ed79cb93f9d655501a828c6cddd68282de62d (diff) | |
parent | afb1a64ccb81b7ed792f64151986f40f53af8da5 (diff) |
Merge branch 'master' into wm-drag-drop-rewrite
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 82 |
1 files changed, 64 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 9b38ca8009c..46854bc6307 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -18,20 +18,22 @@ * \ingroup RNA */ +#include <errno.h> #include <float.h> +#include <inttypes.h> #include <limits.h> +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <errno.h> #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" #include "RNA_define.h" -#include "RNA_types.h" #include "RNA_enum_types.h" +#include "RNA_types.h" #include "rna_internal.h" @@ -480,8 +482,14 @@ static const char *rna_type_type_name(PropertyRNA *prop) case PROP_BOOLEAN: return "bool"; case PROP_INT: - case PROP_ENUM: return "int"; + case PROP_ENUM: { + EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop; + if (eprop->native_enum_type) { + return eprop->native_enum_type; + } + return "int"; + } case PROP_FLOAT: return "float"; case PROP_STRING: @@ -587,7 +595,7 @@ static void rna_float_print(FILE *f, float num) else if (num == FLT_MAX) { fprintf(f, "FLT_MAX"); } - else if ((ABS(num) < INT64_MAX) && ((int64_t)num == num)) { + else if ((fabsf(num) < INT64_MAX) && ((int64_t)num == num)) { fprintf(f, "%.1ff", num); } else { @@ -595,7 +603,7 @@ static void rna_float_print(FILE *f, float num) } } -static void rna_int_print(FILE *f, int num) +static void rna_int_print(FILE *f, int64_t num) { if (num == INT_MIN) { fprintf(f, "INT_MIN"); @@ -603,8 +611,17 @@ static void rna_int_print(FILE *f, int num) else if (num == INT_MAX) { fprintf(f, "INT_MAX"); } + else if (num == INT64_MIN) { + fprintf(f, "INT64_MIN"); + } + else if (num == INT64_MAX) { + fprintf(f, "INT64_MAX"); + } + else if (num < INT_MIN || num > INT_MAX) { + fprintf(f, "%" PRId64 "LL", num); + } else { - fprintf(f, "%d", num); + fprintf(f, "%d", (int)num); } } @@ -642,7 +659,19 @@ static char *rna_def_property_get_func( } } } - else if (prop->type == PROP_INT || prop->type == PROP_BOOLEAN || prop->type == PROP_ENUM) { + else if (prop->type == PROP_BOOLEAN) { + if (IS_DNATYPE_BOOLEAN_COMPAT(dp->dnatype) == 0) { + CLOG_ERROR(&LOG, + "%s.%s is a '%s' but wrapped as type '%s'.", + srna->identifier, + prop->identifier, + dp->dnatype, + RNA_property_typename(prop->type)); + DefRNA.error = 1; + return NULL; + } + } + else if (prop->type == PROP_INT || prop->type == PROP_ENUM) { if (IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) { CLOG_ERROR(&LOG, "%s.%s is a '%s' but wrapped as type '%s'.", @@ -784,10 +813,11 @@ static char *rna_def_property_get_func( if (dp->dnaarraylength == 1) { if (prop->type == PROP_BOOLEAN && dp->booleanbit) { fprintf(f, - " values[i] = %s((data->%s & (%du << i)) != 0);\n", + " values[i] = %s((data->%s & (", (dp->booleannegative) ? "!" : "", - dp->dnaname, - dp->booleanbit); + dp->dnaname); + rna_int_print(f, dp->booleanbit); + fprintf(f, " << i)) != 0);\n"); } else { fprintf(f, @@ -1111,11 +1141,14 @@ static char *rna_def_property_set_func( if (dp->dnaarraylength == 1) { if (prop->type == PROP_BOOLEAN && dp->booleanbit) { fprintf(f, - " if (%svalues[i]) data->%s |= (%du << i);\n", + " if (%svalues[i]) data->%s |= (", (dp->booleannegative) ? "!" : "", - dp->dnaname, - dp->booleanbit); - fprintf(f, " else data->%s &= ~(%du << i);\n", dp->dnaname, dp->booleanbit); + dp->dnaname); + rna_int_print(f, dp->booleanbit); + fprintf(f, " << i);\n"); + fprintf(f, " else data->%s &= ~(", dp->dnaname); + rna_int_print(f, dp->booleanbit); + fprintf(f, " << i);\n"); } else { fprintf( @@ -4232,6 +4265,9 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint}, {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve}, {"rna_gpencil.c", NULL, RNA_def_gpencil}, +#ifdef WITH_NEW_OBJECT_TYPES + {"rna_hair.c", NULL, RNA_def_hair}, +#endif {"rna_image.c", "rna_image_api.c", RNA_def_image}, {"rna_key.c", NULL, RNA_def_key}, {"rna_light.c", NULL, RNA_def_light}, @@ -4254,6 +4290,9 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_packedfile.c", NULL, RNA_def_packedfile}, {"rna_palette.c", NULL, RNA_def_palette}, {"rna_particle.c", NULL, RNA_def_particle}, +#ifdef WITH_NEW_OBJECT_TYPES + {"rna_pointcloud.c", NULL, RNA_def_pointcloud}, +#endif {"rna_pose.c", "rna_pose_api.c", RNA_def_pose}, {"rna_curveprofile.c", NULL, RNA_def_profile}, {"rna_lightprobe.c", NULL, RNA_def_lightprobe}, @@ -4272,6 +4311,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_ui.c", "rna_ui_api.c", RNA_def_ui}, {"rna_userdef.c", NULL, RNA_def_userdef}, {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont}, + {"rna_volume.c", NULL, RNA_def_volume}, {"rna_wm.c", "rna_wm_api.c", RNA_def_wm}, {"rna_wm_gizmo.c", "rna_wm_gizmo_api.c", RNA_def_wm_gizmo}, {"rna_workspace.c", "rna_workspace_api.c", RNA_def_workspace}, @@ -4279,6 +4319,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_movieclip.c", NULL, RNA_def_movieclip}, {"rna_tracking.c", NULL, RNA_def_tracking}, {"rna_mask.c", NULL, RNA_def_mask}, + {"rna_xr.c", NULL, RNA_def_xr}, {NULL, NULL}, }; @@ -4304,12 +4345,13 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const fprintf(f, "#include \"DNA_ID.h\"\n"); fprintf(f, "#include \"DNA_scene_types.h\"\n"); + fprintf(f, "#include \"DNA_node_types.h\"\n"); fprintf(f, "#include \"BLI_blenlib.h\"\n\n"); fprintf(f, "#include \"BLI_utildefines.h\"\n\n"); fprintf(f, "#include \"BKE_context.h\"\n"); - fprintf(f, "#include \"BKE_library.h\"\n"); + fprintf(f, "#include \"BKE_lib_id.h\"\n"); fprintf(f, "#include \"BKE_main.h\"\n"); fprintf(f, "#include \"BKE_report.h\"\n"); @@ -4320,7 +4362,9 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const /* include the generated prototypes header */ fprintf(f, "#include \"rna_prototypes_gen.h\"\n\n"); - fprintf(f, "#include \"%s\"\n", filename); + if (filename) { + fprintf(f, "#include \"%s\"\n", filename); + } if (api_filename) { fprintf(f, "#include \"%s\"\n", api_filename); } @@ -4394,6 +4438,7 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) " * Do not edit manually, changes will be overwritten. */\n\n"); fprintf(f, "#include \"RNA_types.h\"\n\n"); + fprintf(f, "#include \"DNA_node_types.h\"\n\n"); fprintf(f, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n"); @@ -4626,8 +4671,8 @@ static const char *cpp_classes = " operator void*() { return ptr.data; }\n" " operator bool() { return ptr.data != NULL; }\n" "\n" - " bool operator==(const Pointer &other) { return ptr.data == other.ptr.data; }\n" - " bool operator!=(const Pointer &other) { return ptr.data != other.ptr.data; }\n" + " bool operator==(const Pointer &other) const { return ptr.data == other.ptr.data; }\n" + " bool operator!=(const Pointer &other) const { return ptr.data != other.ptr.data; }\n" "\n" " PointerRNA ptr;\n" "};\n" @@ -4828,6 +4873,7 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) fprintf(f, "#include \"RNA_blender.h\"\n"); fprintf(f, "#include \"RNA_types.h\"\n"); fprintf(f, "#include \"RNA_access.h\"\n"); + fprintf(f, "#include \"DNA_node_types.h\"\n"); fprintf(f, "%s", cpp_classes); |