]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/os-macosx.mm
alien.c-types: not necessary to import `short` differently anymore
[factor.git] / vm / os-macosx.mm
index ee96bc2016eb41f4021fa4b843e914a3cfebac7d..71c70f7a489cf505f1a90c4e7c5a317c64a5e83e 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <mach/mach_time.h>
 #include <sys/utsname.h>
+#include <unistd.h>
+#include <stdio.h>
 
 #include "master.hpp"
 
@@ -22,7 +24,7 @@ void early_init(void) {
   }
 }
 
-/* You must free() this yourself. */
+// You must free() this yourself.
 const char* vm_executable_path(void) {
   return safe_strdup([[[NSBundle mainBundle] executablePath] UTF8String]);
 }
@@ -38,12 +40,11 @@ const char* default_image_path(void) {
 
   if ([path hasSuffix:@".app"] || [path hasSuffix:@".app/"]) {
     NSFileManager* mgr = [NSFileManager defaultManager];
+    NSString* root = [path stringByDeletingLastPathComponent];
+    NSString* resources = [path stringByAppendingPathComponent:@"Contents/Resources"];
 
-    NSString* imageInBundle =
-        [[path stringByAppendingPathComponent:@"Contents/Resources"]
-            stringByAppendingPathComponent:image];
-    NSString* imageAlongBundle = [[path stringByDeletingLastPathComponent]
-        stringByAppendingPathComponent:image];
+    NSString* imageInBundle = [resources stringByAppendingPathComponent:image];
+    NSString* imageAlongBundle = [root stringByAppendingPathComponent:image];
 
     returnVal = ([mgr fileExistsAtPath:imageInBundle] ? imageInBundle
                                                       : imageAlongBundle);
@@ -54,6 +55,7 @@ const char* default_image_path(void) {
     returnVal = [returnVal stringByDeletingLastPathComponent];
     returnVal = [returnVal stringByDeletingLastPathComponent];
     returnVal = [returnVal stringByAppendingPathComponent:image];
+
   } else {
     returnVal = [path stringByAppendingPathComponent:image];
   }
@@ -66,7 +68,7 @@ void factor_vm::init_signals(void) {
   mach_initialize();
 }
 
-/* Amateurs at Apple: implement this function, properly! */
+// Amateurs at Apple: implement this function, properly!
 Protocol* objc_getProtocol(char* name) {
   if (strcmp(name, "NSTextInput") == 0)
     return @protocol(NSTextInput);