Merge branch 'master' into windows-llvm-13.0.0

This commit is contained in:
gingerBill
2023-09-06 17:34:16 +01:00
33 changed files with 991 additions and 153 deletions

View File

@@ -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) {

View File

@@ -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

View File

@@ -327,7 +327,7 @@ ctprintf :: proc(format: string, args: ..any) -> cstring {
// Returns: A formatted string
//
sbprint :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
wprint(strings.to_writer(buf), ..args, sep=sep)
wprint(strings.to_writer(buf), ..args, sep=sep, flush=true)
return strings.to_string(buf^)
}
// Formats and writes to a strings.Builder buffer using the default print settings
@@ -340,7 +340,7 @@ sbprint :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
// Returns: The resulting formatted string
//
sbprintln :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
wprintln(strings.to_writer(buf), ..args, sep=sep)
wprintln(strings.to_writer(buf), ..args, sep=sep, flush=true)
return strings.to_string(buf^)
}
// Formats and writes to a strings.Builder buffer according to the specified format string
@@ -353,7 +353,7 @@ sbprintln :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
// Returns: The resulting formatted string
//
sbprintf :: proc(buf: ^strings.Builder, fmt: string, args: ..any) -> string {
wprintf(strings.to_writer(buf), fmt, ..args)
wprintf(strings.to_writer(buf), fmt, ..args, flush=true)
return strings.to_string(buf^)
}
// Formats and writes to an io.Writer using the default print settings
@@ -365,7 +365,7 @@ sbprintf :: proc(buf: ^strings.Builder, fmt: string, args: ..any) -> string {
//
// Returns: The number of bytes written
//
wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
wprint :: proc(w: io.Writer, args: ..any, sep := " ", flush := true) -> int {
fi: Info
fi.writer = w
@@ -391,7 +391,9 @@ wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
fmt_value(&fi, args[i], 'v')
}
io.flush(auto_cast w)
if flush {
io.flush(w)
}
return fi.n
}
@@ -404,7 +406,7 @@ wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
//
// Returns: The number of bytes written
//
wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
wprintln :: proc(w: io.Writer, args: ..any, sep := " ", flush := true) -> int {
fi: Info
fi.writer = w
@@ -416,7 +418,9 @@ wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
fmt_value(&fi, args[i], 'v')
}
io.write_byte(fi.writer, '\n', &fi.n)
io.flush(auto_cast w)
if flush {
io.flush(w)
}
return fi.n
}
// Formats and writes to an io.Writer according to the specified format string
@@ -428,7 +432,7 @@ wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
//
// Returns: The number of bytes written
//
wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int {
wprintf :: proc(w: io.Writer, fmt: string, args: ..any, flush := true) -> int {
fi: Info
arg_index: int = 0
end := len(fmt)
@@ -698,8 +702,9 @@ wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int {
}
io.write_string(fi.writer, ")", &fi.n)
}
io.flush(auto_cast w)
if flush {
io.flush(w)
}
return fi.n
}
@@ -711,9 +716,11 @@ wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int {
//
// Returns: The number of bytes written and an io.Error if encountered
//
wprint_type :: proc(w: io.Writer, info: ^runtime.Type_Info) -> (int, io.Error) {
wprint_type :: proc(w: io.Writer, info: ^runtime.Type_Info, flush := true) -> (int, io.Error) {
n, err := reflect.write_type(w, info)
io.flush(auto_cast w)
if flush {
io.flush(w)
}
return n, err
}
// Writes a typeid value to an io.Writer
@@ -724,9 +731,11 @@ wprint_type :: proc(w: io.Writer, info: ^runtime.Type_Info) -> (int, io.Error) {
//
// Returns: The number of bytes written and an io.Error if encountered
//
wprint_typeid :: proc(w: io.Writer, id: typeid) -> (int, io.Error) {
wprint_typeid :: proc(w: io.Writer, id: typeid, flush := true) -> (int, io.Error) {
n, err := reflect.write_type(w, type_info_of(id))
io.flush(auto_cast w)
if flush {
io.flush(w)
}
return n, err
}
// Parses an integer from a given string starting at a specified offset

View File

@@ -32,15 +32,15 @@ stderr := io.Writer{
}
// print formats using the default print settings and writes to stdout
print :: proc(args: ..any, sep := " ") -> int { return wprint(w=stdout, args=args, sep=sep) }
print :: proc(args: ..any, sep := " ", flush := true) -> int { return wprint(w=stdout, args=args, sep=sep, flush=flush) }
// println formats using the default print settings and writes to stdout
println :: proc(args: ..any, sep := " ") -> int { return wprintln(w=stdout, args=args, sep=sep) }
println :: proc(args: ..any, sep := " ", flush := true) -> int { return wprintln(w=stdout, args=args, sep=sep, flush=flush) }
// printf formats according to the specififed format string and writes to stdout
printf :: proc(fmt: string, args: ..any) -> int { return wprintf(stdout, fmt, ..args) }
printf :: proc(fmt: string, args: ..any, flush := true) -> int { return wprintf(stdout, fmt, ..args, flush=flush) }
// eprint formats using the default print settings and writes to stderr
eprint :: proc(args: ..any, sep := " ") -> int { return wprint(w=stderr, args=args, sep=sep) }
eprint :: proc(args: ..any, sep := " ", flush := true) -> int { return wprint(w=stderr, args=args, sep=sep, flush=flush) }
// eprintln formats using the default print settings and writes to stderr
eprintln :: proc(args: ..any, sep := " ") -> int { return wprintln(w=stderr, args=args, sep=sep) }
eprintln :: proc(args: ..any, sep := " ", flush := true) -> int { return wprintln(w=stderr, args=args, sep=sep, flush=flush) }
// eprintf formats according to the specififed format string and writes to stderr
eprintf :: proc(fmt: string, args: ..any) -> int { return wprintf(stderr, fmt, ..args) }
eprintf :: proc(fmt: string, args: ..any, flush := true) -> int { return wprintf(stderr, fmt, ..args, flush=flush) }

View File

@@ -7,18 +7,18 @@ import "core:io"
import "core:bufio"
// fprint formats using the default print settings and writes to fd
fprint :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
fprint :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true) -> int {
buf: [1024]byte
b: bufio.Writer
defer bufio.writer_flush(&b)
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
w := bufio.writer_to_writer(&b)
return wprint(w, ..args, sep=sep)
return wprint(w, ..args, sep=sep, flush=flush)
}
// fprintln formats using the default print settings and writes to fd
fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
fprintln :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true) -> int {
buf: [1024]byte
b: bufio.Writer
defer bufio.writer_flush(&b)
@@ -26,10 +26,10 @@ fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
w := bufio.writer_to_writer(&b)
return wprintln(w, ..args, sep=sep)
return wprintln(w, ..args, sep=sep, flush=flush)
}
// fprintf formats according to the specified format string and writes to fd
fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int {
fprintf :: proc(fd: os.Handle, fmt: string, args: ..any, flush := true) -> int {
buf: [1024]byte
b: bufio.Writer
defer bufio.writer_flush(&b)
@@ -37,9 +37,9 @@ fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int {
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
w := bufio.writer_to_writer(&b)
return wprintf(w, fmt, ..args)
return wprintf(w, fmt, ..args, flush=flush)
}
fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io.Error) {
fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info, flush := true) -> (n: int, err: io.Error) {
buf: [1024]byte
b: bufio.Writer
defer bufio.writer_flush(&b)
@@ -47,9 +47,9 @@ fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
w := bufio.writer_to_writer(&b)
return wprint_type(w, info)
return wprint_type(w, info, flush=flush)
}
fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) {
fprint_typeid :: proc(fd: os.Handle, id: typeid, flush := true) -> (n: int, err: io.Error) {
buf: [1024]byte
b: bufio.Writer
defer bufio.writer_flush(&b)
@@ -57,19 +57,19 @@ fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) {
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
w := bufio.writer_to_writer(&b)
return wprint_typeid(w, id)
return wprint_typeid(w, id, flush=flush)
}
// print formats using the default print settings and writes to os.stdout
print :: proc(args: ..any, sep := " ") -> int { return fprint(os.stdout, ..args, sep=sep) }
print :: proc(args: ..any, sep := " ", flush := true) -> int { return fprint(os.stdout, ..args, sep=sep, flush=flush) }
// println formats using the default print settings and writes to os.stdout
println :: proc(args: ..any, sep := " ") -> int { return fprintln(os.stdout, ..args, sep=sep) }
println :: proc(args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stdout, ..args, sep=sep, flush=flush) }
// printf formats according to the specified format string and writes to os.stdout
printf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args) }
printf :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stdout, fmt, ..args, flush=flush) }
// eprint formats using the default print settings and writes to os.stderr
eprint :: proc(args: ..any, sep := " ") -> int { return fprint(os.stderr, ..args, sep=sep) }
eprint :: proc(args: ..any, sep := " ", flush := true) -> int { return fprint(os.stderr, ..args, sep=sep, flush=flush) }
// eprintln formats using the default print settings and writes to os.stderr
eprintln :: proc(args: ..any, sep := " ") -> int { return fprintln(os.stderr, ..args, sep=sep) }
eprintln :: proc(args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stderr, ..args, sep=sep, flush=flush) }
// eprintf formats according to the specified format string and writes to os.stderr
eprintf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args) }
eprintf :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stderr, fmt, ..args, flush=flush) }

