aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2024-08-16 13:08:15 +0200
committerGitHub <noreply@github.com>2024-08-16 13:08:15 +0200
commit6fc39c1b5d09dfd25462fc7e9fff9ac03c20cd6e (patch)
tree15aa2e028703a14934589ca087fb10fcaa51ade7
parentd91fa162d82d82f715bcd0f6e6b2f55eb17a3889 (diff)
parent004036dc591bfec83ed74de41cb732820bc8f22b (diff)
Merge pull request #4075 from yay/more-foundation-bindings
More Foundation bindings.
-rw-r--r--core/sys/darwin/Foundation/NSApplication.odin5
-rw-r--r--core/sys/darwin/Foundation/NSDate.odin12
-rw-r--r--core/sys/darwin/Foundation/NSEvent.odin26
-rw-r--r--core/sys/darwin/Foundation/NSScreen.odin4
-rw-r--r--core/sys/darwin/Foundation/NSWindow.odin57
-rw-r--r--core/sys/darwin/Foundation/objc.odin24
6 files changed, 104 insertions, 24 deletions
diff --git a/core/sys/darwin/Foundation/NSApplication.odin b/core/sys/darwin/Foundation/NSApplication.odin
index 34221aed6..c2c93a3fe 100644
--- a/core/sys/darwin/Foundation/NSApplication.odin
+++ b/core/sys/darwin/Foundation/NSApplication.odin
@@ -110,6 +110,11 @@ Application_run :: proc "c" (self: ^Application) {
msgSend(nil, self, "run")
}
+@(objc_type=Application, objc_name="finishLaunching")
+Application_finishLaunching :: proc "c" (self: ^Application) {
+ msgSend(nil, self, "finishLaunching")
+}
+
@(objc_type=Application, objc_name="terminate")
Application_terminate :: proc "c" (self: ^Application, sender: ^Object) {
msgSend(nil, self, "terminate:", sender)
diff --git a/core/sys/darwin/Foundation/NSDate.odin b/core/sys/darwin/Foundation/NSDate.odin
index f8096c698..41efb0cf5 100644
--- a/core/sys/darwin/Foundation/NSDate.odin
+++ b/core/sys/darwin/Foundation/NSDate.odin
@@ -16,4 +16,14 @@ Date_init :: proc "c" (self: ^Date) -> ^Date {
@(objc_type=Date, objc_name="dateWithTimeIntervalSinceNow")
Date_dateWithTimeIntervalSinceNow :: proc "c" (secs: TimeInterval) -> ^Date {
return msgSend(^Date, Date, "dateWithTimeIntervalSinceNow:", secs)
-} \ No newline at end of file
+}
+
+@(objc_type=Date, objc_name="distantFuture", objc_is_class_method=true)
+Date_distantFuture :: proc "c" () -> ^Date {
+ return msgSend(^Date, Date, "distantFuture")
+}
+
+@(objc_type=Date, objc_name="distantPast", objc_is_class_method=true)
+Date_distantPast :: proc "c" () -> ^Date {
+ return msgSend(^Date, Date, "distantPast")
+}
diff --git a/core/sys/darwin/Foundation/NSEvent.odin b/core/sys/darwin/Foundation/NSEvent.odin
index b9f247230..f20afd3ab 100644
--- a/core/sys/darwin/Foundation/NSEvent.odin
+++ b/core/sys/darwin/Foundation/NSEvent.odin
@@ -105,6 +105,28 @@ PointingDeviceType :: enum UInteger {
Eraser = 3,
}
+EventModifierFlag :: enum UInteger {
+ CapsLock = 16,
+ Shift = 17,
+ Control = 18,
+ Option = 19,
+ Command = 20,
+ NumericPad = 21,
+ Help = 22,
+ Function = 23,
+}
+
+EventModifierFlags :: distinct bit_set[EventModifierFlag; UInteger]
+EventModifierFlagCapsLock :: EventModifierFlags{.CapsLock}
+EventModifierFlagShift :: EventModifierFlags{.Shift}
+EventModifierFlagControl :: EventModifierFlags{.Control}
+EventModifierFlagOption :: EventModifierFlags{.Option}
+EventModifierFlagCommand :: EventModifierFlags{.Command}
+EventModifierFlagNumericPad :: EventModifierFlags{.NumericPad}
+EventModifierFlagHelp :: EventModifierFlags{.Help}
+EventModifierFlagFunction :: EventModifierFlags{.Function}
+EventModifierFlagDeviceIndependentFlagsMask : UInteger : 0xffff0000
+
// Defined in Carbon.framework Events.h
kVK :: enum {
ANSI_A = 0x00,
@@ -236,8 +258,8 @@ Event_type :: proc "c" (self: ^Event) -> EventType {
return msgSend(EventType, self, "type")
}
@(objc_type=Event, objc_name="modifierFlags")
-Event_modifierFlags :: proc "c" (self: ^Event) -> UInteger {
- return msgSend(UInteger, self, "modifierFlags")
+Event_modifierFlags :: proc "c" (self: ^Event) -> EventModifierFlags {
+ return msgSend(EventModifierFlags, self, "modifierFlags")
}
@(objc_type=Event, objc_name="timestamp")
Event_timestamp :: proc "c" (self: ^Event) -> TimeInterval {
diff --git a/core/sys/darwin/Foundation/NSScreen.odin b/core/sys/darwin/Foundation/NSScreen.odin
index a8fe44aa5..79ab00fbe 100644
--- a/core/sys/darwin/Foundation/NSScreen.odin
+++ b/core/sys/darwin/Foundation/NSScreen.odin
@@ -31,3 +31,7 @@ Screen_visibleFrame :: proc "c" (self: ^Screen) -> Rect {
Screen_colorSpace :: proc "c" (self: ^Screen) -> ^ColorSpace {
return msgSend(^ColorSpace, self, "colorSpace")
}
+@(objc_type=Screen, objc_name="backingScaleFactor")
+Screen_backingScaleFactor :: proc "c" (self: ^Screen) -> Float {
+ return msgSend(Float, self, "backingScaleFactor")
+} \ No newline at end of file
diff --git a/core/sys/darwin/Foundation/NSWindow.odin b/core/sys/darwin/Foundation/NSWindow.odin
index e6103a58a..0fe334207 100644
--- a/core/sys/darwin/Foundation/NSWindow.odin
+++ b/core/sys/darwin/Foundation/NSWindow.odin
@@ -627,18 +627,7 @@ Window_alloc :: proc "c" () -> ^Window {
@(objc_type=Window, objc_name="initWithContentRect")
Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: BOOL) -> ^Window {
- self := self
- // HACK: due to a compiler bug, the generated calling code does not
- // currently work for this message. Has to do with passing a struct along
- // with other parameters, so we don't send the rect here.
- // Omiting the rect argument here actually works, because of how the C
- // calling conventions are defined.
- self = msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", styleMask, backing, doDefer)
-
- // apply the contentRect now, since we did not pass it to the init call
- msgSend(nil, self, "setContentSize:", contentRect.size)
- msgSend(nil, self, "setFrameOrigin:", contentRect.origin)
- return self
+ return msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", contentRect, styleMask, backing, doDefer)
}
@(objc_type=Window, objc_name="contentView")
Window_contentView :: proc "c" (self: ^Window) -> ^View {
@@ -716,3 +705,47 @@ Window_backingScaleFactor :: proc "c" (self: ^Window) -> Float {
Window_setWantsLayer :: proc "c" (self: ^Window, ok: BOOL) {
msgSend(nil, self, "setWantsLayer:", ok)
}
+@(objc_type=Window, objc_name="setIsMiniaturized")
+Window_setIsMiniaturized :: proc "c" (self: ^Window, ok: BOOL) {
+ msgSend(nil, self, "setIsMiniaturized:", ok)
+}
+@(objc_type=Window, objc_name="setIsVisible")
+Window_setIsVisible :: proc "c" (self: ^Window, ok: BOOL) {
+ msgSend(nil, self, "setIsVisible:", ok)
+}
+@(objc_type=Window, objc_name="setIsZoomed")
+Window_setIsZoomed :: proc "c" (self: ^Window, ok: BOOL) {
+ msgSend(nil, self, "setIsZoomed:", ok)
+}
+@(objc_type=Window, objc_name="isZoomable")
+Window_isZoomable :: proc "c" (self: ^Window) -> BOOL {
+ return msgSend(BOOL, self, "isZoomable")
+}
+@(objc_type=Window, objc_name="isResizable")
+Window_isResizable :: proc "c" (self: ^Window) -> BOOL {
+ return msgSend(BOOL, self, "isResizable")
+}
+@(objc_type=Window, objc_name="isModalPanel")
+Window_isModalPanel :: proc "c" (self: ^Window) -> BOOL {
+ return msgSend(BOOL, self, "isModalPanel")
+}
+@(objc_type=Window, objc_name="isMiniaturizable")
+Window_isMiniaturizable :: proc "c" (self: ^Window) -> BOOL {
+ return msgSend(BOOL, self, "isMiniaturizable")
+}
+@(objc_type=Window, objc_name="isFloatingPanel")
+Window_isFloatingPanel :: proc "c" (self: ^Window) -> BOOL {
+ return msgSend(BOOL, self, "isFloatingPanel")
+}
+@(objc_type=Window, objc_name="hasCloseBox")
+Window_hasCloseBox :: proc "c" (self: ^Window) -> BOOL {
+ return msgSend(BOOL, self, "hasCloseBox")
+}
+@(objc_type=Window, objc_name="hasTitleBar")
+Window_hasTitleBar :: proc "c" (self: ^Window) -> BOOL {
+ return msgSend(BOOL, self, "hasTitleBar")
+}
+@(objc_type=Window, objc_name="orderedIndex")
+Window_orderedIndex :: proc "c" (self: ^Window) -> Integer {
+ return msgSend(Integer, self, "orderedIndex")
+} \ No newline at end of file
diff --git a/core/sys/darwin/Foundation/objc.odin b/core/sys/darwin/Foundation/objc.odin
index 673996cbe..51cfee444 100644
--- a/core/sys/darwin/Foundation/objc.odin
+++ b/core/sys/darwin/Foundation/objc.odin
@@ -10,17 +10,23 @@ import "core:c"
IMP :: proc "c" (object: id, sel: SEL, #c_vararg args: ..any) -> id
foreign Foundation {
- objc_lookUpClass :: proc "c" (name: cstring) -> Class ---
- sel_registerName :: proc "c" (name: cstring) -> SEL ---
- objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class ---
- objc_registerClassPair :: proc "c" (cls : Class) ---
+ objc_getMetaClass :: proc "c" (name: cstring) -> id ---
+ objc_lookUpClass :: proc "c" (name: cstring) -> Class ---
+ objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class ---
+ objc_registerClassPair :: proc "c" (cls : Class) ---
- class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL ---
- class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method ---
- class_createInstance :: proc "c" (cls: Class, extraBytes: c.size_t) -> id ---
+ sel_registerName :: proc "c" (name: cstring) -> SEL ---
+
+ class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL ---
+ class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method ---
+ class_createInstance :: proc "c" (cls: Class, extraBytes: c.size_t) -> id ---
method_setImplementation :: proc "c" (method: Method, imp: IMP) ---
- object_getIndexedIvars :: proc(obj: id) -> rawptr ---
+
+ object_getClass :: proc "c" (obj: id) -> Class ---
+ object_setClass :: proc "c" (obj: id, cls: Class) -> Class ---
+ object_getClassName :: proc "c" (obj: id) -> cstring ---
+ object_getIndexedIvars :: proc "c" (obj: id) -> rawptr ---
}
@@ -72,7 +78,7 @@ objc_class_internals :: struct {
info: c.long,
instance_size: c.long,
ivars: ^objc_ivar_list,
-
+
methodLists: ^^objc_method_list,
cache: rawptr,