RNA: Fix compile error when assigning to a typed enum in C++
When a RNA file was compiled in C++, building would fail when defining a RNA enum property that assigns to a enum value with a defined (i.e. non-integer) type. Pull Request: https://projects.blender.org/blender/blender/pulls/109136
This commit is contained in:
committed by
Julian Eisel
parent
fff98eb59f
commit
fa59084025
@@ -1422,8 +1422,20 @@ static char *rna_def_property_set_func(
|
||||
}
|
||||
else {
|
||||
rna_clamp_value_range(f, prop);
|
||||
/* C++ may require casting to an enum type. */
|
||||
fprintf(f, "#ifdef __cplusplus\n");
|
||||
fprintf(f,
|
||||
/* If #rna_clamp_value() adds an expression like `CLAMPIS(...)` (instead of an
|
||||
lvalue), #decltype() yields a reference, so that has to be removed.*/
|
||||
" data->%s = %s(std::remove_reference_t<decltype(data->%s)>)",
|
||||
dp->dnaname,
|
||||
(dp->booleannegative) ? "!" : "",
|
||||
dp->dnaname);
|
||||
rna_clamp_value(f, prop, 0);
|
||||
fprintf(f, "#else\n");
|
||||
fprintf(f, " data->%s = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
|
||||
rna_clamp_value(f, prop, 0);
|
||||
fprintf(f, "#endif\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user