Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht>2020-03-03 19:21:18 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-03-03 19:21:47 +0300
commit0c603cffd123689c3021862a9d76dad9fbe13f4d (patch)
tree2b5112f4154e1019d8968fc74f85409001eb5fde /source/blender/makesrna/intern/makesrna.c
parent78383f7a9f9c3a2b3cc5f6c1ea0834cd7278317c (diff)
RNA: support 64 bit boolean bitflags in DNA
This does not affect the RNA access API, since how the boolean is read from DNA abstracted away in the API. Differential Revision: https://developer.blender.org/D7002
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r--source/blender/makesrna/intern/makesrna.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 2f5d9ae7a50..7b23364bd90 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -18,6 +18,7 @@
* \ingroup RNA
*/
+#include <inttypes.h>
#include <float.h>
#include <limits.h>
#include <stdio.h>
@@ -595,7 +596,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 +604,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 +652,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 +806,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 +1134,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(