Added a c++ platform layer file.

master
Yuval Dolev 2019-12-24 16:57:05 +02:00
parent 18dd91197f
commit 54f5e72aa5
2 changed files with 48 additions and 4 deletions

1
platform_mac/mac_4ed.cpp Normal file
View File

@ -0,0 +1 @@
/* Mac C++ layer for 4coder */

View File

@ -1,5 +1,36 @@
/* Mac Objective C layer for 4coder */
#include <Cocoa/Cocoa.h>
#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<NSApplicationDelegate, NSWindowDelegate>
@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
}
}