diff options
Diffstat (limited to 'source/blender/makesdna/intern/dna_genfile.c')
-rw-r--r-- | source/blender/makesdna/intern/dna_genfile.c | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 525c7030029..bc1ee28d582 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -51,17 +51,9 @@ #include "DNA_genfile.h" #include "DNA_sdna_types.h" // for SDNA ;-) - -/* gcc 4.1 on mingw was complaining that __int64 was already defined - * actually is saw the line below as typedef long long long long... - * Anyhow, since its already defined, its safe to do an ifndef here- Campbell */ -#ifdef FREE_WINDOWS -# ifndef __int64 -typedef long long __int64; -# endif -#endif - -/* +/** + * \section dna_genfile Overview + * * - please note: no builtin security to detect input of double structs * - if you want a struct not to be in DNA file: add two hash marks above it (#<enter>#<enter>) * @@ -72,6 +64,7 @@ typedef long long __int64; * * Create a structDNA: only needed when one of the input include (.h) files change. * File Syntax: + * <pre> * SDNA (4 bytes) (magic number) * NAME (4 bytes) * <nr> (4 bytes) amount of names (int) @@ -93,12 +86,13 @@ typedef long long __int64; * STRC (4 bytes) * <nr> amount of structs (int) * <typenr><nr_of_elems> <typenr><namenr> <typenr><namenr> ... + *</pre> * - * !!Remember to read/write integer and short aligned!! + * **Remember to read/write integer and short aligned!** * * While writing a file, the names of a struct is indicated with a type number, - * to be found with: type = findstruct_nr(SDNA *, char *) - * The value of 'type' corresponds with the the index within the structs array + * to be found with: ``type = DNA_struct_find_nr(SDNA *, const char *)`` + * The value of ``type`` corresponds with the the index within the structs array * * For the moment: the complete DNA file is included in a .blend file. For * the future we can think of smarter methods, like only included the used @@ -114,7 +108,7 @@ typedef long long __int64; * - change of a pointer type: when the name doesn't change the contents is copied * * NOT YET: - * - array (vec[3]) to float struct (vec3f) + * - array (``vec[3]``) to float struct (``vec3f``) * * DONE: * - endian compatibility @@ -307,7 +301,7 @@ static short *findstruct_name(SDNA *sdna, const char *str) */ int DNA_struct_find_nr(SDNA *sdna, const char *str) { - short *sp = NULL; + const short *sp = NULL; if (sdna->lastfind < sdna->nr_structs) { sp = sdna->structs[sdna->lastfind]; @@ -566,7 +560,7 @@ SDNA *DNA_sdna_from_data(const void *data, const int datalen, bool do_endian_swa static void recurs_test_compflags(const SDNA *sdna, char *compflags, int structnr) { int a, b, typenr, elems; - short *sp; + const short *sp; const char *cp; /* check all structs, test if it's inside another struct */ @@ -810,11 +804,7 @@ static void cast_elem( */ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata, const char *olddata) { -#ifdef WIN32 - __int64 lval; -#else - long long lval; -#endif + int64_t lval; int arrlen; arrlen = DNA_elem_array_size(name); @@ -825,22 +815,15 @@ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata memcpy(curdata, olddata, curlen); } else if (curlen == 4 && oldlen == 8) { -#ifdef WIN32 - lval = *( (__int64 *)olddata); -#else - lval = *( (long long *)olddata); -#endif + lval = *((int64_t *)olddata); + /* WARNING: 32-bit Blender trying to load file saved by 64-bit Blender, * pointers may lose uniqueness on truncation! (Hopefully this wont * happen unless/until we ever get to multi-gigabyte .blend files...) */ *((int *)curdata) = lval >> 3; } else if (curlen == 8 && oldlen == 4) { -#ifdef WIN32 - *( (__int64 *)curdata) = *((int *)olddata); -#else - *( (long long *)curdata) = *((int *)olddata); -#endif + *((int64_t *)curdata) = *((int *)olddata); } else { /* for debug */ @@ -1307,7 +1290,7 @@ int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const ch const int SDNAnr = DNA_struct_find_nr(sdna, stype); const short * const spo = sdna->structs[SDNAnr]; - char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL); + const char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL); BLI_assert(SDNAnr != -1); return (int)((intptr_t)cp); } @@ -1319,7 +1302,7 @@ bool DNA_struct_elem_find(SDNA *sdna, const char *stype, const char *vartype, co if (SDNAnr != -1) { const short * const spo = sdna->structs[SDNAnr]; - char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL); + const char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL); if (cp) return true; return (int)((intptr_t)cp); |