aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perlind <lucasp@blackmagicdesign.com>2023-08-30 10:13:01 +1000
committerLucas Perlind <lucasp@blackmagicdesign.com>2023-08-30 10:18:17 +1000
commit46e7fa52b3bee1105d16df003530955421bb0b4c (patch)
tree07fee90fe39a76eee61bdbeeb35afeef21ba6394
parent29f7eaad78df02b0470d769835ff8c5e7ddf0542 (diff)
Add more NS bindings and correctly link NS block
-rw-r--r--vendor/darwin/Foundation/NSApplication.odin4
-rw-r--r--vendor/darwin/Foundation/NSBlock.odin10
-rw-r--r--vendor/darwin/Foundation/NSWindow.odin10
3 files changed, 20 insertions, 4 deletions
diff --git a/vendor/darwin/Foundation/NSApplication.odin b/vendor/darwin/Foundation/NSApplication.odin
index c763d7210..3fa0d28b6 100644
--- a/vendor/darwin/Foundation/NSApplication.odin
+++ b/vendor/darwin/Foundation/NSApplication.odin
@@ -123,6 +123,10 @@ Application_nextEventMatchingMask :: proc "c" (self: ^Application, mask: EventMa
Application_sendEvent :: proc "c" (self: ^Application, event: ^Event) {
msgSend(Event, self, "sendEvent:", event)
}
+@(objc_type=Application, objc_name="updateWindows")
+Application_updateWindows :: proc "c" (self: ^Application) {
+ msgSend(nil, self, "updateWindows")
+}
@(objc_class="NSRunningApplication")
diff --git a/vendor/darwin/Foundation/NSBlock.odin b/vendor/darwin/Foundation/NSBlock.odin
index 7fa061484..9cc58da71 100644
--- a/vendor/darwin/Foundation/NSBlock.odin
+++ b/vendor/darwin/Foundation/NSBlock.odin
@@ -48,6 +48,11 @@ global_block_descriptor := Block_Descriptor{
size = size_of(Internal_Block_Literal),
}
+foreign import libSystem "system:System.framework"
+foreign libSystem {
+ _NSConcreteGlobalBlock: ^intrinsics.objc_class
+}
+
@(private="file")
Block_createInternal :: proc "c" (is_global: bool, user_data: rawptr, user_proc: proc "c" (user_data: rawptr)) -> ^Block {
// Set to true on blocks that have captures (and thus are not true
@@ -66,9 +71,8 @@ Block_createInternal :: proc "c" (is_global: bool, user_data: rawptr, user_proc:
extraBytes :: size_of(Internal_Block_Literal) - size_of(Internal_Block_Literal_Base)
- cls := intrinsics.objc_find_class("NSConcreteGlobalBlock")
- bl := (^Internal_Block_Literal)(AllocateObject(cls, extraBytes, nil))
- bl.isa = cls
+ bl := (^Internal_Block_Literal)(AllocateObject(_NSConcreteGlobalBlock, extraBytes, nil))
+ bl.isa = _NSConcreteGlobalBlock
bl.flags = BLOCK_IS_GLOBAL if is_global else 0
bl.invoke = proc "c" (bl: ^Internal_Block_Literal) {
bl.user_proc(bl.user_data)
diff --git a/vendor/darwin/Foundation/NSWindow.odin b/vendor/darwin/Foundation/NSWindow.odin
index bf95b8751..16dd5afc3 100644
--- a/vendor/darwin/Foundation/NSWindow.odin
+++ b/vendor/darwin/Foundation/NSWindow.odin
@@ -612,6 +612,10 @@ View_wantsLayer :: proc "c" (self: ^View) -> BOOL {
View_setWantsLayer :: proc "c" (self: ^View, wantsLayer: BOOL) {
msgSend(nil, self, "setWantsLayer:", wantsLayer)
}
+@(objc_type=View, objc_name="convertPointFromView")
+View_convertPointFromView :: proc "c" (self: ^View, point: Point, view: ^View) -> Point {
+ return msgSend(Point, self, "convertPoint:fromView:", point, view)
+}
@(objc_class="NSWindow")
Window :: struct {using _: Responder}
@@ -703,4 +707,8 @@ Window_close :: proc "c" (self: ^Window) {
@(objc_type=Window, objc_name="setDelegate")
Window_setDelegate :: proc "c" (self: ^Window, delegate: ^WindowDelegate) {
msgSend(nil, self, "setDelegate:", delegate)
-} \ No newline at end of file
+}
+@(objc_type=Window, objc_name="backingScaleFactor")
+Window_backingScaleFactor :: proc "c" (self: ^Window) -> Float {
+ return msgSend(Float, self, "backingScaleFactor")
+}