Finished building up the config system meta program for
This commit is contained in:
parent
4aa2f3e992
commit
e7659e147b
|
@ -525,72 +525,66 @@ config_lookup_assignment(Config *config, String var_name, int32_t subscript){
|
|||
return(assignment);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_var(Config *config, String var_name, int32_t subscript, Config_RValue_Type type, void *out);
|
||||
static Config_Get_Result
|
||||
config_var(Config *config, String var_name, int32_t subscript);
|
||||
|
||||
static bool32
|
||||
config_evaluate_rvalue(Config *config, Config_Assignment *assignment, Config_RValue *r,
|
||||
Config_RValue_Type type, void *out){
|
||||
bool32 success = false;
|
||||
static Config_Get_Result
|
||||
config_evaluate_rvalue(Config *config, Config_Assignment *assignment, Config_RValue *r){
|
||||
Config_Get_Result result = {0};
|
||||
if (r != 0 && !assignment->visited){
|
||||
if (type == ConfigRValueType_NoType){
|
||||
success = true;
|
||||
}
|
||||
else if (r->type == ConfigRValueType_LValue){
|
||||
if (r->type == ConfigRValueType_LValue){
|
||||
assignment->visited = true;
|
||||
Config_LValue *l = r->lvalue;
|
||||
success = config_var(config, l->identifier, l->index, type, out);
|
||||
result = config_var(config, l->identifier, l->index);
|
||||
assignment->visited = false;
|
||||
}
|
||||
else if (r->type == type){
|
||||
success = true;
|
||||
if (out != 0){
|
||||
switch (type){
|
||||
case ConfigRValueType_Boolean:
|
||||
{
|
||||
*(bool32*)out = r->boolean;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Integer:
|
||||
{
|
||||
*(int32_t*)out = r->integer;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_String:
|
||||
{
|
||||
*(String*)out = r->string;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Character:
|
||||
{
|
||||
*(char*)out = r->character;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Compound:
|
||||
{
|
||||
*(Config_Compound**)out = r->compound;
|
||||
}break;
|
||||
}
|
||||
else{
|
||||
result.success = true;
|
||||
result.type = r->type;
|
||||
switch (r->type){
|
||||
case ConfigRValueType_Boolean:
|
||||
{
|
||||
result.boolean = r->boolean;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Integer:
|
||||
{
|
||||
result.integer = r->integer;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_String:
|
||||
{
|
||||
result.string = r->string;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Character:
|
||||
{
|
||||
result.character = r->character;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Compound:
|
||||
{
|
||||
result.compound = r->compound;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(success);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_var(Config *config, String var_name, int32_t subscript, Config_RValue_Type type, void *var_out){
|
||||
static Config_Get_Result
|
||||
config_var(Config *config, String var_name, int32_t subscript){
|
||||
Config_Get_Result result = {0};
|
||||
Config_Assignment *assignment = config_lookup_assignment(config, var_name, subscript);
|
||||
bool32 success = false;
|
||||
if (assignment != 0){
|
||||
success = config_evaluate_rvalue(config, assignment, assignment->r, type, var_out);
|
||||
result = config_evaluate_rvalue(config, assignment, assignment->r);
|
||||
}
|
||||
return(success);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_member(Config *config, Config_Compound *compound, String var_name, int32_t index,
|
||||
Config_RValue_Type type, void *var_out){
|
||||
bool32 success = false;
|
||||
static Config_Get_Result
|
||||
config_compound_member(Config *config, Config_Compound *compound, String var_name, int32_t index){
|
||||
Config_Get_Result result = {0};
|
||||
int32_t implicit_index = 0;
|
||||
bool32 implicit_index_is_valid = true;
|
||||
for (Config_Compound_Element *element = compound->first;
|
||||
|
@ -623,11 +617,11 @@ config_compound_member(Config *config, Config_Compound *compound, String var_nam
|
|||
}
|
||||
if (element_matches_query){
|
||||
Config_Assignment dummy_assignment = {0};
|
||||
success = config_evaluate_rvalue(config, &dummy_assignment, element->r, type, var_out);
|
||||
result = config_evaluate_rvalue(config, &dummy_assignment, element->r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(success);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static Iteration_Step_Result
|
||||
|
@ -643,223 +637,383 @@ typed_array_get_count(Config *parsed, Config_Compound *compound, Config_RValue_T
|
|||
|
||||
static bool32
|
||||
config_has_var(Config *config, String var_name, int32_t subscript){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_NoType, 0);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_has_var(Config *config, char *var_name, int32_t subscript){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_NoType, 0);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_bool_var(Config *config, String var_name, int32_t subscript, bool32* var_out){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_Boolean, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.boolean;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_bool_var(Config *config, char *var_name, int32_t subscript, bool32* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_Boolean, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.boolean;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_int_var(Config *config, String var_name, int32_t subscript, int32_t* var_out){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.integer;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_int_var(Config *config, char *var_name, int32_t subscript, int32_t* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.integer;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_uint_var(Config *config, String var_name, int32_t subscript, uint32_t* var_out){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.uinteger;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_uint_var(Config *config, char *var_name, int32_t subscript, uint32_t* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.uinteger;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_string_var(Config *config, String var_name, int32_t subscript, String* var_out){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_String, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_string_var(Config *config, char *var_name, int32_t subscript, String* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_String, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_placed_string_var(Config *config, String var_name, int32_t subscript, String* var_out, char *space, int32_t space_size){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_String, var_out);
|
||||
if (result){
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
bool32 success = result.success;
|
||||
if (success){
|
||||
String str = *var_out;
|
||||
*var_out = make_string_cap(space, 0, space_size);
|
||||
copy(var_out, str);
|
||||
}
|
||||
return(result);
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_placed_string_var(Config *config, char *var_name, int32_t subscript, String* var_out, char *space, int32_t space_size){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_String, var_out);
|
||||
if (result){
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
bool32 success = result.success;
|
||||
if (success){
|
||||
String str = *var_out;
|
||||
*var_out = make_string_cap(space, 0, space_size);
|
||||
copy(var_out, str);
|
||||
}
|
||||
return(result);
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_char_var(Config *config, String var_name, int32_t subscript, char* var_out){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_Character, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.character;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_char_var(Config *config, char *var_name, int32_t subscript, char* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_Character, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.character;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_var(Config *config, String var_name, int32_t subscript, Config_Compound** var_out){
|
||||
bool32 result = config_var(config, var_name, subscript, ConfigRValueType_Compound, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.compound;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_var(Config *config, char *var_name, int32_t subscript, Config_Compound** var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_var(config, var_name_str, subscript, ConfigRValueType_Compound, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_var(config, var_name_str, subscript);
|
||||
if (result.success){
|
||||
*var_out = result.compound;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_has_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_NoType, 0);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_has_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_NoType, 0);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_bool_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, bool32* var_out){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_Boolean, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
if (result.success){
|
||||
*var_out = result.boolean;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_bool_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, bool32* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_Boolean, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
if (result.success){
|
||||
*var_out = result.boolean;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_int_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, int32_t* var_out){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
if (result.success){
|
||||
*var_out = result.integer;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_int_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, int32_t* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
if (result.success){
|
||||
*var_out = result.integer;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_uint_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, uint32_t* var_out){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
if (result.success){
|
||||
*var_out = result.uinteger;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_uint_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, uint32_t* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_Integer, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
if (result.success){
|
||||
*var_out = result.uinteger;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_string_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, String* var_out){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_String, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_string_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, String* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_String, var_out);
|
||||
return(result);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_placed_string_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, String* var_out, char *space, int32_t space_size){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_String, var_out);
|
||||
if (result){
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
bool32 success = result.success;
|
||||
if (success){
|
||||
String str = *var_out;
|
||||
*var_out = make_string_cap(space, 0, space_size);
|
||||
copy(var_out, str);
|
||||
}
|
||||
return(result);
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_placed_string_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, String* var_out, char *space, int32_t space_size){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_String, var_out);
|
||||
if (result){
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
if (result.success){
|
||||
*var_out = result.string;
|
||||
}
|
||||
bool32 success = result.success;
|
||||
if (success){
|
||||
String str = *var_out;
|
||||
*var_out = make_string_cap(space, 0, space_size);
|
||||
copy(var_out, str);
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_char_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, char* var_out){
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
if (result.success){
|
||||
*var_out = result.character;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_char_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, char* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
if (result.success){
|
||||
*var_out = result.character;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_compound_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, Config_Compound** var_out){
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name, index);
|
||||
if (result.success){
|
||||
*var_out = result.compound;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_compound_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, Config_Compound** var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
Config_Get_Result result = config_compound_member(config, compound, var_name_str, index);
|
||||
if (result.success){
|
||||
*var_out = result.compound;
|
||||
}
|
||||
return(result.success);
|
||||
}
|
||||
|
||||
static Iteration_Step_Result
|
||||
typed_has_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_NoType,
|
||||
index, 0);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static Iteration_Step_Result
|
||||
typed_bool_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index, bool32* var_out){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_Boolean,
|
||||
index, var_out);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static Iteration_Step_Result
|
||||
typed_int_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index, int32_t* var_out){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_Integer,
|
||||
index, var_out);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static Iteration_Step_Result
|
||||
typed_uint_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index, uint32_t* var_out){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_Integer,
|
||||
index, var_out);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static Iteration_Step_Result
|
||||
typed_string_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index, String* var_out){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_String,
|
||||
index, var_out);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static Iteration_Step_Result
|
||||
typed_placed_string_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index, String* var_out, char *space, int32_t space_size){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_String,
|
||||
index, var_out);
|
||||
bool32 success = (result == Iteration_Good);
|
||||
if (success){
|
||||
String str = *var_out;
|
||||
*var_out = make_string_cap(space, 0, space_size);
|
||||
copy(var_out, str);
|
||||
|
@ -867,38 +1021,62 @@ config_compound_placed_string_member(Config *config, Config_Compound *compound,
|
|||
return(result);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_char_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, char* var_out){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_Character, var_out);
|
||||
static Iteration_Step_Result
|
||||
typed_char_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index, char* var_out){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_Character,
|
||||
index, var_out);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_char_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, char* var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_Character, var_out);
|
||||
static Iteration_Step_Result
|
||||
typed_compound_array_iteration_step(Config *config, Config_Compound *compound,
|
||||
int32_t index, Config_Compound** var_out){
|
||||
Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_Compound,
|
||||
index, var_out);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_compound_member(Config *config, Config_Compound *compound,
|
||||
String var_name, int32_t index, Config_Compound** var_out){
|
||||
bool32 result = config_compound_member(config, compound, var_name, index,
|
||||
ConfigRValueType_Compound, var_out);
|
||||
return(result);
|
||||
static int32_t
|
||||
typed_bool_array_get_count(Config *config, Config_Compound *compound){
|
||||
int32_t count = typed_array_get_count(config, compound, ConfigRValueType_Boolean);
|
||||
return(count);
|
||||
}
|
||||
|
||||
static bool32
|
||||
config_compound_compound_member(Config *config, Config_Compound *compound,
|
||||
char *var_name, int32_t index, Config_Compound** var_out){
|
||||
String var_name_str = make_string_slowly(var_name);
|
||||
bool32 result = config_compound_member(config, compound, var_name_str, index,
|
||||
ConfigRValueType_Compound, var_out);
|
||||
return(result);
|
||||
static int32_t
|
||||
typed_int_array_get_count(Config *config, Config_Compound *compound){
|
||||
int32_t count = typed_array_get_count(config, compound, ConfigRValueType_Integer);
|
||||
return(count);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
typed_float_array_get_count(Config *config, Config_Compound *compound){
|
||||
int32_t count = typed_array_get_count(config, compound, ConfigRValueType_Float);
|
||||
return(count);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
typed_string_array_get_count(Config *config, Config_Compound *compound){
|
||||
int32_t count = typed_array_get_count(config, compound, ConfigRValueType_String);
|
||||
return(count);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
typed_character_array_get_count(Config *config, Config_Compound *compound){
|
||||
int32_t count = typed_array_get_count(config, compound, ConfigRValueType_Character);
|
||||
return(count);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
typed_compound_array_get_count(Config *config, Config_Compound *compound){
|
||||
int32_t count = typed_array_get_count(config, compound, ConfigRValueType_Compound);
|
||||
return(count);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
typed_no_type_array_get_count(Config *config, Config_Compound *compound){
|
||||
int32_t count = typed_array_get_count(config, compound, ConfigRValueType_NoType);
|
||||
return(count);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
@ -906,16 +1084,45 @@ config_compound_compound_member(Config *config, Config_Compound *compound,
|
|||
static Iteration_Step_Result
|
||||
typed_array_iteration_step(Config *parsed, Config_Compound *compound, Config_RValue_Type type,
|
||||
int32_t index, void *var_out){
|
||||
Iteration_Step_Result result = Iteration_Good;
|
||||
if (!config_compound_member(parsed, compound, make_lit_string("~"), index, type, var_out)){
|
||||
if (config_compound_has_member(parsed, compound, "~", index)){
|
||||
result = Iteration_Skip;
|
||||
Iteration_Step_Result step_result = Iteration_Quit;
|
||||
Config_Get_Result result = config_compound_member(parsed, compound, make_lit_string("~"), index);
|
||||
if (result.success){
|
||||
if (result.type == type){
|
||||
step_result = Iteration_Good;
|
||||
if (var_out != 0){
|
||||
switch (type){
|
||||
case ConfigRValueType_Boolean:
|
||||
{
|
||||
*(bool32*)var_out = result.boolean;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Integer:
|
||||
{
|
||||
*(int32_t*)var_out = result.integer;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_String:
|
||||
{
|
||||
*(String*)var_out = result.string;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Character:
|
||||
{
|
||||
*(char*)var_out = result.character;
|
||||
}break;
|
||||
|
||||
case ConfigRValueType_Compound:
|
||||
{
|
||||
*(Config_Compound**)var_out = result.compound;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
result = Iteration_Quit;
|
||||
step_result = Iteration_Skip;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
return(step_result);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
|
|
|
@ -134,6 +134,21 @@ struct Config{
|
|||
|
||||
////////////////////////////////
|
||||
|
||||
struct Config_Get_Result{
|
||||
bool32 success;
|
||||
Config_RValue_Type type;
|
||||
union{
|
||||
bool32 boolean;
|
||||
int32_t integer;
|
||||
uint32_t uinteger;
|
||||
String string;
|
||||
char character;
|
||||
Config_Compound *compound;
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
struct Extension_List{
|
||||
char space[256];
|
||||
char *exts[94];
|
||||
|
|
|
@ -229,7 +229,7 @@ static Command_Metadata fcoder_metacmd_table[193] = {
|
|||
{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 368 },
|
||||
{ PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 174 },
|
||||
{ PROC_LINKS(click_set_mark, 0), "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 187 },
|
||||
{ PROC_LINKS(close_all_code, 0), "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 975 },
|
||||
{ PROC_LINKS(close_all_code, 0), "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 981 },
|
||||
{ PROC_LINKS(close_build_panel, 0), "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "C:\\work\\4ed\\code\\4coder_build_commands.cpp", 46, 205 },
|
||||
{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 441 },
|
||||
{ PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 26 },
|
||||
|
@ -295,7 +295,7 @@ static Command_Metadata fcoder_metacmd_table[193] = {
|
|||
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 800 },
|
||||
{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 747 },
|
||||
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 759 },
|
||||
{ PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 998 },
|
||||
{ PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 1004 },
|
||||
{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1101 },
|
||||
{ PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "C:\\work\\4ed\\code\\4coder_miblo_numbers.cpp", 45, 110 },
|
||||
{ PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "C:\\work\\4ed\\code\\4coder_miblo_numbers.cpp", 45, 383 },
|
||||
|
@ -317,8 +317,8 @@ static Command_Metadata fcoder_metacmd_table[193] = {
|
|||
{ PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "C:\\work\\4ed\\code\\4coder_jump_direct.cpp", 43, 116 },
|
||||
{ PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "C:\\work\\4ed\\code\\4coder_jump_sticky.cpp", 43, 571 },
|
||||
{ PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "C:\\work\\4ed\\code\\4coder_jump_sticky.cpp", 43, 556 },
|
||||
{ PROC_LINKS(open_all_code, 0), "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 982 },
|
||||
{ PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 989 },
|
||||
{ PROC_LINKS(open_all_code, 0), "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 988 },
|
||||
{ PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 995 },
|
||||
{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1457 },
|
||||
{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1320 },
|
||||
{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Switches to the next active panel and begins an open file dialogue.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1465 },
|
||||
|
@ -335,8 +335,8 @@ static Command_Metadata fcoder_metacmd_table[193] = {
|
|||
{ PROC_LINKS(paste_next, 0), "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 84 },
|
||||
{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 135 },
|
||||
{ PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "C:\\work\\4ed\\code\\4coder_scope_commands.cpp", 46, 481 },
|
||||
{ PROC_LINKS(project_fkey_command, 0), "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 1005 },
|
||||
{ PROC_LINKS(project_go_to_root_directory, 0), "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 1030 },
|
||||
{ PROC_LINKS(project_fkey_command, 0), "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 1011 },
|
||||
{ PROC_LINKS(project_go_to_root_directory, 0), "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 1036 },
|
||||
{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 893 },
|
||||
{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 913 },
|
||||
{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 931 },
|
||||
|
@ -378,7 +378,7 @@ static Command_Metadata fcoder_metacmd_table[193] = {
|
|||
{ PROC_LINKS(set_bindings_default, 0), "set_bindings_default", 20, "Remap keybindings using the 'default' mapping rule.", 51, "C:\\work\\4ed\\code\\4coder_remapping_commands.cpp", 50, 61 },
|
||||
{ PROC_LINKS(set_bindings_mac_default, 0), "set_bindings_mac_default", 24, "Remap keybindings using the 'mac-default' mapping rule.", 55, "C:\\work\\4ed\\code\\4coder_remapping_commands.cpp", 50, 75 },
|
||||
{ PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 86 },
|
||||
{ PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 1078 },
|
||||
{ PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 1084 },
|
||||
{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 464 },
|
||||
{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 450 },
|
||||
{ PROC_LINKS(snipe_token_or_word, 0), "snipe_token_or_word", 19, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "C:\\work\\4ed\\code\\4coder_seek.cpp", 36, 1259 },
|
||||
|
|
|
@ -162,6 +162,9 @@ open_all_files_in_directory_pattern_match(Application_Links *app, Partition *scr
|
|||
char *mem = push_array(scratch, char, size);
|
||||
String space = make_string_cap(mem, 0, size);
|
||||
append(&space, dir);
|
||||
if (space.size == 0 || !char_is_slash(space.str[space.size - 1])){
|
||||
append(&space, '/');
|
||||
}
|
||||
open_all_files_in_directory_pattern_match__inner(app, space, whitelist, blacklist, flags);
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
@ -186,6 +189,9 @@ open_all_files_in_hot_with_extension(Application_Links *app, Partition *scratch,
|
|||
char *mem = push_array(scratch, char, size);
|
||||
String space = make_string_cap(mem, 0, size);
|
||||
space.size = directory_get_hot(app, space.str, space.memory_size);
|
||||
if (space.size == 0 || !char_is_slash(space.str[space.size - 1])){
|
||||
append(&space, '/');
|
||||
}
|
||||
Project_File_Pattern_Array whitelist = get_pattern_array_from_cstring_array(scratch, array);
|
||||
Project_File_Pattern_Array blacklist = get_standard_blacklist(scratch);
|
||||
open_all_files_in_directory_pattern_match__inner(app, space, whitelist, blacklist, flags);
|
||||
|
@ -383,7 +389,7 @@ parse_project__config_data__version_1(Partition *arena, String root_dir, Config
|
|||
}
|
||||
|
||||
config_compound_bool_member(parsed, src, "recursive", 1, &dst->recursive);
|
||||
config_compound_bool_member(parsed, src, "relative", 1, &dst->relative);
|
||||
config_compound_bool_member(parsed, src, "relative", 2, &dst->relative);
|
||||
|
||||
++c;
|
||||
++dst;
|
||||
|
|
Loading…
Reference in New Issue