View File

@@ -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)

View File

@@ -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),

View File

@@ -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),

View File

@@ -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.

View File

@@ -419,6 +419,7 @@ Range_Stmt :: struct {
in_pos: tokenizer.Pos,
expr: ^Expr,
body: ^Stmt,
reverse: bool,
}
Inline_Range_Stmt :: struct {

View File

@@ -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))

View File

@@ -601,14 +601,15 @@ assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #c
@builtin
assign_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error {
if len(args) == 0 {
new_size := index + len(arg)
if len(arg) == 0 {
ok = true
} else if index+len(args) < len(array) {
copy(array[index:], args)
} else if new_size < len(array) {
copy(array[index:], arg)
ok = true
} else {
resize(array, index+1+len(args), loc) or_return
copy(array[index:], args)
resize(array, new_size, loc) or_return
copy(array[index:], arg)
ok = true
}
return

View File

@@ -259,7 +259,7 @@ _quick_sort :: proc(it: Interface, a, b, max_depth: int) {
a, b, max_depth := a, b, max_depth
if b-a > 12 { // only use shell sort for lengths <= 12
for b-a > 12 { // only use shell sort for lengths <= 12
if max_depth == 0 {
heap_sort(it, a, b)
return

View File

@@ -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,
}

View File

@@ -2,9 +2,10 @@
rem call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 1> NUL
rem call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64 1> NUL
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 1> NUL
rem call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 1> NUL
rem call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 1> NUL
rem call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 1> NUL
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 1> NUL
set _NO_DEBUG_HEAP=1
set ODIN_IGNORE_MSVC_CHECK=1

View File

@@ -629,6 +629,9 @@ gb_internal i64 check_distance_between_types(CheckerContext *c, Operand *operand
if (operand->mode == Addressing_Type) {
if (is_type_typeid(type)) {
if (is_type_polymorphic(operand->type)) {
return -1;
}
add_type_info_type(c, operand->type);
return 4;
}
@@ -1118,10 +1121,17 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ
LIT(context_name));
break;
case Addressing_Type:
error(operand->expr,
"Cannot assign '%s' which is a type in %.*s",
op_type_str,
LIT(context_name));
if (is_type_polymorphic(operand->type)) {
error(operand->expr,
"Cannot assign '%s' which is a polymorphic type in %.*s",
op_type_str,
LIT(context_name));
} else {
error(operand->expr,
"Cannot assign '%s' which is a type in %.*s",
op_type_str,
LIT(context_name));
}
break;
default:
// TODO(bill): is this a good enough error message?
@@ -7927,7 +7937,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);

View File

@@ -1922,6 +1922,12 @@ gb_internal void add_type_info_type_internal(CheckerContext *c, Type *t) {
for_array(i, bt->Union.variants) {
add_type_info_type_internal(c, bt->Union.variants[i]);
}
if (bt->Union.scope != nullptr) {
for (auto const &entry : bt->Union.scope->elements) {
Entity *e = entry.value;
add_type_info_type_internal(c, e->type);
}
}
break;
case Type_Struct:
@@ -2265,7 +2271,6 @@ gb_internal void add_dependency_to_set(Checker *c, Entity *entity) {
if (decl == nullptr) {
return;
}
for (Type *t : decl->type_info_deps) {
add_min_dep_type_info(c, t);
}
@@ -4505,6 +4510,23 @@ gb_internal String get_invalid_import_name(String input) {
return input;
}
gb_internal DECL_ATTRIBUTE_PROC(import_decl_attribute) {
if (name == ATTRIBUTE_USER_TAG_NAME) {
ExactValue ev = check_decl_attribute_value(c, value);
if (ev.kind != ExactValue_String) {
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "require") {
if (value != nullptr) {
error(elem, "Expected no parameter for '%.*s'", LIT(name));
}
ac->require_declaration = true;
return true;
}
return false;
}
gb_internal void check_add_import_decl(CheckerContext *ctx, Ast *decl) {
if (decl->state_flags & StateFlag_BeenHandled) return;
decl->state_flags |= StateFlag_BeenHandled;
@@ -4553,10 +4575,12 @@ gb_internal void check_add_import_decl(CheckerContext *ctx, Ast *decl) {
force_use = true;
}
// NOTE(bill, 2019-05-19): If the directory path is not a valid entity name, force the user to assign a custom one
// if (import_name.len == 0 || import_name == "_") {
// import_name = scope->pkg->name;
// }
AttributeContext ac = {};
check_decl_attributes(ctx, id->attributes, import_decl_attribute, &ac);
if (ac.require_declaration) {
force_use = true;
}
if (import_name.len == 0) {
String invalid_name = id->fullpath;

View File

@@ -1094,8 +1094,11 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
}
if (is_constant) {
LLVMValueRef elem_value = lb_const_value(m, tav.type, tav.value, allow_local).value;
GB_ASSERT(LLVMIsConstant(elem_value));
values[index] = LLVMConstInsertValue(values[index], elem_value, idx_list, idx_list_len);
if (LLVMIsConstant(elem_value)) {
values[index] = LLVMConstInsertValue(values[index], elem_value, idx_list, idx_list_len);
} else {
is_constant = false;
}
}
}
}

View File

@@ -1212,6 +1212,7 @@ gb_internal Ast *ast_import_decl(AstFile *f, Token token, Token relpath, Token i
result->ImportDecl.import_name = import_name;
result->ImportDecl.docs = docs;
result->ImportDecl.comment = comment;
result->ImportDecl.attributes.allocator = ast_allocator(f);
return result;
}
@@ -4634,7 +4635,9 @@ gb_internal Ast *parse_attribute(AstFile *f, Token token, TokenKind open_kind, T
array_add(&decl->ForeignBlockDecl.attributes, attribute);
} else if (decl->kind == Ast_ForeignImportDecl) {
array_add(&decl->ForeignImportDecl.attributes, attribute);
}else {
} else if (decl->kind == Ast_ImportDecl) {
array_add(&decl->ImportDecl.attributes, attribute);
} else {
syntax_error(decl, "Expected a value or foreign declaration after an attribute, got %.*s", LIT(ast_strings[decl->kind]));
return ast_bad_stmt(f, token, f->curr_token);
}

View File

@@ -617,6 +617,7 @@ AST_KIND(_DeclBegin, "", bool) \
Token relpath; \
String fullpath; \
Token import_name; \
Array<Ast *> attributes; \
CommentGroup *docs; \
CommentGroup *comment; \
}) \

View File

@@ -416,6 +416,9 @@ struct TB_Node {
uint16_t input_count; // number of node inputs
uint16_t extra_count; // number of bytes for extra operand data
// local to the TB_Passes
uint32_t lattice_id;
TB_Attrib* attribs;
TB_Node** inputs;
@@ -429,8 +432,9 @@ struct TB_Node {
// this represents switch (many targets), if (one target) and goto (only default) logic.
typedef struct { // TB_BRANCH
// avoid empty structs with flexible members
int64_t _;
size_t succ_count;
TB_Node** succ;
int64_t keys[];
} TB_NodeBranch;
@@ -464,11 +468,6 @@ typedef struct {
TB_CharUnits size, align;
} TB_NodeLocal;
typedef struct {
TB_SourceFile* file;
int line, column;
} TB_NodeLine;
typedef struct {
float value;
} TB_NodeFloat32;
@@ -510,12 +509,6 @@ typedef struct {
// immediate dominator (can be approximate)
int dom_depth;
TB_Node* dom;
size_t succ_count;
TB_Node** succ;
size_t proj_count;
TB_Node** projs;
} TB_NodeRegion;
typedef struct TB_MultiOutput {
@@ -648,6 +641,22 @@ TB_API TB_Assembly* tb_output_get_asm(TB_FunctionOutput* out);
// this is relative to the start of the function (the start of the prologue)
TB_API TB_Safepoint* tb_safepoint_get(TB_Function* f, uint32_t relative_ip);
////////////////////////////////
// JIT compilation
////////////////////////////////
typedef struct TB_JIT TB_JIT;
// passing 0 to jit_heap_capacity will default to 4MiB
TB_API TB_JIT* tb_jit_begin(TB_Module* m, size_t jit_heap_capacity);
TB_API void* tb_jit_place_function(TB_JIT* jit, TB_Function* f);
TB_API void* tb_jit_place_global(TB_JIT* jit, TB_Global* g);
TB_API void tb_jit_end(TB_JIT* jit);
TB_API void* tb_jit_get_code_ptr(TB_Function* f);
// Generates a 2MiB stack
TB_API void* tb_jit_stack_create(size_t* out_size);
////////////////////////////////
// Exporter
////////////////////////////////
@@ -716,18 +725,8 @@ TB_API void tb_linker_append_object(TB_Linker* l, TB_Slice obj_name, TB_Slice co
TB_API void tb_linker_append_library(TB_Linker* l, TB_Slice ar_name, TB_Slice content);
////////////////////////////////
// JIT compilation
// Symbols
////////////////////////////////
typedef struct TB_JITContext TB_JITContext;
// passing 0 to jit_heap_capacity will default to 4MiB
TB_API TB_JITContext* tb_module_begin_jit(TB_Module* m, size_t jit_heap_capacity);
TB_API void* tb_module_apply_function(TB_JITContext* jit, TB_Function* f);
TB_API void* tb_module_apply_global(TB_JITContext* jit, TB_Global* g);
// fixes page permissions, applies missing relocations
TB_API void tb_module_ready_jit(TB_JITContext* jit);
TB_API void tb_module_end_jit(TB_JITContext* jit);
#define TB_FOR_FUNCTIONS(it, module) for (TB_Function* it = tb_first_function(module); it != NULL; it = tb_next_function(it))
TB_API TB_Function* tb_first_function(TB_Module* m);
TB_API TB_Function* tb_next_function(TB_Function* f);
@@ -889,7 +888,6 @@ TB_API void tb_inst_reset_location(TB_Function* f);
TB_API TB_Function* tb_function_create(TB_Module* m, ptrdiff_t len, const char* name, TB_Linkage linkage, TB_ComdatType comdat);
TB_API TB_Arena* tb_function_get_arena(TB_Function* f);
TB_API void* tb_function_get_jit_pos(TB_Function* f);
// if len is -1, it's null terminated
TB_API void tb_symbol_set_name(TB_Symbol* s, ptrdiff_t len, const char* name);
@@ -909,7 +907,7 @@ TB_API TB_Node* tb_inst_get_control(TB_Function* f);
TB_API TB_Node* tb_inst_region(TB_Function* f);
// if len is -1, it's null terminated
TB_API void tb_inst_set_region_name(TB_Module* m, TB_Node* n, ptrdiff_t len, const char* name);
TB_API void tb_inst_set_region_name(TB_Function* f, TB_Node* n, ptrdiff_t len, const char* name);
TB_API void tb_inst_unreachable(TB_Function* f);
TB_API void tb_inst_debugbreak(TB_Function* f);
@@ -1048,7 +1046,7 @@ TB_API TB_Node* tb_inst_syscall(TB_Function* f, TB_DataType dt, TB_Node* syscall
TB_API TB_MultiOutput tb_inst_call(TB_Function* f, TB_FunctionPrototype* proto, TB_Node* target, size_t param_count, TB_Node** params);
// Managed
TB_API TB_Node* tb_inst_safepoint(TB_Function* f, size_t param_count, TB_Node** params);
TB_API TB_Node* tb_inst_safepoint(TB_Function* f, TB_Node* poke_site, size_t param_count, TB_Node** params);
TB_API TB_Node* tb_inst_incomplete_phi(TB_Function* f, TB_DataType dt, TB_Node* region, size_t preds);
TB_API bool tb_inst_add_phi_operand(TB_Function* f, TB_Node* phi, TB_Node* region, TB_Node* val);

Binary file not shown.

View File

@@ -15,7 +15,7 @@ gb_internal TB_Node *cg_control_region(cgProcedure *p, char const *name) {
n = -1 + gb_snprintf(new_name, n+11, "%.*s_%u", cast(int)n, name, p->control_regions.count);
TB_Node *region = tb_inst_region(p->func);
tb_inst_set_region_name(p->module->mod, region, n, new_name);
tb_inst_set_region_name(p->func, region, n, new_name);
GB_ASSERT(p->scope_index >= 0);
array_add(&p->control_regions, cgControlRegion{region, p->scope_index});

View File

@@ -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 {

View File

@@ -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 ---
}

View File

@@ -1,9 +1,21 @@
package objc_Foundation
foreign import "system:Foundation.framework"
import "core:intrinsics"
import "core:runtime"
import "core:strings"
RunLoopMode :: ^String
@(link_prefix="NS")
foreign Foundation {
RunLoopCommonModes: RunLoopMode
DefaultRunLoopMode: RunLoopMode
EventTrackingRunLoopMode: RunLoopMode
ModalPanelRunLoopMode: RunLoopMode
}
ActivationPolicy :: enum UInteger {
Regular = 0,
Accessory = 1,
@@ -87,12 +99,34 @@ Application_run :: proc "c" (self: ^Application) {
msgSend(nil, self, "run")
}
@(objc_type=Application, objc_name="terminate")
Application_terminate :: proc "c" (self: ^Application, sender: ^Object) {
msgSend(nil, self, "terminate:", sender)
}
@(objc_type=Application, objc_name="isRunning")
Application_isRunning :: proc "c" (self: ^Application) -> BOOL {
return msgSend(BOOL, self, "isRunning")
}
@(objc_type=Application, objc_name="currentEvent")
Application_currentEvent :: proc "c" (self: ^Application) -> ^Event {
return msgSend(^Event, self, "currentEvent")
}
@(objc_type=Application, objc_name="nextEventMatchingMask")
Application_nextEventMatchingMask :: proc "c" (self: ^Application, mask: EventMask, expiration: ^Date, in_mode: RunLoopMode, dequeue: BOOL) -> ^Event {
return msgSend(^Event, self, "nextEventMatchingMask:untilDate:inMode:dequeue:", mask, expiration, in_mode, dequeue)
}
@(objc_type=Application, objc_name="sendEvent")
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")

View File

@@ -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)

149
vendor/darwin/Foundation/NSColor.odin vendored Normal file
View File

@@ -0,0 +1,149 @@
package objc_Foundation
@(objc_class="NSColorSpace")
ColorSpace :: struct {using _: Object}
@(objc_class="NSColor")
Color :: struct {using _: Object}
@(objc_type=Color, objc_name="colorWithSRGBRed", objc_is_class_method=true)
Color_colorWithSRGBRed :: proc "c" (red, green, blue, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithSRGBRed:green:blue:alpha:", red, green, blue, alpha)
}
@(objc_type=Color, objc_name="colorWithCalibratedHue", objc_is_class_method=true)
Color_colorWithCalibratedHue :: proc "c" (hue, saturation, brightness, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithCalibratedHue:hue:saturation:brightness:alpha:", hue, saturation, brightness, alpha)
}
@(objc_type=Color, objc_name="colorWithCalibratedRed", objc_is_class_method=true)
Color_colorWithCalibratedRed :: proc "c" (red, green, blue, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithCalibratedRed:green:blue:alpha:", red, green, blue, alpha)
}
@(objc_type=Color, objc_name="colorWithCalibratedWhite", objc_is_class_method=true)
Color_colorWithCalibratedWhite :: proc "c" (white, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithCalibratedWhite:alpha:", white, alpha)
}
@(objc_type=Color, objc_name="colorWithDeviceCyan", objc_is_class_method=true)
Color_colorWithDeviceCyan :: proc "c" (cyan, magenta, yellow, black, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithDeviceCyan:magenta:yellow:black:", cyan, magenta, yellow, black)
}
@(objc_type=Color, objc_name="colorWithDeviceHue", objc_is_class_method=true)
Color_colorWithDeviceHue :: proc "c" (hue, saturation, brightness, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithDeviceHue:hue:saturation:brightness:alpha:", hue, saturation, brightness, alpha)
}
@(objc_type=Color, objc_name="colorWithDeviceRed", objc_is_class_method=true)
Color_colorWithDeviceRed :: proc "c" (red, green, blue, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithDeviceRed:green:blue:alpha:", red, green, blue, alpha)
}
@(objc_type=Color, objc_name="colorWithDeviceWhite", objc_is_class_method=true)
Color_colorWithDeviceWhite :: proc "c" (white, alpha: Float) -> ^Color {
return msgSend(^Color, Color, "colorWithDeviceWhite:alpha:", white, alpha)
}
@(objc_type=Color, objc_name="blackColor", objc_is_class_method=true)
Color_blackColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "blackColor")
}
@(objc_type=Color, objc_name="whiteColor", objc_is_class_method=true)
Color_whiteColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "whiteColor")
}
@(objc_type=Color, objc_name="redColor", objc_is_class_method=true)
Color_redColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "redColor")
}
@(objc_type=Color, objc_name="greenColor", objc_is_class_method=true)
Color_greenColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "greenColor")
}
@(objc_type=Color, objc_name="orangeColor", objc_is_class_method=true)
Color_orangeColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "orangeColor")
}
@(objc_type=Color, objc_name="purpleColor", objc_is_class_method=true)
Color_purpleColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "purpleColor")
}
@(objc_type=Color, objc_name="cyanColor", objc_is_class_method=true)
Color_cyanColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "cyanColor")
}
@(objc_type=Color, objc_name="blueColor", objc_is_class_method=true)
Color_blueColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "blueColor")
}
@(objc_type=Color, objc_name="magentaColor", objc_is_class_method=true)
Color_magentaColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "magentaColor")
}
@(objc_type=Color, objc_name="yellowColor", objc_is_class_method=true)
Color_yellowColor :: proc "c" () -> ^Color {
return msgSend(^Color, Color, "yellowColor")
}
@(objc_type=Color, objc_name="getCMYKA")
Color_getCMYKA :: proc "c" (self: ^Color) -> (cyan, magenta, yellow, black, alpha: Float) {
msgSend(nil, Color, "getCyan:magenta:yellow:black:alpha:", &cyan, &magenta, &yellow, &black, &alpha)
return
}
@(objc_type=Color, objc_name="getHSBA")
Color_getHSBA :: proc "c" (self: ^Color) -> (hue, saturation, brightness, alpha: Float) {
msgSend(nil, Color, "getHue:saturation:brightness:alpha:", &hue, &saturation, &brightness, &alpha)
return
}
@(objc_type=Color, objc_name="getRGBA")
Color_getRGBA :: proc "c" (self: ^Color) -> (red, green, blue, alpha: Float) {
msgSend(nil, Color, "getRed:green:blue:alpha:", &red, &green, &blue, &alpha)
return
}
@(objc_type=Color, objc_name="getWhiteAlpha")
Color_getWhiteAlpha :: proc "c" (self: ^Color) -> (white, alpha: Float) {
msgSend(nil, Color, "getWhite:alpha:", &white, &alpha)
return
}
@(objc_type=Color, objc_name="colorWithColorSpace", objc_is_class_method=true)
Color_colorWithColorSpace :: proc "c" (space: ^ColorSpace, components: []Float) -> ^Color {
return msgSend(^Color, Color, "colorWithColorSpace:components:count", space, raw_data(components), Integer(len(components)))
}
@(objc_type=Color, objc_name="colorSpaceName")
Color_colorSpaceName :: proc "c" (self: ^Color) -> ^String {
return msgSend(^String, self, "colorSpaceName")
}
@(objc_type=Color, objc_name="colorSpace")
Color_colorSpace :: proc "c" (self: ^Color) -> ^ColorSpace {
return msgSend(^ColorSpace, self, "colorSpace")
}
@(objc_type=Color, objc_name="colorUsingColorSpaceName")
Color_colorUsingColorSpaceName :: proc "c" (self: ^Color, colorSpace: ^String, device: ^Dictionary = nil) -> ^Color {
if device != nil {
return msgSend(^Color, self, "colorUsingColorSpaceName:device:", colorSpace, device)
}
return msgSend(^Color, self, "colorUsingColorSpaceName:", colorSpace)
}
@(objc_type=Color, objc_name="numberOfComponents")
Color_numberOfComponents :: proc "c" (self: ^Color) -> Integer {
return msgSend(Integer, self, "numberOfComponents")
}
@(objc_type=Color, objc_name="getComponents")
Color_getComponents :: proc "c" (self: ^Color, components: [^]Float) {
msgSend(nil, self, "getComponents:", components)
}

