diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-15 04:15:24 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-15 04:15:24 +0400 |
commit | 41729976753523ee08a0afaf6a26b6caf3dee1d6 (patch) | |
tree | ba264fba22084f44eb50b952f375715f501acff9 /source/blender/makesdna/intern/makesdna.c | |
parent | a5f8298ea5d13d7707bc0cbf0722013276bab9d6 (diff) | |
parent | a425790065fedb2ae49f1b79770945d8528790d9 (diff) |
Merged changes in the trunk up to revision 50607.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
Diffstat (limited to 'source/blender/makesdna/intern/makesdna.c')
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index bd1266bba81..d55810deeac 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -146,8 +146,8 @@ static int nr_types = 0; static int nr_structs = 0; static char **names, *namedata; /* at address names[a] is string a */ static char **types, *typedata; /* at address types[a] is string a */ -static short *typelens; /* at typelens[a] is de length of type a */ -static short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits), in fact any 64bit system */ +static short *typelens_native; /* at typelens[a] is the length of type 'a' on this systems bitness (32 or 64) */ +static short *typelens_64; /* contains sizes as they are calculated on 64 bit systems */ static short **structs, *structdata; /* at sp = structs[a] is the first address of a struct definition * sp[0] is type number * sp[1] is amount of elements @@ -244,8 +244,8 @@ static int add_type(const char *str, int len) for (nr = 0; nr < nr_types; nr++) { if (strcmp(str, types[nr]) == 0) { if (len) { - typelens[nr] = len; - alphalens[nr] = len; + typelens_native[nr] = len; + typelens_64[nr] = len; } return nr; } @@ -258,8 +258,8 @@ static int add_type(const char *str, int len) } strcpy(cp, str); types[nr_types] = cp; - typelens[nr_types] = len; - alphalens[nr_types] = len; + typelens_native[nr_types] = len; + typelens_64[nr_types] = len; if (nr_types >= maxnr) { printf("too many types\n"); @@ -714,7 +714,7 @@ static int arraysize(char *astr, int len) static int calculate_structlens(int firststruct) { - int a, b, len, alphalen, unknown = nr_structs, lastunknown, structtype, type, mul, namelen; + int a, b, len_native, len_64, unknown = nr_structs, lastunknown, structtype, type, mul, namelen; short *sp, *structpoin; char *cp; int has_pointer, dna_error = 0; @@ -729,11 +729,11 @@ static int calculate_structlens(int firststruct) structtype = structpoin[0]; /* when length is not known... */ - if (typelens[structtype] == 0) { + if (typelens_native[structtype] == 0) { sp = structpoin + 2; - len = 0; - alphalen = 0; + len_native = 0; + len_64 = 0; has_pointer = 0; /* check all elements in struct */ @@ -756,25 +756,25 @@ static int calculate_structlens(int firststruct) /* 4-8 aligned/ */ if (sizeof(void *) == 4) { - if (len % 4) { - printf("Align pointer error in struct (len4): %s %s\n", types[structtype], cp); + if (len_native % 4) { + printf("Align pointer error in struct (len_native 4): %s %s\n", types[structtype], cp); dna_error = 1; } } else { - if (len % 8) { - printf("Align pointer error in struct (len8): %s %s\n", types[structtype], cp); + if (len_native % 8) { + printf("Align pointer error in struct (len_native 8): %s %s\n", types[structtype], cp); dna_error = 1; } } - if (alphalen % 8) { - printf("Align pointer error in struct (alphalen8): %s %s\n", types[structtype], cp); + if (len_64 % 8) { + printf("Align pointer error in struct (len_64 8): %s %s\n", types[structtype], cp); dna_error = 1; } - len += sizeof(void *) * mul; - alphalen += 8 * mul; + len_native += sizeof(void *) * mul; + len_64 += 8 * mul; } else if (cp[0] == '[') { @@ -782,7 +782,7 @@ static int calculate_structlens(int firststruct) printf("Parse error in struct, invalid member name: %s %s\n", types[structtype], cp); dna_error = 1; } - else if (typelens[type]) { + else if (typelens_native[type]) { /* has the name an extra length? (array) */ mul = 1; if (cp[namelen - 1] == ']') mul = arraysize(cp, namelen); @@ -794,54 +794,54 @@ static int calculate_structlens(int firststruct) /* struct alignment */ if (type >= firststruct) { - if (sizeof(void *) == 8 && (len % 8) ) { + if (sizeof(void *) == 8 && (len_native % 8) ) { printf("Align struct error: %s %s\n", types[structtype], cp); dna_error = 1; } } /* 2-4-8 aligned/ */ - if (type < firststruct && typelens[type] > 4 && (len % 8)) { - printf("Align 8 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len % 8); + if (type < firststruct && typelens_native[type] > 4 && (len_native % 8)) { + printf("Align 8 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len_native % 8); dna_error = 1; } - if (typelens[type] > 3 && (len % 4) ) { - printf("Align 4 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len % 4); + if (typelens_native[type] > 3 && (len_native % 4) ) { + printf("Align 4 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len_native % 4); dna_error = 1; } - else if (typelens[type] == 2 && (len % 2) ) { - printf("Align 2 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len % 2); + else if (typelens_native[type] == 2 && (len_native % 2) ) { + printf("Align 2 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len_native % 2); dna_error = 1; } - len += mul * typelens[type]; - alphalen += mul * alphalens[type]; + len_native += mul * typelens_native[type]; + len_64 += mul * typelens_64[type]; } else { - len = 0; - alphalen = 0; + len_native = 0; + len_64 = 0; break; } } - if (len == 0) { + if (len_native == 0) { unknown++; } else { - typelens[structtype] = len; - alphalens[structtype] = alphalen; + typelens_native[structtype] = len_native; + typelens_64[structtype] = len_64; /* two ways to detect if a struct contains a pointer: - * has_pointer is set or alphalen != len */ - if (has_pointer || alphalen != len) { - if (alphalen % 8) { - printf("Sizeerror 8 in struct: %s (add %d bytes)\n", types[structtype], alphalen % 8); + * has_pointer is set or len_64 != len_native */ + if (has_pointer || len_64 != len_native) { + if (len_64 % 8) { + printf("Sizeerror 8 in struct: %s (add %d bytes)\n", types[structtype], len_64 % 8); dna_error = 1; } } - if (len % 4) { - printf("Sizeerror 4 in struct: %s (add %d bytes)\n", types[structtype], len % 4); + if (len_native % 4) { + printf("Sizeerror 4 in struct: %s (add %d bytes)\n", types[structtype], len_native % 4); dna_error = 1; } @@ -863,7 +863,7 @@ static int calculate_structlens(int firststruct) structtype = structpoin[0]; /* length unknown */ - if (typelens[structtype] != 0) { + if (typelens_native[structtype] != 0) { printf(" %s\n", types[structtype]); } } @@ -877,7 +877,7 @@ static int calculate_structlens(int firststruct) structtype = structpoin[0]; /* length unknown yet */ - if (typelens[structtype] == 0) { + if (typelens_native[structtype] == 0) { printf(" %s\n", types[structtype]); } } @@ -923,7 +923,7 @@ void printStructLengths(void) for (a = 0; a < nr_structs; a++) { structpoin = structs[a]; structtype = structpoin[0]; - printf("\t%s\t:%d\n", types[structtype], typelens[structtype]); + printf("\t%s\t:%d\n", types[structtype], typelens_native[structtype]); } } @@ -954,8 +954,8 @@ static int make_structDNA(char *baseDirectory, FILE *file) /* a maximum of 5000 variables, must be sufficient? */ names = MEM_callocN(sizeof(char *) * maxnr, "names"); types = MEM_callocN(sizeof(char *) * maxnr, "types"); - typelens = MEM_callocN(sizeof(short) * maxnr, "typelens"); - alphalens = MEM_callocN(sizeof(short) * maxnr, "alphalens"); + typelens_native = MEM_callocN(sizeof(short) * maxnr, "typelens_native"); + typelens_64 = MEM_callocN(sizeof(short) * maxnr, "typelens_64"); structs = MEM_callocN(sizeof(short) * maxnr, "structs"); /* insertion of all known types */ @@ -1008,7 +1008,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) } printf("\n"); - sp = typelens; + sp = typelens_native; for (a = 0; a < nr_types; a++, sp++) { printf(" %s %d\n", types[a], *sp); } @@ -1016,7 +1016,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) for (a = 0; a < nr_structs; a++) { sp = structs[a]; - printf(" struct %s elems: %d size: %d\n", types[sp[0]], sp[1], typelens[sp[0]]); + printf(" struct %s elems: %d size: %d\n", types[sp[0]], sp[1], typelens_native[sp[0]]); num_types = sp[1]; sp += 2; /* ? num_types was elem? */ @@ -1068,7 +1068,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) len = 2 * nr_types; if (nr_types & 1) len += 2; - dna_write(file, typelens, len); + dna_write(file, typelens_native, len); /* WRITE STRUCTS */ strcpy(str, "STRC"); @@ -1099,7 +1099,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) } fprintf(fp, "main() {\n"); - sp = typelens; + sp = typelens_native; sp += firststruct; for (a = firststruct; a < nr_types; a++, sp++) { if (*sp) { @@ -1121,8 +1121,8 @@ static int make_structDNA(char *baseDirectory, FILE *file) MEM_freeN(structdata); MEM_freeN(names); MEM_freeN(types); - MEM_freeN(typelens); - MEM_freeN(alphalens); + MEM_freeN(typelens_native); + MEM_freeN(typelens_64); MEM_freeN(structs); if (debugSDNA > -1) printf("done.\n"); |