From 78fbd146f3cd9a5c97307ff6f2d14422e7ae54b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Jun 2018 17:04:09 +0200 Subject: Cleanup: trailing space for DNA headers --- source/blender/makesdna/intern/dna_genfile.c | 142 +++++++++++++-------------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'source/blender/makesdna/intern/dna_genfile.c') diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 2e21223d042..32e41863ad1 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -201,10 +201,10 @@ static int elementsize(const SDNA *sdna, short type, short name) { int mul, namelen, len; const char *cp; - + cp = sdna->names[name]; len = 0; - + namelen = strlen(cp); /* is it a pointer or function pointer? */ if (ispointer(cp)) { @@ -213,7 +213,7 @@ static int elementsize(const SDNA *sdna, short type, short name) if (cp[namelen - 1] == ']') { mul = DNA_elem_array_size(cp); } - + len = sdna->pointerlen * mul; } else if (sdna->typelens[type]) { @@ -222,11 +222,11 @@ static int elementsize(const SDNA *sdna, short type, short name) if (cp[namelen - 1] == ']') { mul = DNA_elem_array_size(cp); } - + len = mul * sdna->typelens[type]; - + } - + return len; } @@ -236,13 +236,13 @@ static void printstruct(SDNA *sdna, short strnr) /* is for debug */ int b, nr; short *sp; - + sp = sdna->structs[strnr]; - + printf("struct %s\n", sdna->types[sp[0]]); nr = sp[1]; sp += 2; - + for (b = 0; b < nr; b++, sp += 2) { printf(" %s %s\n", sdna->types[sp[0]], sdna->names[sp[1]]); } @@ -322,7 +322,7 @@ static bool init_structDNA( int *data, *verg, gravity_fix = -1; short *sp; char str[8]; - + verg = (int *)str; data = (int *)sdna->data; @@ -343,17 +343,17 @@ static bool init_structDNA( const char *cp; data++; - + /* load names array */ strcpy(str, "NAME"); if (*data == *verg) { data++; - + sdna->nr_names = *data; if (do_endian_swap) { BLI_endian_switch_int32(&sdna->nr_names); } - + data++; sdna->names = MEM_callocN(sizeof(void *) * sdna->nr_names, "sdnanames"); } @@ -361,7 +361,7 @@ static bool init_structDNA( *r_error_message = "NAME error in SDNA file"; return false; } - + cp = (char *)data; for (int nr = 0; nr < sdna->nr_names; nr++) { sdna->names[nr] = cp; @@ -381,7 +381,7 @@ static bool init_structDNA( } cp = pad_up_4(cp); - + /* load type names array */ data = (int *)cp; strcpy(str, "TYPE"); @@ -392,7 +392,7 @@ static bool init_structDNA( if (do_endian_swap) { BLI_endian_switch_int32(&sdna->nr_types); } - + data++; sdna->types = MEM_callocN(sizeof(void *) * sdna->nr_types, "sdnatypes"); } @@ -400,25 +400,25 @@ static bool init_structDNA( *r_error_message = "TYPE error in SDNA file"; return false; } - + cp = (char *)data; for (int nr = 0; nr < sdna->nr_types; nr++) { sdna->types[nr] = cp; - + /* this is a patch, to change struct names without a conflict with SDNA */ /* be careful to use it, in this case for a system-struct (opengl/X) */ - + if (*cp == 'b') { /* struct Screen was already used by X, 'bScreen' replaces the old IrisGL 'Screen' struct */ if (strcmp("bScreen", cp) == 0) sdna->types[nr] = cp + 1; } - + while (*cp) cp++; cp++; } cp = pad_up_4(cp); - + /* load typelen array */ data = (int *)cp; strcpy(str, "TLEN"); @@ -426,11 +426,11 @@ static bool init_structDNA( data++; sp = (short *)data; sdna->typelens = sp; - + if (do_endian_swap) { BLI_endian_switch_int16_array(sp, sdna->nr_types); } - + sp += sdna->nr_types; } else { @@ -444,12 +444,12 @@ static bool init_structDNA( strcpy(str, "STRC"); if (*data == *verg) { data++; - + sdna->nr_structs = *data; if (do_endian_swap) { BLI_endian_switch_int32(&sdna->nr_structs); } - + data++; sdna->structs = MEM_callocN(sizeof(void *) * sdna->nr_structs, "sdnastrcs"); } @@ -457,17 +457,17 @@ static bool init_structDNA( *r_error_message = "STRC error in SDNA file"; return false; } - + sp = (short *)data; for (int nr = 0; nr < sdna->nr_structs; nr++) { sdna->structs[nr] = sp; - + if (do_endian_swap) { short a; - + BLI_endian_switch_int16(&sp[0]); BLI_endian_switch_int16(&sp[1]); - + a = sp[1]; sp += 2; while (a--) { @@ -552,7 +552,7 @@ SDNA *DNA_sdna_from_data( sdna->data = data; } sdna->data_alloc = data_alloc; - + if (init_structDNA(sdna, do_endian_swap, &error_message)) { return sdna; @@ -606,11 +606,11 @@ static void recurs_test_compflags(const SDNA *sdna, char *compflags, int structn int a, b, typenr, elems; const short *sp; const char *cp; - + /* check all structs, test if it's inside another struct */ sp = sdna->structs[structnr]; typenr = sp[0]; - + for (a = 0; a < sdna->nr_structs; a++) { if ((a != structnr) && (compflags[a] == SDNA_CMP_EQUAL)) { sp = sdna->structs[a]; @@ -627,7 +627,7 @@ static void recurs_test_compflags(const SDNA *sdna, char *compflags, int structn } } } - + } @@ -641,7 +641,7 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna const short *sp_old, *sp_new; const char *str1, *str2; char *compflags; - + if (oldsdna->nr_structs == 0) { printf("error: file without SDNA\n"); return NULL; @@ -649,14 +649,14 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna compflags = MEM_callocN(oldsdna->nr_structs, "compflags"); - /* we check all structs in 'oldsdna' and compare them with + /* we check all structs in 'oldsdna' and compare them with * the structs in 'newsdna' */ unsigned int newsdna_index_last = 0; - + for (a = 0; a < oldsdna->nr_structs; a++) { sp_old = oldsdna->structs[a]; - + /* search for type in cur */ int sp_new_index = DNA_struct_find_nr_ex(newsdna, oldsdna->types[sp_old[0]], &newsdna_index_last); @@ -667,7 +667,7 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna sp_new = newsdna->structs[sp_new_index]; /* initial assumption */ compflags[a] = SDNA_CMP_NOT_EQUAL; - + /* compare length and amount of elems */ if (sp_new[1] == sp_old[1]) { if (newsdna->typelens[sp_new[0]] == oldsdna->typelens[sp_old[0]]) { @@ -701,7 +701,7 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna } } - + } } @@ -718,7 +718,7 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna recurs_test_compflags(oldsdna, compflags, a); } } - + #if 0 for (a = 0; a < oldsdna->nr_structs; a++) { if (compflags[a] == SDNA_CMP_NOT_EQUAL) { @@ -801,7 +801,7 @@ static void cast_elem( case SDNA_TYPE_UINT64: val = *( (uint64_t *)olddata); break; } - + switch (ctypenr) { case SDNA_TYPE_CHAR: *curdata = val; break; @@ -846,11 +846,11 @@ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata { int64_t lval; int arrlen; - + arrlen = DNA_elem_array_size(name); - + while (arrlen > 0) { - + if (curlen == oldlen) { memcpy(curdata, olddata, curlen); } @@ -869,7 +869,7 @@ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata /* for debug */ printf("errpr: illegal pointersize!\n"); } - + olddata += oldlen; curdata += curlen; arrlen--; @@ -883,7 +883,7 @@ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata static int elem_strcmp(const char *name, const char *oname) { int a = 0; - + while (1) { if (name[a] != oname[a]) return 1; if (name[a] == '[' || oname[a] == '[') break; @@ -916,9 +916,9 @@ static const char *find_elem( { int a, elemcount, len; const char *otype, *oname; - + /* without arraypart, so names can differ: return old namenr and type */ - + /* in old is the old struct */ elemcount = old[1]; old += 2; @@ -934,10 +934,10 @@ static const char *find_elem( if (sppo) *sppo = old; return olddata; } - + return NULL; } - + olddata += len; } return NULL; @@ -975,7 +975,7 @@ static void reconstruct_elem( */ int a, elemcount, len, countpos, oldsize, cursize, mul; const char *otype, *oname, *cp; - + /* is 'name' an array? */ cp = name; countpos = 0; @@ -983,7 +983,7 @@ static void reconstruct_elem( cp++; countpos++; } if (*cp != '[') countpos = 0; - + /* in old is the old struct */ elemcount = old[1]; old += 2; @@ -991,9 +991,9 @@ static void reconstruct_elem( otype = oldsdna->types[old[0]]; oname = oldsdna->names[old[1]]; len = elementsize(oldsdna, old[0], old[1]); - + if (strcmp(name, oname) == 0) { /* name equal */ - + if (ispointer(name)) { /* pointer of functionpointer afhandelen */ cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, name, curdata, olddata); } @@ -1009,7 +1009,7 @@ static void reconstruct_elem( else if (countpos != 0) { /* name is an array */ if (oname[countpos] == '[' && strncmp(name, oname, countpos) == 0) { /* basis equal */ - + cursize = DNA_elem_array_size(name); oldsize = DNA_elem_array_size(oname); @@ -1022,7 +1022,7 @@ static void reconstruct_elem( mul = len / oldsize; /* size of single old array element */ mul *= (cursize < oldsize) ? cursize : oldsize; /* smaller of sizes of old and new arrays */ memcpy(curdata, olddata, mul); - + if (oldsize > cursize && strcmp(type, "char") == 0) { /* string had to be truncated, ensure it's still null-terminated */ curdata[mul - 1] = '\0'; @@ -1086,7 +1086,7 @@ static void reconstruct_struct( spo = oldsdna->structs[oldSDNAnr]; elen = oldsdna->typelens[spo[0]]; memcpy(cur, data, elen); - + return; } @@ -1102,7 +1102,7 @@ static void reconstruct_struct( for (a = 0; a < elemcount; a++, spc += 2) { /* convert each field */ type = newsdna->types[spc[0]]; name = newsdna->names[spc[1]]; - + elen = elementsize(newsdna, spc[0], spc[1]); /* test: is type a struct? */ @@ -1110,26 +1110,26 @@ static void reconstruct_struct( /* struct field type */ /* where does the old struct data start (and is there an old one?) */ cpo = (char *)find_elem(oldsdna, type, name, spo, data, &sppo); - + if (cpo) { oldSDNAnr = DNA_struct_find_nr_ex(oldsdna, type, &oldsdna_index_last); curSDNAnr = DNA_struct_find_nr_ex(newsdna, type, &cursdna_index_last); - + /* array! */ mul = DNA_elem_array_size(name); nameo = oldsdna->names[sppo[1]]; mulo = DNA_elem_array_size(nameo); - + eleno = elementsize(oldsdna, sppo[0], sppo[1]); - + elen /= mul; eleno /= mulo; - + while (mul--) { reconstruct_struct(newsdna, oldsdna, compflags, oldSDNAnr, cpo, curSDNAnr, cpc); cpo += eleno; cpc += elen; - + /* new struct array larger than old */ mulo--; if (mulo <= 0) break; @@ -1167,18 +1167,18 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data) if (oldSDNAnr == -1) return; firststructtypenr = *(oldsdna->structs[0]); - + spo = spc = oldsdna->structs[oldSDNAnr]; elemcount = spo[1]; spc += 2; cur = data; - + for (a = 0; a < elemcount; a++, spc += 2) { type = oldsdna->types[spc[0]]; name = oldsdna->names[spc[1]]; - + /* elementsize = including arraysize */ elen = elementsize(oldsdna, spc[0], spc[1]); @@ -1189,7 +1189,7 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data) char *cpo = (char *)find_elem(oldsdna, type, name, spo, data, NULL); if (cpo) { oldSDNAnr = DNA_struct_find_nr_ex(oldsdna, type, &oldsdna_index_last); - + mul = DNA_elem_array_size(name); elena = elen / mul; @@ -1255,7 +1255,7 @@ void *DNA_struct_reconstruct( char *cur, *cpc; const char *cpo; const char *type; - + /* oldSDNAnr == structnr, we're looking for the corresponding 'cur' number */ spo = oldsdna->structs[oldSDNAnr]; type = oldsdna->types[spo[0]]; @@ -1304,11 +1304,11 @@ bool DNA_struct_find(const SDNA *sdna, const char *stype) bool DNA_struct_elem_find(const SDNA *sdna, const char *stype, const char *vartype, const char *name) { const int SDNAnr = DNA_struct_find_nr(sdna, stype); - + if (SDNAnr != -1) { const short * const spo = sdna->structs[SDNAnr]; const char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL); - + if (cp) { return true; } -- cgit v1.2.3