diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-23 08:40:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-23 08:40:07 +0400 |
commit | 27b47892a029d8734d42cc121402155f912102d9 (patch) | |
tree | 7ca0082a6683792a7ba50f0ae1489c219586d400 /source/blender/makesdna | |
parent | 3cce96320e9e7dcacfde7b92c110482500661f14 (diff) |
add DNA support for int64_t. nothing uses this currently.
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r-- | source/blender/makesdna/DNA_genfile.h | 8 | ||||
-rw-r--r-- | source/blender/makesdna/intern/dna_genfile.c | 20 | ||||
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 1 |
3 files changed, 26 insertions, 3 deletions
diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index 1ca669836ac..83292d3d8f8 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -47,10 +47,14 @@ typedef enum eSDNA_Type { SDNA_TYPE_LONG = 5, SDNA_TYPE_ULONG = 6, SDNA_TYPE_FLOAT = 7, - SDNA_TYPE_DOUBLE = 8 - /* ,SDNA_TYPE_VOID = 9 */ /* nothing uses yet */ + SDNA_TYPE_DOUBLE = 8, + SDNA_TYPE_INT64 = 9 + /* ,SDNA_TYPE_VOID = 10 */ /* nothing uses yet */ } eSDNA_Type; +/* define so switch statements don't complain */ +#define SDNA_TYPE_VOID 10 + struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap); void DNA_sdna_free(struct SDNA *sdna); diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 88b6fa65370..db0c2bc0e2d 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -491,7 +491,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap) for(nr=0; nr<sdna->nr_structs; nr++) { sp= sdna->structs[nr]; if(strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) - sp[10]= 9; + sp[10]= SDNA_TYPE_VOID; } } @@ -666,6 +666,7 @@ static eSDNA_Type sdna_type_nr(const char *dna_type) else if((strcmp(dna_type, "ulong")==0)||(strcmp(dna_type, "unsigned long")==0)) return SDNA_TYPE_ULONG; else if( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT; else if( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE; + else if( strcmp(dna_type, "int64_t")==0) return SDNA_TYPE_INT64; else return -1; /* invalid! */ } @@ -708,6 +709,8 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch val= *( (float *)olddata); break; case SDNA_TYPE_DOUBLE: val= *( (double *)olddata); break; + case SDNA_TYPE_INT64: + val= *( (int64_t *)olddata); break; } switch(ctypenr) { @@ -731,6 +734,8 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch case SDNA_TYPE_DOUBLE: if(otypenr<2) val/= 255; *( (double *)curdata)= val; break; + case SDNA_TYPE_INT64: + *( (int64_t *)curdata)= val; break; } olddata+= oldlen; @@ -1088,6 +1093,18 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) cpo+= 4; } } + else if ( (spc[0]==SDNA_TYPE_INT64)) { + mul= DNA_elem_array_size(name, strlen(name)); + cpo= cur; + while(mul--) { + cval= cpo[0]; cpo[0]= cpo[7]; cpo[7]= cval; + cval= cpo[1]; cpo[1]= cpo[6]; cpo[6]= cval; + cval= cpo[2]; cpo[2]= cpo[5]; cpo[5]= cval; + cval= cpo[3]; cpo[3]= cpo[4]; cpo[4]= cval; + + cpo+= 8; + } + } } } cur+= elen; @@ -1152,6 +1169,7 @@ int DNA_elem_type_size(const eSDNA_Type elem_nr) case SDNA_TYPE_FLOAT: return 4; case SDNA_TYPE_DOUBLE: + case SDNA_TYPE_INT64: return 8; } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index e3f62fa0f4d..0c417e9f884 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -938,6 +938,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) add_type("ulong", 4); /* SDNA_TYPE_ULONG */ add_type("float", 4); /* SDNA_TYPE_FLOAT */ add_type("double", 8); /* SDNA_TYPE_DOUBLE */ + add_type("int64_t", 8); /* SDNA_TYPE_INT64 */ add_type("void", 0); /* SDNA_TYPE_VOID */ // the defines above shouldn't be output in the padding file... |