updated ebiten version from 2.7.9 to 2.9.9
This commit is contained in:
+138
-77
@@ -21,48 +21,62 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
class_NSInvocation = objc.GetClass("NSInvocation")
|
||||
class_NSMethodSignature = objc.GetClass("NSMethodSignature")
|
||||
class_NSAutoreleasePool = objc.GetClass("NSAutoreleasePool")
|
||||
class_NSString = objc.GetClass("NSString")
|
||||
class_NSProcessInfo = objc.GetClass("NSProcessInfo")
|
||||
class_NSColor = objc.GetClass("NSColor")
|
||||
class_NSWindow = objc.GetClass("NSWindow")
|
||||
class_NSView = objc.GetClass("NSView")
|
||||
class_NSScreen = objc.GetClass("NSScreen")
|
||||
class_NSInvocation = objc.GetClass("NSInvocation")
|
||||
class_NSMethodSignature = objc.GetClass("NSMethodSignature")
|
||||
class_NSAutoreleasePool = objc.GetClass("NSAutoreleasePool")
|
||||
class_NSString = objc.GetClass("NSString")
|
||||
class_NSColor = objc.GetClass("NSColor")
|
||||
class_NSScreen = objc.GetClass("NSScreen")
|
||||
class_NSRunLoop = objc.GetClass("NSRunLoop")
|
||||
class_NSMachPort = objc.GetClass("NSMachPort")
|
||||
class_NSWorkspace = objc.GetClass("NSWorkspace")
|
||||
class_NSNotificationCenter = objc.GetClass("NSNotificationCenter")
|
||||
class_NSOperationQueue = objc.GetClass("NSOperationQueue")
|
||||
)
|
||||
|
||||
var (
|
||||
sel_alloc = objc.RegisterName("alloc")
|
||||
sel_new = objc.RegisterName("new")
|
||||
sel_release = objc.RegisterName("release")
|
||||
sel_invocationWithMethodSignature = objc.RegisterName("invocationWithMethodSignature:")
|
||||
sel_setSelector = objc.RegisterName("setSelector:")
|
||||
sel_setTarget = objc.RegisterName("setTarget:")
|
||||
sel_setArgumentAtIndex = objc.RegisterName("setArgument:atIndex:")
|
||||
sel_getReturnValue = objc.RegisterName("getReturnValue:")
|
||||
sel_invoke = objc.RegisterName("invoke")
|
||||
sel_invokeWithTarget = objc.RegisterName("invokeWithTarget:")
|
||||
sel_instanceMethodSignatureForSelector = objc.RegisterName("instanceMethodSignatureForSelector:")
|
||||
sel_signatureWithObjCTypes = objc.RegisterName("signatureWithObjCTypes:")
|
||||
sel_initWithUTF8String = objc.RegisterName("initWithUTF8String:")
|
||||
sel_UTF8String = objc.RegisterName("UTF8String")
|
||||
sel_length = objc.RegisterName("length")
|
||||
sel_processInfo = objc.RegisterName("processInfo")
|
||||
sel_frame = objc.RegisterName("frame")
|
||||
sel_contentView = objc.RegisterName("contentView")
|
||||
sel_setBackgroundColor = objc.RegisterName("setBackgroundColor:")
|
||||
sel_colorWithSRGBRedGreenBlueAlpha = objc.RegisterName("colorWithSRGBRed:green:blue:alpha:")
|
||||
sel_setFrameSize = objc.RegisterName("setFrameSize:")
|
||||
sel_object = objc.RegisterName("object")
|
||||
sel_styleMask = objc.RegisterName("styleMask")
|
||||
sel_setStyleMask = objc.RegisterName("setStyleMask:")
|
||||
sel_mainScreen = objc.RegisterName("mainScreen")
|
||||
sel_screen = objc.RegisterName("screen")
|
||||
sel_isVisible = objc.RegisterName("isVisible")
|
||||
sel_deviceDescription = objc.RegisterName("deviceDescription")
|
||||
sel_objectForKey = objc.RegisterName("objectForKey:")
|
||||
sel_unsignedIntValue = objc.RegisterName("unsignedIntValue")
|
||||
sel_retain = objc.RegisterName("retain")
|
||||
sel_alloc = objc.RegisterName("alloc")
|
||||
sel_new = objc.RegisterName("new")
|
||||
sel_release = objc.RegisterName("release")
|
||||
sel_invocationWithMethodSignature = objc.RegisterName("invocationWithMethodSignature:")
|
||||
sel_setSelector = objc.RegisterName("setSelector:")
|
||||
sel_setTarget = objc.RegisterName("setTarget:")
|
||||
sel_setArgumentAtIndex = objc.RegisterName("setArgument:atIndex:")
|
||||
sel_getReturnValue = objc.RegisterName("getReturnValue:")
|
||||
sel_invoke = objc.RegisterName("invoke")
|
||||
sel_invokeWithTarget = objc.RegisterName("invokeWithTarget:")
|
||||
sel_signatureWithObjCTypes = objc.RegisterName("signatureWithObjCTypes:")
|
||||
sel_initWithUTF8String = objc.RegisterName("initWithUTF8String:")
|
||||
sel_UTF8String = objc.RegisterName("UTF8String")
|
||||
sel_length = objc.RegisterName("length")
|
||||
sel_frame = objc.RegisterName("frame")
|
||||
sel_contentView = objc.RegisterName("contentView")
|
||||
sel_setBackgroundColor = objc.RegisterName("setBackgroundColor:")
|
||||
sel_colorWithSRGBRedGreenBlueAlpha = objc.RegisterName("colorWithSRGBRed:green:blue:alpha:")
|
||||
sel_setFrameSize = objc.RegisterName("setFrameSize:")
|
||||
sel_object = objc.RegisterName("object")
|
||||
sel_styleMask = objc.RegisterName("styleMask")
|
||||
sel_setStyleMask = objc.RegisterName("setStyleMask:")
|
||||
sel_mainScreen = objc.RegisterName("mainScreen")
|
||||
sel_screen = objc.RegisterName("screen")
|
||||
sel_isVisible = objc.RegisterName("isVisible")
|
||||
sel_deviceDescription = objc.RegisterName("deviceDescription")
|
||||
sel_objectForKey = objc.RegisterName("objectForKey:")
|
||||
sel_unsignedIntValue = objc.RegisterName("unsignedIntValue")
|
||||
sel_setLayer = objc.RegisterName("setLayer:")
|
||||
sel_setWantsLayer = objc.RegisterName("setWantsLayer:")
|
||||
sel_mainRunLoop = objc.RegisterName("mainRunLoop")
|
||||
sel_currentRunLoop = objc.RegisterName("currentRunLoop")
|
||||
sel_run = objc.RegisterName("run")
|
||||
sel_performBlock = objc.RegisterName("performBlock:")
|
||||
sel_port = objc.RegisterName("port")
|
||||
sel_addPort = objc.RegisterName("addPort:forMode:")
|
||||
sel_sharedWorkspace = objc.RegisterName("sharedWorkspace")
|
||||
sel_notificationCenter = objc.RegisterName("notificationCenter")
|
||||
sel_addObserver = objc.RegisterName("addObserver:selector:name:object:")
|
||||
sel_addObserverForName = objc.RegisterName("addObserverForName:object:queue:usingBlock:")
|
||||
sel_mainQueue = objc.RegisterName("mainQueue")
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -98,6 +112,14 @@ type NSPoint = CGPoint
|
||||
type NSRect = CGRect
|
||||
type NSSize = CGSize
|
||||
|
||||
type NSObject struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func (n NSObject) Retain() {
|
||||
n.Send(sel_retain)
|
||||
}
|
||||
|
||||
type NSError struct {
|
||||
objc.ID
|
||||
}
|
||||
@@ -110,18 +132,6 @@ func NSColor_colorWithSRGBRedGreenBlueAlpha(red, green, blue, alpha CGFloat) (co
|
||||
return NSColor{objc.ID(class_NSColor).Send(sel_colorWithSRGBRedGreenBlueAlpha, red, green, blue, alpha)}
|
||||
}
|
||||
|
||||
type NSOperatingSystemVersion struct {
|
||||
Major, Minor, Patch NSInteger
|
||||
}
|
||||
|
||||
type NSProcessInfo struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func NSProcessInfo_processInfo() NSProcessInfo {
|
||||
return NSProcessInfo{objc.ID(class_NSProcessInfo).Send(sel_processInfo)}
|
||||
}
|
||||
|
||||
type NSWindow struct {
|
||||
objc.ID
|
||||
}
|
||||
@@ -147,14 +157,7 @@ func (w NSWindow) Screen() NSScreen {
|
||||
}
|
||||
|
||||
func (w NSWindow) Frame() NSRect {
|
||||
sig := NSMethodSignature_instanceMethodSignatureForSelector(objc.ID(class_NSWindow), sel_frame)
|
||||
inv := NSInvocation_invocationWithMethodSignature(sig)
|
||||
inv.SetTarget(w.ID)
|
||||
inv.SetSelector(sel_frame)
|
||||
inv.Invoke()
|
||||
var rect NSRect
|
||||
inv.GetReturnValue(unsafe.Pointer(&rect))
|
||||
return rect
|
||||
return objc.Send[NSRect](w.ID, sel_frame)
|
||||
}
|
||||
|
||||
func (w NSWindow) ContentView() NSView {
|
||||
@@ -166,29 +169,19 @@ type NSView struct {
|
||||
}
|
||||
|
||||
func (v NSView) SetFrameSize(size CGSize) {
|
||||
sig := NSMethodSignature_instanceMethodSignatureForSelector(objc.ID(class_NSView), sel_setFrameSize)
|
||||
inv := NSInvocation_invocationWithMethodSignature(sig)
|
||||
inv.SetSelector(sel_setFrameSize)
|
||||
inv.SetArgumentAtIndex(unsafe.Pointer(&size), 2)
|
||||
inv.InvokeWithTarget(v.ID)
|
||||
v.ID.Send(sel_setFrameSize, size)
|
||||
}
|
||||
|
||||
func (v NSView) Frame() NSRect {
|
||||
sig := NSMethodSignature_instanceMethodSignatureForSelector(objc.ID(class_NSView), sel_frame)
|
||||
inv := NSInvocation_invocationWithMethodSignature(sig)
|
||||
inv.SetSelector(sel_frame)
|
||||
inv.InvokeWithTarget(v.ID)
|
||||
var rect NSRect
|
||||
inv.GetReturnValue(unsafe.Pointer(&rect))
|
||||
return rect
|
||||
return objc.Send[NSRect](v.ID, sel_frame)
|
||||
}
|
||||
|
||||
func (v NSView) SetLayer(layer uintptr) {
|
||||
v.Send(objc.RegisterName("setLayer:"), layer)
|
||||
v.Send(sel_setLayer, layer)
|
||||
}
|
||||
|
||||
func (v NSView) SetWantsLayer(wantsLayer bool) {
|
||||
v.Send(objc.RegisterName("setWantsLayer:"), wantsLayer)
|
||||
v.Send(sel_setWantsLayer, wantsLayer)
|
||||
}
|
||||
|
||||
// NSInvocation is being used to call functions that can't be called directly with purego.SyscallN.
|
||||
@@ -229,10 +222,6 @@ type NSMethodSignature struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func NSMethodSignature_instanceMethodSignatureForSelector(self objc.ID, cmd objc.SEL) NSMethodSignature {
|
||||
return NSMethodSignature{self.Send(sel_instanceMethodSignatureForSelector, cmd)}
|
||||
}
|
||||
|
||||
// NSMethodSignature_signatureWithObjCTypes takes a string that represents the type signature of a method.
|
||||
// It follows the encoding specified in the Apple Docs.
|
||||
//
|
||||
@@ -304,3 +293,75 @@ type NSNumber struct {
|
||||
func (n NSNumber) UnsignedIntValue() uint {
|
||||
return uint(n.Send(sel_unsignedIntValue))
|
||||
}
|
||||
|
||||
type NSRunLoop struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func NSRunLoop_mainRunLoop() NSRunLoop {
|
||||
return NSRunLoop{objc.ID(class_NSRunLoop).Send(sel_mainRunLoop)}
|
||||
}
|
||||
|
||||
func NSRunLoop_currentRunLoop() NSRunLoop {
|
||||
return NSRunLoop{objc.ID(class_NSRunLoop).Send(sel_currentRunLoop)}
|
||||
}
|
||||
|
||||
func (r NSRunLoop) AddPort(port NSMachPort, mode NSRunLoopMode) {
|
||||
r.Send(sel_addPort, port.ID, mode)
|
||||
}
|
||||
|
||||
func (r NSRunLoop) Run() {
|
||||
r.Send(sel_run)
|
||||
}
|
||||
|
||||
func (r NSRunLoop) PerformBlock(block objc.Block) {
|
||||
r.Send(sel_performBlock, block)
|
||||
}
|
||||
|
||||
type NSRunLoopMode NSString
|
||||
|
||||
var (
|
||||
NSRunLoopCommonModes = NSRunLoopMode(NSString_alloc().InitWithUTF8String("kCFRunLoopCommonModes"))
|
||||
NSDefaultRunLoopMode = NSRunLoopMode(NSString_alloc().InitWithUTF8String("kCFRunLoopDefaultMode"))
|
||||
)
|
||||
|
||||
type NSMachPort struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func NSMachPort_port() NSMachPort {
|
||||
return NSMachPort{objc.ID(class_NSMachPort).Send(sel_port)}
|
||||
}
|
||||
|
||||
type NSWorkspace struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func NSWorkspace_sharedWorkspace() NSWorkspace {
|
||||
return NSWorkspace{objc.ID(class_NSWorkspace).Send(sel_sharedWorkspace)}
|
||||
}
|
||||
|
||||
func (w NSWorkspace) NotificationCenter() NSNotificationCenter {
|
||||
return NSNotificationCenter{w.Send(sel_notificationCenter)}
|
||||
}
|
||||
|
||||
var (
|
||||
NSWorkspaceDidWakeNotification = NSString_alloc().InitWithUTF8String("NSWorkspaceDidWakeNotification")
|
||||
NSWorkspaceScreensDidWakeNotification = NSString_alloc().InitWithUTF8String("NSWorkspaceScreensDidWakeNotification")
|
||||
)
|
||||
|
||||
type NSNotificationCenter struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func (n NSNotificationCenter) AddObserverForName(name NSString, object objc.ID, queue NSOperationQueue, usingBlock objc.Block) objc.ID {
|
||||
return n.Send(sel_addObserverForName, name.ID, object, queue.ID, usingBlock)
|
||||
}
|
||||
|
||||
type NSOperationQueue struct {
|
||||
objc.ID
|
||||
}
|
||||
|
||||
func NSOperationQueue_mainQueue() NSOperationQueue {
|
||||
return NSOperationQueue{objc.ID(class_NSOperationQueue).Send(sel_mainQueue)}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user