Put version in variable dump

master
Allen Webster 2020-11-24 20:16:07 -08:00
parent eee6ae3640
commit ee37906724
2 changed files with 9 additions and 92 deletions

View File

@ -540,95 +540,6 @@ def_config_parser_recover(Config_Parser *ctx){
//////////////////////////////// ////////////////////////////////
// NOTE(allen): Dump Config to Variables // NOTE(allen): Dump Config to Variables
#if 0
struct Config_Assignment{
Config_Assignment *next;
Config_Assignment *prev;
u8 *pos;
Config_LValue *l;
Config_RValue *r;
b32 visited;
};
struct Config_LValue{
String_Const_u8 identifier;
i32 index;
};
struct Config_RValue{
Config_RValue_Type type;
union{
Config_LValue *lvalue;
b32 boolean;
i32 integer;
u32 uinteger;
String_Const_u8 string;
char character;
Config_Compound *compound;
};
};
struct Config{
i32 *version;
Config_Assignment *first;
Config_Assignment *last;
i32 count;
Config_Error_List errors;
String_Const_u8 file_name;
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_Element *first;
struct Config_Compound_Element *last;
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
function Config_Get_Result function Config_Get_Result
config_var(Config *config, String_Const_u8 var_name, i32 subscript); config_var(Config *config, String_Const_u8 var_name, i32 subscript);
@ -772,6 +683,12 @@ def_var_from_config(Application_Links *app, Variable_Handle parent, String_Const
Scratch_Block scratch(app); Scratch_Block scratch(app);
if (config->version != 0){
String_ID version_key = vars_save_string(string_u8_litexpr("version"));
String_ID version_value = vars_save_string(push_stringf(scratch, "%d", *config->version));
vars_new_variable(parent, version_key, version_value);
}
for (Config_Assignment *node = config->first; for (Config_Assignment *node = config->first;
node != 0; node != 0;
node = node->next){ node = node->next){
@ -779,8 +696,8 @@ def_var_from_config(Application_Links *app, Variable_Handle parent, String_Const
Config_LValue *l = node->l; Config_LValue *l = node->l;
if (l != 0){ if (l != 0){
String_Const_u8 string = l->identifier; String_Const_u8 string = l->identifier;
if (string.size == 0){ if (l->index != 0){
string = push_stringf(scratch, "%d", l->index); string = push_stringf(scratch, "%.*s.%d", string_expand(string), l->index);
} }
l_value = vars_save_string(string); l_value = vars_save_string(string);
} }

View File

@ -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, 851 }, { 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, 851 },
{ 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, 1744 }, { 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, 1661 },
{ 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 },