View File

@@ -2,4 +2,465 @@ package objc_Foundation
@(objc_class="NSEvent")
Event :: struct {using _: Object}
// TODO: implement NSEvent
EventMask :: distinct bit_set[EventType; UInteger]
EventMaskAny :: ~EventMask{}
when size_of(UInteger) == 4 {
// We don't support a 32-bit darwin system but this is mostly to shut up the type checker for the time being
EventType :: enum UInteger {
LeftMouseDown = 1,
LeftMouseUp = 2,
RightMouseDown = 3,
RightMouseUp = 4,
MouseMoved = 5,
LeftMouseDragged = 6,
RightMouseDragged = 7,
MouseEntered = 8,
MouseExited = 9,
KeyDown = 10,
KeyUp = 11,
FlagsChanged = 12,
AppKitDefined = 13,
SystemDefined = 14,
ApplicationDefined = 15,
Periodic = 16,
CursorUpdate = 17,
Rotate = 18,
BeginGesture = 19,
EndGesture = 20,
ScrollWheel = 22,
TabletPoint = 23,
TabletProximity = 24,
OtherMouseDown = 25,
OtherMouseUp = 26,
OtherMouseDragged = 27,
Gesture = 29,
Magnify = 30,
Swipe = 31,
}
} else {
EventType :: enum UInteger {
LeftMouseDown = 1,
LeftMouseUp = 2,
RightMouseDown = 3,
RightMouseUp = 4,
MouseMoved = 5,
LeftMouseDragged = 6,
RightMouseDragged = 7,
MouseEntered = 8,
MouseExited = 9,
KeyDown = 10,
KeyUp = 11,
FlagsChanged = 12,
AppKitDefined = 13,
SystemDefined = 14,
ApplicationDefined = 15,
Periodic = 16,
CursorUpdate = 17,
Rotate = 18,
BeginGesture = 19,
EndGesture = 20,
ScrollWheel = 22,
TabletPoint = 23,
TabletProximity = 24,
OtherMouseDown = 25,
OtherMouseUp = 26,
OtherMouseDragged = 27,
Gesture = 29,
Magnify = 30,
Swipe = 31,
SmartMagnify = 32,
QuickLook = 33,
Pressure = 34,
DirectTouch = 37,
ChangeMode = 38,
}
}
EventPhase :: distinct bit_set[EventPhaseFlag; UInteger]
EventPhaseFlag :: enum UInteger {
Began = 0,
Stationary = 1,
Changed = 2,
Ended = 3,
Cancelled = 4,
MayBegin = 5,
}
EventPhaseNone :: EventPhase{}
EventPhaseBegan :: EventPhase{.Began}
EventPhaseStationary :: EventPhase{.Stationary}
EventPhaseChanged :: EventPhase{.Changed}
EventPhaseEnded :: EventPhase{.Ended}
EventPhaseCancelled :: EventPhase{.Cancelled}
EventPhaseMayBegin :: EventPhase{.MayBegin}
/* pointer types for NSTabletProximity events or mouse events with subtype NSTabletProximityEventSubtype*/
PointingDeviceType :: enum UInteger {
Unknown = 0,
Pen = 1,
Cursor = 2,
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")
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")
}
@(objc_type=Event, objc_name="timestamp")
Event_timestamp :: proc "c" (self: ^Event) -> TimeInterval {
return msgSend(TimeInterval, self, "timestamp")
}
@(objc_type=Event, objc_name="window")
Event_window :: proc "c" (self: ^Event) -> ^Window {
return msgSend(^Window, self, "window")
}
@(objc_type=Event, objc_name="windowNumber")
Event_windowNumber :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "windowNumber")
}
/* these messages are valid for all mouse down/up/drag events */
@(objc_type=Event, objc_name="clickCount")
Event_clickCount :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "clickCount")
}
// for NSOtherMouse events, but will return valid constants for NSLeftMouse and NSRightMouse
@(objc_type=Event, objc_name="buttonNumber")
Event_buttonNumber :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "buttonNumber")
}
/* these messages are valid for all mouse down/up/drag and enter/exit events */
@(objc_type=Event, objc_name="eventNumber")
Event_eventNumber :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "eventNumber")
}
/* -pressure is valid for all mouse down/up/drag events, and is also valid for NSTabletPoint events on 10.4 or later */
@(objc_type=Event, objc_name="pressure")
Event_pressure :: proc "c" (self: ^Event) -> f32 {
return msgSend(f32, self, "pressure")
}
/* -locationInWindow is valid for all mouse-related events */
@(objc_type=Event, objc_name="locationInWindow")
Event_locationInWindow :: proc "c" (self: ^Event) -> Point {
return msgSend(Point, self, "locationInWindow")
}
@(objc_type=Event, objc_name="deltaX")
Event_deltaX :: proc "c" (self: ^Event) -> Float {
return msgSend(Float, self, "deltaX")
}
@(objc_type=Event, objc_name="deltaY")
Event_deltaY :: proc "c" (self: ^Event) -> Float {
return msgSend(Float, self, "deltaY")
}
@(objc_type=Event, objc_name="deltaZ")
Event_deltaZ :: proc "c" (self: ^Event) -> Float {
return msgSend(Float, self, "deltaZ")
}
@(objc_type=Event, objc_name="delta")
Event_delta :: proc "c" (self: ^Event) -> (x, y, z: Float) {
x = self->deltaX()
y = self->deltaY()
z = self->deltaZ()
return
}
@(objc_type=Event, objc_name="hasPreciseScrollingDeltas")
Event_hasPreciseScrollingDeltas :: proc "c" (self: ^Event) -> BOOL {
return msgSend(BOOL, self, "hasPreciseScrollingDeltas")
}
@(objc_type=Event, objc_name="scrollingDeltaX")
Event_scrollingDeltaX :: proc "c" (self: ^Event) -> Float {
return msgSend(Float, self, "scrollingDeltaX")
}
@(objc_type=Event, objc_name="scrollingDeltaY")
Event_scrollingDeltaY :: proc "c" (self: ^Event) -> Float {
return msgSend(Float, self, "scrollingDeltaY")
}
@(objc_type=Event, objc_name="scrollingDelta")
Event_scrollingDelta :: proc "c" (self: ^Event) -> (x, y: Float) {
x = self->scrollingDeltaX()
y = self->scrollingDeltaY()
return
}
@(objc_type=Event, objc_name="momentumPhase")
Event_momentumPhase :: proc "c" (self: ^Event) -> EventPhase {
return msgSend(EventPhase, self, "momentumPhase")
}
@(objc_type=Event, objc_name="phase")
Event_phase :: proc "c" (self: ^Event) -> EventPhase {
return msgSend(EventPhase, self, "phase")
}
@(objc_type=Event, objc_name="isDirectionInvertedFromDevice")
Event_isDirectionInvertedFromDevice :: proc "c" (self: ^Event) -> BOOL {
return msgSend(BOOL, self, "isDirectionInvertedFromDevice")
}
@(objc_type=Event, objc_name="characters")
Event_characters :: proc "c" (self: ^Event) -> ^String {
return msgSend(^String, self, "characters")
}
@(objc_type=Event, objc_name="charactersIgnoringModifiers")
Event_charactersIgnoringModifiers :: proc "c" (self: ^Event) -> ^String {
return msgSend(^String, self, "charactersIgnoringModifiers")
}
@(objc_type=Event, objc_name="isARepeat")
Event_isARepeat :: proc "c" (self: ^Event) -> BOOL {
return msgSend(BOOL, self, "isARepeat")
}
@(objc_type=Event, objc_name="keyCode")
Event_keyCode :: proc "c" (self: ^Event) -> u16 {
return msgSend(u16, self, "keyCode")
}
@(objc_type=Event, objc_name="subtype")
Event_subtype :: proc "c" (self: ^Event) -> i16 {
return msgSend(i16, self, "subtype")
}
@(objc_type=Event, objc_name="data1")
Event_data1 :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "data1")
}
@(objc_type=Event, objc_name="data2")
Event_data2 :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "data2")
}
@(objc_type=Event, objc_name="absoluteX")
Event_absoluteX :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "absoluteX")
}
@(objc_type=Event, objc_name="absoluteY")
Event_absoluteY :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "absoluteY")
}
@(objc_type=Event, objc_name="absoluteZ")
Event_absoluteZ :: proc "c" (self: ^Event) -> Integer {
return msgSend(Integer, self, "absoluteZ")
}
@(objc_type=Event, objc_name="absolute")
Event_absolute :: proc "c" (self: ^Event) -> (x, y, z: Integer) {
x = self->absoluteX()
y = self->absoluteY()
z = self->absoluteZ()
return
}
@(objc_type=Event, objc_name="buttonMask")
Event_buttonMask :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "buttonMask")
}
@(objc_type=Event, objc_name="tilt")
tilt :: proc "c" (self: ^Event) -> Point {
return msgSend(Point, self, "tilt")
}
@(objc_type=Event, objc_name="tangentialPressure")
Event_tangentialPressure :: proc "c" (self: ^Event) -> f32 {
return msgSend(f32, self, "tangentialPressure")
}
@(objc_type=Event, objc_name="vendorDefined")
Event_vendorDefined :: proc "c" (self: ^Event) -> id {
return msgSend(id, self, "vendorDefined")
}
@(objc_type=Event, objc_name="vendorID")
Event_vendorID :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "vendorID")
}
@(objc_type=Event, objc_name="tabletID")
Event_tabletID :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "tabletID")
}
@(objc_type=Event, objc_name="pointingDeviceID")
Event_pointingDeviceID :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "pointingDeviceID")
}
@(objc_type=Event, objc_name="systemTabletID")
Event_systemTabletID :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "systemTabletID")
}
@(objc_type=Event, objc_name="vendorPointingDeviceType")
Event_vendorPointingDeviceType :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "vendorPointingDeviceType")
}
@(objc_type=Event, objc_name="pointingDeviceSerialNumber")
Event_pointingDeviceSerialNumber :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "pointingDeviceSerialNumber")
}
@(objc_type=Event, objc_name="uniqueID")
Event_uniqueID :: proc "c" (self: ^Event) -> u64 {
return msgSend(u64, self, "uniqueID")
}
@(objc_type=Event, objc_name="capabilityMask")
Event_capabilityMask :: proc "c" (self: ^Event) -> UInteger {
return msgSend(UInteger, self, "capabilityMask")
}
@(objc_type=Event, objc_name="pointingDeviceType")
Event_pointingDeviceType :: proc "c" (self: ^Event) -> PointingDeviceType {
return msgSend(PointingDeviceType, self, "pointingDeviceType")
}
@(objc_type=Event, objc_name="isEnteringProximity")
Event_isEnteringProximity :: proc "c" (self: ^Event) -> BOOL {
return msgSend(BOOL, self, "isEnteringProximity")
}
@(objc_type=Event, objc_name="isSwipeTrackingFromScrollEventsEnabled")
Event_isSwipeTrackingFromScrollEventsEnabled :: proc "c" (self: ^Event) -> BOOL {
return msgSend(BOOL, self, "isSwipeTrackingFromScrollEventsEnabled")
}

