From 894479bfcaa12a41a006bf00227397479e3f0d65 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 26 Sep 2017 11:44:13 -0400 Subject: [PATCH] mostly wrapped up the mac init function, need to link free type properly, left lots of unimplemented stubs to work on --- platform_mac/mac_4ed.cpp | 35 ++++++++++-- platform_mac/mac_4ed.m | 2 + platform_mac/mac_4ed_file_track.cpp | 63 +++++++++++++++++++++ platform_mac/osx_objective_c_to_cpp_links.h | 3 + 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 platform_mac/mac_4ed_file_track.cpp diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index 8acb2416..040401c8 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -109,7 +109,6 @@ system_schedule_step(){ //////////////////////////////// -// TODO(allen): add a "shown but auto-hides on timer" setting here. internal Sys_Show_Mouse_Cursor_Sig(system_show_mouse_cursor){ // TODO(allen) @@ -241,7 +240,6 @@ osx_init(){ // Memory init // - memset(&osx, 0, sizeof(osx)); memset(&target, 0, sizeof(target)); memset(&memory_vars, 0, sizeof(memory_vars)); memset(&plat_settings, 0, sizeof(plat_settings)); @@ -275,7 +273,7 @@ osx_init(){ // Read command line // - read_command_line(argc, argv); + read_command_line(osx.argc, osx.argv); // // Threads @@ -289,8 +287,37 @@ osx_init(){ coroutines_init(); - // TODO + // + // Font System Init + // + + system_font_init(&sysfunc.font, 0, 0, plat_settings.font_size, plat_settings.use_hinting); + + // + // App Init + // + + char cwd[4096]; + u32 size = sysfunc.get_current_path(cwd, sizeof(cwd)); + if (size == 0 || size >= sizeof(cwd)){ + system_error_box("Could not get current directory at launch."); + } + String curdir = make_string(cwd, size); + terminate_with_null(&curdir); + replace_char(&curdir, '\\', '/'); + + String clipboard_string = {0}; + if (osx.has_clipboard_item){ + clipboard_string = make_string(osx.clipboard_data, osx.clipboard_size); + } + + LOG("Initializing application variables\n"); + app.init(&sysfunc, &target, &memory_vars, clipboard_string, curdir, custom_api); } +#include "4ed_shared_fonts.cpp" +#include "mac_4ed_file_track.cpp" +#include "4ed_font_static_functions.cpp" + // BOTTOM diff --git a/platform_mac/mac_4ed.m b/platform_mac/mac_4ed.m index b9f9158b..7b0540fc 100644 --- a/platform_mac/mac_4ed.m +++ b/platform_mac/mac_4ed.m @@ -291,6 +291,8 @@ main(int argc, char **argv){ umem clipboard_size = MB(4); osx.clipboard_data = osx_allocate(clipboard_size); osx.clipboard_max = clipboard_size; + osx.argc = argc; + osx.argv = argv; osx_init(); diff --git a/platform_mac/mac_4ed_file_track.cpp b/platform_mac/mac_4ed_file_track.cpp new file mode 100644 index 00000000..cbf3ba4e --- /dev/null +++ b/platform_mac/mac_4ed_file_track.cpp @@ -0,0 +1,63 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 28.06.2017 + * + * Mac file tracking C++ wrapper. + * + */ + +// TOP + + +File_Track_Result +init_track_system(File_Track_System *system, Partition *scratch, void *table_memory, i32 table_memory_size, void *listener_memory, i32 listener_memory_size){ + File_Track_Result result = FileTrack_Good; + NotImplemented; + return(result); +} + +File_Track_Result +add_listener(File_Track_System *system, Partition *scratch, u8 *filename){ + File_Track_Result result = FileTrack_Good; + NotImplemented; + return(result); +} + +File_Track_Result +remove_listener(File_Track_System *system, Partition *scratch, u8 *filename){ + File_Track_Result result = FileTrack_Good; + NotImplemented; + return(result); +} + +File_Track_Result +move_track_system(File_Track_System *system, Partition *scratch, void *mem, i32 size){ + File_Track_Result result = FileTrack_Good; + NotImplemented; + return(result); +} + +File_Track_Result +expand_track_system_listeners(File_Track_System *system, Partition *scratch, void *mem, i32 size){ + File_Track_Result result = FileTrack_Good; + NotImplemented; + return(result); +} + +File_Track_Result +get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, i32 max, i32 *size){ + File_Track_Result result = FileTrack_Good; + NotImplemented; + return(result); +} + +File_Track_Result +shut_down_track_system(File_Track_System *system, Partition *scratch){ + File_Track_Result result = FileTrack_Good; + NotImplemented; + return(result); +} + +// BOTTOM + diff --git a/platform_mac/osx_objective_c_to_cpp_links.h b/platform_mac/osx_objective_c_to_cpp_links.h index eb00b9d8..25d5f994 100644 --- a/platform_mac/osx_objective_c_to_cpp_links.h +++ b/platform_mac/osx_objective_c_to_cpp_links.h @@ -42,6 +42,9 @@ typedef struct OSX_Vars{ b32 full_screen; b32 do_toggle; + + i32 argc; + char **argv; } OSX_Vars; // In C++ layer.