[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50262] trunk/blender/source/blender/ makesdna/intern/makesdna.c: code cleanup: replace term 'alpha' with '64' in makesdna, this was historic that dec-alpha was the first 64bit system blender was ported for , but now its not helpful to call it this way.
Campbell Barton
ideasman42 at gmail.com
Wed Aug 29 11:51:39 CEST 2012
Revision: 50262
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50262
Author: campbellbarton
Date: 2012-08-29 09:51:38 +0000 (Wed, 29 Aug 2012)
Log Message:
-----------
code cleanup: replace term 'alpha' with '64' in makesdna, this was historic that dec-alpha was the first 64bit system blender was ported for, but now its not helpful to call it this way.
Modified Paths:
--------------
trunk/blender/source/blender/makesdna/intern/makesdna.c
Modified: trunk/blender/source/blender/makesdna/intern/makesdna.c
===================================================================
--- trunk/blender/source/blender/makesdna/intern/makesdna.c 2012-08-29 08:17:38 UTC (rev 50261)
+++ trunk/blender/source/blender/makesdna/intern/makesdna.c 2012-08-29 09:51:38 UTC (rev 50262)
@@ -144,8 +144,8 @@
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
@@ -242,8 +242,8 @@
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;
}
@@ -256,8 +256,8 @@
}
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");
@@ -712,7 +712,7 @@
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;
@@ -727,11 +727,11 @@
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 */
@@ -754,25 +754,25 @@
/* 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] == '[') {
@@ -780,7 +780,7 @@
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);
@@ -792,54 +792,54 @@
/* 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;
}
@@ -861,7 +861,7 @@
structtype = structpoin[0];
/* length unknown */
- if (typelens[structtype] != 0) {
+ if (typelens_native[structtype] != 0) {
printf(" %s\n", types[structtype]);
}
}
@@ -875,7 +875,7 @@
structtype = structpoin[0];
/* length unknown yet */
- if (typelens[structtype] == 0) {
+ if (typelens_native[structtype] == 0) {
printf(" %s\n", types[structtype]);
}
}
@@ -921,7 +921,7 @@
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]);
}
}
@@ -952,8 +952,8 @@
/* 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 */
@@ -1006,7 +1006,7 @@
}
printf("\n");
- sp = typelens;
+ sp = typelens_native;
for (a = 0; a < nr_types; a++, sp++) {
printf(" %s %d\n", types[a], *sp);
}
@@ -1014,7 +1014,7 @@
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? */
@@ -1066,7 +1066,7 @@
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");
@@ -1097,7 +1097,7 @@
}
fprintf(fp, "main() {\n");
- sp = typelens;
+ sp = typelens_native;
sp += firststruct;
for (a = firststruct; a < nr_types; a++, sp++) {
if (*sp) {
@@ -1119,8 +1119,8 @@
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");
More information about the Bf-blender-cvs
mailing list