Finished first pass of config -> variables
parent
d9eb312ccb
commit
6cd965ffbe
|
@ -583,6 +583,29 @@ struct Config{
|
||||||
String_Const_u8 data;
|
String_Const_u8 data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef i32 Config_Layout_Type;
|
||||||
|
enum{
|
||||||
|
ConfigLayoutType_Unset = 0,
|
||||||
|
ConfigLayoutType_Identifier = 1,
|
||||||
|
ConfigLayoutType_Integer = 2,
|
||||||
|
ConfigLayoutType_COUNT = 3,
|
||||||
|
};
|
||||||
|
struct Config_Layout{
|
||||||
|
Config_Layout_Type type;
|
||||||
|
u8 *pos;
|
||||||
|
union{
|
||||||
|
String_Const_u8 identifier;
|
||||||
|
i32 integer;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Config_Compound_Element{
|
||||||
|
Config_Compound_Element *next;
|
||||||
|
Config_Compound_Element *prev;
|
||||||
|
|
||||||
|
Config_Layout l;
|
||||||
|
Config_RValue *r;
|
||||||
|
};
|
||||||
|
|
||||||
struct Config_Compound{
|
struct Config_Compound{
|
||||||
struct Config_Compound_Element *first;
|
struct Config_Compound_Element *first;
|
||||||
|
@ -590,8 +613,153 @@ struct Config_Compound{
|
||||||
i32 count;
|
i32 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Config_Get_Result{
|
||||||
|
b32 success;
|
||||||
|
Config_RValue_Type type;
|
||||||
|
u8 *pos;
|
||||||
|
union{
|
||||||
|
b32 boolean;
|
||||||
|
i32 integer;
|
||||||
|
u32 uinteger;
|
||||||
|
String_Const_u8 string;
|
||||||
|
char character;
|
||||||
|
Config_Compound *compound;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
function Config_Get_Result
|
||||||
|
config_var(Config *config, String_Const_u8 var_name, i32 subscript);
|
||||||
|
|
||||||
|
function void
|
||||||
|
def_var_dump_rvalue(Application_Links *app, Config *config, Variable_Handle dst, String_ID l_value, Config_RValue *r){
|
||||||
|
Scratch_Block scratch(app);
|
||||||
|
|
||||||
|
b32 *boolean = 0;
|
||||||
|
i32 *integer = 0;
|
||||||
|
String_Const_u8 *string = 0;
|
||||||
|
Config_Compound *compound = 0;
|
||||||
|
|
||||||
|
Config_Get_Result get_result = {};
|
||||||
|
|
||||||
|
switch (r->type){
|
||||||
|
case ConfigRValueType_LValue:
|
||||||
|
{
|
||||||
|
Config_LValue *l = r->lvalue;
|
||||||
|
if (l != 0){
|
||||||
|
get_result = config_var(config, l->identifier, l->index);
|
||||||
|
if (get_result.success){
|
||||||
|
switch (get_result.type){
|
||||||
|
case ConfigRValueType_Boolean:
|
||||||
|
{
|
||||||
|
boolean = &get_result.boolean;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigRValueType_Integer:
|
||||||
|
{
|
||||||
|
integer = &get_result.integer;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigRValueType_String:
|
||||||
|
{
|
||||||
|
string = &get_result.string;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigRValueType_Compound:
|
||||||
|
{
|
||||||
|
compound = get_result.compound;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigRValueType_Boolean:
|
||||||
|
{
|
||||||
|
boolean = &r->boolean;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigRValueType_Integer:
|
||||||
|
{
|
||||||
|
integer = &r->integer;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigRValueType_String:
|
||||||
|
{
|
||||||
|
string = &r->string;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigRValueType_Compound:
|
||||||
|
{
|
||||||
|
compound = r->compound;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boolean != 0){
|
||||||
|
String_ID val = 0;
|
||||||
|
if (*boolean){
|
||||||
|
val = vars_save_string(string_litinit("true"));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
val = vars_save_string(string_litinit("false"));
|
||||||
|
}
|
||||||
|
vars_new_variable(dst, l_value, val);
|
||||||
|
}
|
||||||
|
else if (integer != 0){
|
||||||
|
// TODO(allen): signed/unsigned problem
|
||||||
|
String_ID val = vars_save_string(push_stringf(scratch, "%d", *integer));
|
||||||
|
vars_new_variable(dst, l_value, val);
|
||||||
|
}
|
||||||
|
else if (string != 0){
|
||||||
|
String_ID val = vars_save_string(*string);
|
||||||
|
vars_new_variable(dst, l_value, val);
|
||||||
|
}
|
||||||
|
else if (compound != 0){
|
||||||
|
Variable_Handle sub_var = vars_new_variable(dst, l_value);
|
||||||
|
|
||||||
|
i32 implicit_index = 0;
|
||||||
|
b32 implicit_allowed = true;
|
||||||
|
|
||||||
|
Config_Compound_Element *node = 0;
|
||||||
|
if (compound != 0){
|
||||||
|
node = compound->first;
|
||||||
|
}
|
||||||
|
for (; node != 0;
|
||||||
|
node = node->next, implicit_index += 1){
|
||||||
|
String_ID sub_l_value = 0;
|
||||||
|
|
||||||
|
switch (node->l.type){
|
||||||
|
case ConfigLayoutType_Unset:
|
||||||
|
{
|
||||||
|
if (implicit_allowed){
|
||||||
|
sub_l_value = vars_save_string(push_stringf(scratch, "%d", implicit_index));
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigLayoutType_Identifier:
|
||||||
|
{
|
||||||
|
implicit_allowed = false;
|
||||||
|
sub_l_value = vars_save_string(node->l.identifier);
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case ConfigLayoutType_Integer:
|
||||||
|
{
|
||||||
|
implicit_allowed = false;
|
||||||
|
sub_l_value = vars_save_string(push_stringf(scratch, "%d", node->l.integer));
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub_l_value != 0){
|
||||||
|
Config_RValue *r = node->r;
|
||||||
|
if (r != 0){
|
||||||
|
def_var_dump_rvalue(app, config, sub_var, sub_l_value, r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Variable_Handle
|
function Variable_Handle
|
||||||
def_var_from_config(Application_Links *app, Variable_Handle parent, String_Const_u8 key, Config *config){
|
def_var_from_config(Application_Links *app, Variable_Handle parent, String_Const_u8 key, Config *config){
|
||||||
Variable_Handle result = vars_get_nil();
|
Variable_Handle result = vars_get_nil();
|
||||||
|
@ -619,46 +787,8 @@ def_var_from_config(Application_Links *app, Variable_Handle parent, String_Const
|
||||||
|
|
||||||
if (l_value != 0){
|
if (l_value != 0){
|
||||||
Config_RValue *r = node->r;
|
Config_RValue *r = node->r;
|
||||||
|
|
||||||
if (r != 0){
|
if (r != 0){
|
||||||
switch (r->type){
|
def_var_dump_rvalue(app, config, var, l_value, r);
|
||||||
case ConfigRValueType_LValue:
|
|
||||||
{
|
|
||||||
// TODO(allen):
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case ConfigRValueType_Boolean:
|
|
||||||
{
|
|
||||||
String_ID val = 0;
|
|
||||||
if (r->boolean){
|
|
||||||
val = vars_save_string(string_litinit("true"));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
val = vars_save_string(string_litinit("false"));
|
|
||||||
}
|
|
||||||
vars_new_variable(var, l_value, val);
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case ConfigRValueType_Integer:
|
|
||||||
{
|
|
||||||
// TODO(allen): signed/unsigned problem
|
|
||||||
String_Const_u8 string = push_stringf(scratch, "%d", r->integer);
|
|
||||||
String_ID val = vars_save_string(string);
|
|
||||||
vars_new_variable(var, l_value, val);
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case ConfigRValueType_String:
|
|
||||||
{
|
|
||||||
String_ID val = vars_save_string(r->string);
|
|
||||||
vars_new_variable(var, l_value, val);
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case ConfigRValueType_Compound:
|
|
||||||
{
|
|
||||||
Variable_Handle sub_var = vars_new_variable(var, l_value);
|
|
||||||
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,7 +799,7 @@ def_var_from_config(Application_Links *app, Variable_Handle parent, String_Const
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// NOTE(allen): Nonsense from the old system
|
// NOTE(allen): Eval
|
||||||
|
|
||||||
function Config_Assignment*
|
function Config_Assignment*
|
||||||
config_lookup_assignment(Config *config, String_Const_u8 var_name, i32 subscript){
|
config_lookup_assignment(Config *config, String_Const_u8 var_name, i32 subscript){
|
||||||
|
@ -685,9 +815,6 @@ config_lookup_assignment(Config *config, String_Const_u8 var_name, i32 subscript
|
||||||
return(assignment);
|
return(assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Config_Get_Result
|
|
||||||
config_var(Config *config, String_Const_u8 var_name, i32 subscript);
|
|
||||||
|
|
||||||
function Config_Get_Result
|
function Config_Get_Result
|
||||||
config_evaluate_rvalue(Config *config, Config_Assignment *assignment, Config_RValue *r){
|
config_evaluate_rvalue(Config *config, Config_Assignment *assignment, Config_RValue *r){
|
||||||
Config_Get_Result result = {};
|
Config_Get_Result result = {};
|
||||||
|
@ -738,6 +865,10 @@ config_var(Config *config, String_Const_u8 var_name, i32 subscript){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// NOTE(allen): Nonsense from the old system
|
||||||
|
|
||||||
function Config_Get_Result
|
function Config_Get_Result
|
||||||
config_compound_member(Config *config, Config_Compound *compound, String_Const_u8 var_name, i32 index){
|
config_compound_member(Config *config, Config_Compound *compound, String_Const_u8 var_name, i32 index){
|
||||||
Config_Get_Result result = {};
|
Config_Get_Result result = {};
|
||||||
|
|
|
@ -88,10 +88,10 @@ struct Config_Integer{
|
||||||
|
|
||||||
typedef i32 Config_Layout_Type;
|
typedef i32 Config_Layout_Type;
|
||||||
enum{
|
enum{
|
||||||
ConfigLayoutType_Unset = 0,
|
ConfigLayoutType_Unset,
|
||||||
ConfigLayoutType_Identifier = 1,
|
ConfigLayoutType_Identifier,
|
||||||
ConfigLayoutType_Integer = 2,
|
ConfigLayoutType_Integer,
|
||||||
ConfigLayoutType_COUNT = 3,
|
ConfigLayoutType_COUNT,
|
||||||
};
|
};
|
||||||
struct Config_Layout{
|
struct Config_Layout{
|
||||||
Config_Layout_Type type;
|
Config_Layout_Type type;
|
||||||
|
|
|
@ -372,7 +372,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
||||||
{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 },
|
{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 },
|
||||||
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 },
|
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 },
|
||||||
{ PROC_LINKS(load_project, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 867 },
|
{ PROC_LINKS(load_project, 0), false, "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, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 867 },
|
||||||
{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1667 },
|
{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1797 },
|
||||||
{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 533 },
|
{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 533 },
|
||||||
{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 545 },
|
{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 545 },
|
||||||
{ PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1493 },
|
{ PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1493 },
|
||||||
|
|
Loading…
Reference in New Issue