View File

@@ -2,4 +2,32 @@ package objc_Foundation
@(objc_class="NSScreen")
Screen :: struct {using _: Object}
// TODO: implement NSScreen
@(objc_type=Screen, objc_name="mainScreen")
Screen_mainScreen :: proc "c" () -> ^Screen {
return msgSend(^Screen, Screen, "mainScreen")
}
@(objc_type=Screen, objc_name="deepestScreen")
Screen_deepestScreen :: proc "c" () -> ^Screen {
return msgSend(^Screen, Screen, "deepestScreen")
}
@(objc_type=Screen, objc_name="screens")
Screen_screens :: proc "c" () -> ^Array {
return msgSend(^Array, Screen, "screens")
}
@(objc_type=Screen, objc_name="frame")
Screen_frame :: proc "c" (self: ^Screen) -> Rect {
return msgSend(Rect, self, "frame")
}
@(objc_type=Screen, objc_name="depth")
Screen_depth :: proc "c" (self: ^Screen) -> Depth {
return msgSend(Depth, self, "depth")
}
@(objc_type=Screen, objc_name="visibleFrame")
Screen_visibleFrame :: proc "c" (self: ^Screen) -> Rect {
return msgSend(Rect, self, "visibleFrame")
}
@(objc_type=Screen, objc_name="colorSpace")
Screen_colorSpace :: proc "c" (self: ^Screen) -> ^ColorSpace {
return msgSend(^ColorSpace, self, "colorSpace")
}

