From 29f7eaad78df02b0470d769835ff8c5e7ddf0542 Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Fri, 25 Aug 2023 13:46:03 +1000 Subject: [PATCH 01/10] Correct run loop linking --- vendor/darwin/Foundation/NSApplication.odin | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vendor/darwin/Foundation/NSApplication.odin b/vendor/darwin/Foundation/NSApplication.odin index 7dfb0a879..c763d7210 100644 --- a/vendor/darwin/Foundation/NSApplication.odin +++ b/vendor/darwin/Foundation/NSApplication.odin @@ -10,11 +10,10 @@ RunLoopMode :: ^String @(link_prefix="NS") foreign Foundation { - CommonRunLoopMode: RunLoopMode + RunLoopCommonModes: RunLoopMode DefaultRunLoopMode: RunLoopMode EventTrackingRunLoopMode: RunLoopMode ModalPanelRunLoopMode: RunLoopMode - TrackingRunLoopMode: RunLoopMode } ActivationPolicy :: enum UInteger { From e51915a529a4fafbf6f7a7ba469b475f5d1b9fba Mon Sep 17 00:00:00 2001 From: Tetralux Date: Sat, 26 Aug 2023 11:25:37 +0000 Subject: [PATCH 02/10] [net] Assorted cleanup - Remove some old comments - Fix some doc comments - Improve some doc comments - Unify name of the errors related to UDP packet sizes (i.e: recv buffer too small, and message too big to send) --- core/net/addr.odin | 2 +- core/net/errors_darwin.odin | 16 +++++++--------- core/net/errors_linux.odin | 14 +++++--------- core/net/errors_windows.odin | 17 +++++------------ 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/core/net/addr.odin b/core/net/addr.odin index be04be15e..f0c47e926 100644 --- a/core/net/addr.odin +++ b/core/net/addr.odin @@ -587,7 +587,7 @@ address_to_string :: proc(addr: Address, allocator := context.temp_allocator) -> } // Returns a temporarily-allocated string representation of the endpoint. -// If there's a port, uses the `[address]:port` format. +// If there's a port, uses the `ip4address:port` or `[ip6address]:port` format, respectively. endpoint_to_string :: proc(ep: Endpoint, allocator := context.temp_allocator) -> string { if ep.port == 0 { return address_to_string(ep.address, allocator) diff --git a/core/net/errors_darwin.odin b/core/net/errors_darwin.odin index 39cf4c665..c80d2cf56 100644 --- a/core/net/errors_darwin.odin +++ b/core/net/errors_darwin.odin @@ -109,12 +109,12 @@ TCP_Recv_Error :: enum c.int { } UDP_Recv_Error :: enum c.int { - None = 0, - Truncated = c.int(os.EMSGSIZE), // The buffer is too small to fit the entire message, and the message was truncated. - Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. - Not_Descriptor = c.int(os.EBADF), // The so-called socket is, in fact, not even a valid descriptor. - Bad_Buffer = c.int(os.EFAULT), // The buffer did not point to a valid location in memory. - Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). + None = 0, + Buffer_Too_Small = c.int(os.EMSGSIZE), // The buffer is too small to fit the entire message, and the message was truncated. When this happens, the rest of message is lost. + Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. + Not_Descriptor = c.int(os.EBADF), // The so-called socket is, in fact, not even a valid descriptor. + Bad_Buffer = c.int(os.EFAULT), // The buffer did not point to a valid location in memory. + Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. // NOTE: No, really. Presumably this means something different for nonblocking sockets... @@ -122,11 +122,9 @@ UDP_Recv_Error :: enum c.int { Socket_Not_Bound = c.int(os.EINVAL), // The socket must be bound for this operation, but isn't. } -// TODO TCP_Send_Error :: enum c.int { None = 0, - // TODO: merge with other errors? Aborted = c.int(os.ECONNABORTED), Connection_Closed = c.int(os.ECONNRESET), Not_Connected = c.int(os.ENOTCONN), @@ -151,7 +149,7 @@ TCP_Send_Error :: enum c.int { // TODO UDP_Send_Error :: enum c.int { None = 0, - Truncated = c.int(os.EMSGSIZE), // The message is too big. No data was sent. + Message_Too_Long = c.int(os.EMSGSIZE), // The message is larger than the maximum UDP packet size. No data was sent. // TODO: not sure what the exact circumstances for this is yet Network_Unreachable = c.int(os.ENETUNREACH), diff --git a/core/net/errors_linux.odin b/core/net/errors_linux.odin index 9366f4435..d76132ad5 100644 --- a/core/net/errors_linux.odin +++ b/core/net/errors_linux.odin @@ -105,9 +105,7 @@ TCP_Recv_Error :: enum c.int { UDP_Recv_Error :: enum c.int { None = 0, - // The buffer is too small to fit the entire message, and the message was truncated. - // When this happens, the rest of message is lost. - Buffer_Too_Small = c.int(os.EMSGSIZE), + Buffer_Too_Small = c.int(os.EMSGSIZE), // The buffer is too small to fit the entire message, and the message was truncated. When this happens, the rest of message is lost. Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. Not_Descriptor = c.int(os.EBADF), // The so-called socket is, in fact, not even a valid descriptor. Bad_Buffer = c.int(os.EFAULT), // The buffer did not point to a valid location in memory. @@ -119,10 +117,8 @@ UDP_Recv_Error :: enum c.int { Socket_Not_Bound = c.int(os.EINVAL), // The socket must be bound for this operation, but isn't. } -// TODO TCP_Send_Error :: enum c.int { None = 0, - // TODO(tetra): merge with other errors? Aborted = c.int(os.ECONNABORTED), Connection_Closed = c.int(os.ECONNRESET), Not_Connected = c.int(os.ENOTCONN), @@ -135,16 +131,16 @@ TCP_Send_Error :: enum c.int { // doesn't fit in the send queue. No_Buffer_Space_Available = c.int(os.ENOBUFS), Offline = c.int(os.ENETDOWN), - Host_Unreachable = c.int(os.EHOSTUNREACH), // A signal occurred before any data was transmitted. See signal(7). - Interrupted = c.int(os.EINTR), // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. - Timeout = c.int(os.EWOULDBLOCK), // NOTE: No, really. Presumably this means something different for nonblocking sockets... + Host_Unreachable = c.int(os.EHOSTUNREACH), + Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). + Timeout = c.int(os.EWOULDBLOCK), // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. } // TODO UDP_Send_Error :: enum c.int { None = 0, - Message_Too_Long = c.int(os.EMSGSIZE), // The message is too big. No data was sent. + Message_Too_Long = c.int(os.EMSGSIZE), // The message is larger than the maximum UDP packet size. No data was sent. // TODO: not sure what the exact circumstances for this is yet Network_Unreachable = c.int(os.ENETUNREACH), diff --git a/core/net/errors_windows.odin b/core/net/errors_windows.odin index 272aa0a96..0538c2b82 100644 --- a/core/net/errors_windows.odin +++ b/core/net/errors_windows.odin @@ -92,8 +92,6 @@ TCP_Recv_Error :: enum c.int { Not_Socket = win.WSAENOTSOCK, Shutdown = win.WSAESHUTDOWN, Would_Block = win.WSAEWOULDBLOCK, - - // TODO: not functionally different from Reset; merge? Aborted = win.WSAECONNABORTED, Timeout = win.WSAETIMEDOUT, @@ -107,11 +105,8 @@ TCP_Recv_Error :: enum c.int { UDP_Recv_Error :: enum c.int { None = 0, Network_Subsystem_Failure = win.WSAENETDOWN, - - // TODO: not functionally different from Reset; merge? - // UDP packets are limited in size, and the length of the incoming message exceeded it. - Aborted = win.WSAECONNABORTED, - Truncated = win.WSAEMSGSIZE, + Aborted = win.WSAECONNABORTED, + Buffer_Too_Small = win.WSAEMSGSIZE, // The buffer is too small to fit the entire message, and the message was truncated. When this happens, the rest of message is lost. Remote_Not_Listening = win.WSAECONNRESET, // The machine at the remote endpoint doesn't have the given port open to receiving UDP data. Shutdown = win.WSAESHUTDOWN, Broadcast_Disabled = win.WSAEACCES, // A broadcast address was specified, but the .Broadcast socket option isn't set. @@ -133,7 +128,6 @@ UDP_Recv_Error :: enum c.int { TCP_Send_Error :: enum c.int { None = 0, - // TODO: not functionally different from Reset; merge? Aborted = win.WSAECONNABORTED, Not_Connected = win.WSAENOTCONN, Shutdown = win.WSAESHUTDOWN, @@ -159,10 +153,9 @@ UDP_Send_Error :: enum c.int { None = 0, Network_Subsystem_Failure = win.WSAENETDOWN, - // TODO: not functionally different from Reset; merge? - Aborted = win.WSAECONNABORTED, // UDP packets are limited in size, and len(buf) exceeded it. - Message_Too_Long = win.WSAEMSGSIZE, // The machine at the remote endpoint doesn't have the given port open to receiving UDP data. - Remote_Not_Listening = win.WSAECONNRESET, + Aborted = win.WSAECONNABORTED, + Message_Too_Long = win.WSAEMSGSIZE, // The message is larger than the maximum UDP packet size. + Remote_Not_Listening = win.WSAECONNRESET, // The machine at the remote endpoint doesn't have the given port open to receiving UDP data. Shutdown = win.WSAESHUTDOWN, // A broadcast address was specified, but the .Broadcast socket option isn't set. Broadcast_Disabled = win.WSAEACCES, Bad_Buffer = win.WSAEFAULT, // Connection is broken due to keepalive activity detecting a failure during the operation. From 076b20a9a5c1e1604099a528e6bd9f5a679b3189 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Sat, 26 Aug 2023 19:09:04 +0200 Subject: [PATCH 03/10] fix queue reserve always doubling in size when there is enough space --- core/container/queue/queue.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/container/queue/queue.odin b/core/container/queue/queue.odin index af44ef671..5783cbc6c 100644 --- a/core/container/queue/queue.odin +++ b/core/container/queue/queue.odin @@ -56,7 +56,7 @@ space :: proc(q: $Q/Queue($T)) -> int { // Reserve enough space for at least the specified capacity reserve :: proc(q: ^$Q/Queue($T), capacity: int) -> runtime.Allocator_Error { - if uint(capacity) > q.len { + if capacity > space(q^) { return _grow(q, uint(capacity)) } return nil From 8c4bd762805af570d1dc29ef2c6480084b4da6e1 Mon Sep 17 00:00:00 2001 From: Pix Date: Sun, 27 Aug 2023 21:03:49 +0800 Subject: [PATCH 04/10] Updating to be the correct function name in documentation. --- core/bufio/writer.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bufio/writer.odin b/core/bufio/writer.odin index bfa8b804f..c3debdaaa 100644 --- a/core/bufio/writer.odin +++ b/core/bufio/writer.odin @@ -159,7 +159,7 @@ writer_write_rune :: proc(b: ^Writer, r: rune) -> (size: int, err: io.Error) { return } -// writer_write writes a string into the buffer +// writer_write_string writes a string into the buffer // It returns the number of bytes written // If n < len(p), it will return an error explaining why the write is short writer_write_string :: proc(b: ^Writer, s: string) -> (int, io.Error) { From 0a2678973b3668ad42ff0d6d44cb8d26cae6053a Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Tue, 29 Aug 2023 10:44:21 +0200 Subject: [PATCH 05/10] Fix the OVERLAPPED_ENTRY type definition --- core/sys/windows/types.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 8971f2875..d5377eb2f 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -2475,9 +2475,9 @@ OVERLAPPED :: struct { } OVERLAPPED_ENTRY :: struct { - lpCompletionKey: c_ulong, + lpCompletionKey: ULONG_PTR, lpOverlapped: ^OVERLAPPED, - Internal: c_ulong, + Internal: ULONG_PTR, dwNumberOfBytesTransferred: DWORD, } From 46e7fa52b3bee1105d16df003530955421bb0b4c Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Wed, 30 Aug 2023 10:13:01 +1000 Subject: [PATCH 06/10] Add more NS bindings and correctly link NS block --- vendor/darwin/Foundation/NSApplication.odin | 4 ++++ vendor/darwin/Foundation/NSBlock.odin | 10 +++++++--- vendor/darwin/Foundation/NSWindow.odin | 10 +++++++++- 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") +} From a182dc78f45cdbdca6675f945d3fbd5a61ca3250 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Thu, 31 Aug 2023 02:31:11 +0200 Subject: [PATCH 07/10] fix #2779 ternary with a union of enum --- src/check_expr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 399c25a9d..a0d3c24bf 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7927,7 +7927,7 @@ gb_internal ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *n // NOTE(bill, 2023-01-30): Allow for expression like this: // x: union{f32} = f32(123) if cond else nil - if (type_hint && !is_type_any(type_hint) && !ternary_compare_types(x.type, y.type)) { + if (type_hint && !is_type_any(type_hint)) { if (check_is_assignable_to(c, &x, type_hint) && check_is_assignable_to(c, &y, type_hint)) { check_cast(c, &x, type_hint); check_cast(c, &y, type_hint); From 747116aeb08d9a2aacec9161b2a29b7ec6b82d61 Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Thu, 31 Aug 2023 17:35:05 +1000 Subject: [PATCH 08/10] Add more darwin bindings --- vendor/darwin/CoreVideo/CVDisplayLink.odin | 43 +++++++ vendor/darwin/Foundation/NSEvent.odin | 124 +++++++++++++++++++++ vendor/darwin/QuartzCore/QuartzCore.odin | 35 +++++- 3 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 vendor/darwin/CoreVideo/CVDisplayLink.odin diff --git a/vendor/darwin/CoreVideo/CVDisplayLink.odin b/vendor/darwin/CoreVideo/CVDisplayLink.odin new file mode 100644 index 000000000..fae988e0a --- /dev/null +++ b/vendor/darwin/CoreVideo/CVDisplayLink.odin @@ -0,0 +1,43 @@ +package CoreVideo + +DisplayLinkRef :: distinct rawptr +Return :: i32 + +TimeStamp :: struct { + version: u32, + videoTimeScale: i32, + videoTime: i64, + hostTime: u64, + rateScalar: f64, + videoRefreshPeriod: i64, + smpteTime: CVSMPTETime, + flags: u64, + reserved: u64, +} + +CVSMPTETime :: struct { + sbuframes: i16, + subframeDivisor: i16, + count: u32, + type: u32, + flags: u32, + hours: i16, + minutes: i16, + seconds: i16, + frames: i16, +} + +OptionFlags :: u64 +DisplayLinkOutputCallback :: #type proc "c" (displayLink: DisplayLinkRef, #by_ptr inNow: TimeStamp, #by_ptr inOutputTime: TimeStamp, flagsIn: OptionFlags, flagsOut: ^OptionFlags, displayLinkContext: rawptr) -> Return + +foreign import CoreVideo "system:CoreVideo.framework" +@(link_prefix="CV") +foreign CoreVideo { + DisplayLinkCreateWithActiveCGDisplays :: proc "c" (displayLinkOut: ^DisplayLinkRef) -> Return --- + DisplayLinkStart :: proc "c" (displayLink: DisplayLinkRef) -> Return --- + DisplayLinkStop :: proc "c" (displayLink: DisplayLinkRef) -> Return --- + DisplayLinkSetOutputCallback :: proc "c" (displayLink: DisplayLinkRef, callback: DisplayLinkOutputCallback, userInfo: rawptr) -> Return --- + DisplayLinkRelease :: proc "c" (displayLink: DisplayLinkRef) --- + DisplayLinkRetain :: proc "c" (displayLink: DisplayLinkRef) -> DisplayLinkRef --- +} + diff --git a/vendor/darwin/Foundation/NSEvent.odin b/vendor/darwin/Foundation/NSEvent.odin index b57057bbe..b9f247230 100644 --- a/vendor/darwin/Foundation/NSEvent.odin +++ b/vendor/darwin/Foundation/NSEvent.odin @@ -105,6 +105,130 @@ PointingDeviceType :: enum UInteger { Eraser = 3, } +// Defined in Carbon.framework Events.h +kVK :: enum { + ANSI_A = 0x00, + ANSI_S = 0x01, + ANSI_D = 0x02, + ANSI_F = 0x03, + ANSI_H = 0x04, + ANSI_G = 0x05, + ANSI_Z = 0x06, + ANSI_X = 0x07, + ANSI_C = 0x08, + ANSI_V = 0x09, + ANSI_B = 0x0B, + ANSI_Q = 0x0C, + ANSI_W = 0x0D, + ANSI_E = 0x0E, + ANSI_R = 0x0F, + ANSI_Y = 0x10, + ANSI_T = 0x11, + ANSI_1 = 0x12, + ANSI_2 = 0x13, + ANSI_3 = 0x14, + ANSI_4 = 0x15, + ANSI_6 = 0x16, + ANSI_5 = 0x17, + ANSI_Equal = 0x18, + ANSI_9 = 0x19, + ANSI_7 = 0x1A, + ANSI_Minus = 0x1B, + ANSI_8 = 0x1C, + ANSI_0 = 0x1D, + ANSI_RightBracket = 0x1E, + ANSI_O = 0x1F, + ANSI_U = 0x20, + ANSI_LeftBracket = 0x21, + ANSI_I = 0x22, + ANSI_P = 0x23, + ANSI_L = 0x25, + ANSI_J = 0x26, + ANSI_Quote = 0x27, + ANSI_K = 0x28, + ANSI_Semicolon = 0x29, + ANSI_Backslash = 0x2A, + ANSI_Comma = 0x2B, + ANSI_Slash = 0x2C, + ANSI_N = 0x2D, + ANSI_M = 0x2E, + ANSI_Period = 0x2F, + ANSI_Grave = 0x32, + ANSI_KeypadDecimal = 0x41, + ANSI_KeypadMultiply = 0x43, + ANSI_KeypadPlus = 0x45, + ANSI_KeypadClear = 0x47, + ANSI_KeypadDivide = 0x4B, + ANSI_KeypadEnter = 0x4C, + ANSI_KeypadMinus = 0x4E, + ANSI_KeypadEquals = 0x51, + ANSI_Keypad0 = 0x52, + ANSI_Keypad1 = 0x53, + ANSI_Keypad2 = 0x54, + ANSI_Keypad3 = 0x55, + ANSI_Keypad4 = 0x56, + ANSI_Keypad5 = 0x57, + ANSI_Keypad6 = 0x58, + ANSI_Keypad7 = 0x59, + ANSI_Keypad8 = 0x5B, + ANSI_Keypad9 = 0x5C, + Return = 0x24, + Tab = 0x30, + Space = 0x31, + Delete = 0x33, + Escape = 0x35, + Command = 0x37, + Shift = 0x38, + CapsLock = 0x39, + Option = 0x3A, + Control = 0x3B, + RightCommand = 0x36, + RightShift = 0x3C, + RightOption = 0x3D, + RightControl = 0x3E, + Function = 0x3F, + F17 = 0x40, + VolumeUp = 0x48, + VolumeDown = 0x49, + Mute = 0x4A, + F18 = 0x4F, + F19 = 0x50, + F20 = 0x5A, + F5 = 0x60, + F6 = 0x61, + F7 = 0x62, + F3 = 0x63, + F8 = 0x64, + F9 = 0x65, + F11 = 0x67, + F13 = 0x69, + F16 = 0x6A, + F14 = 0x6B, + F10 = 0x6D, + F12 = 0x6F, + F15 = 0x71, + Help = 0x72, + Home = 0x73, + PageUp = 0x74, + ForwardDelete = 0x75, + F4 = 0x76, + End = 0x77, + F2 = 0x78, + PageDown = 0x79, + F1 = 0x7A, + LeftArrow = 0x7B, + RightArrow = 0x7C, + DownArrow = 0x7D, + UpArrow = 0x7E, + JIS_Yen = 0x5D, + JIS_Underscore = 0x5E, + JIS_KeypadComma = 0x5F, + JIS_Eisu = 0x66, + JIS_Kana = 0x68, + ISO_Section = 0x0A, +} + + /* these messages are valid for all events */ @(objc_type=Event, objc_name="type") diff --git a/vendor/darwin/QuartzCore/QuartzCore.odin b/vendor/darwin/QuartzCore/QuartzCore.odin index 53dde3e94..93998d95d 100644 --- a/vendor/darwin/QuartzCore/QuartzCore.odin +++ b/vendor/darwin/QuartzCore/QuartzCore.odin @@ -55,7 +55,14 @@ MetalLayer_framebufferOnly :: proc "c" (self: ^MetalLayer) -> NS.BOOL { MetalLayer_setFramebufferOnly :: proc "c" (self: ^MetalLayer, ok: NS.BOOL) { msgSend(nil, self, "setFramebufferOnly:", ok) } - +@(objc_type=MetalLayer, objc_name="maximumDrawableCount") +MetalLayer_maximumDrawableCount :: proc "c" (self: ^MetalLayer) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maximumDrawableCount") +} +@(objc_type=MetalLayer, objc_name="setMaximumDrawableCount") +MetalLayer_setMaximumDrawableCount :: proc "c" (self: ^MetalLayer, count: NS.UInteger) { + msgSend(nil, self, "setMaximumDrawableCount:", count) +} @(objc_type=MetalLayer, objc_name="drawableSize") MetalLayer_drawableSize :: proc "c" (self: ^MetalLayer) -> NS.Size { @@ -65,7 +72,22 @@ MetalLayer_drawableSize :: proc "c" (self: ^MetalLayer) -> NS.Size { MetalLayer_setDrawableSize :: proc "c" (self: ^MetalLayer, drawableSize: NS.Size) { msgSend(nil, self, "setDrawableSize:", drawableSize) } - +@(objc_type=MetalLayer, objc_name="displaySyncEnabled") +MetalLayer_displaySyncEnabled :: proc "c" (self: ^MetalLayer) -> NS.BOOL { + return msgSend(NS.BOOL, self, "displaySyncEnabled") +} +@(objc_type=MetalLayer, objc_name="setDisplaySyncEnabled") +MetalLayer_setDisplaySyncEnabled :: proc "c" (self: ^MetalLayer, enabled: NS.BOOL) { + msgSend(nil, self, "setDisplaySyncEnabled:", enabled) +} +@(objc_type=MetalLayer, objc_name="presentsWithTransaction") +MetalLayer_presentsWithTransaction :: proc "c" (self: ^MetalLayer) -> NS.BOOL { + return msgSend(NS.BOOL, self, "presentsWithTransaction") +} +@(objc_type=MetalLayer, objc_name="setPresentsWithTransaction") +MetalLayer_setPresentsWithTransaction :: proc "c" (self: ^MetalLayer, enabled: NS.BOOL) { + msgSend(nil, self, "setPresentsWithTransaction:", enabled) +} @(objc_type=MetalLayer, objc_name="frame") MetalLayer_frame :: proc "c" (self: ^MetalLayer) -> NS.Rect { @@ -95,4 +117,11 @@ MetalDrawable_layer :: proc "c" (self: ^MetalDrawable) -> ^MetalLayer { @(objc_type=MetalDrawable, objc_name="texture") MetalDrawable_texture :: proc "c" (self: ^MetalDrawable) -> ^MTL.Texture { return msgSend(^MTL.Texture, self, "texture") -} \ No newline at end of file +} + +DrawablePresentedHandler :: ^NS.Block +@(objc_type=MetalDrawable, objc_name="addPresentedHandler") +MetalDrawable_addPresentedHandler :: proc "c" (self: ^MetalDrawable, block: DrawablePresentedHandler) { + msgSend(nil, self, "addPresentedHandler:", block) +} + From 64a63b38791947c5ae7c21fb355fc35d240dc47f Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sun, 3 Sep 2023 16:15:03 +0200 Subject: [PATCH 09/10] Add #reverse to `odin/parser`. --- core/odin/ast/ast.odin | 1 + core/odin/parser/parser.odin | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/core/odin/ast/ast.odin b/core/odin/ast/ast.odin index 58d977171..f2c3e029b 100644 --- a/core/odin/ast/ast.odin +++ b/core/odin/ast/ast.odin @@ -419,6 +419,7 @@ Range_Stmt :: struct { in_pos: tokenizer.Pos, expr: ^Expr, body: ^Stmt, + reverse: bool, } Inline_Range_Stmt :: struct { diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index 122e73b9c..da6530911 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -1431,6 +1431,18 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt { return es case "unroll": return parse_unrolled_for_loop(p, tag) + case "reverse": + stmt := parse_for_stmt(p) + + if range, is_range := stmt.derived.(^ast.Range_Stmt); is_range { + if range.reverse { + error(p, range.pos, "#reverse already applied to a 'for in' statement") + } + range.reverse = true + } else { + error(p, range.pos, "#reverse can only be applied to a 'for in' statement") + } + return stmt case "include": error(p, tag.pos, "#include is not a valid import declaration kind. Did you meant 'import'?") return ast.new(ast.Bad_Stmt, tok.pos, end_pos(tag)) From 12dd912ce9b52b0ab6b150ef50e886f1b48381c5 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Mon, 4 Sep 2023 20:48:03 +0200 Subject: [PATCH 10/10] fix commonmark import --- vendor/commonmark/cmark.odin | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vendor/commonmark/cmark.odin b/vendor/commonmark/cmark.odin index 1aced1efd..4de9b763e 100644 --- a/vendor/commonmark/cmark.odin +++ b/vendor/commonmark/cmark.odin @@ -17,9 +17,7 @@ when ODIN_OS == .Windows { "cmark_static.lib", } } else when ODIN_OS == .Linux { - foreign import lib { - "libcmark.a", - } + foreign import lib "system:cmark" } Option :: enum c.int {