From 2f9a4dbe3a6121a4015c19c4370cca05017f1827 Mon Sep 17 00:00:00 2001 From: Yuval Dolev Date: Thu, 26 Dec 2019 00:19:50 +0200 Subject: [PATCH] Fixed compilation errors and tested system_get_canonical. --- platform_mac/mac_4ed.cpp | 15 ++++++++++++++- platform_mac/mac_4ed.mm | 14 +++++--------- platform_mac/mac_objective_c_to_cpp_links.h | 13 +++++++++++-- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index ec82755a..7b66f04d 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -48,6 +48,7 @@ #include "4coder_hash_functions.cpp" #include "4coder_system_allocator.cpp" +#include "4coder_malloc_allocator.cpp" #include "4coder_codepoint_map.cpp" #include "4ed_mem.cpp" @@ -74,8 +75,20 @@ global Render_Target target; //////////////////////////////// +external String_Const_u8 +mac_SCu8(u8* str, u64 size){ + String_Const_u8 result = SCu8(str, size); + return(result); +} + +external String_Const_u8 +mac_push_string_copy(Arena *arena, String_Const_u8 src){ + String_Const_u8 result = push_string_copy(arena, src); + return(result); +} + external void -mac_init() { +mac_init(){ // NOTE(yuval): Context Setup Thread_Context _tctx = {}; thread_ctx_init(&_tctx, ThreadKind_Main, diff --git a/platform_mac/mac_4ed.mm b/platform_mac/mac_4ed.mm index d3c4f601..a39fe56e 100644 --- a/platform_mac/mac_4ed.mm +++ b/platform_mac/mac_4ed.mm @@ -47,13 +47,13 @@ mac_standardize_path(Arena* arena, String_Const_u8 path){ [[NSString alloc] initWithBytes:path.data length:path.size encoding:NSUTF8StringEncoding]; NSString *standardized_path_ns_str = [path_ns_str stringByStandardizingPath]; - String_Const_u8 standardized_path = SCu8([standardized_path_ns_str UTF8String],[standardized_path_ns_str lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); + String_Const_u8 standardized_path = mac_SCu8((u8*)[standardized_path_ns_str UTF8String],[standardized_path_ns_str lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - String_Const_u8 result = push_string_copy(arena, standardized_path); + String_Const_u8 result = mac_push_string_copy(arena, standardized_path); - [path release]; + [path_ns_str release]; - return result; + return(result); } external i32 @@ -61,16 +61,12 @@ mac_get_binary_path(void *buffer, u32 size){ pid_t pid = getpid(); i32 bytes_read = proc_pidpath(pid, buffer, size); - return bytes_read; + return(bytes_read); } int main(int arg_count, char **args){ @autoreleasepool{ - NSFileManager *fileManager = [[NSFileManager alloc] init]; - NSString *displayNameAtPath = [fileManager displayNameAtPath:@"build"]; - NSLog(@"Display Name: %@", displayNameAtPath); - // NOTE(yuval): Create NSApplication & Delegate NSApplication* app = [NSApplication sharedApplication]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; diff --git a/platform_mac/mac_objective_c_to_cpp_links.h b/platform_mac/mac_objective_c_to_cpp_links.h index 0dc4ae3a..c5f4db62 100644 --- a/platform_mac/mac_objective_c_to_cpp_links.h +++ b/platform_mac/mac_objective_c_to_cpp_links.h @@ -3,13 +3,22 @@ #if !defined(MAC_OBJECTIVE_C_TO_CPP_LINKS_H) #define MAC_OBJECTIVE_C_TO_CPP_LINKS_H -// In C++ layer. +// In C++ layer +external String_Const_u8 +mac_SCu8(u8* str, u64 size); + +external String_Const_u8 +mac_push_string_copy(Arena *arena, String_Const_u8 src); + external void mac_init(); -// In Objective-C layer. +// In Objective-C layer external i32 mac_get_binary_path(void* buffer, u32 size); +external String_Const_u8 +mac_standardize_path(Arena* arena, String_Const_u8 path); + #endif