50 assert(ind <= (
int)
m_Names.size());
136 short type = oldStrc[0];
143 int eleLen = curStruct[1];
146 for (
int j = 0; j < eleLen; j++, curStruct += 2)
148 if (curStruct[0] == type)
152 if (
m_Names[curStruct[1]].m_isPointer)
169 assert(!(
m_Names.size() == 0));
187#ifdef SLOW_FORWARD_COMPATIBLE
188 char *typeName =
mTypes[oldLookup];
195 short *curStruct = memDNA->
mStructs[newLookup];
201 short *curStruct = memDNA->
mStructs[oldLookup];
207#ifndef TEST_BACKWARD_FORWARD_COMPATIBILITY
209 if (curStruct[1] == oldStruct[1])
212 if (
mTlens[oldStruct[0]] == memDNA->
mTlens[curStruct[0]])
215 int elementLength = oldStruct[1];
220 for (
int j = 0; j < elementLength; j++, curStruct += 2, oldStruct += 2)
225 if (strcmp(
mTypes[oldStruct[0]], memDNA->
mTypes[curStruct[0]]) != 0)
232 if (strcmp(
m_Names[oldStruct[1]].m_name, memDNA->
m_Names[curStruct[1]].m_name) != 0)
257 int len = strlen(name);
274 bp = strchr(name,
'[');
280 while (++bp < name + len - 1)
287 if (c <= '9' && c >=
'0')
294 printf(
"array parse error.\n");
304 bp = strchr(bp,
'[');
310 while (++bp < name + len - 1)
317 if (c <= '9' && c >=
'0')
324 printf(
"array2 parse error.\n");
352 intPtr = (
int *)data;
362 if (strncmp(data,
"SDNA", 4) == 0)
379 for (i = 0; i < dataLen; i++)
400 assert(strncmp(cp,
"TYPE", 4) == 0);
411 for (i = 0; i < dataLen; i++)
428 assert(strncmp(cp,
"TLEN", 4) == 0);
433 shtPtr = (
short *)intPtr;
434 for (i = 0; i < dataLen; i++, shtPtr++)
441 if (dataLen & 1) shtPtr++;
454 intPtr = (
int *)shtPtr;
456 assert(strncmp(cp,
"STRC", 4) == 0);
466 shtPtr = (
short *)intPtr;
467 for (i = 0; i < dataLen; i++)
478 for (
int a = 0; a < len; a++, shtPtr += 2)
485 shtPtr += (2 * shtPtr[1]) + 2;
506 int len = strlen(
string);
509 for (
int i = 0; i < len; i++)
514 next = &
string[i + 1];
530 for (i = 0; i < numTypes; i++)
546 short *newStruct =
mStructs[oldLookup];
547 char *typeName =
mTypes[newStruct[0]];
548 printf(
"%3d: %s ", i, typeName);
551 int len = oldStruct[1];
552 printf(
" (%d fields) ", len);
557 for (j = 0; j < len; ++j, oldStruct += 2)
559 const char *name =
m_Names[oldStruct[1]].m_name;
560 printf(
"%s %s",
mTypes[oldStruct[0]], name);
561 int elemNumBytes = 0;
564 if (
m_Names[oldStruct[1]].m_isPointer)
572 printf(
" /* %d bytes */", elemNumBytes * arrayDimensions);
582 totalBytes += elemNumBytes * arrayDimensions;
584 printf(
"\ntotalBytes=%d\n\n", totalBytes);
589 for (i=0; i<bf->types_count; ++i) {
592 printf(
"%3d: sizeof(%s%s)=%d",
594 bf->types[i].is_struct ?
"struct " :
"atomic ",
595 bf->types[i].name, bf->types[i].size);
596 if (bf->types[i].is_struct) {
598 printf(
", %d fields: { ", bf->types[i].fieldtypes_count);
599 for (j=0; j<bf->types[i].fieldtypes_count; ++j) {
601 bf->types[bf->types[i].fieldtypes[j]].name,
602 bf->names[bf->types[i].fieldnames[j]]);
603 if (j == bf->types[i].fieldtypes_count-1) {
static int name_is_array(char *name, int *dim1, int *dim2)
T * btAlignPointer(T *unalignedPtr, size_t alignment)
align a pointer to the provided alignment, upwards
static short swapShort(short sht)
static int swapInt(int inte)
int getArraySizeNew(short name)
btAlignedObjectArray< int > mCMPFlags
btAlignedObjectArray< short * > mStructs
bool flagNone(int dna_nr)
void initCmpFlags(bDNA *memDNA)
void init(char *data, int len, bool swap=false)
void initRecurseCmpFlags(int i)
bool flagEqual(int dna_nr)
btHashMap< btHashInt, int > mStructReverse
bool flagNotEqual(int dna_nr)
btAlignedObjectArray< bNameInfo > m_Names
btAlignedObjectArray< char * > mTypes
void dumpTypeDefinitions()
bool lessThan(bDNA *other)
int getReverseType(short type)
btAlignedObjectArray< short > mTlens
short * getStruct(int ind)
int getArraySize(char *str)
btHashMap< btHashString, int > mTypeLookup
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
void push_back(const T &_Val)
const T & at(int n) const
void insert(const Key &key, const Value &value)
const Value * find(const Key &key) const
very basic hashable string implementation, compatible with btHashMap