cocoa-cb: move the GL dummy function to swift

it's possible to get a function pointer through a closure after all in
swift. remove the GL dummy function from the c header and do it in the
swift code instead.
This commit is contained in:
Akemi 2018-02-28 14:58:31 +01:00
parent bd410f897b
commit 5cbcf80d35
2 changed files with 3 additions and 6 deletions

View File

@ -19,6 +19,8 @@ import Cocoa
import OpenGL.GL
import OpenGL.GL3
let glDummy: @convention(c) () -> Void = {}
class MPVHelper: NSObject {
var mpvHandle: OpaquePointer?
@ -72,7 +74,7 @@ class MPVHelper: NSObject {
let addr = CFBundleGetFunctionPointerForName(indentifier, symbol)
if symbol as String == "glFlush" {
return glDummyPtr()
return unsafeBitCast(glDummy, to: UnsafeMutableRawPointer.self)
}
return addr

View File

@ -47,8 +47,3 @@ static int SWIFT_KEY_MOUSE_LEAVE = MP_KEY_MOUSE_LEAVE;
static int SWIFT_KEY_MOUSE_ENTER = MP_KEY_MOUSE_ENTER;
static int SWIFT_KEY_STATE_DOWN = MP_KEY_STATE_DOWN;
static int SWIFT_KEY_STATE_UP = MP_KEY_STATE_UP;
// dummy function to override glFlush()
static void glDummy() {}
static void *glDummyPtr(void) __attribute__((unused));
static void *glDummyPtr() { return &glDummy; }