Move '4ed_search_list.h/.cpp' to custom layer; rename to 4coder_*

master
Allen Webster 2020-11-23 20:06:03 -08:00
parent 0eecb215ef
commit 0486e92577
8 changed files with 100 additions and 94 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -37,7 +37,7 @@
#include "4ed_font_set.h" #include "4ed_font_set.h"
#include "4ed_render_target.h" #include "4ed_render_target.h"
#include "4ed_search_list.h" #include "4coder_search_list.h"
#include "4ed.h" #include "4ed.h"
#include "generated/system_api.cpp" #include "generated/system_api.cpp"
@ -58,7 +58,7 @@
#include "4ed_mem.cpp" #include "4ed_mem.cpp"
#include "4ed_font_set.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.h"
#include "4ed_font_provider_freetype.cpp" #include "4ed_font_provider_freetype.cpp"

View File

@ -30,7 +30,7 @@
#include "4ed_font_set.h" #include "4ed_font_set.h"
#include "4ed_render_target.h" #include "4ed_render_target.h"
#include "4ed_search_list.h" #include "4coder_search_list.h"
#include "4ed.h" #include "4ed.h"
#include "generated/system_api.cpp" #include "generated/system_api.cpp"
@ -44,7 +44,7 @@
#include "4coder_table.cpp" #include "4coder_table.cpp"
#include "4coder_log.cpp" #include "4coder_log.cpp"
#include "4ed_search_list.cpp" #include "4coder_search_list.cpp"
#include "mac_objective_c_to_cpp_links.h" #include "mac_objective_c_to_cpp_links.h"

View File

@ -32,7 +32,7 @@
#include "4ed_font_set.h" #include "4ed_font_set.h"
#include "4ed_render_target.h" #include "4ed_render_target.h"
#include "4ed_search_list.h" #include "4coder_search_list.h"
#include "4ed.h" #include "4ed.h"
#include "generated/system_api.cpp" #include "generated/system_api.cpp"
@ -46,7 +46,7 @@
#include "4coder_table.cpp" #include "4coder_table.cpp"
#include "4coder_log.cpp" #include "4coder_log.cpp"
#include "4ed_search_list.cpp" #include "4coder_search_list.cpp"
#undef function #undef function
#define UNICODE #define UNICODE
@ -1690,10 +1690,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
{ {
App_Get_Functions *get_funcs = 0; App_Get_Functions *get_funcs = 0;
Scratch_Block scratch(win32vars.tctx); 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)){ if (system_load_library(scratch, core_path, &core_library)){
get_funcs = (App_Get_Functions*)system_get_proc(core_library, "app_get_functions"); get_funcs = (App_Get_Functions*)system_get_proc(core_library, "app_get_functions");
if (get_funcs != 0){ if (get_funcs != 0){
@ -1747,9 +1748,9 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
Scratch_Block scratch(win32vars.tctx); Scratch_Block scratch(win32vars.tctx);
String_Const_u8 default_file_name = string_u8_litexpr("custom_4coder.dll"); String_Const_u8 default_file_name = string_u8_litexpr("custom_4coder.dll");
Path_Search_List search_list = {}; List_String_Const_u8 search_list = {};
search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory); def_search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory);
search_list_add_system_path(scratch, &search_list, SystemPath_Binary); def_search_list_add_system_path(scratch, &search_list, SystemPath_Binary);
String_Const_u8 custom_file_names[2] = {}; String_Const_u8 custom_file_names[2] = {};
i32 custom_file_count = 1; i32 custom_file_count = 1;
if (plat_settings.custom_dll != 0){ 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 = {}; String_Const_u8 custom_file_name = {};
for (i32 i = 0; i < custom_file_count; i += 1){ 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){ if (custom_file_name.size > 0){
break; break;
} }

View File

@ -4,6 +4,7 @@
+ Added lookup acceleration to code index data + Added lookup acceleration to code index data
+ Added highlighting for functions, types, and macros in code index + Added highlighting for functions, types, and macros in code index
+ Default input is now dispatched through an "implicit map" callback + 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 + Fix: crash when pasting in read only buffer
4.1.6 4.1.6