mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Add more NS bindings and correctly link NS block
This commit is contained in:
+4
@@ -123,6 +123,10 @@ Application_nextEventMatchingMask :: proc "c" (self: ^Application, mask: EventMa
|
|||||||
Application_sendEvent :: proc "c" (self: ^Application, event: ^Event) {
|
Application_sendEvent :: proc "c" (self: ^Application, event: ^Event) {
|
||||||
msgSend(Event, self, "sendEvent:", 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")
|
@(objc_class="NSRunningApplication")
|
||||||
|
|||||||
+7
-3
@@ -48,6 +48,11 @@ global_block_descriptor := Block_Descriptor{
|
|||||||
size = size_of(Internal_Block_Literal),
|
size = size_of(Internal_Block_Literal),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreign import libSystem "system:System.framework"
|
||||||
|
foreign libSystem {
|
||||||
|
_NSConcreteGlobalBlock: ^intrinsics.objc_class
|
||||||
|
}
|
||||||
|
|
||||||
@(private="file")
|
@(private="file")
|
||||||
Block_createInternal :: proc "c" (is_global: bool, user_data: rawptr, user_proc: proc "c" (user_data: rawptr)) -> ^Block {
|
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
|
// 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)
|
extraBytes :: size_of(Internal_Block_Literal) - size_of(Internal_Block_Literal_Base)
|
||||||
|
|
||||||
cls := intrinsics.objc_find_class("NSConcreteGlobalBlock")
|
bl := (^Internal_Block_Literal)(AllocateObject(_NSConcreteGlobalBlock, extraBytes, nil))
|
||||||
bl := (^Internal_Block_Literal)(AllocateObject(cls, extraBytes, nil))
|
bl.isa = _NSConcreteGlobalBlock
|
||||||
bl.isa = cls
|
|
||||||
bl.flags = BLOCK_IS_GLOBAL if is_global else 0
|
bl.flags = BLOCK_IS_GLOBAL if is_global else 0
|
||||||
bl.invoke = proc "c" (bl: ^Internal_Block_Literal) {
|
bl.invoke = proc "c" (bl: ^Internal_Block_Literal) {
|
||||||
bl.user_proc(bl.user_data)
|
bl.user_proc(bl.user_data)
|
||||||
|
|||||||
+8
@@ -612,6 +612,10 @@ View_wantsLayer :: proc "c" (self: ^View) -> BOOL {
|
|||||||
View_setWantsLayer :: proc "c" (self: ^View, wantsLayer: BOOL) {
|
View_setWantsLayer :: proc "c" (self: ^View, wantsLayer: BOOL) {
|
||||||
msgSend(nil, self, "setWantsLayer:", wantsLayer)
|
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")
|
@(objc_class="NSWindow")
|
||||||
Window :: struct {using _: Responder}
|
Window :: struct {using _: Responder}
|
||||||
@@ -704,3 +708,7 @@ Window_close :: proc "c" (self: ^Window) {
|
|||||||
Window_setDelegate :: proc "c" (self: ^Window, delegate: ^WindowDelegate) {
|
Window_setDelegate :: proc "c" (self: ^Window, delegate: ^WindowDelegate) {
|
||||||
msgSend(nil, self, "setDelegate:", delegate)
|
msgSend(nil, self, "setDelegate:", delegate)
|
||||||
}
|
}
|
||||||
|
@(objc_type=Window, objc_name="backingScaleFactor")
|
||||||
|
Window_backingScaleFactor :: proc "c" (self: ^Window) -> Float {
|
||||||
|
return msgSend(Float, self, "backingScaleFactor")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user