From 54f5e72aa50e94ffa460324755b538cd422caad0 Mon Sep 17 00:00:00 2001 From: Yuval Dolev Date: Tue, 24 Dec 2019 16:57:05 +0200 Subject: [PATCH] Added a c++ platform layer file. --- platform_mac/mac_4ed.cpp | 1 + platform_mac/mac_4ed.mm | 51 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 platform_mac/mac_4ed.cpp diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp new file mode 100644 index 00000000..a5486f8e --- /dev/null +++ b/platform_mac/mac_4ed.cpp @@ -0,0 +1 @@ +/* Mac C++ layer for 4coder */ \ No newline at end of file diff --git a/platform_mac/mac_4ed.mm b/platform_mac/mac_4ed.mm index 0c7a2c5e..52390586 100644 --- a/platform_mac/mac_4ed.mm +++ b/platform_mac/mac_4ed.mm @@ -1,5 +1,36 @@ +/* Mac Objective C layer for 4coder */ + #include +#define FPS 60 +#define frame_useconds (1000000 / FPS) + +#include "4coder_base_types.h" +#include "4coder_version.h" +#include "4coder_events.h" + +#include "4coder_system_types.h" +#define STATIC_LINK_API +#include "generated/system_api.h" + +#include "generated/system_api.cpp" + +#include "4coder_base_types.cpp" + +//////////////////////////////// + +#define SLASH '\\' +#define DLL "dll" + +#include "4coder_hash_functions.cpp" +#include "4coder_system_allocator.cpp" +#include "4coder_codepoint_map.cpp" + +#include "4ed_mem.cpp" +#include "4ed_font_set.cpp" + +//////////////////////////////// + @interface App_Delegate : NSObject @end @@ -19,7 +50,7 @@ return frame_size; } -- (void)windowWillClose:(id)sender { +- (void)windowWillClose:(id)sender{ // global_running = false; } @end @@ -27,7 +58,7 @@ int main(int arg_count, char **args){ @autoreleasepool{ - // NOTE(yuval): NSApplication & Delegate Creation + // NOTE(yuval): Create NSApplication & Delegate NSApplication* app = [NSApplication sharedApplication]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; @@ -36,7 +67,7 @@ main(int arg_count, char **args){ [NSApp finishLaunching]; -#if 0 + // NOTE(yuval): Context Setup Thread_Context _tctx = {}; thread_ctx_init(&_tctx, ThreadKind_Main, get_base_allocator_system(), @@ -45,11 +76,23 @@ main(int arg_count, char **args){ block_zero_struct(&global_mac_vars); global_mac_vars.tctx = &_tctx; + API_VTable_system system_vtable = {}; + system_api_fill_vtable(&system_vtable); + + API_VTable_graphics graphics_vtable = {}; + graphics_api_fill_vtable(&graphics_vtable); + + API_VTable_font font_vtable = {}; + font_api_fill_vtable(&font_vtable); + + // NOTE(yuval): Memory + global_mac_vars.frame_arena = reserve_arena(global_mac_vars.tctx); + global_target.arean = make_arena_system(KB(256)); + // NOTE(yuval): Application Core Update Application_Step_Result result = {}; if (app.step != 0){ result = app.step(mac_vars.tctx, &target, base_ptr, &input); } -#endif } } \ No newline at end of file