27
vendor/darwin/Foundation/NSSet.odin vendored Normal file
View File

@@ -0,0 +1,27 @@
package objc_Foundation
@(objc_class="NSSet")
Set :: struct {using _: Copying(Set)}
@(objc_type=Set, objc_name="alloc", objc_is_class_method=true)
Set_alloc :: proc "c" () -> ^Set {
return msgSend(^Set, Set, "alloc")
}
@(objc_type=Set, objc_name="init")
Set_init :: proc "c" (self: ^Set) -> ^Set {
return msgSend(^Set, self, "init")
}
@(objc_type=Set, objc_name="initWithObjects")
Set_initWithObjects :: proc "c" (self: ^Set, objects: [^]^Object, count: UInteger) -> ^Set {
return msgSend(^Set, self, "initWithObjects:count:", objects, count)
}
@(objc_type=Set, objc_name="initWithCoder")
Set_initWithCoder :: proc "c" (self: ^Set, coder: ^Coder) -> ^Set {
return msgSend(^Set, self, "initWithCoder:", coder)
}

View File

@@ -3,20 +3,25 @@ package objc_Foundation
import "core:strings"
import "core:runtime"
import "core:intrinsics"
import NS "vendor:darwin/Foundation"
Rect :: struct {
using origin: Point,
using size: Size,
}
Depth :: enum UInteger {
onehundredtwentyeightBitRGB = 544,
sixtyfourBitRGB = 528,
twentyfourBitRGB = 520,
}
when size_of(Float) == 8 {
_RECT_ENCODING :: "{CGRect="+_POINT_ENCODING+_SIZE_ENCODING+"}"
} else {
_RECT_ENCODING :: "{NSRect="+_POINT_ENCODING+_SIZE_ENCODING+"}"
}
WindowStyleFlag :: enum NS.UInteger {
WindowStyleFlag :: enum UInteger {
Titled = 0,
Closable = 1,
Miniaturizable = 2,
@@ -30,7 +35,7 @@ WindowStyleFlag :: enum NS.UInteger {
NonactivatingPanel = 7,
HUDWindow = 13,
}
WindowStyleMask :: distinct bit_set[WindowStyleFlag; NS.UInteger]
WindowStyleMask :: distinct bit_set[WindowStyleFlag; UInteger]
WindowStyleMaskBorderless :: WindowStyleMask{}
WindowStyleMaskTitled :: WindowStyleMask{.Titled}
WindowStyleMaskClosable :: WindowStyleMask{.Closable}
@@ -45,7 +50,7 @@ WindowStyleMaskDocModalWindow :: WindowStyleMask{.DocModalWindow}
WindowStyleMaskNonactivatingPanel :: WindowStyleMask{.NonactivatingPanel}
WindowStyleMaskHUDWindow :: WindowStyleMask{.HUDWindow}
BackingStoreType :: enum NS.UInteger {
BackingStoreType :: enum UInteger {
Retained = 0,
Nonretained = 1,
Buffered = 2,
@@ -124,7 +129,8 @@ WindowDelegateTemplate :: struct {
windowDidExitVersionBrowser: proc(notification: ^Notification),
}
WindowDelegate :: struct { using _: Object }
WindowDelegate :: struct { using _: Object } // This is not the same as NSWindowDelegate
_WindowDelegateInternal :: struct {
using _: WindowDelegateTemplate,
_context: runtime.Context,
@@ -555,11 +561,8 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
return cast(^WindowDelegate)del
}
@(objc_class="NSColor")
Color :: struct {using _: Object}
@(objc_class="CALayer")
Layer :: struct { using _: NS.Object }
Layer :: struct { using _: Object }
@(objc_type=Layer, objc_name="contentsScale")
Layer_contentsScale :: proc "c" (self: ^Layer) -> Float {
@@ -589,6 +592,10 @@ View :: struct {using _: Responder}
View_initWithFrame :: proc "c" (self: ^View, frame: Rect) -> ^View {
return msgSend(^View, self, "initWithFrame:", frame)
}
@(objc_type=View, objc_name="bounds")
View_bounds :: proc "c" (self: ^View) -> Rect {
return msgSend(Rect, self, "bounds")
}
@(objc_type=View, objc_name="layer")
View_layer :: proc "c" (self: ^View) -> ^Layer {
return msgSend(^Layer, self, "layer")
@@ -605,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}
@@ -615,7 +626,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 {
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
@@ -650,39 +661,39 @@ Window_setFrame :: proc "c" (self: ^Window, frame: Rect) {
msgSend(nil, self, "setFrame:", frame)
}
@(objc_type=Window, objc_name="opaque")
Window_opaque :: proc "c" (self: ^Window) -> NS.BOOL {
return msgSend(NS.BOOL, self, "opaque")
Window_opaque :: proc "c" (self: ^Window) -> BOOL {
return msgSend(BOOL, self, "opaque")
}
@(objc_type=Window, objc_name="setOpaque")
Window_setOpaque :: proc "c" (self: ^Window, ok: NS.BOOL) {
Window_setOpaque :: proc "c" (self: ^Window, ok: BOOL) {
msgSend(nil, self, "setOpaque:", ok)
}
@(objc_type=Window, objc_name="backgroundColor")
Window_backgroundColor :: proc "c" (self: ^Window) -> ^NS.Color {
return msgSend(^NS.Color, self, "backgroundColor")
Window_backgroundColor :: proc "c" (self: ^Window) -> ^Color {
return msgSend(^Color, self, "backgroundColor")
}
@(objc_type=Window, objc_name="setBackgroundColor")
Window_setBackgroundColor :: proc "c" (self: ^Window, color: ^NS.Color) {
Window_setBackgroundColor :: proc "c" (self: ^Window, color: ^Color) {
msgSend(nil, self, "setBackgroundColor:", color)
}
@(objc_type=Window, objc_name="makeKeyAndOrderFront")
Window_makeKeyAndOrderFront :: proc "c" (self: ^Window, key: ^NS.Object) {
Window_makeKeyAndOrderFront :: proc "c" (self: ^Window, key: ^Object) {
msgSend(nil, self, "makeKeyAndOrderFront:", key)
}
@(objc_type=Window, objc_name="setTitle")
Window_setTitle :: proc "c" (self: ^Window, title: ^NS.String) {
Window_setTitle :: proc "c" (self: ^Window, title: ^String) {
msgSend(nil, self, "setTitle:", title)
}
@(objc_type=Window, objc_name="setTitlebarAppearsTransparent")
Window_setTitlebarAppearsTransparent :: proc "c" (self: ^Window, ok: NS.BOOL) {
Window_setTitlebarAppearsTransparent :: proc "c" (self: ^Window, ok: BOOL) {
msgSend(nil, self, "setTitlebarAppearsTransparent:", ok)
}
@(objc_type=Window, objc_name="setMovable")
Window_setMovable :: proc "c" (self: ^Window, ok: NS.BOOL) {
Window_setMovable :: proc "c" (self: ^Window, ok: BOOL) {
msgSend(nil, self, "setMovable:", ok)
}
@(objc_type=Window, objc_name="setMovableByWindowBackground")
Window_setMovableByWindowBackground :: proc "c" (self: ^Window, ok: NS.BOOL) {
Window_setMovableByWindowBackground :: proc "c" (self: ^Window, ok: BOOL) {
msgSend(nil, self, "setMovableByWindowBackground:", ok)
}
@(objc_type=Window, objc_name="setStyleMask")
@@ -696,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")
}

View File

@@ -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)
}