Browse Source

Merge branch 'master' of https://github.com/odin-lang/Odin

gingerBill 1 year ago
parent
commit
c660b43105

+ 1 - 1
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) {

+ 1 - 1
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

+ 1 - 1
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)

+ 7 - 9
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),

+ 5 - 9
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), 

+ 5 - 12
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.

+ 1 - 0
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 {

+ 12 - 0
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))

+ 2 - 2
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,
 }
 

+ 1 - 1
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);

+ 1 - 3
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 {

+ 43 - 0
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 ---
+}
+

+ 5 - 2
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 {
@@ -124,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")

+ 7 - 3
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)

+ 124 - 0
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")

+ 9 - 1
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)
-}
+}
+@(objc_type=Window, objc_name="backingScaleFactor")
+Window_backingScaleFactor :: proc "c" (self: ^Window) -> Float {
+	return msgSend(Float, self, "backingScaleFactor")
+}

+ 32 - 3
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")
-}
+}
+
+DrawablePresentedHandler :: ^NS.Block
+@(objc_type=MetalDrawable, objc_name="addPresentedHandler")
+MetalDrawable_addPresentedHandler :: proc "c" (self: ^MetalDrawable, block: DrawablePresentedHandler) {
+	msgSend(nil, self, "addPresentedHandler:", block)
+}
+