Switch to relying on string_push and string_push_copy everywhere
parent
89516d827b
commit
4db6beddd0
|
@ -1623,7 +1623,7 @@ load_config_and_apply(Application_Links *app, Partition *scratch, Config_Data *c
|
||||||
|
|
||||||
// Values
|
// Values
|
||||||
Temp_Memory temp2 = begin_temp_memory(scratch);
|
Temp_Memory temp2 = begin_temp_memory(scratch);
|
||||||
String space = push_string(scratch, partition_remaining(scratch));
|
String space = string_push(scratch, partition_remaining(scratch));
|
||||||
|
|
||||||
{
|
{
|
||||||
config_feedback_string(&space, "user_name", config->user_name);
|
config_feedback_string(&space, "user_name", config->user_name);
|
||||||
|
|
|
@ -1320,40 +1320,6 @@ dump_file_search_up_path(Partition *arena, String path, String file_name){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String
|
|
||||||
push_string(Partition *arena, int32_t cap){
|
|
||||||
char *mem = push_array(arena, char, cap);
|
|
||||||
String result = {};
|
|
||||||
if (mem != 0){
|
|
||||||
result = make_string_cap(mem, 0, cap);
|
|
||||||
}
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static String
|
|
||||||
push_string_copy(Partition *arena, String str){
|
|
||||||
String result = {};
|
|
||||||
if (str.str != 0){
|
|
||||||
result = push_string(arena, str.size + 1);
|
|
||||||
push_align(arena, 8);
|
|
||||||
if (result.str != 0){
|
|
||||||
copy(&result, str);
|
|
||||||
terminate_with_null(&result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static String
|
|
||||||
push_string_copy(Partition *arena, char *str, int32_t size){
|
|
||||||
return(push_string_copy(arena, make_string(str, size)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static String
|
|
||||||
push_string_copy(Partition *arena, char *str){
|
|
||||||
return(push_string_copy(arena, make_string_slowly(str)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sort_pairs_by_key__quick(Sort_Pair_i32 *pairs, int32_t first, int32_t one_past_last){
|
sort_pairs_by_key__quick(Sort_Pair_i32 *pairs, int32_t first, int32_t one_past_last){
|
||||||
int32_t dif = one_past_last - first;
|
int32_t dif = one_past_last - first;
|
||||||
|
|
|
@ -556,7 +556,7 @@ generate_hot_directory_file_list(Application_Links *app, Partition *arena, Liste
|
||||||
info < one_past_last;
|
info < one_past_last;
|
||||||
info += 1){
|
info += 1){
|
||||||
if (info->folder) continue;
|
if (info->folder) continue;
|
||||||
String file_name = push_string_copy(arena, make_string(info->filename, info->filename_len));
|
String file_name = string_push_copy(arena, make_string(info->filename, info->filename_len));
|
||||||
char *is_loaded = "";
|
char *is_loaded = "";
|
||||||
char *status_flag = "";
|
char *status_flag = "";
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ get_pattern_array_from_cstring_array(Partition *arena, CString_Array list){
|
||||||
array.count = count;
|
array.count = count;
|
||||||
for (int32_t i = 0; i < count; ++i){
|
for (int32_t i = 0; i < count; ++i){
|
||||||
String base_str = make_string_slowly(list.strings[i]);
|
String base_str = make_string_slowly(list.strings[i]);
|
||||||
String str = push_string(arena, base_str.size + 3);
|
String str = string_push(arena, base_str.size + 3);
|
||||||
append(&str, "*.");
|
append(&str, "*.");
|
||||||
append(&str, base_str);
|
append(&str, base_str);
|
||||||
terminate_with_null(&str);
|
terminate_with_null(&str);
|
||||||
|
@ -259,18 +259,18 @@ parse_project__config_data__version_0(Partition *arena, String file_dir, Config
|
||||||
|
|
||||||
Config_Compound *compound = 0;
|
Config_Compound *compound = 0;
|
||||||
if (config_compound_var(parsed, fkey_command_name, j, &compound)){
|
if (config_compound_var(parsed, fkey_command_name, j, &compound)){
|
||||||
command->name = push_string(arena, 4);
|
command->name = string_push(arena, 4);
|
||||||
append_int_to_str(&command->name, j);
|
append_int_to_str(&command->name, j);
|
||||||
terminate_with_null(&command->name);
|
terminate_with_null(&command->name);
|
||||||
|
|
||||||
String cmd = {};
|
String cmd = {};
|
||||||
if (config_compound_string_member(parsed, compound, "cmd", 0, &cmd)){
|
if (config_compound_string_member(parsed, compound, "cmd", 0, &cmd)){
|
||||||
command->cmd = push_string_copy(arena, cmd);
|
command->cmd = string_push_copy(arena, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
String out = {};
|
String out = {};
|
||||||
if (config_compound_string_member(parsed, compound, "out", 1, &out)){
|
if (config_compound_string_member(parsed, compound, "out", 1, &out)){
|
||||||
command->out = push_string_copy(arena, out);
|
command->out = string_push_copy(arena, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 footer_panel = false;
|
bool32 footer_panel = false;
|
||||||
|
@ -284,7 +284,7 @@ parse_project__config_data__version_0(Partition *arena, String file_dir, Config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
command->name = push_string(arena, 4);
|
command->name = string_push(arena, 4);
|
||||||
append_int_to_str(&command->name, j);
|
append_int_to_str(&command->name, j);
|
||||||
terminate_with_null(&command->name);
|
terminate_with_null(&command->name);
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ parse_project__extract_pattern_array(Partition *arena, Config *parsed,
|
||||||
for (Config_Get_Result_Node *node = list.first;
|
for (Config_Get_Result_Node *node = list.first;
|
||||||
node != 0;
|
node != 0;
|
||||||
node = node->next, i += 1){
|
node = node->next, i += 1){
|
||||||
String str = push_string_copy(arena, node->result.string);
|
String str = string_push_copy(arena, node->result.string);
|
||||||
get_absolutes(str, &array_out->patterns[i].absolutes, false, false);
|
get_absolutes(str, &array_out->patterns[i].absolutes, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ parse_project__config_data__version_1(Partition *arena, String root_dir, Config
|
||||||
// Set new project directory
|
// Set new project directory
|
||||||
{
|
{
|
||||||
int32_t cap = root_dir.size + 1;
|
int32_t cap = root_dir.size + 1;
|
||||||
project->dir = push_string(arena, cap);
|
project->dir = string_push(arena, cap);
|
||||||
copy(&project->dir, root_dir);
|
copy(&project->dir, root_dir);
|
||||||
terminate_with_null(&project->dir);
|
terminate_with_null(&project->dir);
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ parse_project__config_data__version_1(Partition *arena, String root_dir, Config
|
||||||
{
|
{
|
||||||
String str = {};
|
String str = {};
|
||||||
if (config_string_var(parsed, "project_name", 0, &str)){
|
if (config_string_var(parsed, "project_name", 0, &str)){
|
||||||
project->name = push_string_copy(arena, str);
|
project->name = string_push_copy(arena, str);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
project->name = make_lit_string("");
|
project->name = make_lit_string("");
|
||||||
|
@ -413,7 +413,7 @@ parse_project__config_data__version_1(Partition *arena, String root_dir, Config
|
||||||
|
|
||||||
String str = {};
|
String str = {};
|
||||||
if (config_compound_string_member(parsed, src, "path", 0, &str)){
|
if (config_compound_string_member(parsed, src, "path", 0, &str)){
|
||||||
dst->path = push_string_copy(arena, str);
|
dst->path = string_push_copy(arena, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
config_compound_bool_member(parsed, src, "recursive", 1, &dst->recursive);
|
config_compound_bool_member(parsed, src, "recursive", 1, &dst->recursive);
|
||||||
|
@ -513,9 +513,9 @@ parse_project__config_data__version_1(Partition *arena, String root_dir, Config
|
||||||
config_compound_bool_member(parsed, src, "cursor_at_end", 5,
|
config_compound_bool_member(parsed, src, "cursor_at_end", 5,
|
||||||
&cursor_at_end);
|
&cursor_at_end);
|
||||||
|
|
||||||
dst->name = push_string_copy(arena, name);
|
dst->name = string_push_copy(arena, name);
|
||||||
dst->cmd = push_string_copy(arena, cmd_str);
|
dst->cmd = string_push_copy(arena, cmd_str);
|
||||||
dst->out = push_string_copy(arena, out);
|
dst->out = string_push_copy(arena, out);
|
||||||
dst->footer_panel = footer_panel;
|
dst->footer_panel = footer_panel;
|
||||||
dst->save_dirty_files = save_dirty_files;
|
dst->save_dirty_files = save_dirty_files;
|
||||||
dst->cursor_at_end = cursor_at_end;
|
dst->cursor_at_end = cursor_at_end;
|
||||||
|
@ -652,7 +652,7 @@ project_deep_copy__pattern_array(Partition *arena, Project_File_Pattern_Array *s
|
||||||
int32_t abs_count = src->absolutes.count;
|
int32_t abs_count = src->absolutes.count;
|
||||||
dst->absolutes.count = abs_count;
|
dst->absolutes.count = abs_count;
|
||||||
for (int32_t j = 0; j < abs_count; ++j){
|
for (int32_t j = 0; j < abs_count; ++j){
|
||||||
dst->absolutes.a[j] = push_string_copy(arena, src->absolutes.a[j]);
|
dst->absolutes.a[j] = string_push_copy(arena, src->absolutes.a[j]);
|
||||||
if (dst->absolutes.a[j].str == 0){
|
if (dst->absolutes.a[j].str == 0){
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
@ -666,12 +666,12 @@ static Project
|
||||||
project_deep_copy__inner(Partition *arena, Project *project){
|
project_deep_copy__inner(Partition *arena, Project *project){
|
||||||
Project result = {};
|
Project result = {};
|
||||||
|
|
||||||
result.dir = push_string_copy(arena, project->dir);
|
result.dir = string_push_copy(arena, project->dir);
|
||||||
if (result.dir.str == 0){
|
if (result.dir.str == 0){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.name = push_string_copy(arena, project->name);
|
result.name = string_push_copy(arena, project->name);
|
||||||
if (result.name.str == 0){
|
if (result.name.str == 0){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -694,7 +694,7 @@ project_deep_copy__inner(Partition *arena, Project *project){
|
||||||
Project_File_Load_Path *dst = result.load_path_array.paths;
|
Project_File_Load_Path *dst = result.load_path_array.paths;
|
||||||
Project_File_Load_Path *src = project->load_path_array.paths;
|
Project_File_Load_Path *src = project->load_path_array.paths;
|
||||||
for (int32_t i = 0; i < path_count; ++i, ++dst, ++src){
|
for (int32_t i = 0; i < path_count; ++i, ++dst, ++src){
|
||||||
dst->path = push_string_copy(arena, src->path);
|
dst->path = string_push_copy(arena, src->path);
|
||||||
if (dst->path.str == 0){
|
if (dst->path.str == 0){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -716,19 +716,19 @@ project_deep_copy__inner(Partition *arena, Project *project){
|
||||||
for (int32_t i = 0; i < command_count; ++i, ++dst, ++src){
|
for (int32_t i = 0; i < command_count; ++i, ++dst, ++src){
|
||||||
memset(dst, 0, sizeof(*dst));
|
memset(dst, 0, sizeof(*dst));
|
||||||
if (src->name.str != 0){
|
if (src->name.str != 0){
|
||||||
dst->name = push_string_copy(arena, src->name);
|
dst->name = string_push_copy(arena, src->name);
|
||||||
if (dst->name.str == 0){
|
if (dst->name.str == 0){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (src->cmd.str != 0){
|
if (src->cmd.str != 0){
|
||||||
dst->cmd = push_string_copy(arena, src->cmd);
|
dst->cmd = string_push_copy(arena, src->cmd);
|
||||||
if (dst->cmd.str == 0){
|
if (dst->cmd.str == 0){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (src->out.str != 0){
|
if (src->out.str != 0){
|
||||||
dst->out = push_string_copy(arena, src->out);
|
dst->out = string_push_copy(arena, src->out);
|
||||||
if (dst->out.str == 0){
|
if (dst->out.str == 0){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -922,7 +922,7 @@ set_current_project(Application_Links *app, Partition *scratch, Project *project
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Temp_Memory temp2 = begin_temp_memory(scratch);
|
Temp_Memory temp2 = begin_temp_memory(scratch);
|
||||||
String space = push_string(scratch, partition_remaining(scratch));
|
String space = string_push(scratch, partition_remaining(scratch));
|
||||||
|
|
||||||
{
|
{
|
||||||
config_feedback_string(&space, "'root_directory'", project->dir);
|
config_feedback_string(&space, "'root_directory'", project->dir);
|
||||||
|
@ -1218,9 +1218,9 @@ project_generate_bat_script(Partition *scratch, String opts, String compiler,
|
||||||
|
|
||||||
Temp_Memory temp = begin_temp_memory(scratch);
|
Temp_Memory temp = begin_temp_memory(scratch);
|
||||||
|
|
||||||
String cf = push_string_copy(scratch, code_file);
|
String cf = string_push_copy(scratch, code_file);
|
||||||
String od = push_string_copy(scratch, output_dir);
|
String od = string_push_copy(scratch, output_dir);
|
||||||
String bf = push_string_copy(scratch, binary_file);
|
String bf = string_push_copy(scratch, binary_file);
|
||||||
|
|
||||||
replace_char(&cf, '/', '\\');
|
replace_char(&cf, '/', '\\');
|
||||||
replace_char(&od, '/', '\\');
|
replace_char(&od, '/', '\\');
|
||||||
|
@ -1309,8 +1309,8 @@ project_generate_project_4coder_file(Partition *scratch,
|
||||||
String od = output_dir;
|
String od = output_dir;
|
||||||
String bf = binary_file;
|
String bf = binary_file;
|
||||||
|
|
||||||
String od_win = push_string(scratch, od.size*2);
|
String od_win = string_push(scratch, od.size*2);
|
||||||
String bf_win = push_string(scratch, bf.size*2);
|
String bf_win = string_push(scratch, bf.size*2);
|
||||||
|
|
||||||
append(&od_win, od);
|
append(&od_win, od);
|
||||||
append(&bf_win, bf);
|
append(&bf_win, bf);
|
||||||
|
@ -1539,8 +1539,8 @@ CUSTOM_DOC("Open a lister of all commands in the currently loaded project.")
|
||||||
int32_t option_count = current_project.command_array.count;
|
int32_t option_count = current_project.command_array.count;
|
||||||
Lister_Option *options = push_array(arena, Lister_Option, option_count);
|
Lister_Option *options = push_array(arena, Lister_Option, option_count);
|
||||||
for (int32_t i = 0; i < current_project.command_array.count; i += 1){
|
for (int32_t i = 0; i < current_project.command_array.count; i += 1){
|
||||||
String string = push_string_copy(arena, current_project.command_array.commands[i].name);
|
String string = string_push_copy(arena, current_project.command_array.commands[i].name);
|
||||||
String status = push_string_copy(arena, current_project.command_array.commands[i].cmd);
|
String status = string_push_copy(arena, current_project.command_array.commands[i].cmd);
|
||||||
options[i].string = string.str;
|
options[i].string = string.str;
|
||||||
options[i].status = status.str;
|
options[i].status = status.str;
|
||||||
options[i].user_data = IntAsPtr(i);
|
options[i].user_data = IntAsPtr(i);
|
||||||
|
|
|
@ -451,7 +451,7 @@ lister_add_item(Partition *arena, Lister *lister,
|
||||||
void *user_data, int32_t extra_space){
|
void *user_data, int32_t extra_space){
|
||||||
return(lister_add_item(arena, lister,
|
return(lister_add_item(arena, lister,
|
||||||
string,
|
string,
|
||||||
lister_prealloced(push_string_copy(arena, status)),
|
lister_prealloced(string_push_copy(arena, status)),
|
||||||
user_data, extra_space));
|
user_data, extra_space));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ lister_add_item(Partition *arena, Lister *lister,
|
||||||
String string, Lister_Prealloced_String status,
|
String string, Lister_Prealloced_String status,
|
||||||
void *user_data, int32_t extra_space){
|
void *user_data, int32_t extra_space){
|
||||||
return(lister_add_item(arena, lister,
|
return(lister_add_item(arena, lister,
|
||||||
lister_prealloced(push_string_copy(arena, string)),
|
lister_prealloced(string_push_copy(arena, string)),
|
||||||
status,
|
status,
|
||||||
user_data, extra_space));
|
user_data, extra_space));
|
||||||
}
|
}
|
||||||
|
@ -470,8 +470,8 @@ lister_add_item(Partition *arena, Lister *lister,
|
||||||
String string, String status,
|
String string, String status,
|
||||||
void *user_data, int32_t extra_space){
|
void *user_data, int32_t extra_space){
|
||||||
return(lister_add_item(arena, lister,
|
return(lister_add_item(arena, lister,
|
||||||
lister_prealloced(push_string_copy(arena, string)),
|
lister_prealloced(string_push_copy(arena, string)),
|
||||||
lister_prealloced(push_string_copy(arena, status)),
|
lister_prealloced(string_push_copy(arena, status)),
|
||||||
user_data, extra_space));
|
user_data, extra_space));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ lister_add_ui_item(Partition *arena, Lister *lister,
|
||||||
String string, int32_t index,
|
String string, int32_t index,
|
||||||
void *user_data, int32_t extra_space){
|
void *user_data, int32_t extra_space){
|
||||||
return(lister_add_ui_item(arena, lister,
|
return(lister_add_ui_item(arena, lister,
|
||||||
lister_prealloced(push_string_copy(arena, string)),
|
lister_prealloced(string_push_copy(arena, string)),
|
||||||
index,
|
index,
|
||||||
user_data, extra_space));
|
user_data, extra_space));
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,11 +185,6 @@ set_token(Parse_Context *context, Cpp_Token *token){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String
|
|
||||||
str_alloc(Partition *part, i32 cap){
|
|
||||||
return(make_string_cap(push_array(part, char, cap), 0, cap));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal Item_Set
|
internal Item_Set
|
||||||
allocate_item_set(Partition *part, i32 count){
|
allocate_item_set(Partition *part, i32 count){
|
||||||
Item_Set item_set = {};
|
Item_Set item_set = {};
|
||||||
|
|
|
@ -73,18 +73,18 @@ generate_custom_headers(Partition *part){
|
||||||
String *macro = &func_4ed_names.names[i].macro;
|
String *macro = &func_4ed_names.names[i].macro;
|
||||||
String *public_name = &func_4ed_names.names[i].public_name;
|
String *public_name = &func_4ed_names.names[i].public_name;
|
||||||
|
|
||||||
*macro = str_alloc(part, name_string.size+4);
|
*macro = string_push(part, name_string.size + 4);
|
||||||
to_upper(macro, name_string);
|
to_upper(macro, name_string);
|
||||||
append(macro, make_lit_string("_SIG"));
|
append(macro, make_lit_string("_SIG"));
|
||||||
|
|
||||||
*public_name = str_alloc(part, name_string.size);
|
*public_name = string_push(part, name_string.size);
|
||||||
to_lower(public_name, name_string);
|
to_lower(public_name, name_string);
|
||||||
|
|
||||||
push_align(part, 8);
|
push_align(part, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): Output
|
// NOTE(allen): Output
|
||||||
String out = str_alloc(part, 10 << 20);
|
String out = string_push(part, 10 << 20);
|
||||||
|
|
||||||
// NOTE(allen): Custom API headers
|
// NOTE(allen): Custom API headers
|
||||||
append(&out, "struct Application_Links;\n");
|
append(&out, "struct Application_Links;\n");
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
@echo off
|
|
||||||
pushd ..\4coder-non-source\test_data
|
|
||||||
set run_path=%cd%\sample_files
|
|
||||||
set data_path=%cd%\input_data
|
|
||||||
popd
|
|
||||||
pushd ..\build
|
|
||||||
set build=%cd%
|
|
||||||
popd
|
|
||||||
pushd %run_path%
|
|
||||||
%build%\4ed -T %data_path%\test_load_rome_txt.4id
|
|
||||||
popd
|
|
Loading…
Reference in New Issue