added life (entity component system) type, and changed chemical param to try to match more to archeus (or at least what I've read from wikipedia)
This commit is contained in:
parent
e698fb54a2
commit
990c22d27d
6 changed files with 43 additions and 21 deletions
|
|
@ -250,6 +250,9 @@ uint32_t ARC_Chemical_GetStringIdFn(ARC_String *string){
|
|||
if(ARC_String_EqualsCStringWithStrlen(string, "<escapeChar>")){
|
||||
return ARC_CHEMICAL_ESCAPE_CHAR;
|
||||
}
|
||||
if(ARC_String_EqualsCStringWithStrlen(string, "<numberSign>")){
|
||||
return ARC_CHEMICAL_NUMBER_SIGN;
|
||||
}
|
||||
if(ARC_String_EqualsCStringWithStrlen(string, "<number>")){
|
||||
return ARC_CHEMICAL_NUMBER_TAG;
|
||||
}
|
||||
|
|
@ -561,7 +564,7 @@ void ARC_Chemical_Create(ARC_Chemical **chemical){
|
|||
"<allowSpace> -> SPACE <allowSpace> | TAB <allowSpace> | LAMBDA\n"
|
||||
|
||||
"<type> -> <variable>\n"
|
||||
"<value> -> <variable> | <number> | <string> | <nestedValue>\n"
|
||||
"<value> -> <variable> | <numberSign> | <string> | <nestedValue>\n"
|
||||
"<nestedValue> -> OPEN_CURLY_BRACE <whitespace> <valueArgs> <whitespace> CLOSE_CURLY_BRACE\n"
|
||||
"<valueArgs> -> <value> COMMA <valueArgs> | <value>\n"
|
||||
|
||||
|
|
@ -574,6 +577,7 @@ void ARC_Chemical_Create(ARC_Chemical **chemical){
|
|||
"<stringChar> -> TAB | SPACE | BANG | HASH | DOLLAR | PERCENT | AMPERSAND | SINGLE_QUOTE | OPEN_PAREN | CLOSE_PAREN | ASTERISK | PLUS | COMMA | MINUS | PERIOD | SLASH | NUMBER | COLON | SEMICOLON | LESS_THAN | GREATER_THAN | EQUAL | QUESTION_MARK | AT | ALPHA_UPPER_CHAR | OPEN_BRACKET | CLOSE_BRACKET | CARET | UNDERSCORE | GRAVE | ALPHA_LOWER_CHAR | OPEN_CURLY_BRACE | VERTICAL_LINE | CLOSE_CURLY_BRACE | TILDE\n"
|
||||
"<escapeChar> -> BACKSLASH BACKSLASH | BACKSLASH QUOTE | BACKSLASH ALPHA_UPPER_CHAR | BACKSLASH ALPHA_LOWER_CHAR\n"
|
||||
|
||||
"<numberSign> -> MINUS <number> | <number>\n"
|
||||
"<number> -> NUMBER <number> | NUMBER\n"
|
||||
|
||||
"<whitespace> -> SPACE <whitespace> | TAB <whitespace> | NEWLINE <whitespace> | LAMBDA\n";
|
||||
|
|
@ -669,15 +673,15 @@ void ARC_Chemical_SetGroupWithCStr(ARC_Chemical *chemical, const char *groupName
|
|||
chemical->currentGroup = currentGroup;
|
||||
}
|
||||
|
||||
void *ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *element){
|
||||
void *ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *energy){
|
||||
//check if the group separator exists
|
||||
uint64_t startSeparatorIndex = ARC_String_FindCStringWithStrlen(element, ARC_CHEMICAL_GROUP_SEPARATOR);
|
||||
uint64_t startSeparatorIndex = ARC_String_FindCStringWithStrlen(energy, ARC_CHEMICAL_GROUP_SEPARATOR);
|
||||
if(startSeparatorIndex == ~(uint64_t)0){
|
||||
//use empty group
|
||||
chemical->currentGroup = ARC_Hashtable_Get(chemical->groups, (void *)ARC_CHEMICAL_DEFAULT_GROUP);
|
||||
|
||||
//get the typeData and pass back the data without the cleanup function
|
||||
ARC_ChemicalTypeData *typeData = (ARC_ChemicalTypeData *)ARC_Hashtable_Get(chemical->currentGroup, (void *)element->data);
|
||||
ARC_ChemicalTypeData *typeData = (ARC_ChemicalTypeData *)ARC_Hashtable_Get(chemical->currentGroup, (void *)energy->data);
|
||||
if(typeData == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -688,7 +692,7 @@ void *ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *element){
|
|||
//get the group
|
||||
startSeparatorIndex--;
|
||||
ARC_String *groupString;
|
||||
ARC_String_CopySubstring(&groupString, element, 0, startSeparatorIndex);
|
||||
ARC_String_CopySubstring(&groupString, energy, 0, startSeparatorIndex);
|
||||
|
||||
//set the group
|
||||
chemical->currentGroup = ARC_Hashtable_Get(chemical->groups, (void *)groupString->data);
|
||||
|
|
@ -697,13 +701,13 @@ void *ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *element){
|
|||
ARC_String_Destroy(groupString);
|
||||
|
||||
//get the element
|
||||
ARC_String *elementString;
|
||||
ARC_String *energyString;
|
||||
startSeparatorIndex += strlen(ARC_CHEMICAL_GROUP_SEPARATOR);
|
||||
ARC_String_CopySubstring(&elementString, element, startSeparatorIndex, element->length - startSeparatorIndex);
|
||||
ARC_String_CopySubstring(&energyString, energy, startSeparatorIndex, energy->length - startSeparatorIndex);
|
||||
|
||||
//this will either return the value or NULL
|
||||
ARC_ChemicalTypeData *typeData = (ARC_ChemicalTypeData *)ARC_Hashtable_Get(chemical->currentGroup, (void *)elementString->data);
|
||||
ARC_String_Destroy(elementString);
|
||||
ARC_ChemicalTypeData *typeData = (ARC_ChemicalTypeData *)ARC_Hashtable_Get(chemical->currentGroup, (void *)energyString->data);
|
||||
ARC_String_Destroy(energyString);
|
||||
if(typeData == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -711,16 +715,16 @@ void *ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *element){
|
|||
return typeData->data;
|
||||
}
|
||||
|
||||
void *ARC_Chemical_GetWithCStr(ARC_Chemical *chemical, const char *element){
|
||||
void *ARC_Chemical_GetWithCStr(ARC_Chemical *chemical, const char *energy){
|
||||
//create and copy into ARC_String
|
||||
ARC_String *elementString;
|
||||
ARC_String_CreateWithStrlen(&elementString, (char *)element);
|
||||
ARC_String *energyString;
|
||||
ARC_String_CreateWithStrlen(&energyString, (char *)energy);
|
||||
|
||||
//get the return value
|
||||
void *returnValue = ARC_Chemical_Get(chemical, elementString);
|
||||
void *returnValue = ARC_Chemical_Get(chemical, energyString);
|
||||
|
||||
//cleanup
|
||||
ARC_String_Destroy(elementString);
|
||||
ARC_String_Destroy(energyString);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue