DNA: support int8_t type in DNA structs
Differential Revision: https://developer.blender.org/D8908
This commit is contained in:
parent
7b9d94e073
commit
9b15c552cc
|
@ -63,6 +63,7 @@ typedef enum eSDNA_Type {
|
|||
#define SDNA_TYPE_VOID 9
|
||||
SDNA_TYPE_INT64 = 10,
|
||||
SDNA_TYPE_UINT64 = 11,
|
||||
SDNA_TYPE_INT8 = 12,
|
||||
} eSDNA_Type;
|
||||
|
||||
/**
|
||||
|
|
|
@ -792,6 +792,9 @@ static void cast_primitive_type(const eSDNA_Type old_type,
|
|||
old_value_i = *((uint64_t *)old_data);
|
||||
old_value_f = (double)old_value_i;
|
||||
break;
|
||||
case SDNA_TYPE_INT8:
|
||||
old_value_i = (uint64_t) * ((int8_t *)old_data);
|
||||
old_value_f = (double)old_value_i;
|
||||
}
|
||||
|
||||
switch (new_type) {
|
||||
|
@ -828,6 +831,9 @@ static void cast_primitive_type(const eSDNA_Type old_type,
|
|||
case SDNA_TYPE_UINT64:
|
||||
*((uint64_t *)new_data) = old_value_i;
|
||||
break;
|
||||
case SDNA_TYPE_INT8:
|
||||
*((int8_t *)new_data) = (int8_t)old_value_i;
|
||||
break;
|
||||
}
|
||||
|
||||
old_data += oldlen;
|
||||
|
@ -1655,6 +1661,7 @@ int DNA_elem_type_size(const eSDNA_Type elem_nr)
|
|||
switch (elem_nr) {
|
||||
case SDNA_TYPE_CHAR:
|
||||
case SDNA_TYPE_UCHAR:
|
||||
case SDNA_TYPE_INT8:
|
||||
return 1;
|
||||
case SDNA_TYPE_SHORT:
|
||||
case SDNA_TYPE_USHORT:
|
||||
|
|
|
@ -235,9 +235,6 @@ void DNA_alias_maps(enum eDNA_RenameDir version_dir, GHash **r_struct_map, GHash
|
|||
|
||||
if (version_dir == DNA_RENAME_STATIC_FROM_ALIAS) {
|
||||
const char *renames[][2] = {
|
||||
/* Disable 'int8_t' until we support 'signed char', since changing negative
|
||||
* values to a different type isn't supported and will change the value. */
|
||||
/* {"int8_t", "char"}, */
|
||||
{"uint8_t", "uchar"},
|
||||
{"int16_t", "short"},
|
||||
{"uint16_t", "ushort"},
|
||||
|
|
|
@ -1222,6 +1222,7 @@ static int make_structDNA(const char *base_directory,
|
|||
add_type("int64_t", 8); /* SDNA_TYPE_INT64 */
|
||||
add_type("uint64_t", 8); /* SDNA_TYPE_UINT64 */
|
||||
add_type("void", 0); /* SDNA_TYPE_VOID */
|
||||
add_type("int8_t", 1); /* SDNA_TYPE_INT8 */
|
||||
|
||||
/* the defines above shouldn't be output in the padding file... */
|
||||
const int firststruct = types_len;
|
||||
|
@ -1516,16 +1517,12 @@ int main(int argc, char **argv)
|
|||
*
|
||||
* - 'long': even though DNA supports, 'long' shouldn't be used since it can be either 32 or 64bit,
|
||||
* use int, int32_t or int64_t instead.
|
||||
* - 'int8_t': as DNA doesn't yet support 'signed char' types,
|
||||
* all char types are assumed to be unsigned.
|
||||
* We should be able to support this, it's just not something which has been added yet.
|
||||
*
|
||||
* Only valid use would be as a runtime variable if an API expected a long,
|
||||
* but so far we don't have this happening.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC poison long
|
||||
# pragma GCC poison int8_t
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
|
|
@ -513,7 +513,7 @@ const char *RNA_property_typename(PropertyType type);
|
|||
#define IS_DNATYPE_FLOAT_COMPAT(_str) (strcmp(_str, "float") == 0 || strcmp(_str, "double") == 0)
|
||||
#define IS_DNATYPE_INT_COMPAT(_str) \
|
||||
(strcmp(_str, "int") == 0 || strcmp(_str, "short") == 0 || strcmp(_str, "char") == 0 || \
|
||||
strcmp(_str, "uchar") == 0 || strcmp(_str, "ushort") == 0)
|
||||
strcmp(_str, "uchar") == 0 || strcmp(_str, "ushort") == 0 || strcmp(_str, "int8_t") == 0)
|
||||
#define IS_DNATYPE_BOOLEAN_COMPAT(_str) \
|
||||
(IS_DNATYPE_INT_COMPAT(_str) || strcmp(_str, "int64_t") == 0 || strcmp(_str, "uint64_t") == 0)
|
||||
|
||||
|
|
|
@ -2410,6 +2410,10 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
|
|||
iprop->softmin = -10000; /* rather arbitrary .. */
|
||||
iprop->softmax = 10000;
|
||||
}
|
||||
else if (dp->dnatype && STREQ(dp->dnatype, "int8_t")) {
|
||||
iprop->hardmin = iprop->softmin = INT8_MIN;
|
||||
iprop->hardmax = iprop->softmax = INT8_MAX;
|
||||
}
|
||||
|
||||
if (prop->subtype == PROP_UNSIGNED || prop->subtype == PROP_PERCENTAGE ||
|
||||
prop->subtype == PROP_FACTOR) {
|
||||
|
|
Loading…
Reference in New Issue