From 0486e92577b85a46eb563cf4e9d0e38f687413a8 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 23 Nov 2020 20:06:03 -0800 Subject: [PATCH] Move '4ed_search_list.h/.cpp' to custom layer; rename to 4coder_* --- 4ed_search_list.cpp | 58 ---------------------------------- 4ed_search_list.h | 23 -------------- custom/4coder_search_list.cpp | 59 +++++++++++++++++++++++++++++++++++ custom/4coder_search_list.h | 26 +++++++++++++++ platform_linux/linux_4ed.cpp | 4 +-- platform_mac/mac_4ed.mm | 4 +-- platform_win32/win32_4ed.cpp | 19 +++++------ ship_files/changes.txt | 1 + 8 files changed, 100 insertions(+), 94 deletions(-) delete mode 100644 4ed_search_list.cpp delete mode 100644 4ed_search_list.h create mode 100644 custom/4coder_search_list.cpp create mode 100644 custom/4coder_search_list.h diff --git a/4ed_search_list.cpp b/4ed_search_list.cpp deleted file mode 100644 index 9eecc551..00000000 --- a/4ed_search_list.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 01.10.2019 - * - * Search list helper. - * - */ - -// TOP - -function void -search_list_add_path__inner(Arena *arena, Path_Search_List *list, String_Const_u8 path){ - string_list_push(arena, &list->list, path); - list->max_member_length = Max(list->max_member_length, path.size); -} - -function void -search_list_add_path(Arena *arena, Path_Search_List *list, String_Const_u8 path){ - search_list_add_path__inner(arena, list, push_string_copy(arena, path)); -} - -function void -search_list_add_system_path(Arena *arena, Path_Search_List *list, System_Path_Code path){ - search_list_add_path__inner(arena, list, system_get_path(arena, path)); -} - -function String_Const_u8 -get_full_path(Arena *arena, Path_Search_List *search_list, String_Const_u8 relative){ - String_Const_u8 result = {}; - Temp_Memory restore_point = begin_temp(arena); - u64 buffer_cap = search_list->max_member_length + relative.size + 1; - u8 *buffer = push_array(arena, u8, buffer_cap); - u8 *opl = buffer + buffer_cap; - u8 *relative_base = opl - 1 - relative.size; - block_copy(relative_base, relative.str, relative.size); - relative_base[relative.size] = 0; - for (Node_String_Const_u8 *node = search_list->list.first; - node != 0; - node = node->next){ - u64 node_size = node->string.size; - u8 *path_base = relative_base - node_size; - block_copy(path_base, node->string.str, node_size); - String_Const_u8 name = SCu8(path_base, opl); - File_Attributes attribs = system_quick_file_attributes(arena, name); - if (attribs.size > 0){ - result = name; - break; - } - } - if (result.size == 0){ - end_temp(restore_point); - } - return(result); -} - -// BOTTOM - diff --git a/4ed_search_list.h b/4ed_search_list.h deleted file mode 100644 index ab10fc76..00000000 --- a/4ed_search_list.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 01.10.2019 - * - * Search list helper. - * - */ - -// TOP - -#if !defined(FRED_SEARCH_LIST_H) -#define FRED_SEARCH_LIST_H - -struct Path_Search_List{ - List_String_Const_u8 list; - u64 max_member_length; -}; - -#endif - -// BOTTOM - diff --git a/custom/4coder_search_list.cpp b/custom/4coder_search_list.cpp new file mode 100644 index 00000000..63b3e3e7 --- /dev/null +++ b/custom/4coder_search_list.cpp @@ -0,0 +1,59 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 01.10.2019 + * + * Search list helper. + * + */ + +// TOP + +//////////////////////////////// +// NOTE(allen): Search List Functions + +function void +def_search_list_add_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 path){ + String_Const_u8 path_copy = push_string_copy(arena, path); + string_list_push(arena, list, path_copy); +} + +function void +def_search_list_add_system_path(Arena *arena, List_String_Const_u8 *list, System_Path_Code path){ + String_Const_u8 path_string = system_get_path(arena, path); + string_list_push(arena, list, path_string); +} + +function String_Const_u8 +def_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 relative){ + String_Const_u8 result = {}; + + Temp_Memory temp = begin_temp(arena); + + u8 slash = '/'; + + for (Node_String_Const_u8 *node = list->first; + node != 0; + node = node->next){ + String_Const_u8 full_name = {}; + full_name.size = node->string.size + 1 + relative.size; + full_name.str = push_array(arena, u8, full_name.size + 1); + block_copy(full_name.str, node->string.str, node->string.size); + full_name.str[node->string.size] = slash; + block_copy(full_name.str + node->string.size + 1, relative.str, relative.size); + full_name.str[full_name.size] = 0; + + File_Attributes attribs = system_quick_file_attributes(arena, full_name); + if (attribs.last_write_time > 0){ + result = full_name; + break; + } + + end_temp(temp); + } + + return(result); +} + +// BOTTOM + diff --git a/custom/4coder_search_list.h b/custom/4coder_search_list.h new file mode 100644 index 00000000..eb5b782d --- /dev/null +++ b/custom/4coder_search_list.h @@ -0,0 +1,26 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 01.10.2019 + * + * Search list helper. + * + */ + +// TOP + +#if !defined(FRED_SEARCH_LIST_H) +#define FRED_SEARCH_LIST_H + +//////////////////////////////// +// NOTE(allen): Search List Functions + +function void def_search_list_add_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 path); +function void def_search_list_add_system_path(Arena *arena, List_String_Const_u8 *list, System_Path_Code path); + +function String_Const_u8 def_get_full_path(Arena *arena, List_String_Const_u8 *list, String_Const_u8 file_name); + +#endif + +// BOTTOM + diff --git a/platform_linux/linux_4ed.cpp b/platform_linux/linux_4ed.cpp index efea98a6..c404709f 100644 --- a/platform_linux/linux_4ed.cpp +++ b/platform_linux/linux_4ed.cpp @@ -37,7 +37,7 @@ #include "4ed_font_set.h" #include "4ed_render_target.h" -#include "4ed_search_list.h" +#include "4coder_search_list.h" #include "4ed.h" #include "generated/system_api.cpp" @@ -58,7 +58,7 @@ #include "4ed_mem.cpp" #include "4ed_font_set.cpp" -#include "4ed_search_list.cpp" +#include "4coder_search_list.cpp" #include "4ed_font_provider_freetype.h" #include "4ed_font_provider_freetype.cpp" diff --git a/platform_mac/mac_4ed.mm b/platform_mac/mac_4ed.mm index b9f4d93c..7c5cc54c 100644 --- a/platform_mac/mac_4ed.mm +++ b/platform_mac/mac_4ed.mm @@ -30,7 +30,7 @@ #include "4ed_font_set.h" #include "4ed_render_target.h" -#include "4ed_search_list.h" +#include "4coder_search_list.h" #include "4ed.h" #include "generated/system_api.cpp" @@ -44,7 +44,7 @@ #include "4coder_table.cpp" #include "4coder_log.cpp" -#include "4ed_search_list.cpp" +#include "4coder_search_list.cpp" #include "mac_objective_c_to_cpp_links.h" diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index cbfa1c28..52c90a4d 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -32,7 +32,7 @@ #include "4ed_font_set.h" #include "4ed_render_target.h" -#include "4ed_search_list.h" +#include "4coder_search_list.h" #include "4ed.h" #include "generated/system_api.cpp" @@ -46,7 +46,7 @@ #include "4coder_table.cpp" #include "4coder_log.cpp" -#include "4ed_search_list.cpp" +#include "4coder_search_list.cpp" #undef function #define UNICODE @@ -1690,10 +1690,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS { App_Get_Functions *get_funcs = 0; Scratch_Block scratch(win32vars.tctx); - Path_Search_List search_list = {}; - search_list_add_system_path(scratch, &search_list, SystemPath_Binary); - String_Const_u8 core_path = get_full_path(scratch, &search_list, SCu8("4ed_app.dll")); + List_String_Const_u8 search_list = {}; + def_search_list_add_system_path(scratch, &search_list, SystemPath_Binary); + + String_Const_u8 core_path = def_get_full_path(scratch, &search_list, SCu8("4ed_app.dll")); if (system_load_library(scratch, core_path, &core_library)){ get_funcs = (App_Get_Functions*)system_get_proc(core_library, "app_get_functions"); if (get_funcs != 0){ @@ -1747,9 +1748,9 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS Scratch_Block scratch(win32vars.tctx); String_Const_u8 default_file_name = string_u8_litexpr("custom_4coder.dll"); - Path_Search_List search_list = {}; - search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory); - search_list_add_system_path(scratch, &search_list, SystemPath_Binary); + List_String_Const_u8 search_list = {}; + def_search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory); + def_search_list_add_system_path(scratch, &search_list, SystemPath_Binary); String_Const_u8 custom_file_names[2] = {}; i32 custom_file_count = 1; if (plat_settings.custom_dll != 0){ @@ -1764,7 +1765,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS } String_Const_u8 custom_file_name = {}; for (i32 i = 0; i < custom_file_count; i += 1){ - custom_file_name = get_full_path(scratch, &search_list, custom_file_names[i]); + custom_file_name = def_get_full_path(scratch, &search_list, custom_file_names[i]); if (custom_file_name.size > 0){ break; } diff --git a/ship_files/changes.txt b/ship_files/changes.txt index ea04f84f..c5b92079 100644 --- a/ship_files/changes.txt +++ b/ship_files/changes.txt @@ -4,6 +4,7 @@ + Added lookup acceleration to code index data + Added highlighting for functions, types, and macros in code index + Default input is now dispatched through an "implicit map" callback + + Audio system API and default audio mixer with examples in 4coder_examples.cpp + Fix: crash when pasting in read only buffer 4.1.6