Removes the objective C file, replacing it with the C api.
This commit is contained in:
parent
eb79381c89
commit
4c52b1dea4
|
@ -1,20 +0,0 @@
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#include "lua.h"
|
|
||||||
|
|
||||||
#ifdef MACOS_USE_BUNDLE
|
|
||||||
void set_macos_bundle_resources(lua_State *L)
|
|
||||||
{ @autoreleasepool
|
|
||||||
{
|
|
||||||
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
|
|
||||||
lua_pushstring(L, [resource_path UTF8String]);
|
|
||||||
lua_setglobal(L, "MACOS_RESOURCES");
|
|
||||||
}}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Thanks to mathewmariani, taken from his lite-macos github repository. */
|
|
||||||
void enable_momentum_scroll() {
|
|
||||||
[[NSUserDefaults standardUserDefaults]
|
|
||||||
setBool: YES
|
|
||||||
forKey: @"AppleMomentumScrollSupported"];
|
|
||||||
}
|
|
||||||
|
|
21
src/main.c
21
src/main.c
|
@ -12,6 +12,9 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <objc/runtime.h>
|
||||||
|
#include <objc/message.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,10 +80,20 @@ static void init_window_icon(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
void enable_momentum_scroll();
|
static void enable_momentum_scroll() {
|
||||||
#ifdef MACOS_USE_BUNDLE
|
void* standardUserDefaults = objc_msgSend(objc_getClass("NSUserDefaults"), NSSelectorFromString(CFSTR("standardUserDefaults")));
|
||||||
void set_macos_bundle_resources(lua_State *L);
|
objc_msgSend(standardUserDefaults, "setBool", true, CFSTR("AppleMomentumScrollSupported"));
|
||||||
#endif
|
}
|
||||||
|
#ifdef MACOS_USE_BUNDLE
|
||||||
|
static void set_macos_bundle_resources(lua_State *L) {
|
||||||
|
id autoreleasePool = objc_msgSend(objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_registerName("alloc")), sel_registerName("init"));
|
||||||
|
void* obj = objc_msgSend(objc_getClass("NSBundle"), NSSelectorFromString(CFSTR("mainBundle")));
|
||||||
|
const char* utf8string = objc_msgSend(objc_msgSend(obj, NSSelectorFromString(CFSTR("resourcePath"))), NSSelectorFromString(CFSTR("UTF8String")));
|
||||||
|
lua_pushstring(L, utf8string);
|
||||||
|
lua_setglobal(L, "MACOS_RESOURCES");
|
||||||
|
objc_msgSend(autoreleasePool, sel_registerName("drain"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
Loading…
Reference in New Issue