mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-04 09:44:40 +00:00
Merge pull request #6035 from janga-perlind/darwin-bindings
More bindings for darwin
This commit is contained in:
@@ -1,21 +1,9 @@
|
||||
package objc_Foundation
|
||||
|
||||
foreign import "system:Foundation.framework"
|
||||
|
||||
import "base:intrinsics"
|
||||
import "base:runtime"
|
||||
import "core:strings"
|
||||
|
||||
RunLoopMode :: ^String
|
||||
|
||||
@(link_prefix="NS")
|
||||
foreign Foundation {
|
||||
RunLoopCommonModes: RunLoopMode
|
||||
DefaultRunLoopMode: RunLoopMode
|
||||
EventTrackingRunLoopMode: RunLoopMode
|
||||
ModalPanelRunLoopMode: RunLoopMode
|
||||
}
|
||||
|
||||
ActivationPolicy :: enum UInteger {
|
||||
Regular = 0,
|
||||
Accessory = 1,
|
||||
@@ -206,6 +194,13 @@ Application_updateWindows :: proc "c" (self: ^Application) {
|
||||
msgSend(nil, self, "updateWindows")
|
||||
}
|
||||
|
||||
@(objc_type=Application, objc_name="sendAction")
|
||||
Application_sendAction :: proc "c" (self: ^Application, action: SEL, to: id, from: id) {
|
||||
msgSend(nil, self, "sendAction:to:from:", action, to, from)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@(objc_class="NSRunningApplication")
|
||||
RunningApplication :: struct {using _: Object}
|
||||
|
||||
26
core/sys/darwin/Foundation/NSCursor.odin
Normal file
26
core/sys/darwin/Foundation/NSCursor.odin
Normal file
@@ -0,0 +1,26 @@
|
||||
package objc_Foundation
|
||||
|
||||
@(objc_class="NSCursor")
|
||||
Cursor :: struct {using _: Object}
|
||||
|
||||
@(objc_type=Cursor, objc_name="set")
|
||||
Cursor_set :: proc(self: ^Cursor) {
|
||||
msgSend(EventType, self, "set")
|
||||
}
|
||||
@(objc_type=Cursor, objc_name="currentCursor", objc_is_class_method=true)
|
||||
Cursor_currentCursor :: proc "c" () -> ^Cursor {
|
||||
return msgSend(^Cursor, Cursor, "currentCursor")
|
||||
}
|
||||
@(objc_type=Cursor, objc_name="IBeamCursor", objc_is_class_method=true)
|
||||
Cursor_IBeamCursor :: proc "c" () -> ^Cursor {
|
||||
return msgSend(^Cursor, Cursor, "IBeamCursor")
|
||||
}
|
||||
@(objc_type=Cursor, objc_name="arrowCursor", objc_is_class_method=true)
|
||||
Cursor_arrowCursor :: proc "c" () -> ^Cursor {
|
||||
return msgSend(^Cursor, Cursor, "arrowCursor")
|
||||
}
|
||||
@(objc_type=Cursor, objc_name="pointingHandCursor", objc_is_class_method=true)
|
||||
Cursor_pointingHandCursor :: proc "c" () -> ^Cursor {
|
||||
return msgSend(^Cursor, Cursor, "pointingHandCursor")
|
||||
}
|
||||
|
||||
@@ -334,6 +334,11 @@ Event_locationInWindow :: proc "c" (self: ^Event) -> Point {
|
||||
return msgSend(Point, self, "locationInWindow")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="mouseLocation", objc_is_class_method=true)
|
||||
Event_mouseLocation :: proc "c" () -> Point {
|
||||
return msgSend(Point, Event, "mouseLocation")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="deltaX")
|
||||
Event_deltaX :: proc "c" (self: ^Event) -> Float {
|
||||
|
||||
@@ -81,6 +81,12 @@ debugDescription :: proc "c" (self: ^Object) -> ^String {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Object, objc_name="performSelectorOnMainThread")
|
||||
performSelectorOnMainThread :: proc "c" (self: ^Object, aSelector: SEL, arg: id, wait: BOOL) {
|
||||
msgSend(^String, self, "performSelectorOnMainThread:withObject:waitUntilDone:", aSelector, arg, wait)
|
||||
}
|
||||
|
||||
bridgingCast :: proc "c" ($T: typeid, obj: ^Object) where intrinsics.type_is_pointer(T), intrinsics.type_is_subtype_of(T, ^Object) {
|
||||
return (T)(obj)
|
||||
}
|
||||
@@ -88,4 +94,4 @@ bridgingCast :: proc "c" ($T: typeid, obj: ^Object) where intrinsics.type_is_poi
|
||||
|
||||
@(objc_class="NSCoder")
|
||||
Coder :: struct {using _: Object}
|
||||
// TODO(bill): Implement all the methods for this massive type
|
||||
// TODO(bill): Implement all the methods for this massive type
|
||||
|
||||
27
core/sys/darwin/Foundation/NSRunLoop.odin
Normal file
27
core/sys/darwin/Foundation/NSRunLoop.odin
Normal file
@@ -0,0 +1,27 @@
|
||||
package objc_Foundation
|
||||
|
||||
foreign import "system:Foundation.framework"
|
||||
|
||||
RunLoopMode :: ^String
|
||||
|
||||
@(link_prefix="NS")
|
||||
foreign Foundation {
|
||||
RunLoopCommonModes: RunLoopMode
|
||||
DefaultRunLoopMode: RunLoopMode
|
||||
EventTrackingRunLoopMode: RunLoopMode
|
||||
ModalPanelRunLoopMode: RunLoopMode
|
||||
}
|
||||
|
||||
@(objc_class="NSRunLoop")
|
||||
RunLoop :: struct { using _: Object }
|
||||
|
||||
@(objc_type=RunLoop, objc_name="mainRunLoop", objc_is_class_method=true)
|
||||
RunLoop_mainRunLoop :: proc() -> ^RunLoop {
|
||||
return msgSend(^RunLoop, RunLoop, "mainRunLoop")
|
||||
}
|
||||
|
||||
@(objc_type=RunLoop, objc_name="addTimerForMode")
|
||||
RunLoop_addTimerForMode :: proc(self: ^RunLoop, timer: ^Timer, forMode: RunLoopMode) {
|
||||
msgSend(nil, self, "addTimer:forMode:", timer, forMode)
|
||||
}
|
||||
|
||||
15
core/sys/darwin/Foundation/NSTimer.odin
Normal file
15
core/sys/darwin/Foundation/NSTimer.odin
Normal file
@@ -0,0 +1,15 @@
|
||||
package objc_Foundation
|
||||
|
||||
@(objc_class="NSTimer")
|
||||
Timer :: struct { using _: Object }
|
||||
|
||||
@(objc_type=Timer, objc_name="scheduledTimerWithTimeIntervalRepeatsBlock", objc_is_class_method=true)
|
||||
Timer_scheduledTimerWithTimeIntervalRepeatsBlock :: proc(interval: TimeInterval, repeats: BOOL, block: ^Block) -> ^Timer {
|
||||
return msgSend(^Timer, Timer, "scheduledTimerWithTimeInterval:repeats:block:")
|
||||
}
|
||||
|
||||
@(objc_type=Timer, objc_name="scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeat", objc_is_class_method=true)
|
||||
Timer_scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeat :: proc(interval: TimeInterval, aTarget: id, aSelector: SEL, userInfo: id, repeats: BOOL) -> ^Timer {
|
||||
return msgSend(^Timer, Timer, "scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:", interval, aTarget, aSelector, userInfo, repeats)
|
||||
}
|
||||
|
||||
@@ -699,6 +699,14 @@ View_convertPointFromView :: proc "c" (self: ^View, point: Point, view: ^View) -
|
||||
View_addSubview :: proc "c" (self: ^View, view: ^View) {
|
||||
msgSend(nil, self, "addSubview:", view)
|
||||
}
|
||||
@(objc_type=View, objc_name="isFlipped")
|
||||
View_isFlipped :: proc "c" (self: ^View) -> BOOL {
|
||||
return msgSend(BOOL, self, "isFlipped")
|
||||
}
|
||||
@(objc_type=View, objc_name="setIsFlipped")
|
||||
View_setIsFlipped :: proc "c" (self: ^View, flipped: BOOL) {
|
||||
msgSend(nil, self, "setIsFlipped:", flipped)
|
||||
}
|
||||
|
||||
@(objc_class="NSWindow")
|
||||
Window :: struct {using _: Responder}
|
||||
|
||||
22
vendor/darwin/QuartzCore/QuartzCore.odin
vendored
22
vendor/darwin/QuartzCore/QuartzCore.odin
vendored
@@ -47,6 +47,10 @@ MetalLayer_pixelFormat :: proc "c" (self: ^MetalLayer) -> MTL.PixelFormat {
|
||||
MetalLayer_setPixelFormat :: proc "c" (self: ^MetalLayer, pixelFormat: MTL.PixelFormat) {
|
||||
msgSend(nil, self, "setPixelFormat:", pixelFormat)
|
||||
}
|
||||
@(objc_type=MetalLayer, objc_name="setColorSpace")
|
||||
MetalLayer_setColorSpace :: proc "c" (self: ^MetalLayer, colorspace: NS.id) {
|
||||
msgSend(nil, self, "setColorspace:", colorspace)
|
||||
}
|
||||
|
||||
@(objc_type=MetalLayer, objc_name="framebufferOnly")
|
||||
MetalLayer_framebufferOnly :: proc "c" (self: ^MetalLayer) -> NS.BOOL {
|
||||
@@ -126,3 +130,21 @@ MetalDrawable_addPresentedHandler :: proc "c" (self: ^MetalDrawable, block: Draw
|
||||
msgSend(nil, self, "addPresentedHandler:", block)
|
||||
}
|
||||
|
||||
@(objc_class="CATransaction")
|
||||
Transaction :: struct { using _: NS.Object }
|
||||
|
||||
@(objc_type=Transaction, objc_name="begin", objc_is_class_method=true)
|
||||
transaction_begin :: proc() {
|
||||
msgSend(nil, Transaction, "begin")
|
||||
}
|
||||
|
||||
@(objc_type=Transaction, objc_name="commit", objc_is_class_method=true)
|
||||
transaction_commit :: proc() {
|
||||
msgSend(nil, Transaction, "commit")
|
||||
}
|
||||
|
||||
@(objc_type=Transaction, objc_name="flush", objc_is_class_method=true)
|
||||
transaction_flush :: proc() {
|
||||
msgSend(nil, Transaction, "flush")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user