|
@@ -10,6 +10,9 @@ static int typeNameIndex = 0;
|
|
|
static int typeNameSwap = 0;
|
|
|
static char typeName[2][ARRAY_NAME];
|
|
|
|
|
|
+static bool useGlobals = false;
|
|
|
+static Structs globalStructs;
|
|
|
+
|
|
|
static void dtAppend(const char* s) {
|
|
|
int index = 0;
|
|
|
while(typeNameIndex < (ARRAY_NAME - 1) && s[index] != '\0') {
|
|
@@ -211,7 +214,7 @@ void stsDelete(Structs* sts) {
|
|
|
free(sts->data);
|
|
|
}
|
|
|
|
|
|
-Struct* stsSearch(Structs* sts, const char* name) {
|
|
|
+static Struct* stsInternSearch(Structs* sts, const char* name) {
|
|
|
for(int i = 0; i < sts->entries; i++) {
|
|
|
if(strcmp(sts->data[i].name, name) == 0) {
|
|
|
return sts->data + i;
|
|
@@ -220,6 +223,16 @@ Struct* stsSearch(Structs* sts, const char* name) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+Struct* stsSearch(Structs* sts, const char* name) {
|
|
|
+ if(useGlobals) {
|
|
|
+ Struct* st = stsInternSearch(&globalStructs, name);
|
|
|
+ if(st != NULL) {
|
|
|
+ return st;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return stsInternSearch(sts, name);
|
|
|
+}
|
|
|
+
|
|
|
Struct* stsAdd(Structs* sts, const char* name) {
|
|
|
if(sts->entries >= sts->capacity) {
|
|
|
sts->capacity *= 2;
|
|
@@ -231,4 +244,22 @@ Struct* stsAdd(Structs* sts, const char* name) {
|
|
|
sts->data[index].name = name;
|
|
|
sts->data[index].vars = NULL;
|
|
|
return sts->data + index;
|
|
|
+}
|
|
|
+
|
|
|
+void gstsInit() {
|
|
|
+ stsInit(&globalStructs);
|
|
|
+ useGlobals = true;
|
|
|
+}
|
|
|
+
|
|
|
+void gstsDelete() {
|
|
|
+ stsDelete(&globalStructs);
|
|
|
+ useGlobals = false;
|
|
|
+}
|
|
|
+
|
|
|
+Structs* gstsGet() {
|
|
|
+ return &globalStructs;
|
|
|
+}
|
|
|
+
|
|
|
+Struct* gstsAdd(const char* name) {
|
|
|
+ return stsAdd(&globalStructs, name);
|
|
|
}
|