mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 14:18:47 +00:00
Merge pull request #4075 from yay/more-foundation-bindings
More Foundation bindings.
This commit is contained in:
@@ -110,6 +110,11 @@ Application_run :: proc "c" (self: ^Application) {
|
|||||||
msgSend(nil, self, "run")
|
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")
|
@(objc_type=Application, objc_name="terminate")
|
||||||
Application_terminate :: proc "c" (self: ^Application, sender: ^Object) {
|
Application_terminate :: proc "c" (self: ^Application, sender: ^Object) {
|
||||||
msgSend(nil, self, "terminate:", sender)
|
msgSend(nil, self, "terminate:", sender)
|
||||||
|
|||||||
@@ -16,4 +16,14 @@ Date_init :: proc "c" (self: ^Date) -> ^Date {
|
|||||||
@(objc_type=Date, objc_name="dateWithTimeIntervalSinceNow")
|
@(objc_type=Date, objc_name="dateWithTimeIntervalSinceNow")
|
||||||
Date_dateWithTimeIntervalSinceNow :: proc "c" (secs: TimeInterval) -> ^Date {
|
Date_dateWithTimeIntervalSinceNow :: proc "c" (secs: TimeInterval) -> ^Date {
|
||||||
return msgSend(^Date, Date, "dateWithTimeIntervalSinceNow:", secs)
|
return msgSend(^Date, Date, "dateWithTimeIntervalSinceNow:", secs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(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")
|
||||||
|
}
|
||||||
|
|||||||
@@ -105,6 +105,28 @@ PointingDeviceType :: enum UInteger {
|
|||||||
Eraser = 3,
|
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
|
// Defined in Carbon.framework Events.h
|
||||||
kVK :: enum {
|
kVK :: enum {
|
||||||
ANSI_A = 0x00,
|
ANSI_A = 0x00,
|
||||||
@@ -236,8 +258,8 @@ Event_type :: proc "c" (self: ^Event) -> EventType {
|
|||||||
return msgSend(EventType, self, "type")
|
return msgSend(EventType, self, "type")
|
||||||
}
|
}
|
||||||
@(objc_type=Event, objc_name="modifierFlags")
|
@(objc_type=Event, objc_name="modifierFlags")
|
||||||
Event_modifierFlags :: proc "c" (self: ^Event) -> UInteger {
|
Event_modifierFlags :: proc "c" (self: ^Event) -> EventModifierFlags {
|
||||||
return msgSend(UInteger, self, "modifierFlags")
|
return msgSend(EventModifierFlags, self, "modifierFlags")
|
||||||
}
|
}
|
||||||
@(objc_type=Event, objc_name="timestamp")
|
@(objc_type=Event, objc_name="timestamp")
|
||||||
Event_timestamp :: proc "c" (self: ^Event) -> TimeInterval {
|
Event_timestamp :: proc "c" (self: ^Event) -> TimeInterval {
|
||||||
|
|||||||
@@ -31,3 +31,7 @@ Screen_visibleFrame :: proc "c" (self: ^Screen) -> Rect {
|
|||||||
Screen_colorSpace :: proc "c" (self: ^Screen) -> ^ColorSpace {
|
Screen_colorSpace :: proc "c" (self: ^Screen) -> ^ColorSpace {
|
||||||
return msgSend(^ColorSpace, self, "colorSpace")
|
return msgSend(^ColorSpace, self, "colorSpace")
|
||||||
}
|
}
|
||||||
|
@(objc_type=Screen, objc_name="backingScaleFactor")
|
||||||
|
Screen_backingScaleFactor :: proc "c" (self: ^Screen) -> Float {
|
||||||
|
return msgSend(Float, self, "backingScaleFactor")
|
||||||
|
}
|
||||||
@@ -627,18 +627,7 @@ Window_alloc :: proc "c" () -> ^Window {
|
|||||||
|
|
||||||
@(objc_type=Window, objc_name="initWithContentRect")
|
@(objc_type=Window, objc_name="initWithContentRect")
|
||||||
Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: BOOL) -> ^Window {
|
Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: BOOL) -> ^Window {
|
||||||
self := self
|
return msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", contentRect, styleMask, backing, doDefer)
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
@(objc_type=Window, objc_name="contentView")
|
@(objc_type=Window, objc_name="contentView")
|
||||||
Window_contentView :: proc "c" (self: ^Window) -> ^View {
|
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) {
|
Window_setWantsLayer :: proc "c" (self: ^Window, ok: BOOL) {
|
||||||
msgSend(nil, self, "setWantsLayer:", ok)
|
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")
|
||||||
|
}
|
||||||
@@ -10,17 +10,23 @@ import "core:c"
|
|||||||
IMP :: proc "c" (object: id, sel: SEL, #c_vararg args: ..any) -> id
|
IMP :: proc "c" (object: id, sel: SEL, #c_vararg args: ..any) -> id
|
||||||
|
|
||||||
foreign Foundation {
|
foreign Foundation {
|
||||||
objc_lookUpClass :: proc "c" (name: cstring) -> Class ---
|
objc_getMetaClass :: proc "c" (name: cstring) -> id ---
|
||||||
sel_registerName :: proc "c" (name: cstring) -> SEL ---
|
objc_lookUpClass :: proc "c" (name: cstring) -> Class ---
|
||||||
objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class ---
|
objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class ---
|
||||||
objc_registerClassPair :: proc "c" (cls : Class) ---
|
objc_registerClassPair :: proc "c" (cls : Class) ---
|
||||||
|
|
||||||
class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL ---
|
sel_registerName :: proc "c" (name: cstring) -> SEL ---
|
||||||
class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method ---
|
|
||||||
class_createInstance :: proc "c" (cls: Class, extraBytes: c.size_t) -> id ---
|
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) ---
|
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,
|
info: c.long,
|
||||||
instance_size: c.long,
|
instance_size: c.long,
|
||||||
ivars: ^objc_ivar_list,
|
ivars: ^objc_ivar_list,
|
||||||
|
|
||||||
methodLists: ^^objc_method_list,
|
methodLists: ^^objc_method_list,
|
||||||
|
|
||||||
cache: rawptr,
|
cache: rawptr,
|
||||||
|
|||||||
Reference in New Issue
Block a user