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:
authorJacques Lucke <jacques@blender.org>2021-04-13 10:39:05 +0300
committerJacques Lucke <jacques@blender.org>2021-04-13 10:39:20 +0300
commit9b15c552cc125ff7b41ba81220c2072db6a46848 (patch)
treecce1c30e362471920edc2e66ff3e59d0c415c057 /source/blender/makesdna/intern
parent7b9d94e07360cb3d80457cbd73d72ecc5529505b (diff)
DNA: support int8_t type in DNA structs
Differential Revision: https://developer.blender.org/D8908
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c7
-rw-r--r--source/blender/makesdna/intern/dna_utils.c3
-rw-r--r--source/blender/makesdna/intern/makesdna.c5
3 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index d199638710d..6c88d5f7230 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -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:
diff --git a/source/blender/makesdna/intern/dna_utils.c b/source/blender/makesdna/intern/dna_utils.c
index 3cf5c52a4c6..f050934b5b3 100644
--- a/source/blender/makesdna/intern/dna_utils.c
+++ b/source/blender/makesdna/intern/dna_utils.c
@@ -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"},
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 26fc56cfa1d..85bcc94c335 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -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"