Merge tag 'dev-2025-06'

This commit is contained in:
ed
2025-06-07 11:48:16 -04:00
82 changed files with 3302 additions and 1597 deletions
+2 -2
View File
@@ -350,7 +350,7 @@ index_byte :: proc "contextless" (s: []byte, c: byte) -> (index: int) #no_bounds
}
c_vec: simd.u8x16 = c
when !simd.IS_EMULATED {
when simd.HAS_HARDWARE_SIMD {
// Note: While this is something that could also logically take
// advantage of AVX512, the various downclocking and power
// consumption related woes make premature to have a dedicated
@@ -485,7 +485,7 @@ last_index_byte :: proc "contextless" (s: []byte, c: byte) -> int #no_bounds_che
}
c_vec: simd.u8x16 = c
when !simd.IS_EMULATED {
when simd.HAS_HARDWARE_SIMD {
// Note: While this is something that could also logically take
// advantage of AVX512, the various downclocking and power
// consumption related woes make premature to have a dedicated
+1 -1
View File
@@ -6,7 +6,7 @@ import "core:sys/info"
// is_supported returns true iff hardware accelerated AES
// is supported.
is_supported :: proc "contextless" () -> bool {
features, ok := info.cpu_features.?
features, ok := info.cpu.features.?
if !ok {
return false
}
@@ -39,7 +39,7 @@ when ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32 {
// Some targets lack runtime feature detection, and will flat out refuse
// to load binaries that have unknown instructions. This is distinct from
// `simd.IS_EMULATED` as actually good designs support runtime feature
// `simd.HAS_HARDWARE_SIMD` as actually good designs support runtime feature
// detection and that constant establishes a baseline.
//
// See:
@@ -227,7 +227,7 @@ is_performant :: proc "contextless" () -> bool {
req_features :: info.CPU_Features{.V}
}
features, ok := info.cpu_features.?
features, ok := info.cpu.features.?
if !ok {
return false
}
@@ -41,7 +41,7 @@ _VEC_TWO: simd.u64x4 : {2, 0, 2, 0}
is_performant :: proc "contextless" () -> bool {
req_features :: info.CPU_Features{.avx, .avx2}
features, ok := info.cpu_features.?
features, ok := info.cpu.features.?
if !ok {
return false
}
+1 -1
View File
@@ -52,7 +52,7 @@ K_15 :: simd.u64x2{0xa4506ceb90befffa, 0xc67178f2bef9a3f7}
// is_hardware_accelerated_256 returns true iff hardware accelerated
// SHA-224/SHA-256 is supported.
is_hardware_accelerated_256 :: proc "contextless" () -> bool {
features, ok := info.cpu_features.?
features, ok := info.cpu.features.?
if !ok {
return false
}
-2
View File
@@ -63,8 +63,6 @@ Example:
read_csv_from_string :: proc(filename: string) {
r: csv.Reader
r.trim_leading_space = true
r.reuse_record = true // Without it you have to delete(record)
r.reuse_record_buffer = true // Without it you have to each of the fields within it
defer csv.reader_destroy(&r)
csv_data, ok := os.read_entire_file(filename)
+1 -1
View File
@@ -130,7 +130,7 @@ reader_destroy :: proc(r: ^Reader) {
for record, row_idx in csv.iterator_next(&r) { ... }
TIP: If you process the results within the loop and don't need to own the results,
you can set the Reader's `reuse_record` and `reuse_record_reuse_record_buffer` to true;
you can set the Reader's `reuse_record` and `reuse_record_buffer` to true;
you won't need to delete the record or its fields.
*/
iterator_next :: proc(r: ^Reader) -> (record: []string, idx: int, err: Error, more: bool) {
+1 -82
View File
@@ -317,85 +317,4 @@ crc32_table := [8][256]u32{
0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53,
0x2c8e0fff, 0xe0240f61, 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, 0x264b06e6,
},
}
/*
@(optimization_mode="speed")
crc32 :: proc "contextless" (data: []byte, seed := u32(0)) -> u32 {
result := ~u32(seed);
#no_bounds_check for b in data {
result = result>>8 ~ _crc32_table[(result ~ u32(b)) & 0xff];
}
return ~result;
}
@private _crc32_table := [256]u32{
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
};
*/
}
-3
View File
@@ -1212,7 +1212,6 @@ Filter_Params :: struct #packed {
depth_scale_table :: []u8{0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01}
// @(optimization_mode="speed")
defilter_8 :: proc(params: ^Filter_Params) -> (ok: bool) {
using params
@@ -1273,7 +1272,6 @@ defilter_8 :: proc(params: ^Filter_Params) -> (ok: bool) {
return
}
// @(optimization_mode="speed")
defilter_less_than_8 :: proc(params: ^Filter_Params) -> bool #no_bounds_check {
using params
@@ -1436,7 +1434,6 @@ defilter_less_than_8 :: proc(params: ^Filter_Params) -> bool #no_bounds_check {
return true
}
// @(optimization_mode="speed")
defilter_16 :: proc(params: ^Filter_Params) -> bool {
using params
+1 -1
View File
@@ -280,7 +280,7 @@ int_atoi :: proc(res: ^Int, input: string, radix := i8(10), allocator := context
}
pos := ch - '+'
if RADIX_TABLE_REVERSE_SIZE <= pos {
if RADIX_TABLE_REVERSE_SIZE <= u32(pos) {
break
}
y := RADIX_TABLE_REVERSE[pos]
+1 -1
View File
@@ -350,7 +350,7 @@ Example:
Possible Output:
6
500
13
*/
@(require_results)
+25 -5
View File
@@ -315,18 +315,38 @@ check_zero_ptr :: proc(ptr: rawptr, len: int) -> bool {
Offset a given pointer by a given amount.
This procedure offsets the pointer `ptr` to an object of type `T`, by the amount
of bytes specified by `offset*size_of(T)`, and returns the pointer `ptr`.
of bytes specified by `offset * size_of(T)`, and returns the pointer `ptr`.
**Note**: Prefer to use multipointer types, if possible.
*/
ptr_offset :: intrinsics.ptr_offset
/*
Offset a given pointer by a given amount backwards.
Subtract two pointers of the same type, and return the number of `T` between them.
This procedure offsets the pointer `ptr` to an object of type `T`, by the amount
of bytes specified by `offset*size_of(T)` in the negative direction, and
returns the pointer `ptr`.
This procedure subtracts pointer `b` from pointer `a`, both of type `^T`,
and returns an integer count of the `T` between them.
**Inputs**
- `a`: A pointer to a type T
- `b`: A pointer to a type T
**Returns**
- `b` - `a` in items of T as an `int`.
Example:
import "core:mem"
import "core:fmt"
ptr_sub_example :: proc() {
arr: [2]int
fmt.println(mem.ptr_sub(&arr[1], &arr[0]))
}
Output:
1
*/
ptr_sub :: intrinsics.ptr_sub
+1 -1
View File
@@ -477,7 +477,7 @@ block_mark_as_free :: proc(block: ^Block_Header) {
}
@(private, no_sanitize_address)
block_mark_as_used :: proc(block: ^Block_Header, ) {
block_mark_as_used :: proc(block: ^Block_Header) {
next := block_next(block)
block_set_prev_used(next)
block_set_used(block)
+5 -8
View File
@@ -21,20 +21,17 @@ package simd
import "base:builtin"
import "base:intrinsics"
import "base:runtime"
/*
Check if SIMD is software-emulated on a target platform.
This value is `false`, when the compile-time target has the hardware support for
at 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support
for 128-bit SIMD, this value is `true`, and all SIMD operations will likely be
This value is `true`, when the compile-time target has the hardware support for
at least 128-bit (or wider) SIMD. If the compile-time target lacks the hardware support
for 128-bit SIMD, this value is `false`, and all SIMD operations will likely be
emulated.
*/
IS_EMULATED :: true when (ODIN_ARCH == .amd64 || ODIN_ARCH == .i386) && !intrinsics.has_target_feature("sse2") else
true when (ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32) && !intrinsics.has_target_feature("neon") else
true when (ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .wasm32) && !intrinsics.has_target_feature("simd128") else
true when (ODIN_ARCH == .riscv64) && !intrinsics.has_target_feature("v") else
false
HAS_HARDWARE_SIMD :: runtime.HAS_HARDWARE_SIMD
/*
Vector of 16 `u8` lanes (128 bits).
+46 -17
View File
@@ -2,6 +2,7 @@
package strings
import "base:intrinsics"
import "base:runtime"
import "core:bytes"
import "core:io"
import "core:mem"
@@ -458,6 +459,7 @@ equal_fold :: proc(u, v: string) -> (res: bool) {
return s == t
}
/*
Returns the prefix length common between strings `a` and `b`
@@ -488,30 +490,57 @@ Output:
0
*/
prefix_length :: proc(a, b: string) -> (n: int) {
_len := min(len(a), len(b))
prefix_length :: proc "contextless" (a, b: string) -> (n: int) {
RUNE_ERROR :: '\ufffd'
RUNE_SELF :: 0x80
UTF_MAX :: 4
// Scan for matches including partial codepoints.
#no_bounds_check for n < _len && a[n] == b[n] {
n += 1
}
// Now scan to ignore partial codepoints.
if n > 0 {
s := a[:n]
n = 0
for {
r0, w := utf8.decode_rune(s[n:])
if r0 != utf8.RUNE_ERROR {
n += w
} else {
break
n = runtime.memory_prefix_length(raw_data(a), raw_data(b), min(len(a), len(b)))
lim := max(n - UTF_MAX + 1, 0)
for l := n; l > lim; l -= 1 {
r, _ := runtime.string_decode_rune(a[l - 1:])
if r != RUNE_ERROR {
if l > 0 && (a[l - 1] & 0xc0 == 0xc0) {
return l - 1
}
return l
}
}
return
}
/*
Returns the common prefix between strings `a` and `b`
Inputs:
- a: The first input string
- b: The second input string
Returns:
- n: The string prefix common between strings `a` and `b`
Example:
import "core:fmt"
import "core:strings"
common_prefix_example :: proc() {
fmt.println(strings.common_prefix("testing", "test"))
fmt.println(strings.common_prefix("testing", "te"))
fmt.println(strings.common_prefix("telephone", "te"))
}
Output:
test
te
te
*/
common_prefix :: proc(a, b: string) -> string {
return a[:prefix_length(a, b)]
}
/*
Determines if a string `s` starts with a given `prefix`
Inputs:
+45 -45
View File
@@ -256,7 +256,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
return nil
}
if template.applicationWillFinishLaunching != nil {
applicationWillFinishLaunching :: proc "c" (self: id, notification: ^Notification) {
applicationWillFinishLaunching :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillFinishLaunching(notification)
@@ -264,7 +264,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationWillFinishLaunching:"), auto_cast applicationWillFinishLaunching, "v@:@")
}
if template.applicationDidFinishLaunching != nil {
applicationDidFinishLaunching :: proc "c" (self: id, notification: ^Notification) {
applicationDidFinishLaunching :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidFinishLaunching(notification)
@@ -272,7 +272,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidFinishLaunching:"), auto_cast applicationDidFinishLaunching, "v@:@")
}
if template.applicationWillBecomeActive != nil {
applicationWillBecomeActive :: proc "c" (self: id, notification: ^Notification) {
applicationWillBecomeActive :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillBecomeActive(notification)
@@ -280,7 +280,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationWillBecomeActive:"), auto_cast applicationWillBecomeActive, "v@:@")
}
if template.applicationDidBecomeActive != nil {
applicationDidBecomeActive :: proc "c" (self: id, notification: ^Notification) {
applicationDidBecomeActive :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidBecomeActive(notification)
@@ -288,7 +288,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidBecomeActive:"), auto_cast applicationDidBecomeActive, "v@:@")
}
if template.applicationWillResignActive != nil {
applicationWillResignActive :: proc "c" (self: id, notification: ^Notification) {
applicationWillResignActive :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillResignActive(notification)
@@ -296,7 +296,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationWillResignActive:"), auto_cast applicationWillResignActive, "v@:@")
}
if template.applicationDidResignActive != nil {
applicationDidResignActive :: proc "c" (self: id, notification: ^Notification) {
applicationDidResignActive :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidResignActive(notification)
@@ -304,7 +304,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidResignActive:"), auto_cast applicationDidResignActive, "v@:@")
}
if template.applicationShouldTerminate != nil {
applicationShouldTerminate :: proc "c" (self: id, sender: ^Application) -> ApplicationTerminateReply {
applicationShouldTerminate :: proc "c" (self: id, cmd: SEL, sender: ^Application) -> ApplicationTerminateReply {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationShouldTerminate(sender)
@@ -312,7 +312,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationShouldTerminate:"), auto_cast applicationShouldTerminate, _UINTEGER_ENCODING+"@:@")
}
if template.applicationShouldTerminateAfterLastWindowClosed != nil {
applicationShouldTerminateAfterLastWindowClosed :: proc "c" (self: id, sender: ^Application) -> BOOL {
applicationShouldTerminateAfterLastWindowClosed :: proc "c" (self: id, cmd: SEL, sender: ^Application) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationShouldTerminateAfterLastWindowClosed(sender)
@@ -320,7 +320,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationShouldTerminateAfterLastWindowClosed:"), auto_cast applicationShouldTerminateAfterLastWindowClosed, "B@:@")
}
if template.applicationWillTerminate != nil {
applicationWillTerminate :: proc "c" (self: id, notification: ^Notification) {
applicationWillTerminate :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillTerminate(notification)
@@ -328,7 +328,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationWillTerminate:"), auto_cast applicationWillTerminate, "v@:@")
}
if template.applicationWillHide != nil {
applicationWillHide :: proc "c" (self: id, notification: ^Notification) {
applicationWillHide :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillHide(notification)
@@ -336,7 +336,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationWillHide:"), auto_cast applicationWillHide, "v@:@")
}
if template.applicationDidHide != nil {
applicationDidHide :: proc "c" (self: id, notification: ^Notification) {
applicationDidHide :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidHide(notification)
@@ -344,7 +344,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidHide:"), auto_cast applicationDidHide, "v@:@")
}
if template.applicationWillUnhide != nil {
applicationWillUnhide :: proc "c" (self: id, notification: ^Notification) {
applicationWillUnhide :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillUnhide(notification)
@@ -352,7 +352,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationWillUnhide:"), auto_cast applicationWillUnhide, "v@:@")
}
if template.applicationDidUnhide != nil {
applicationDidUnhide :: proc "c" (self: id, notification: ^Notification) {
applicationDidUnhide :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidUnhide(notification)
@@ -360,7 +360,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidUnhide:"), auto_cast applicationDidUnhide, "v@:@")
}
if template.applicationWillUpdate != nil {
applicationWillUpdate :: proc "c" (self: id, notification: ^Notification) {
applicationWillUpdate :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillUpdate(notification)
@@ -368,7 +368,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationWillUpdate:"), auto_cast applicationWillUpdate, "v@:@")
}
if template.applicationDidUpdate != nil {
applicationDidUpdate :: proc "c" (self: id, notification: ^Notification) {
applicationDidUpdate :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidUpdate(notification)
@@ -376,7 +376,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidUpdate:"), auto_cast applicationDidUpdate, "v@:@")
}
if template.applicationShouldHandleReopenHasVisibleWindows != nil {
applicationShouldHandleReopenHasVisibleWindows :: proc "c" (self: id, sender: ^Application, flag: BOOL) -> BOOL {
applicationShouldHandleReopenHasVisibleWindows :: proc "c" (self: id, cmd: SEL, sender: ^Application, flag: BOOL) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationShouldHandleReopenHasVisibleWindows(sender, flag)
@@ -384,7 +384,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationShouldHandleReopen:hasVisibleWindows:"), auto_cast applicationShouldHandleReopenHasVisibleWindows, "B@:@B")
}
if template.applicationDockMenu != nil {
applicationDockMenu :: proc "c" (self: id, sender: ^Application) -> ^Menu {
applicationDockMenu :: proc "c" (self: id, cmd: SEL, sender: ^Application) -> ^Menu {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationDockMenu(sender)
@@ -392,7 +392,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDockMenu:"), auto_cast applicationDockMenu, "@@:@")
}
if template.applicationShouldAutomaticallyLocalizeKeyEquivalents != nil {
applicationShouldAutomaticallyLocalizeKeyEquivalents :: proc "c" (self: id, application: ^Application) -> BOOL {
applicationShouldAutomaticallyLocalizeKeyEquivalents :: proc "c" (self: id, cmd: SEL, application: ^Application) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationShouldAutomaticallyLocalizeKeyEquivalents(application)
@@ -400,7 +400,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationShouldAutomaticallyLocalizeKeyEquivalents:"), auto_cast applicationShouldAutomaticallyLocalizeKeyEquivalents, "B@:@")
}
if template.applicationWillPresentError != nil {
applicationWillPresentError :: proc "c" (self: id, application: ^Application, error: ^Error) -> ^Error {
applicationWillPresentError :: proc "c" (self: id, cmd: SEL, application: ^Application, error: ^Error) -> ^Error {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationWillPresentError(application, error)
@@ -408,7 +408,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:willPresentError:"), auto_cast applicationWillPresentError, "@@:@@")
}
if template.applicationDidChangeScreenParameters != nil {
applicationDidChangeScreenParameters :: proc "c" (self: id, notification: ^Notification) {
applicationDidChangeScreenParameters :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidChangeScreenParameters(notification)
@@ -416,7 +416,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidChangeScreenParameters:"), auto_cast applicationDidChangeScreenParameters, "v@:@")
}
if template.applicationWillContinueUserActivityWithType != nil {
applicationWillContinueUserActivityWithType :: proc "c" (self: id, application: ^Application, userActivityType: ^String) -> BOOL {
applicationWillContinueUserActivityWithType :: proc "c" (self: id, cmd: SEL, application: ^Application, userActivityType: ^String) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationWillContinueUserActivityWithType(application, userActivityType)
@@ -424,7 +424,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:willContinueUserActivityWithType:"), auto_cast applicationWillContinueUserActivityWithType, "B@:@@")
}
if template.applicationContinueUserActivityRestorationHandler != nil {
applicationContinueUserActivityRestorationHandler :: proc "c" (self: id, application: ^Application, userActivity: ^UserActivity, restorationHandler: ^Block) -> BOOL {
applicationContinueUserActivityRestorationHandler :: proc "c" (self: id, cmd: SEL, application: ^Application, userActivity: ^UserActivity, restorationHandler: ^Block) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationContinueUserActivityRestorationHandler(application, userActivity, restorationHandler)
@@ -432,7 +432,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:continueUserActivity:restorationHandler:"), auto_cast applicationContinueUserActivityRestorationHandler, "B@:@@?")
}
if template.applicationDidFailToContinueUserActivityWithTypeError != nil {
applicationDidFailToContinueUserActivityWithTypeError :: proc "c" (self: id, application: ^Application, userActivityType: ^String, error: ^Error) {
applicationDidFailToContinueUserActivityWithTypeError :: proc "c" (self: id, cmd: SEL, application: ^Application, userActivityType: ^String, error: ^Error) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidFailToContinueUserActivityWithTypeError(application, userActivityType, error)
@@ -440,7 +440,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:didFailToContinueUserActivityWithType:error:"), auto_cast applicationDidFailToContinueUserActivityWithTypeError, "v@:@@@")
}
if template.applicationDidUpdateUserActivity != nil {
applicationDidUpdateUserActivity :: proc "c" (self: id, application: ^Application, userActivity: ^UserActivity) {
applicationDidUpdateUserActivity :: proc "c" (self: id, cmd: SEL, application: ^Application, userActivity: ^UserActivity) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidUpdateUserActivity(application, userActivity)
@@ -448,7 +448,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:didUpdateUserActivity:"), auto_cast applicationDidUpdateUserActivity, "v@:@@")
}
if template.applicationDidRegisterForRemoteNotificationsWithDeviceToken != nil {
applicationDidRegisterForRemoteNotificationsWithDeviceToken :: proc "c" (self: id, application: ^Application, deviceToken: ^Data) {
applicationDidRegisterForRemoteNotificationsWithDeviceToken :: proc "c" (self: id, cmd: SEL, application: ^Application, deviceToken: ^Data) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidRegisterForRemoteNotificationsWithDeviceToken(application, deviceToken)
@@ -456,7 +456,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:didRegisterForRemoteNotificationsWithDeviceToken:"), auto_cast applicationDidRegisterForRemoteNotificationsWithDeviceToken, "v@:@@")
}
if template.applicationDidFailToRegisterForRemoteNotificationsWithError != nil {
applicationDidFailToRegisterForRemoteNotificationsWithError :: proc "c" (self: id, application: ^Application, error: ^Error) {
applicationDidFailToRegisterForRemoteNotificationsWithError :: proc "c" (self: id, cmd: SEL, application: ^Application, error: ^Error) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidFailToRegisterForRemoteNotificationsWithError(application, error)
@@ -464,7 +464,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:didFailToRegisterForRemoteNotificationsWithError:"), auto_cast applicationDidFailToRegisterForRemoteNotificationsWithError, "v@:@@")
}
if template.applicationDidReceiveRemoteNotification != nil {
applicationDidReceiveRemoteNotification :: proc "c" (self: id, application: ^Application, userInfo: ^Dictionary) {
applicationDidReceiveRemoteNotification :: proc "c" (self: id, cmd: SEL, application: ^Application, userInfo: ^Dictionary) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidReceiveRemoteNotification(application, userInfo)
@@ -472,7 +472,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:didReceiveRemoteNotification:"), auto_cast applicationDidReceiveRemoteNotification, "v@:@@")
}
// if template.applicationUserDidAcceptCloudKitShareWithMetadata != nil {
// applicationUserDidAcceptCloudKitShareWithMetadata :: proc "c" (self: id, application: ^Application, metadata: ^CKShareMetadata) {
// applicationUserDidAcceptCloudKitShareWithMetadata :: proc "c" (self: id, cmd: SEL, application: ^Application, metadata: ^CKShareMetadata) {
// del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
// context = del._context
// del.applicationUserDidAcceptCloudKitShareWithMetadata(application, metadata)
@@ -480,7 +480,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
// class_addMethod(class, intrinsics.objc_find_selector("application:userDidAcceptCloudKitShareWithMetadata:"), auto_cast applicationUserDidAcceptCloudKitShareWithMetadata, "v@:@@")
// }
// if template.applicationHandlerForIntent != nil {
// applicationHandlerForIntent :: proc "c" (self: id, application: ^Application, intent: ^INIntent) -> id {
// applicationHandlerForIntent :: proc "c" (self: id, cmd: SEL, application: ^Application, intent: ^INIntent) -> id {
// del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
// context = del._context
// return del.applicationHandlerForIntent(application, intent)
@@ -488,7 +488,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
// class_addMethod(class, intrinsics.objc_find_selector("application:handlerForIntent:"), auto_cast applicationHandlerForIntent, "@@:@@")
// }
if template.applicationOpenURLs != nil {
applicationOpenURLs :: proc "c" (self: id, application: ^Application, urls: ^Array) {
applicationOpenURLs :: proc "c" (self: id, cmd: SEL, application: ^Application, urls: ^Array) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationOpenURLs(application, urls)
@@ -496,7 +496,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:openURLs:"), auto_cast applicationOpenURLs, "v@:@@")
}
if template.applicationOpenFile != nil {
applicationOpenFile :: proc "c" (self: id, sender: ^Application, filename: ^String) -> BOOL {
applicationOpenFile :: proc "c" (self: id, cmd: SEL, sender: ^Application, filename: ^String) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationOpenFile(sender, filename)
@@ -504,7 +504,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:openFile:"), auto_cast applicationOpenFile, "B@:@@")
}
if template.applicationOpenFileWithoutUI != nil {
applicationOpenFileWithoutUI :: proc "c" (self: id, sender: id, filename: ^String) -> BOOL {
applicationOpenFileWithoutUI :: proc "c" (self: id, cmd: SEL, sender: id, filename: ^String) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationOpenFileWithoutUI(sender, filename)
@@ -512,7 +512,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:openFileWithoutUI:"), auto_cast applicationOpenFileWithoutUI, "B@:@@")
}
if template.applicationOpenTempFile != nil {
applicationOpenTempFile :: proc "c" (self: id, sender: ^Application, filename: ^String) -> BOOL {
applicationOpenTempFile :: proc "c" (self: id, cmd: SEL, sender: ^Application, filename: ^String) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationOpenTempFile(sender, filename)
@@ -520,7 +520,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:openTempFile:"), auto_cast applicationOpenTempFile, "B@:@@")
}
if template.applicationOpenFiles != nil {
applicationOpenFiles :: proc "c" (self: id, sender: ^Application, filenames: ^Array) {
applicationOpenFiles :: proc "c" (self: id, cmd: SEL, sender: ^Application, filenames: ^Array) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationOpenFiles(sender, filenames)
@@ -528,7 +528,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:openFiles:"), auto_cast applicationOpenFiles, "v@:@@")
}
if template.applicationShouldOpenUntitledFile != nil {
applicationShouldOpenUntitledFile :: proc "c" (self: id, sender: ^Application) -> BOOL {
applicationShouldOpenUntitledFile :: proc "c" (self: id, cmd: SEL, sender: ^Application) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationShouldOpenUntitledFile(sender)
@@ -536,7 +536,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationShouldOpenUntitledFile:"), auto_cast applicationShouldOpenUntitledFile, "B@:@")
}
if template.applicationOpenUntitledFile != nil {
applicationOpenUntitledFile :: proc "c" (self: id, sender: ^Application) -> BOOL {
applicationOpenUntitledFile :: proc "c" (self: id, cmd: SEL, sender: ^Application) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationOpenUntitledFile(sender)
@@ -544,7 +544,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationOpenUntitledFile:"), auto_cast applicationOpenUntitledFile, "B@:@")
}
if template.applicationPrintFile != nil {
applicationPrintFile :: proc "c" (self: id, sender: ^Application, filename: ^String) -> BOOL {
applicationPrintFile :: proc "c" (self: id, cmd: SEL, sender: ^Application, filename: ^String) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationPrintFile(sender, filename)
@@ -552,7 +552,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:printFile:"), auto_cast applicationPrintFile, "B@:@@")
}
if template.applicationPrintFilesWithSettingsShowPrintPanels != nil {
applicationPrintFilesWithSettingsShowPrintPanels :: proc "c" (self: id, application: ^Application, fileNames: ^Array, printSettings: ^Dictionary, showPrintPanels: BOOL) -> ApplicationPrintReply {
applicationPrintFilesWithSettingsShowPrintPanels :: proc "c" (self: id, cmd: SEL, application: ^Application, fileNames: ^Array, printSettings: ^Dictionary, showPrintPanels: BOOL) -> ApplicationPrintReply {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationPrintFilesWithSettingsShowPrintPanels(application, fileNames, printSettings, showPrintPanels)
@@ -560,7 +560,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:printFiles:withSettings:showPrintPanels:"), auto_cast applicationPrintFilesWithSettingsShowPrintPanels, _UINTEGER_ENCODING+"@:@@@B")
}
if template.applicationSupportsSecureRestorableState != nil {
applicationSupportsSecureRestorableState :: proc "c" (self: id, app: ^Application) -> BOOL {
applicationSupportsSecureRestorableState :: proc "c" (self: id, cmd: SEL, app: ^Application) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationSupportsSecureRestorableState(app)
@@ -568,7 +568,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationSupportsSecureRestorableState:"), auto_cast applicationSupportsSecureRestorableState, "B@:@")
}
if template.applicationProtectedDataDidBecomeAvailable != nil {
applicationProtectedDataDidBecomeAvailable :: proc "c" (self: id, notification: ^Notification) {
applicationProtectedDataDidBecomeAvailable :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationProtectedDataDidBecomeAvailable(notification)
@@ -576,7 +576,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationProtectedDataDidBecomeAvailable:"), auto_cast applicationProtectedDataDidBecomeAvailable, "v@:@")
}
if template.applicationProtectedDataWillBecomeUnavailable != nil {
applicationProtectedDataWillBecomeUnavailable :: proc "c" (self: id, notification: ^Notification) {
applicationProtectedDataWillBecomeUnavailable :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationProtectedDataWillBecomeUnavailable(notification)
@@ -584,7 +584,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationProtectedDataWillBecomeUnavailable:"), auto_cast applicationProtectedDataWillBecomeUnavailable, "v@:@")
}
if template.applicationWillEncodeRestorableState != nil {
applicationWillEncodeRestorableState :: proc "c" (self: id, app: ^Application, coder: ^Coder) {
applicationWillEncodeRestorableState :: proc "c" (self: id, cmd: SEL, app: ^Application, coder: ^Coder) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationWillEncodeRestorableState(app, coder)
@@ -592,7 +592,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:willEncodeRestorableState:"), auto_cast applicationWillEncodeRestorableState, "v@:@@")
}
if template.applicationDidDecodeRestorableState != nil {
applicationDidDecodeRestorableState :: proc "c" (self: id, app: ^Application, coder: ^Coder) {
applicationDidDecodeRestorableState :: proc "c" (self: id, cmd: SEL, app: ^Application, coder: ^Coder) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidDecodeRestorableState(app, coder)
@@ -600,7 +600,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("application:didDecodeRestorableState:"), auto_cast applicationDidDecodeRestorableState, "v@:@@")
}
if template.applicationDidChangeOcclusionState != nil {
applicationDidChangeOcclusionState :: proc "c" (self: id, notification: ^Notification) {
applicationDidChangeOcclusionState :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.applicationDidChangeOcclusionState(notification)
@@ -608,7 +608,7 @@ application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTem
class_addMethod(class, intrinsics.objc_find_selector("applicationDidChangeOcclusionState:"), auto_cast applicationDidChangeOcclusionState, "v@:@")
}
if template.applicationDelegateHandlesKey != nil {
applicationDelegateHandlesKey :: proc "c" (self: id, sender: ^Application, key: ^String) -> BOOL {
applicationDelegateHandlesKey :: proc "c" (self: id, cmd: SEL, sender: ^Application, key: ^String) -> BOOL {
del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.applicationDelegateHandlesKey(sender, key)
+52 -52
View File
@@ -146,7 +146,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
return nil
}
if template.windowWillPositionSheetUsingRect != nil {
windowWillPositionSheetUsingRect :: proc "c" (self: id, window: ^Window, sheet: ^Window, rect: Rect) -> Rect {
windowWillPositionSheetUsingRect :: proc "c" (self: id, cmd: SEL, window: ^Window, sheet: ^Window, rect: Rect) -> Rect {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillPositionSheetUsingRect(window, sheet, rect)
@@ -154,7 +154,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:willPositionSheet:usingRect:"), auto_cast windowWillPositionSheetUsingRect, _RECT_ENCODING+"@:@@"+_RECT_ENCODING)
}
if template.windowWillBeginSheet != nil {
windowWillBeginSheet :: proc "c" (self: id, notification: ^Notification) {
windowWillBeginSheet :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillBeginSheet(notification)
@@ -162,7 +162,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillBeginSheet:"), auto_cast windowWillBeginSheet, "v@:@")
}
if template.windowDidEndSheet != nil {
windowDidEndSheet :: proc "c" (self: id, notification: ^Notification) {
windowDidEndSheet :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidEndSheet(notification)
@@ -170,7 +170,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidEndSheet:"), auto_cast windowDidEndSheet, "v@:@")
}
if template.windowWillResizeToSize != nil {
windowWillResizeToSize :: proc "c" (self: id, sender: ^Window, frameSize: Size) -> Size {
windowWillResizeToSize :: proc "c" (self: id, cmd: SEL, sender: ^Window, frameSize: Size) -> Size {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillResizeToSize(sender, frameSize)
@@ -178,7 +178,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillResize:toSize:"), auto_cast windowWillResizeToSize, _SIZE_ENCODING+"@:@"+_SIZE_ENCODING)
}
if template.windowDidResize != nil {
windowDidResize :: proc "c" (self: id, notification: ^Notification) {
windowDidResize :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidResize(notification)
@@ -186,7 +186,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidResize:"), auto_cast windowDidResize, "v@:@")
}
if template.windowWillStartLiveResize != nil {
windowWillStartLiveResize :: proc "c" (self: id, notification: ^Notification) {
windowWillStartLiveResize :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillStartLiveResize(notification)
@@ -194,7 +194,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillStartLiveResize:"), auto_cast windowWillStartLiveResize, "v@:@")
}
if template.windowDidEndLiveResize != nil {
windowDidEndLiveResize :: proc "c" (self: id, notification: ^Notification) {
windowDidEndLiveResize :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidEndLiveResize(notification)
@@ -202,7 +202,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidEndLiveResize:"), auto_cast windowDidEndLiveResize, "v@:@")
}
if template.windowWillMiniaturize != nil {
windowWillMiniaturize :: proc "c" (self: id, notification: ^Notification) {
windowWillMiniaturize :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillMiniaturize(notification)
@@ -210,7 +210,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillMiniaturize:"), auto_cast windowWillMiniaturize, "v@:@")
}
if template.windowDidMiniaturize != nil {
windowDidMiniaturize :: proc "c" (self: id, notification: ^Notification) {
windowDidMiniaturize :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidMiniaturize(notification)
@@ -218,7 +218,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidMiniaturize:"), auto_cast windowDidMiniaturize, "v@:@")
}
if template.windowDidDeminiaturize != nil {
windowDidDeminiaturize :: proc "c" (self: id, notification: ^Notification) {
windowDidDeminiaturize :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidDeminiaturize(notification)
@@ -226,7 +226,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidDeminiaturize:"), auto_cast windowDidDeminiaturize, "v@:@")
}
if template.windowWillUseStandardFrameDefaultFrame != nil {
windowWillUseStandardFrameDefaultFrame :: proc(self: id, window: ^Window, newFrame: Rect) -> Rect {
windowWillUseStandardFrameDefaultFrame :: proc(self: id, cmd: SEL, window: ^Window, newFrame: Rect) -> Rect {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillUseStandardFrameDefaultFrame(window, newFrame)
@@ -234,7 +234,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillUseStandardFrame:defaultFrame:"), auto_cast windowWillUseStandardFrameDefaultFrame, _RECT_ENCODING+"@:@"+_RECT_ENCODING)
}
if template.windowShouldZoomToFrame != nil {
windowShouldZoomToFrame :: proc "c" (self: id, window: ^Window, newFrame: Rect) -> BOOL {
windowShouldZoomToFrame :: proc "c" (self: id, cmd: SEL, window: ^Window, newFrame: Rect) -> BOOL {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowShouldZoomToFrame(window, newFrame)
@@ -242,7 +242,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowShouldZoom:toFrame:"), auto_cast windowShouldZoomToFrame, "B@:@"+_RECT_ENCODING)
}
if template.windowWillUseFullScreenContentSize != nil {
windowWillUseFullScreenContentSize :: proc "c" (self: id, window: ^Window, proposedSize: Size) -> Size {
windowWillUseFullScreenContentSize :: proc "c" (self: id, cmd: SEL, window: ^Window, proposedSize: Size) -> Size {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillUseFullScreenContentSize(window, proposedSize)
@@ -250,7 +250,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:willUseFullScreenContentSize:"), auto_cast windowWillUseFullScreenContentSize, _SIZE_ENCODING+"@:@"+_SIZE_ENCODING)
}
if template.windowWillUseFullScreenPresentationOptions != nil {
windowWillUseFullScreenPresentationOptions :: proc(self: id, window: ^Window, proposedOptions: ApplicationPresentationOptions) -> ApplicationPresentationOptions {
windowWillUseFullScreenPresentationOptions :: proc(self: id, cmd: SEL, window: ^Window, proposedOptions: ApplicationPresentationOptions) -> ApplicationPresentationOptions {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillUseFullScreenPresentationOptions(window, proposedOptions)
@@ -258,7 +258,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:willUseFullScreenPresentationOptions:"), auto_cast windowWillUseFullScreenPresentationOptions, _UINTEGER_ENCODING+"@:@"+_UINTEGER_ENCODING)
}
if template.windowWillEnterFullScreen != nil {
windowWillEnterFullScreen :: proc "c" (self: id, notification: ^Notification) {
windowWillEnterFullScreen :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillEnterFullScreen(notification)
@@ -266,7 +266,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillEnterFullScreen:"), auto_cast windowWillEnterFullScreen, "v@:@")
}
if template.windowDidEnterFullScreen != nil {
windowDidEnterFullScreen :: proc "c" (self: id, notification: ^Notification) {
windowDidEnterFullScreen :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidEnterFullScreen(notification)
@@ -274,7 +274,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidEnterFullScreen:"), auto_cast windowDidEnterFullScreen, "v@:@")
}
if template.windowWillExitFullScreen != nil {
windowWillExitFullScreen :: proc "c" (self: id, notification: ^Notification) {
windowWillExitFullScreen :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillExitFullScreen(notification)
@@ -282,7 +282,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillExitFullScreen:"), auto_cast windowWillExitFullScreen, "v@:@")
}
if template.windowDidExitFullScreen != nil {
windowDidExitFullScreen :: proc "c" (self: id, notification: ^Notification) {
windowDidExitFullScreen :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidExitFullScreen(notification)
@@ -290,7 +290,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidExitFullScreen:"), auto_cast windowDidExitFullScreen, "v@:@")
}
if template.customWindowsToEnterFullScreenForWindow != nil {
customWindowsToEnterFullScreenForWindow :: proc "c" (self: id, window: ^Window) -> ^Array {
customWindowsToEnterFullScreenForWindow :: proc "c" (self: id, cmd: SEL, window: ^Window) -> ^Array {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.customWindowsToEnterFullScreenForWindow(window)
@@ -298,7 +298,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("customWindowsToEnterFullScreenForWindow:"), auto_cast customWindowsToEnterFullScreenForWindow, "@@:@")
}
if template.customWindowsToEnterFullScreenForWindowOnScreen != nil {
customWindowsToEnterFullScreenForWindowOnScreen :: proc(self: id, window: ^Window, screen: ^Screen) -> ^Array {
customWindowsToEnterFullScreenForWindowOnScreen :: proc(self: id, cmd: SEL, window: ^Window, screen: ^Screen) -> ^Array {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.customWindowsToEnterFullScreenForWindowOnScreen(window, screen)
@@ -306,7 +306,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("customWindowsToEnterFullScreenForWindow:onScreen:"), auto_cast customWindowsToEnterFullScreenForWindowOnScreen, "@@:@@")
}
if template.windowStartCustomAnimationToEnterFullScreenWithDuration != nil {
windowStartCustomAnimationToEnterFullScreenWithDuration :: proc "c" (self: id, window: ^Window, duration: TimeInterval) {
windowStartCustomAnimationToEnterFullScreenWithDuration :: proc "c" (self: id, cmd: SEL, window: ^Window, duration: TimeInterval) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowStartCustomAnimationToEnterFullScreenWithDuration(window, duration)
@@ -314,7 +314,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:startCustomAnimationToEnterFullScreenWithDuration:"), auto_cast windowStartCustomAnimationToEnterFullScreenWithDuration, "v@:@@")
}
if template.windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration != nil {
windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration :: proc(self: id, window: ^Window, screen: ^Screen, duration: TimeInterval) {
windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration :: proc(self: id, cmd: SEL, window: ^Window, screen: ^Screen, duration: TimeInterval) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration(window, screen, duration)
@@ -322,7 +322,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:startCustomAnimationToEnterFullScreenOnScreen:withDuration:"), auto_cast windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration, "v@:@@d")
}
if template.windowDidFailToEnterFullScreen != nil {
windowDidFailToEnterFullScreen :: proc "c" (self: id, window: ^Window) {
windowDidFailToEnterFullScreen :: proc "c" (self: id, cmd: SEL, window: ^Window) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidFailToEnterFullScreen(window)
@@ -330,7 +330,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidFailToEnterFullScreen:"), auto_cast windowDidFailToEnterFullScreen, "v@:@")
}
if template.customWindowsToExitFullScreenForWindow != nil {
customWindowsToExitFullScreenForWindow :: proc "c" (self: id, window: ^Window) -> ^Array {
customWindowsToExitFullScreenForWindow :: proc "c" (self: id, cmd: SEL, window: ^Window) -> ^Array {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.customWindowsToExitFullScreenForWindow(window)
@@ -338,7 +338,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("customWindowsToExitFullScreenForWindow:"), auto_cast customWindowsToExitFullScreenForWindow, "@@:@")
}
if template.windowStartCustomAnimationToExitFullScreenWithDuration != nil {
windowStartCustomAnimationToExitFullScreenWithDuration :: proc "c" (self: id, window: ^Window, duration: TimeInterval) {
windowStartCustomAnimationToExitFullScreenWithDuration :: proc "c" (self: id, cmd: SEL, window: ^Window, duration: TimeInterval) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowStartCustomAnimationToExitFullScreenWithDuration(window, duration)
@@ -346,7 +346,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:startCustomAnimationToExitFullScreenWithDuration:"), auto_cast windowStartCustomAnimationToExitFullScreenWithDuration, "v@:@d")
}
if template.windowDidFailToExitFullScreen != nil {
windowDidFailToExitFullScreen :: proc "c" (self: id, window: ^Window) {
windowDidFailToExitFullScreen :: proc "c" (self: id, cmd: SEL, window: ^Window) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidFailToExitFullScreen(window)
@@ -354,7 +354,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidFailToExitFullScreen:"), auto_cast windowDidFailToExitFullScreen, "v@:@")
}
if template.windowWillMove != nil {
windowWillMove :: proc "c" (self: id, notification: ^Notification) {
windowWillMove :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillMove(notification)
@@ -362,7 +362,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillMove:"), auto_cast windowWillMove, "v@:@")
}
if template.windowDidMove != nil {
windowDidMove :: proc "c" (self: id, notification: ^Notification) {
windowDidMove :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidMove(notification)
@@ -370,7 +370,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidMove:"), auto_cast windowDidMove, "v@:@")
}
if template.windowDidChangeScreen != nil {
windowDidChangeScreen :: proc "c" (self: id, notification: ^Notification) {
windowDidChangeScreen :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidChangeScreen(notification)
@@ -378,7 +378,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeScreen:"), auto_cast windowDidChangeScreen, "v@:@")
}
if template.windowDidChangeScreenProfile != nil {
windowDidChangeScreenProfile :: proc "c" (self: id, notification: ^Notification) {
windowDidChangeScreenProfile :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidChangeScreenProfile(notification)
@@ -386,7 +386,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeScreenProfile:"), auto_cast windowDidChangeScreenProfile, "v@:@")
}
if template.windowDidChangeBackingProperties != nil {
windowDidChangeBackingProperties :: proc "c" (self: id, notification: ^Notification) {
windowDidChangeBackingProperties :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidChangeBackingProperties(notification)
@@ -394,7 +394,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeBackingProperties:"), auto_cast windowDidChangeBackingProperties, "v@:@")
}
if template.windowShouldClose != nil {
windowShouldClose :: proc "c" (self:id, sender: ^Window) -> BOOL {
windowShouldClose :: proc "c" (self:id, cmd: SEL, sender: ^Window) -> BOOL {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowShouldClose(sender)
@@ -402,7 +402,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowShouldClose:"), auto_cast windowShouldClose, "B@:@")
}
if template.windowWillClose != nil {
windowWillClose :: proc "c" (self:id, notification: ^Notification) {
windowWillClose :: proc "c" (self:id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillClose(notification)
@@ -410,7 +410,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillClose:"), auto_cast windowWillClose, "v@:@")
}
if template.windowDidBecomeKey != nil {
windowDidBecomeKey :: proc "c" (self: id, notification: ^Notification) {
windowDidBecomeKey :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidBecomeKey(notification)
@@ -418,7 +418,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidBecomeKey:"), auto_cast windowDidBecomeKey, "v@:@")
}
if template.windowDidResignKey != nil {
windowDidResignKey :: proc "c" (self: id, notification: ^Notification) {
windowDidResignKey :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidResignKey(notification)
@@ -426,7 +426,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidResignKey:"), auto_cast windowDidResignKey, "v@:@")
}
if template.windowDidBecomeMain != nil {
windowDidBecomeMain :: proc "c" (self: id, notification: ^Notification) {
windowDidBecomeMain :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidBecomeMain(notification)
@@ -434,7 +434,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidBecomeMain:"), auto_cast windowDidBecomeMain, "v@:@")
}
if template.windowDidResignMain != nil {
windowDidResignMain :: proc "c" (self: id, notification: ^Notification) {
windowDidResignMain :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidResignMain(notification)
@@ -442,7 +442,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidResignMain:"), auto_cast windowDidResignMain, "v@:@")
}
if template.windowWillReturnFieldEditorToObject != nil {
windowWillReturnFieldEditorToObject :: proc "c" (self:id, sender: ^Window, client: id) -> id {
windowWillReturnFieldEditorToObject :: proc "c" (self:id, cmd: SEL, sender: ^Window, client: id) -> id {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillReturnFieldEditorToObject(sender, client)
@@ -450,7 +450,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillReturnFieldEditor:toObject:"), auto_cast windowWillReturnFieldEditorToObject, "@@:@@")
}
if template.windowDidUpdate != nil {
windowDidUpdate :: proc "c" (self: id, notification: ^Notification) {
windowDidUpdate :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidUpdate(notification)
@@ -458,7 +458,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidUpdate:"), auto_cast windowDidUpdate, "v@:@")
}
if template.windowDidExpose != nil {
windowDidExpose :: proc "c" (self: id, notification: ^Notification) {
windowDidExpose :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidExpose(notification)
@@ -466,7 +466,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidExpose:"), auto_cast windowDidExpose, "v@:@")
}
if template.windowDidChangeOcclusionState != nil {
windowDidChangeOcclusionState :: proc "c" (self: id, notification: ^Notification) {
windowDidChangeOcclusionState :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidChangeOcclusionState(notification)
@@ -474,7 +474,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeOcclusionState:"), auto_cast windowDidChangeOcclusionState, "v@:@")
}
if template.windowShouldDragDocumentWithEventFromWithPasteboard != nil {
windowShouldDragDocumentWithEventFromWithPasteboard :: proc "c" (self: id, window: ^Window, event: ^Event, dragImageLocation: Point, pasteboard: ^Pasteboard) -> BOOL {
windowShouldDragDocumentWithEventFromWithPasteboard :: proc "c" (self: id, cmd: SEL, window: ^Window, event: ^Event, dragImageLocation: Point, pasteboard: ^Pasteboard) -> BOOL {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowShouldDragDocumentWithEventFromWithPasteboard(window, event, dragImageLocation, pasteboard)
@@ -482,7 +482,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:shouldDragDocumentWithEvent:from:withPasteboard:"), auto_cast windowShouldDragDocumentWithEventFromWithPasteboard, "B@:@@"+_POINT_ENCODING+"@")
}
if template.windowWillReturnUndoManager != nil {
windowWillReturnUndoManager :: proc "c" (self: id, window: ^Window) -> ^UndoManager {
windowWillReturnUndoManager :: proc "c" (self: id, cmd: SEL, window: ^Window) -> ^UndoManager {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillReturnUndoManager(window)
@@ -490,7 +490,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillReturnUndoManager:"), auto_cast windowWillReturnUndoManager, "@@:@")
}
if template.windowShouldPopUpDocumentPathMenu != nil {
windowShouldPopUpDocumentPathMenu :: proc "c" (self: id, window: ^Window, menu: ^Menu) -> BOOL {
windowShouldPopUpDocumentPathMenu :: proc "c" (self: id, cmd: SEL, window: ^Window, menu: ^Menu) -> BOOL {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowShouldPopUpDocumentPathMenu(window, menu)
@@ -498,7 +498,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:shouldPopUpDocumentPathMenu:"), auto_cast windowShouldPopUpDocumentPathMenu, "B@:@@")
}
if template.windowWillEncodeRestorableState != nil {
windowWillEncodeRestorableState :: proc "c" (self: id, window: ^Window, state: ^Coder) {
windowWillEncodeRestorableState :: proc "c" (self: id, cmd: SEL, window: ^Window, state: ^Coder) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillEncodeRestorableState(window, state)
@@ -506,7 +506,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:willEncodeRestorableState:"), auto_cast windowWillEncodeRestorableState, "v@:@@")
}
if template.windowDidEncodeRestorableState != nil {
windowDidEncodeRestorableState :: proc "c" (self: id, window: ^Window, state: ^Coder) {
windowDidEncodeRestorableState :: proc "c" (self: id, cmd: SEL, window: ^Window, state: ^Coder) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidEncodeRestorableState(window, state)
@@ -514,7 +514,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:didDecodeRestorableState:"), auto_cast windowDidEncodeRestorableState, "v@:@@")
}
if template.windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize != nil {
windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize :: proc "c" (self: id, window: ^Window, maxPreferredFrameSize: Size, maxAllowedFrameSize: Size) -> Size {
windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize :: proc "c" (self: id, cmd: SEL, window: ^Window, maxPreferredFrameSize: Size, maxAllowedFrameSize: Size) -> Size {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
return del.windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize(window, maxPreferredFrameSize, maxPreferredFrameSize)
@@ -522,7 +522,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("window:willResizeForVersionBrowserWithMaxPreferredSize:maxAllowedSize:"), auto_cast windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize, _SIZE_ENCODING+"@:@"+_SIZE_ENCODING+_SIZE_ENCODING)
}
if template.windowWillEnterVersionBrowser != nil {
windowWillEnterVersionBrowser :: proc "c" (self: id, notification: ^Notification) {
windowWillEnterVersionBrowser :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillEnterVersionBrowser(notification)
@@ -530,7 +530,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillEnterVersionBrowser:"), auto_cast windowWillEnterVersionBrowser, "v@:@")
}
if template.windowDidEnterVersionBrowser != nil {
windowDidEnterVersionBrowser :: proc "c" (self: id, notification: ^Notification) {
windowDidEnterVersionBrowser :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidEnterVersionBrowser(notification)
@@ -538,7 +538,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowDidEnterVersionBrowser:"), auto_cast windowDidEnterVersionBrowser, "v@:@")
}
if template.windowWillExitVersionBrowser != nil {
windowWillExitVersionBrowser :: proc "c" (self: id, notification: ^Notification) {
windowWillExitVersionBrowser :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowWillExitVersionBrowser(notification)
@@ -546,7 +546,7 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
class_addMethod(class, intrinsics.objc_find_selector("windowWillExitVersionBrowser:"), auto_cast windowWillExitVersionBrowser, "v@:@")
}
if template.windowDidExitVersionBrowser != nil {
windowDidExitVersionBrowser :: proc "c" (self: id, notification: ^Notification) {
windowDidExitVersionBrowser :: proc "c" (self: id, cmd: SEL, notification: ^Notification) {
del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self)
context = del._context
del.windowDidExitVersionBrowser(notification)
@@ -780,4 +780,4 @@ Window_performWindowDragWithEvent :: proc "c" (self: ^Window, event: ^Event) {
@(objc_type=Window, objc_name="setToolbar")
Window_setToolbar :: proc "c" (self: ^Window, toolbar: ^Toolbar) {
msgSend(nil, self, "setToolbar:", toolbar)
}
}
+12 -12
View File
@@ -204,21 +204,21 @@ accept_nil :: proc "contextless" (s: Fd) -> (Fd, Errno) {
accept :: proc { accept_T, accept_nil }
getsockname_or_peername :: proc "contextless" (s: Fd, sockaddr: ^$T, is_peer: bool) -> Errno {
// sockaddr must contain a valid pointer, or this will segfault because
// we're telling the syscall that there's memory available to write to.
addrlen: socklen_t = size_of(T)
// sockaddr must contain a valid pointer, or this will segfault because
// we're telling the syscall that there's memory available to write to.
addrlen: socklen_t = size_of(T)
result, ok := intrinsics.syscall_bsd(
is_peer ? SYS_getpeername : SYS_getsockname,
cast(uintptr)s,
cast(uintptr)sockaddr,
cast(uintptr)&addrlen)
result, ok := intrinsics.syscall_bsd(
is_peer ? SYS_getpeername : SYS_getsockname,
cast(uintptr)s,
cast(uintptr)sockaddr,
cast(uintptr)&addrlen)
if !ok {
return cast(Errno)result
}
if !ok {
return cast(Errno)result
}
return nil
return nil
}
// Get name of connected peer
+10 -6
View File
@@ -40,9 +40,13 @@ CPU_Feature :: enum u64 {
}
CPU_Features :: distinct bit_set[CPU_Feature; u64]
cpu_features: Maybe(CPU_Features)
cpu_name: Maybe(string)
CPU :: struct {
name: Maybe(string),
features: Maybe(CPU_Features),
physical_cores: int,
logical_cores: int,
}
cpu: CPU
@(private)
cpu_name_buf: [128]byte
@@ -53,7 +57,7 @@ init_cpu_name :: proc "contextless" () {
when ODIN_OS == .Darwin {
if unix.sysctlbyname("machdep.cpu.brand_string", &cpu_name_buf) {
cpu_name = string(cstring(rawptr(&cpu_name_buf)))
cpu.name = string(cstring(rawptr(&cpu_name_buf)))
generic = false
}
}
@@ -61,10 +65,10 @@ init_cpu_name :: proc "contextless" () {
if generic {
when ODIN_ARCH == .arm64 {
copy(cpu_name_buf[:], "ARM64")
cpu_name = string(cpu_name_buf[:len("ARM64")])
cpu.name = string(cpu_name_buf[:len("ARM64")])
} else {
copy(cpu_name_buf[:], "ARM")
cpu_name = string(cpu_name_buf[:len("ARM")])
cpu.name = string(cpu_name_buf[:len("ARM")])
}
}
}
+12
View File
@@ -0,0 +1,12 @@
package sysinfo
import "core:sys/unix"
@(init, private)
init_cpu_core_count :: proc "contextless" () {
physical, logical: i64
unix.sysctlbyname("hw.physicalcpu", &physical)
unix.sysctlbyname("hw.logicalcpu", &logical)
cpu.physical_cores = int(physical)
cpu.logical_cores = int(logical)
}
+1 -1
View File
@@ -5,7 +5,7 @@ import "core:sys/unix"
@(init, private)
init_cpu_features :: proc "contextless" () {
@(static) features: CPU_Features
defer cpu_features = features
defer cpu.features = features
try_set :: proc "contextless" (name: cstring, feature: CPU_Feature) -> (ok: bool) {
support: b32
+16 -12
View File
@@ -3,12 +3,6 @@ package sysinfo
import "base:intrinsics"
// cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) ---
cpuid :: intrinsics.x86_cpuid
// xgetbv :: proc(cx: u32) -> (eax, edx: u32) ---
xgetbv :: intrinsics.x86_xgetbv
CPU_Feature :: enum u64 {
aes, // AES hardware implementation (AES NI)
adx, // Multi-precision add-carry instruction extensions
@@ -49,9 +43,13 @@ CPU_Feature :: enum u64 {
}
CPU_Features :: distinct bit_set[CPU_Feature; u64]
cpu_features: Maybe(CPU_Features)
cpu_name: Maybe(string)
CPU :: struct {
name: Maybe(string),
features: Maybe(CPU_Features),
physical_cores: int, // Initialized by cpu_<os>.odin
logical_cores: int, // Initialized by cpu_<os>.odin
}
cpu: CPU
@(init, private)
init_cpu_features :: proc "c" () {
@@ -88,7 +86,7 @@ init_cpu_features :: proc "c" () {
when ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD {
// xgetbv is an illegal instruction under FreeBSD 13, OpenBSD 7.1 and NetBSD 10
// return before probing further
cpu_features = set
cpu.features = set
return
}
@@ -151,7 +149,7 @@ init_cpu_features :: proc "c" () {
try_set(&set, .rdseed, 18, ebx7)
try_set(&set, .adx, 19, ebx7)
cpu_features = set
cpu.features = set
}
@(private)
@@ -179,5 +177,11 @@ init_cpu_name :: proc "c" () {
for len(brand) > 0 && brand[len(brand) - 1] == 0 || brand[len(brand) - 1] == ' ' {
brand = brand[:len(brand) - 1]
}
cpu_name = brand
cpu.name = brand
}
// cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) ---
cpuid :: intrinsics.x86_cpuid
// xgetbv :: proc(cx: u32) -> (eax, edx: u32) ---
xgetbv :: intrinsics.x86_xgetbv
+1 -1
View File
@@ -17,7 +17,7 @@ init_cpu_features :: proc() {
if rerr != .NONE || n == 0 { return }
features: CPU_Features
defer cpu_features = features
defer cpu.features = features
str := string(buf[:n])
for line in strings.split_lines_iterator(&str) {
+38
View File
@@ -0,0 +1,38 @@
#+build i386, amd64
#+build linux
package sysinfo
import "core:sys/linux"
import "core:strings"
import "core:strconv"
@(init, private)
init_cpu_core_count :: proc() {
fd, err := linux.open("/proc/cpuinfo", {})
if err != .NONE { return }
defer linux.close(fd)
// This is probably enough right?
buf: [4096]byte
n, rerr := linux.read(fd, buf[:])
if rerr != .NONE || n == 0 { return }
str := string(buf[:n])
for line in strings.split_lines_iterator(&str) {
key, _, value := strings.partition(line, ":")
key = strings.trim_space(key)
value = strings.trim_space(value)
if key == "cpu cores" {
if num_physical_cores, ok := strconv.parse_int(value); ok {
cpu.physical_cores = num_physical_cores
}
}
if key == "siblings" {
if num_logical_cores, ok := strconv.parse_int(value); ok {
cpu.logical_cores = num_logical_cores
}
}
}
}
+2 -2
View File
@@ -9,7 +9,7 @@ import "core:sys/linux"
@(init, private)
init_cpu_features :: proc() {
_features: CPU_Features
defer cpu_features = _features
defer cpu.features = _features
HWCAP_Bits :: enum u64 {
I = 'I' - 'A',
@@ -109,5 +109,5 @@ init_cpu_features :: proc() {
@(init, private)
init_cpu_name :: proc() {
cpu_name = "RISCV64"
cpu.name = "RISCV64"
}
+7 -3
View File
@@ -95,6 +95,10 @@ CPU_Feature :: enum u64 {
}
CPU_Features :: distinct bit_set[CPU_Feature; u64]
cpu_features: Maybe(CPU_Features)
cpu_name: Maybe(string)
CPU :: struct {
name: Maybe(string),
features: Maybe(CPU_Features),
physical_cores: int,
logical_cores: int,
}
cpu: CPU
+28
View File
@@ -0,0 +1,28 @@
package sysinfo
import sys "core:sys/windows"
import "base:intrinsics"
@(init, private)
init_cpu_core_count :: proc() {
infos: []sys.SYSTEM_LOGICAL_PROCESSOR_INFORMATION
defer delete(infos)
returned_length: sys.DWORD
// Query for the required buffer size.
if ok := sys.GetLogicalProcessorInformation(raw_data(infos), &returned_length); !ok {
infos = make([]sys.SYSTEM_LOGICAL_PROCESSOR_INFORMATION, returned_length / size_of(sys.SYSTEM_LOGICAL_PROCESSOR_INFORMATION))
}
// If it still doesn't work, return
if ok := sys.GetLogicalProcessorInformation(raw_data(infos), &returned_length); !ok {
return
}
for info in infos {
#partial switch info.Relationship {
case .RelationProcessorCore: cpu.physical_cores += 1
case .RelationNumaNode: cpu.logical_cores += int(intrinsics.count_ones(info.ProcessorMask))
}
}
}
+8 -6
View File
@@ -26,13 +26,15 @@ Example:
import si "core:sys/info"
main :: proc() {
fmt.printfln("Odin: %v", ODIN_VERSION)
fmt.printfln("OS: %v", si.os_version.as_string)
fmt.printfln("OS: %#v", si.os_version)
fmt.printfln("CPU: %v", si.cpu_name)
fmt.printfln("RAM: %#.1M", si.ram.total_ram)
fmt.printfln("Odin: %v", ODIN_VERSION)
fmt.printfln("OS: %v", si.os_version.as_string)
fmt.printfln("OS: %#v", si.os_version)
fmt.printfln("CPU: %v", si.cpu.name)
fmt.printfln("CPU: %v", si.cpu.name)
fmt.printfln("CPU cores: %vc/%vt", si.cpu.physical_cores, si.cpu.logical_cores)
fmt.printfln("RAM: %#.1M", si.ram.total_ram)
// fmt.printfln("Features: %v", si.cpu_features)
// fmt.printfln("Features: %v", si.cpu.features)
// fmt.printfln("MacOS version: %v", si.macos_version)
fmt.println()
+10 -5
View File
@@ -50,7 +50,7 @@ foreign lib {
/*
Send a signal to a thread.
As with kill, if sig is 0, only validation (of the pthread_t given) is done and no signal is sent.
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html ]]
@@ -124,7 +124,7 @@ foreign lib {
sigignore :: proc(sig: Signal) -> result ---
/*
Removes sig from the signal mask of the calling process and suspend the calling process until
Removes sig from the signal mask of the calling process and suspend the calling process until
a signal is received.
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sighold.html ]]
@@ -166,7 +166,7 @@ foreign lib {
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigpending.html ]]
*/
@(link_name=LSIGPENDING)
sigpending :: proc(set: ^sigset_t) -> result ---
sigpending :: proc(set: ^sigset_t) -> result ---
/*
Wait for one of the given signals.
@@ -333,7 +333,7 @@ SS_Flag_Bits :: enum c.int {
SS_Flags :: bit_set[SS_Flag_Bits; c.int]
Sig :: enum c.int {
// Resulting set is the union of the current set and the signal set and the complement of
// Resulting set is the union of the current set and the signal set and the complement of
// the signal set pointed to by the argument.
BLOCK = SIG_BLOCK,
// Resulting set is the intersection of the current set and the complement of the signal set
@@ -395,6 +395,7 @@ when ODIN_OS == .Darwin {
SIGXFSZ :: 25
SIGVTALRM :: 26
SIGPROF :: 27
SIGWINCH :: 28
SIGUSR1 :: 30
SIGUSR2 :: 31
@@ -535,6 +536,7 @@ when ODIN_OS == .Darwin {
SIGXFSZ :: 25
SIGVTALRM :: 26
SIGPROF :: 27
SIGWINCH :: 28
SIGUSR1 :: 30
SIGUSR2 :: 31
@@ -699,6 +701,7 @@ when ODIN_OS == .Darwin {
SIGXFSZ :: 25
SIGVTALRM :: 26
SIGPROF :: 27
SIGWINCH :: 28
SIGUSR1 :: 30
SIGUSR2 :: 31
@@ -876,6 +879,7 @@ when ODIN_OS == .Darwin {
SIGXFSZ :: 25
SIGVTALRM :: 26
SIGPROF :: 27
SIGWINCH :: 28
SIGUSR1 :: 30
SIGUSR2 :: 31
@@ -1036,6 +1040,7 @@ when ODIN_OS == .Darwin {
SIGXFSZ :: 25
SIGVTALRM :: 26
SIGPROF :: 27
SIGWINCH :: 28
SIGPOLL :: 29
SIGSYS :: 31
@@ -1084,7 +1089,7 @@ when ODIN_OS == .Darwin {
@(private)
__SI_MAX_SIZE :: 128
when size_of(int) == 8 {
when size_of(int) == 8 {
@(private)
_pad0 :: struct {
_pad0: c.int,
+3 -7
View File
@@ -110,16 +110,12 @@ class WasmMemoryInterface {
}
loadCstring(ptr) {
return this.loadCstringDirect(this.loadPtr(ptr));
}
loadCstringDirect(start) {
if (start == 0) {
if (ptr == 0) {
return null;
}
let len = 0;
for (; this.mem.getUint8(start+len) != 0; len += 1) {}
return this.loadString(start, len);
for (; this.mem.getUint8(ptr+len) != 0; len += 1) {}
return this.loadString(ptr, len);
}
storeU8(addr, value) { this.mem.setUint8 (addr, value); }
+1 -2
View File
@@ -857,7 +857,6 @@ MEMORY_RESOURCE_NOTIFICATION_TYPE :: enum c_int {
LowMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.LowMemoryResourceNotification
HighMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.HighMemoryResourceNotification
@(default_calling_convention="system")
foreign kernel32 {
CreateMemoryResourceNotification :: proc(
@@ -1194,7 +1193,7 @@ DUMMYUNIONNAME_u :: struct #raw_union {
SYSTEM_LOGICAL_PROCESSOR_INFORMATION :: struct {
ProcessorMask: ULONG_PTR,
Relationship: LOGICAL_PROCESSOR_RELATIONSHIP,
DummyUnion: DUMMYUNIONNAME_u,
using DummyUnion: DUMMYUNIONNAME_u,
}
SYSTEM_POWER_STATUS :: struct {
+2
View File
@@ -52,6 +52,8 @@ foreign Ole32 {
ppv: ^LPVOID,
) -> HRESULT ---
CoTaskMemAlloc :: proc(cb: SIZE_T) -> rawptr ---
CoTaskMemRealloc :: proc(pv: rawptr, cb: SIZE_T) -> rawptr ---
CoTaskMemFree :: proc(pv: rawptr) ---
CLSIDFromProgID :: proc(lpszProgID: LPCOLESTR, lpclsid: LPCLSID) -> HRESULT ---
+8
View File
@@ -173,6 +173,9 @@ FACILITY :: enum DWORD {
EAS = 85,
WEB = 885,
WEB_SOCKET = 886,
XAUDIO2 = 896,
XAPO = 897,
GAMEINPUT = 906,
MOBILE = 1793,
SQLITE = 1967,
SERVICE_FABRIC = 1968,
@@ -231,6 +234,7 @@ ERROR_PIPE_BUSY : DWORD : 231
// https://learn.microsoft.com/en-us/windows/win32/seccrypto/common-hresult-values
S_OK :: 0x00000000 // Operation successful
S_FALSE :: 0x00000001
E_NOTIMPL :: 0x80004001 // Not implemented
E_NOINTERFACE :: 0x80004002 // No such interface supported
E_POINTER :: 0x80004003 // Pointer that is not valid
@@ -270,6 +274,10 @@ MAKE_HRESULT :: #force_inline proc "contextless" (#any_int sev: int, #any_int fa
return HRESULT((uint(sev)<<31) | (uint(fac)<<16) | (uint(code)))
}
HRESULT_FROM_WIN32 :: #force_inline proc "contextless" (#any_int code: int) -> HRESULT {
return HRESULT(code) <= 0 ? HRESULT(code) : HRESULT(uint(code & 0x0000FFFF) | (uint(FACILITY.WIN32) << 16) | 0x80000000)
}
DECODE_HRESULT :: #force_inline proc "contextless" (#any_int hr: int) -> (SEVERITY, FACILITY, int) {
return HRESULT_SEVERITY(hr), HRESULT_FACILITY(hr), HRESULT_CODE(hr)
}
+330 -17
View File
@@ -265,7 +265,7 @@ HWAVE :: distinct HANDLE
HWAVEIN :: distinct HANDLE
HWAVEOUT :: distinct HANDLE
LPHWAVEIN :: ^HWAVEIN
LPHWAVEIN :: ^HWAVEIN
LPHWAVEOUT :: ^HWAVEOUT
// https://learn.microsoft.com/en-us/windows/win32/multimedia/multimedia-timer-structures
@@ -311,9 +311,284 @@ MAXPNAMELEN :: 32
MAXERRORLENGTH :: 256
MMVERSION :: UINT
// Input is four characters string
// Output is little-endian u32 representation
MAKEFOURCC :: #force_inline proc "contextless" (s: [4]byte) -> DWORD {
return (DWORD(s[0])) | (DWORD(s[1]) << 8) | (DWORD(s[2]) << 16) | (DWORD(s[3]) << 24 )
}
/* flags for wFormatTag field of WAVEFORMAT */
WAVE_FORMAT_PCM :: 1
WAVE_FORMAT_UNKNOWN :: 0x0000 /* Microsoft Corporation */
WAVE_FORMAT_ADPCM :: 0x0002 /* Microsoft Corporation */
WAVE_FORMAT_IEEE_FLOAT :: 0x0003 /* Microsoft Corporation */
WAVE_FORMAT_VSELP :: 0x0004 /* Compaq Computer Corp. */
WAVE_FORMAT_IBM_CVSD :: 0x0005 /* IBM Corporation */
WAVE_FORMAT_ALAW :: 0x0006 /* Microsoft Corporation */
WAVE_FORMAT_MULAW :: 0x0007 /* Microsoft Corporation */
WAVE_FORMAT_DTS :: 0x0008 /* Microsoft Corporation */
WAVE_FORMAT_DRM :: 0x0009 /* Microsoft Corporation */
WAVE_FORMAT_WMAVOICE9 :: 0x000A /* Microsoft Corporation */
WAVE_FORMAT_WMAVOICE10 :: 0x000B /* Microsoft Corporation */
WAVE_FORMAT_OKI_ADPCM :: 0x0010 /* OKI */
WAVE_FORMAT_DVI_ADPCM :: 0x0011 /* Intel Corporation */
WAVE_FORMAT_IMA_ADPCM :: WAVE_FORMAT_DVI_ADPCM /* Intel Corporation */
WAVE_FORMAT_MEDIASPACE_ADPCM :: 0x0012 /* Videologic */
WAVE_FORMAT_SIERRA_ADPCM :: 0x0013 /* Sierra Semiconductor Corp */
WAVE_FORMAT_G723_ADPCM :: 0x0014 /* Antex Electronics Corporation */
WAVE_FORMAT_DIGISTD :: 0x0015 /* DSP Solutions, Inc. */
WAVE_FORMAT_DIGIFIX :: 0x0016 /* DSP Solutions, Inc. */
WAVE_FORMAT_DIALOGIC_OKI_ADPCM :: 0x0017 /* Dialogic Corporation */
WAVE_FORMAT_MEDIAVISION_ADPCM :: 0x0018 /* Media Vision, Inc. */
WAVE_FORMAT_CU_CODEC :: 0x0019 /* Hewlett-Packard Company */
WAVE_FORMAT_HP_DYN_VOICE :: 0x001A /* Hewlett-Packard Company */
WAVE_FORMAT_YAMAHA_ADPCM :: 0x0020 /* Yamaha Corporation of America */
WAVE_FORMAT_SONARC :: 0x0021 /* Speech Compression */
WAVE_FORMAT_DSPGROUP_TRUESPEECH :: 0x0022 /* DSP Group, Inc */
WAVE_FORMAT_ECHOSC1 :: 0x0023 /* Echo Speech Corporation */
WAVE_FORMAT_AUDIOFILE_AF36 :: 0x0024 /* Virtual Music, Inc. */
WAVE_FORMAT_APTX :: 0x0025 /* Audio Processing Technology */
WAVE_FORMAT_AUDIOFILE_AF10 :: 0x0026 /* Virtual Music, Inc. */
WAVE_FORMAT_PROSODY_1612 :: 0x0027 /* Aculab plc */
WAVE_FORMAT_LRC :: 0x0028 /* Merging Technologies S.A. */
WAVE_FORMAT_DOLBY_AC2 :: 0x0030 /* Dolby Laboratories */
WAVE_FORMAT_GSM610 :: 0x0031 /* Microsoft Corporation */
WAVE_FORMAT_MSNAUDIO :: 0x0032 /* Microsoft Corporation */
WAVE_FORMAT_ANTEX_ADPCME :: 0x0033 /* Antex Electronics Corporation */
WAVE_FORMAT_CONTROL_RES_VQLPC :: 0x0034 /* Control Resources Limited */
WAVE_FORMAT_DIGIREAL :: 0x0035 /* DSP Solutions, Inc. */
WAVE_FORMAT_DIGIADPCM :: 0x0036 /* DSP Solutions, Inc. */
WAVE_FORMAT_CONTROL_RES_CR10 :: 0x0037 /* Control Resources Limited */
WAVE_FORMAT_NMS_VBXADPCM :: 0x0038 /* Natural MicroSystems */
WAVE_FORMAT_CS_IMAADPCM :: 0x0039 /* Crystal Semiconductor IMA ADPCM */
WAVE_FORMAT_ECHOSC3 :: 0x003A /* Echo Speech Corporation */
WAVE_FORMAT_ROCKWELL_ADPCM :: 0x003B /* Rockwell International */
WAVE_FORMAT_ROCKWELL_DIGITALK :: 0x003C /* Rockwell International */
WAVE_FORMAT_XEBEC :: 0x003D /* Xebec Multimedia Solutions Limited */
WAVE_FORMAT_G721_ADPCM :: 0x0040 /* Antex Electronics Corporation */
WAVE_FORMAT_G728_CELP :: 0x0041 /* Antex Electronics Corporation */
WAVE_FORMAT_MSG723 :: 0x0042 /* Microsoft Corporation */
WAVE_FORMAT_INTEL_G723_1 :: 0x0043 /* Intel Corp. */
WAVE_FORMAT_INTEL_G729 :: 0x0044 /* Intel Corp. */
WAVE_FORMAT_SHARP_G726 :: 0x0045 /* Sharp */
WAVE_FORMAT_MPEG :: 0x0050 /* Microsoft Corporation */
WAVE_FORMAT_RT24 :: 0x0052 /* InSoft, Inc. */
WAVE_FORMAT_PAC :: 0x0053 /* InSoft, Inc. */
WAVE_FORMAT_MPEGLAYER3 :: 0x0055 /* ISO/MPEG Layer3 Format Tag */
WAVE_FORMAT_LUCENT_G723 :: 0x0059 /* Lucent Technologies */
WAVE_FORMAT_CIRRUS :: 0x0060 /* Cirrus Logic */
WAVE_FORMAT_ESPCM :: 0x0061 /* ESS Technology */
WAVE_FORMAT_VOXWARE :: 0x0062 /* Voxware Inc */
WAVE_FORMAT_CANOPUS_ATRAC :: 0x0063 /* Canopus, co., Ltd. */
WAVE_FORMAT_G726_ADPCM :: 0x0064 /* APICOM */
WAVE_FORMAT_G722_ADPCM :: 0x0065 /* APICOM */
WAVE_FORMAT_DSAT :: 0x0066 /* Microsoft Corporation */
WAVE_FORMAT_DSAT_DISPLAY :: 0x0067 /* Microsoft Corporation */
WAVE_FORMAT_VOXWARE_BYTE_ALIGNED :: 0x0069 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_AC8 :: 0x0070 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_AC10 :: 0x0071 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_AC16 :: 0x0072 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_AC20 :: 0x0073 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_RT24 :: 0x0074 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_RT29 :: 0x0075 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_RT29HW :: 0x0076 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_VR12 :: 0x0077 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_VR18 :: 0x0078 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_TQ40 :: 0x0079 /* Voxware Inc */
WAVE_FORMAT_VOXWARE_SC3 :: 0x007A /* Voxware Inc */
WAVE_FORMAT_VOXWARE_SC3_1 :: 0x007B /* Voxware Inc */
WAVE_FORMAT_SOFTSOUND :: 0x0080 /* Softsound, Ltd. */
WAVE_FORMAT_VOXWARE_TQ60 :: 0x0081 /* Voxware Inc */
WAVE_FORMAT_MSRT24 :: 0x0082 /* Microsoft Corporation */
WAVE_FORMAT_G729A :: 0x0083 /* AT&T Labs, Inc. */
WAVE_FORMAT_MVI_MVI2 :: 0x0084 /* Motion Pixels */
WAVE_FORMAT_DF_G726 :: 0x0085 /* DataFusion Systems (Pty) (Ltd) */
WAVE_FORMAT_DF_GSM610 :: 0x0086 /* DataFusion Systems (Pty) (Ltd) */
WAVE_FORMAT_ISIAUDIO :: 0x0088 /* Iterated Systems, Inc. */
WAVE_FORMAT_ONLIVE :: 0x0089 /* OnLive! Technologies, Inc. */
WAVE_FORMAT_MULTITUDE_FT_SX20 :: 0x008A /* Multitude Inc. */
WAVE_FORMAT_INFOCOM_ITS_G721_ADPCM :: 0x008B /* Infocom */
WAVE_FORMAT_CONVEDIA_G729 :: 0x008C /* Convedia Corp. */
WAVE_FORMAT_CONGRUENCY :: 0x008D /* Congruency Inc. */
WAVE_FORMAT_SBC24 :: 0x0091 /* Siemens Business Communications Sys */
WAVE_FORMAT_DOLBY_AC3_SPDIF :: 0x0092 /* Sonic Foundry */
WAVE_FORMAT_MEDIASONIC_G723 :: 0x0093 /* MediaSonic */
WAVE_FORMAT_PROSODY_8KBPS :: 0x0094 /* Aculab plc */
WAVE_FORMAT_ZYXEL_ADPCM :: 0x0097 /* ZyXEL Communications, Inc. */
WAVE_FORMAT_PHILIPS_LPCBB :: 0x0098 /* Philips Speech Processing */
WAVE_FORMAT_PACKED :: 0x0099 /* Studer Professional Audio AG */
WAVE_FORMAT_MALDEN_PHONYTALK :: 0x00A0 /* Malden Electronics Ltd. */
WAVE_FORMAT_RACAL_RECORDER_GSM :: 0x00A1 /* Racal recorders */
WAVE_FORMAT_RACAL_RECORDER_G720_A :: 0x00A2 /* Racal recorders */
WAVE_FORMAT_RACAL_RECORDER_G723_1 :: 0x00A3 /* Racal recorders */
WAVE_FORMAT_RACAL_RECORDER_TETRA_ACELP :: 0x00A4 /* Racal recorders */
WAVE_FORMAT_NEC_AAC :: 0x00B0 /* NEC Corp. */
WAVE_FORMAT_RAW_AAC1 :: 0x00FF /* For Raw AAC, with format block AudioSpecificConfig() (as defined by MPEG-4), that follows WAVEFORMATEX */
WAVE_FORMAT_RHETOREX_ADPCM :: 0x0100 /* Rhetorex Inc. */
WAVE_FORMAT_IRAT :: 0x0101 /* BeCubed Software Inc. */
WAVE_FORMAT_VIVO_G723 :: 0x0111 /* Vivo Software */
WAVE_FORMAT_VIVO_SIREN :: 0x0112 /* Vivo Software */
WAVE_FORMAT_PHILIPS_CELP :: 0x0120 /* Philips Speech Processing */
WAVE_FORMAT_PHILIPS_GRUNDIG :: 0x0121 /* Philips Speech Processing */
WAVE_FORMAT_DIGITAL_G723 :: 0x0123 /* Digital Equipment Corporation */
WAVE_FORMAT_SANYO_LD_ADPCM :: 0x0125 /* Sanyo Electric Co., Ltd. */
WAVE_FORMAT_SIPROLAB_ACEPLNET :: 0x0130 /* Sipro Lab Telecom Inc. */
WAVE_FORMAT_SIPROLAB_ACELP4800 :: 0x0131 /* Sipro Lab Telecom Inc. */
WAVE_FORMAT_SIPROLAB_ACELP8V3 :: 0x0132 /* Sipro Lab Telecom Inc. */
WAVE_FORMAT_SIPROLAB_G729 :: 0x0133 /* Sipro Lab Telecom Inc. */
WAVE_FORMAT_SIPROLAB_G729A :: 0x0134 /* Sipro Lab Telecom Inc. */
WAVE_FORMAT_SIPROLAB_KELVIN :: 0x0135 /* Sipro Lab Telecom Inc. */
WAVE_FORMAT_VOICEAGE_AMR :: 0x0136 /* VoiceAge Corp. */
WAVE_FORMAT_G726ADPCM :: 0x0140 /* Dictaphone Corporation */
WAVE_FORMAT_DICTAPHONE_CELP68 :: 0x0141 /* Dictaphone Corporation */
WAVE_FORMAT_DICTAPHONE_CELP54 :: 0x0142 /* Dictaphone Corporation */
WAVE_FORMAT_QUALCOMM_PUREVOICE :: 0x0150 /* Qualcomm, Inc. */
WAVE_FORMAT_QUALCOMM_HALFRATE :: 0x0151 /* Qualcomm, Inc. */
WAVE_FORMAT_TUBGSM :: 0x0155 /* Ring Zero Systems, Inc. */
WAVE_FORMAT_MSAUDIO1 :: 0x0160 /* Microsoft Corporation */
WAVE_FORMAT_WMAUDIO2 :: 0x0161 /* Microsoft Corporation */
WAVE_FORMAT_WMAUDIO3 :: 0x0162 /* Microsoft Corporation */
WAVE_FORMAT_WMAUDIO_LOSSLESS :: 0x0163 /* Microsoft Corporation */
WAVE_FORMAT_WMASPDIF :: 0x0164 /* Microsoft Corporation */
WAVE_FORMAT_UNISYS_NAP_ADPCM :: 0x0170 /* Unisys Corp. */
WAVE_FORMAT_UNISYS_NAP_ULAW :: 0x0171 /* Unisys Corp. */
WAVE_FORMAT_UNISYS_NAP_ALAW :: 0x0172 /* Unisys Corp. */
WAVE_FORMAT_UNISYS_NAP_16K :: 0x0173 /* Unisys Corp. */
WAVE_FORMAT_SYCOM_ACM_SYC008 :: 0x0174 /* SyCom Technologies */
WAVE_FORMAT_SYCOM_ACM_SYC701_G726L :: 0x0175 /* SyCom Technologies */
WAVE_FORMAT_SYCOM_ACM_SYC701_CELP54 :: 0x0176 /* SyCom Technologies */
WAVE_FORMAT_SYCOM_ACM_SYC701_CELP68 :: 0x0177 /* SyCom Technologies */
WAVE_FORMAT_KNOWLEDGE_ADVENTURE_ADPCM :: 0x0178 /* Knowledge Adventure, Inc. */
WAVE_FORMAT_FRAUNHOFER_IIS_MPEG2_AAC :: 0x0180 /* Fraunhofer IIS */
WAVE_FORMAT_DTS_DS :: 0x0190 /* Digital Theatre Systems, Inc. */
WAVE_FORMAT_CREATIVE_ADPCM :: 0x0200 /* Creative Labs, Inc */
WAVE_FORMAT_CREATIVE_FASTSPEECH8 :: 0x0202 /* Creative Labs, Inc */
WAVE_FORMAT_CREATIVE_FASTSPEECH10 :: 0x0203 /* Creative Labs, Inc */
WAVE_FORMAT_UHER_ADPCM :: 0x0210 /* UHER informatic GmbH */
WAVE_FORMAT_ULEAD_DV_AUDIO :: 0x0215 /* Ulead Systems, Inc. */
WAVE_FORMAT_ULEAD_DV_AUDIO_1 :: 0x0216 /* Ulead Systems, Inc. */
WAVE_FORMAT_QUARTERDECK :: 0x0220 /* Quarterdeck Corporation */
WAVE_FORMAT_ILINK_VC :: 0x0230 /* I-link Worldwide */
WAVE_FORMAT_RAW_SPORT :: 0x0240 /* Aureal Semiconductor */
WAVE_FORMAT_ESST_AC3 :: 0x0241 /* ESS Technology, Inc. */
WAVE_FORMAT_GENERIC_PASSTHRU :: 0x0249
WAVE_FORMAT_IPI_HSX :: 0x0250 /* Interactive Products, Inc. */
WAVE_FORMAT_IPI_RPELP :: 0x0251 /* Interactive Products, Inc. */
WAVE_FORMAT_CS2 :: 0x0260 /* Consistent Software */
WAVE_FORMAT_SONY_SCX :: 0x0270 /* Sony Corp. */
WAVE_FORMAT_SONY_SCY :: 0x0271 /* Sony Corp. */
WAVE_FORMAT_SONY_ATRAC3 :: 0x0272 /* Sony Corp. */
WAVE_FORMAT_SONY_SPC :: 0x0273 /* Sony Corp. */
WAVE_FORMAT_TELUM_AUDIO :: 0x0280 /* Telum Inc. */
WAVE_FORMAT_TELUM_IA_AUDIO :: 0x0281 /* Telum Inc. */
WAVE_FORMAT_NORCOM_VOICE_SYSTEMS_ADPCM :: 0x0285 /* Norcom Electronics Corp. */
WAVE_FORMAT_FM_TOWNS_SND :: 0x0300 /* Fujitsu Corp. */
WAVE_FORMAT_MICRONAS :: 0x0350 /* Micronas Semiconductors, Inc. */
WAVE_FORMAT_MICRONAS_CELP833 :: 0x0351 /* Micronas Semiconductors, Inc. */
WAVE_FORMAT_BTV_DIGITAL :: 0x0400 /* Brooktree Corporation */
WAVE_FORMAT_INTEL_MUSIC_CODER :: 0x0401 /* Intel Corp. */
WAVE_FORMAT_INDEO_AUDIO :: 0x0402 /* Ligos */
WAVE_FORMAT_QDESIGN_MUSIC :: 0x0450 /* QDesign Corporation */
WAVE_FORMAT_ON2_VP7_AUDIO :: 0x0500 /* On2 Technologies */
WAVE_FORMAT_ON2_VP6_AUDIO :: 0x0501 /* On2 Technologies */
WAVE_FORMAT_VME_VMPCM :: 0x0680 /* AT&T Labs, Inc. */
WAVE_FORMAT_TPC :: 0x0681 /* AT&T Labs, Inc. */
WAVE_FORMAT_LIGHTWAVE_LOSSLESS :: 0x08AE /* Clearjump */
WAVE_FORMAT_OLIGSM :: 0x1000 /* Ing C. Olivetti & C., S.p.A. */
WAVE_FORMAT_OLIADPCM :: 0x1001 /* Ing C. Olivetti & C., S.p.A. */
WAVE_FORMAT_OLICELP :: 0x1002 /* Ing C. Olivetti & C., S.p.A. */
WAVE_FORMAT_OLISBC :: 0x1003 /* Ing C. Olivetti & C., S.p.A. */
WAVE_FORMAT_OLIOPR :: 0x1004 /* Ing C. Olivetti & C., S.p.A. */
WAVE_FORMAT_LH_CODEC :: 0x1100 /* Lernout & Hauspie */
WAVE_FORMAT_LH_CODEC_CELP :: 0x1101 /* Lernout & Hauspie */
WAVE_FORMAT_LH_CODEC_SBC8 :: 0x1102 /* Lernout & Hauspie */
WAVE_FORMAT_LH_CODEC_SBC12 :: 0x1103 /* Lernout & Hauspie */
WAVE_FORMAT_LH_CODEC_SBC16 :: 0x1104 /* Lernout & Hauspie */
WAVE_FORMAT_NORRIS :: 0x1400 /* Norris Communications, Inc. */
WAVE_FORMAT_ISIAUDIO_2 :: 0x1401 /* ISIAudio */
WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS :: 0x1500 /* AT&T Labs, Inc. */
WAVE_FORMAT_MPEG_ADTS_AAC :: 0x1600 /* Microsoft Corporation */
WAVE_FORMAT_MPEG_RAW_AAC :: 0x1601 /* Microsoft Corporation */
WAVE_FORMAT_MPEG_LOAS :: 0x1602 /* Microsoft Corporation (MPEG-4 Audio Transport Streams (LOAS/LATM) */
WAVE_FORMAT_NOKIA_MPEG_ADTS_AAC :: 0x1608 /* Microsoft Corporation */
WAVE_FORMAT_NOKIA_MPEG_RAW_AAC :: 0x1609 /* Microsoft Corporation */
WAVE_FORMAT_VODAFONE_MPEG_ADTS_AAC :: 0x160A /* Microsoft Corporation */
WAVE_FORMAT_VODAFONE_MPEG_RAW_AAC :: 0x160B /* Microsoft Corporation */
WAVE_FORMAT_MPEG_HEAAC :: 0x1610 /* Microsoft Corporation (MPEG-2 AAC or MPEG-4 HE-AAC v1/v2 streams with any payload (ADTS, ADIF, LOAS/LATM, RAW). Format block includes MP4 AudioSpecificConfig() -- see HEAACWAVEFORMAT below */
WAVE_FORMAT_VOXWARE_RT24_SPEECH :: 0x181C /* Voxware Inc. */
WAVE_FORMAT_SONICFOUNDRY_LOSSLESS :: 0x1971 /* Sonic Foundry */
WAVE_FORMAT_INNINGS_TELECOM_ADPCM :: 0x1979 /* Innings Telecom Inc. */
WAVE_FORMAT_LUCENT_SX8300P :: 0x1C07 /* Lucent Technologies */
WAVE_FORMAT_LUCENT_SX5363S :: 0x1C0C /* Lucent Technologies */
WAVE_FORMAT_CUSEEME :: 0x1F03 /* CUSeeMe */
WAVE_FORMAT_NTCSOFT_ALF2CM_ACM :: 0x1FC4 /* NTCSoft */
WAVE_FORMAT_DVM :: 0x2000 /* FAST Multimedia AG */
WAVE_FORMAT_DTS2 :: 0x2001
WAVE_FORMAT_MAKEAVIS :: 0x3313
WAVE_FORMAT_DIVIO_MPEG4_AAC :: 0x4143 /* Divio, Inc. */
WAVE_FORMAT_NOKIA_ADAPTIVE_MULTIRATE :: 0x4201 /* Nokia */
WAVE_FORMAT_DIVIO_G726 :: 0x4243 /* Divio, Inc. */
WAVE_FORMAT_LEAD_SPEECH :: 0x434C /* LEAD Technologies */
WAVE_FORMAT_LEAD_VORBIS :: 0x564C /* LEAD Technologies */
WAVE_FORMAT_WAVPACK_AUDIO :: 0x5756 /* xiph.org */
WAVE_FORMAT_ALAC :: 0x6C61 /* Apple Lossless */
WAVE_FORMAT_OGG_VORBIS_MODE_1 :: 0x674F /* Ogg Vorbis */
WAVE_FORMAT_OGG_VORBIS_MODE_2 :: 0x6750 /* Ogg Vorbis */
WAVE_FORMAT_OGG_VORBIS_MODE_3 :: 0x6751 /* Ogg Vorbis */
WAVE_FORMAT_OGG_VORBIS_MODE_1_PLUS :: 0x676F /* Ogg Vorbis */
WAVE_FORMAT_OGG_VORBIS_MODE_2_PLUS :: 0x6770 /* Ogg Vorbis */
WAVE_FORMAT_OGG_VORBIS_MODE_3_PLUS :: 0x6771 /* Ogg Vorbis */
WAVE_FORMAT_3COM_NBX :: 0x7000 /* 3COM Corp. */
WAVE_FORMAT_OPUS :: 0x704F /* Opus */
WAVE_FORMAT_FAAD_AAC :: 0x706D
WAVE_FORMAT_AMR_NB :: 0x7361 /* AMR Narrowband */
WAVE_FORMAT_AMR_WB :: 0x7362 /* AMR Wideband */
WAVE_FORMAT_AMR_WP :: 0x7363 /* AMR Wideband Plus */
WAVE_FORMAT_GSM_AMR_CBR :: 0x7A21 /* GSMA/3GPP */
WAVE_FORMAT_GSM_AMR_VBR_SID :: 0x7A22 /* GSMA/3GPP */
WAVE_FORMAT_COMVERSE_INFOSYS_G723_1 :: 0xA100 /* Comverse Infosys */
WAVE_FORMAT_COMVERSE_INFOSYS_AVQSBC :: 0xA101 /* Comverse Infosys */
WAVE_FORMAT_COMVERSE_INFOSYS_SBC :: 0xA102 /* Comverse Infosys */
WAVE_FORMAT_SYMBOL_G729_A :: 0xA103 /* Symbol Technologies */
WAVE_FORMAT_VOICEAGE_AMR_WB :: 0xA104 /* VoiceAge Corp. */
WAVE_FORMAT_INGENIENT_G726 :: 0xA105 /* Ingenient Technologies, Inc. */
WAVE_FORMAT_MPEG4_AAC :: 0xA106 /* ISO/MPEG-4 */
WAVE_FORMAT_ENCORE_G726 :: 0xA107 /* Encore Software */
WAVE_FORMAT_ZOLL_ASAO :: 0xA108 /* ZOLL Medical Corp. */
WAVE_FORMAT_SPEEX_VOICE :: 0xA109 /* xiph.org */
WAVE_FORMAT_VIANIX_MASC :: 0xA10A /* Vianix LLC */
WAVE_FORMAT_WM9_SPECTRUM_ANALYZER :: 0xA10B /* Microsoft */
WAVE_FORMAT_WMF_SPECTRUM_ANAYZER :: 0xA10C /* Microsoft */
WAVE_FORMAT_GSM_610 :: 0xA10D
WAVE_FORMAT_GSM_620 :: 0xA10E
WAVE_FORMAT_GSM_660 :: 0xA10F
WAVE_FORMAT_GSM_690 :: 0xA110
WAVE_FORMAT_GSM_ADAPTIVE_MULTIRATE_WB :: 0xA111
WAVE_FORMAT_POLYCOM_G722 :: 0xA112 /* Polycom */
WAVE_FORMAT_POLYCOM_G728 :: 0xA113 /* Polycom */
WAVE_FORMAT_POLYCOM_G729_A :: 0xA114 /* Polycom */
WAVE_FORMAT_POLYCOM_SIREN :: 0xA115 /* Polycom */
WAVE_FORMAT_GLOBAL_IP_ILBC :: 0xA116 /* Global IP */
WAVE_FORMAT_RADIOTIME_TIME_SHIFT_RADIO :: 0xA117 /* RadioTime */
WAVE_FORMAT_NICE_ACA :: 0xA118 /* Nice Systems */
WAVE_FORMAT_NICE_ADPCM :: 0xA119 /* Nice Systems */
WAVE_FORMAT_VOCORD_G721 :: 0xA11A /* Vocord Telecom */
WAVE_FORMAT_VOCORD_G726 :: 0xA11B /* Vocord Telecom */
WAVE_FORMAT_VOCORD_G722_1 :: 0xA11C /* Vocord Telecom */
WAVE_FORMAT_VOCORD_G728 :: 0xA11D /* Vocord Telecom */
WAVE_FORMAT_VOCORD_G729 :: 0xA11E /* Vocord Telecom */
WAVE_FORMAT_VOCORD_G729_A :: 0xA11F /* Vocord Telecom */
WAVE_FORMAT_VOCORD_G723_1 :: 0xA120 /* Vocord Telecom */
WAVE_FORMAT_VOCORD_LBC :: 0xA121 /* Vocord Telecom */
WAVE_FORMAT_NICE_G728 :: 0xA122 /* Nice Systems */
WAVE_FORMAT_FRACE_TELECOM_G729 :: 0xA123 /* France Telecom */
WAVE_FORMAT_CODIAN :: 0xA124 /* CODIAN */
WAVE_FORMAT_DOLBY_AC4 :: 0xAC40 /* Dolby AC-4 */
WAVE_FORMAT_FLAC :: 0xF1AC /* flac.sourceforge.net */
WAVE_FORMAT_EXTENSIBLE :: 0xFFFE /* Microsoft */
WAVEFORMATEX :: struct {
wFormatTag: WORD,
nChannels: WORD,
@@ -325,6 +600,20 @@ WAVEFORMATEX :: struct {
}
LPCWAVEFORMATEX :: ^WAVEFORMATEX
// New wave format development should be based on the WAVEFORMATEXTENSIBLE structure.
// WAVEFORMATEXTENSIBLE allows you to avoid having to register a new format tag with Microsoft.
// Simply define a new GUID value for the WAVEFORMATEXTENSIBLE.SubFormat field and use WAVE_FORMAT_EXTENSIBLE in the WAVEFORMATEXTENSIBLE.Format.wFormatTag field.
WAVEFORMATEXTENSIBLE :: struct {
using Format: WAVEFORMATEX,
Samples: struct #raw_union {
wValidBitsPerSample: WORD, /* bits of precision */
wSamplesPerBlock: WORD, /* valid if wBitsPerSample==0 */
wReserved: WORD, /* If neither applies, set to zero. */
},
dwChannelMask: SPEAKER_FLAGS, /* which channels are present in stream */
SubFormat: GUID,
}
WAVEHDR :: struct {
lpData: LPSTR, /* pointer to locked data buffer */
dwBufferLength: DWORD, /* length of data buffer */
@@ -360,26 +649,50 @@ WAVEOUTCAPSW :: struct {
}
LPWAVEOUTCAPSW :: ^WAVEOUTCAPSW
SPEAKER_FLAGS :: distinct bit_set[SPEAKER_FLAG; DWORD]
SPEAKER_FLAG :: enum DWORD {
FRONT_LEFT = 0,
FRONT_RIGHT = 1,
FRONT_CENTER = 2,
LOW_FREQUENCY = 3,
BACK_LEFT = 4,
BACK_RIGHT = 5,
FRONT_LEFT_OF_CENTER = 6,
FRONT_RIGHT_OF_CENTER = 7,
BACK_CENTER = 8,
SIDE_LEFT = 9,
SIDE_RIGHT = 10,
TOP_CENTER = 11,
TOP_FRONT_LEFT = 12,
TOP_FRONT_CENTER = 13,
TOP_FRONT_RIGHT = 14,
TOP_BACK_LEFT = 15,
TOP_BACK_CENTER = 16,
TOP_BACK_RIGHT = 17,
//RESERVED = 0x7FFC0000, // bit mask locations reserved for future use
ALL = 31, // used to specify that any possible permutation of speaker configurations
}
// flag values for PlaySound
SND_SYNC :: 0x0000 /* play synchronously (default) */
SND_ASYNC :: 0x0001 /* play asynchronously */
SND_NODEFAULT :: 0x0002 /* silence (!default) if sound not found */
SND_MEMORY :: 0x0004 /* pszSound points to a memory file */
SND_LOOP :: 0x0008 /* loop the sound until next sndPlaySound */
SND_NOSTOP :: 0x0010 /* don't stop any currently playing sound */
SND_SYNC :: 0x0000 /* play synchronously (default) */
SND_ASYNC :: 0x0001 /* play asynchronously */
SND_NODEFAULT :: 0x0002 /* silence (!default) if sound not found */
SND_MEMORY :: 0x0004 /* pszSound points to a memory file */
SND_LOOP :: 0x0008 /* loop the sound until next sndPlaySound */
SND_NOSTOP :: 0x0010 /* don't stop any currently playing sound */
SND_NOWAIT :: 0x00002000 /* don't wait if the driver is busy */
SND_ALIAS :: 0x00010000 /* name is a registry alias */
SND_ALIAS_ID :: 0x00110000 /* alias is a predefined ID */
SND_FILENAME :: 0x00020000 /* name is file name */
SND_RESOURCE :: 0x00040004 /* name is resource name or atom */
SND_NOWAIT :: 0x00002000 /* don't wait if the driver is busy */
SND_ALIAS :: 0x00010000 /* name is a registry alias */
SND_ALIAS_ID :: 0x00110000 /* alias is a predefined ID */
SND_FILENAME :: 0x00020000 /* name is file name */
SND_RESOURCE :: 0x00040004 /* name is resource name or atom */
SND_PURGE :: 0x0040 /* purge non-static events for task */
SND_APPLICATION :: 0x0080 /* look for application specific association */
SND_PURGE :: 0x0040 /* purge non-static events for task */
SND_APPLICATION :: 0x0080 /* look for application specific association */
SND_SENTRY :: 0x00080000 /* Generate a SoundSentry event with this sound */
SND_RING :: 0x00100000 /* Treat this as a "ring" from a communications app - don't duck me */
SND_SYSTEM :: 0x00200000 /* Treat this as a system sound */
SND_SENTRY :: 0x00080000 /* Generate a SoundSentry event with this sound */
SND_RING :: 0x00100000 /* Treat this as a "ring" from a communications app - don't duck me */
SND_SYSTEM :: 0x00200000 /* Treat this as a system sound */
CALLBACK_TYPEMASK :: 0x00070000 /* callback type mask */
-3
View File
@@ -15,8 +15,6 @@ MAX_PROGRAM_SIZE :: int(max(i16))
MAX_CLASSES :: int(max(u8))
Flag :: enum u8 {
// Global: try to match the pattern anywhere in the string.
Global,
// Multiline: treat `^` and `$` as if they also match newlines.
Multiline,
// Case Insensitive: treat `a-z` as if it was also `A-Z`.
@@ -36,7 +34,6 @@ Flags :: bit_set[Flag; u8]
@(rodata)
Flag_To_Letter := #sparse[Flag]u8 {
.Global = 'g',
.Multiline = 'm',
.Case_Insensitive = 'i',
.Ignore_Whitespace = 'x',
+15 -7
View File
@@ -195,8 +195,12 @@ generate_code :: proc(c: ^Compiler, node: Node) -> (code: Program) {
case ^Node_Anchor:
if .Multiline in c.flags {
append(&code, Opcode.Multiline_Open)
append(&code, Opcode.Multiline_Close)
if specific.start {
append(&code, Opcode.Assert_Start_Multiline)
} else {
append(&code, Opcode.Multiline_Open)
append(&code, Opcode.Multiline_Close)
}
} else {
if specific.start {
append(&code, Opcode.Assert_Start)
@@ -401,7 +405,7 @@ compile :: proc(tree: Node, flags: common.Flags) -> (code: Program, class_data:
pc_open := 0
add_global: if .Global in flags {
optimize_opening: {
// Check if the opening to the pattern is predictable.
// If so, use one of the optimized Wait opcodes.
iter := virtual_machine.Opcode_Iterator{ code[:], 0 }
@@ -412,7 +416,7 @@ compile :: proc(tree: Node, flags: common.Flags) -> (code: Program, class_data:
pc_open += size_of(Opcode)
inject_at(&code, pc_open, Opcode(code[pc + size_of(Opcode) + pc_open]))
pc_open += size_of(u8)
break add_global
break optimize_opening
case .Rune:
operand := intrinsics.unaligned_load(cast(^rune)&code[pc+1])
@@ -420,24 +424,28 @@ compile :: proc(tree: Node, flags: common.Flags) -> (code: Program, class_data:
pc_open += size_of(Opcode)
inject_raw(&code, pc_open, operand)
pc_open += size_of(rune)
break add_global
break optimize_opening
case .Rune_Class:
inject_at(&code, pc_open, Opcode.Wait_For_Rune_Class)
pc_open += size_of(Opcode)
inject_at(&code, pc_open, Opcode(code[pc + size_of(Opcode) + pc_open]))
pc_open += size_of(u8)
break add_global
break optimize_opening
case .Rune_Class_Negated:
inject_at(&code, pc_open, Opcode.Wait_For_Rune_Class_Negated)
pc_open += size_of(Opcode)
inject_at(&code, pc_open, Opcode(code[pc + size_of(Opcode) + pc_open]))
pc_open += size_of(u8)
break add_global
break optimize_opening
case .Save:
continue
case .Assert_Start, .Assert_Start_Multiline:
break optimize_opening
case:
break seek_loop
}
+63 -13
View File
@@ -77,6 +77,8 @@ Match_Iterator :: struct {
vm: virtual_machine.Machine,
idx: int,
temp: runtime.Allocator,
threads: int,
done: bool,
}
/*
@@ -101,7 +103,6 @@ create :: proc(
permanent_allocator := context.allocator,
temporary_allocator := context.temp_allocator,
) -> (result: Regular_Expression, err: Error) {
// For the sake of speed and simplicity, we first run all the intermediate
// processes such as parsing and compilation through the temporary
// allocator.
@@ -166,7 +167,6 @@ to escape the delimiter if found in the middle of the string.
All runes after the closing delimiter will be parsed as flags:
- 'g': Global
- 'm': Multiline
- 'i': Case_Insensitive
- 'x': Ignore_Whitespace
@@ -243,7 +243,6 @@ create_by_user :: proc(
// to `end` here.
for r in pattern[start + end:] {
switch r {
case 'g': flags += { .Global }
case 'm': flags += { .Multiline }
case 'i': flags += { .Case_Insensitive }
case 'x': flags += { .Ignore_Whitespace }
@@ -282,18 +281,13 @@ create_iterator :: proc(
permanent_allocator := context.allocator,
temporary_allocator := context.temp_allocator,
) -> (result: Match_Iterator, err: Error) {
flags := flags
flags += {.Global} // We're iterating over a string, so the next match could start anywhere
if .Multiline in flags {
return {}, .Unsupported_Flag
}
result.regex = create(pattern, flags, permanent_allocator, temporary_allocator) or_return
result.capture = preallocate_capture()
result.temp = temporary_allocator
result.vm = virtual_machine.create(result.regex.program, str)
result.vm.class_data = result.regex.class_data
result.threads = max(1, virtual_machine.opcode_count(result.vm.code) - 1)
return
}
@@ -457,8 +451,27 @@ match_iterator :: proc(it: ^Match_Iterator) -> (result: Capture, index: int, ok:
assert(len(it.capture.pos) >= common.MAX_CAPTURE_GROUPS,
"Pre-allocated RegEx capture `pos` must be at least 10 elements long.")
// Guard against situations in which the iterator should finish.
if it.done {
return
}
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
if it.idx > 0 {
// Reset the state needed to `virtual_machine.run` again.
it.vm.top_thread = 0
it.vm.current_rune = rune(0)
it.vm.current_rune_size = 0
for i in 0..<it.threads {
it.vm.threads[i] = {}
it.vm.next_threads[i] = {}
}
}
// Take note of where the string pointer is before we start.
sp_before := it.vm.string_pointer
saved: ^[2 * common.MAX_CAPTURE_GROUPS]int
{
context.allocator = it.temp
@@ -469,6 +482,28 @@ match_iterator :: proc(it: ^Match_Iterator) -> (result: Capture, index: int, ok:
}
}
if !ok {
// Match failed, bail out.
return
}
if it.vm.string_pointer == sp_before {
// The string pointer did not move, but there was a match.
//
// At this point, the pattern supplied to the iterator will infinitely
// loop if we do not intervene.
it.done = true
}
if it.vm.string_pointer == len(it.vm.memory) {
// The VM hit the end of the string.
//
// We do not check at the start, because a match of pattern `$`
// against string "" is valid and must return a match.
//
// This check prevents a double-match of `$` against a non-empty string.
it.done = true
}
str := string(it.vm.memory)
num_groups: int
@@ -488,9 +523,7 @@ match_iterator :: proc(it: ^Match_Iterator) -> (result: Capture, index: int, ok:
num_groups = n
}
defer if ok {
it.idx += 1
}
defer it.idx += 1
if num_groups > 0 {
result = {it.capture.pos[:num_groups], it.capture.groups[:num_groups]}
@@ -504,8 +537,25 @@ match :: proc {
match_iterator,
}
/*
Reset an iterator, allowing it to be run again as if new.
Inputs:
- it: The iterator to reset.
*/
reset :: proc(it: ^Match_Iterator) {
it.idx = 0
it.done = false
it.idx = 0
it.vm.string_pointer = 0
it.vm.top_thread = 0
it.vm.current_rune = rune(0)
it.vm.current_rune_size = 0
it.vm.last_rune = rune(0)
for i in 0..<it.threads {
it.vm.threads[i] = {}
it.vm.next_threads[i] = {}
}
}
/*
+24 -16
View File
@@ -109,34 +109,42 @@ For more information, see: https://swtch.com/~rsc/regexp/regexp2.html
(0x0A) Assert_Start
Asserts that the thread is at the beginning of a string.
Asserts that the thread is at the beginning of the string.
(0x0B) Assert_End
(0x0B) Assert_Start_Multiline
Asserts that the thread is at the end of a string.
This opcode is compiled in only when the `Multiline` flag is present as a
replacement for the `^` text anchor.
(0x0C) Assert_Word_Boundary
Asserts that the thread is at the beginning of the string or previously
parsed either a "\n" or "\r".
(0x0C) Assert_End
Asserts that the thread is at the end of the string.
(0x0D) Assert_Word_Boundary
Asserts that the thread is on a word boundary, which can be the start or
end of the text. This examines both the current rune and the next rune.
(0x0D) Assert_Non_Word_Boundary
(0x0E) Assert_Non_Word_Boundary
A modified version of Assert_Word_Boundary that returns the opposite value.
(0x0E) Multiline_Open
(0x0F) Multiline_Open
This opcode is compiled in only when the `Multiline` flag is present, and
it replaces both `^` and `$` text anchors.
This opcode is compiled in only when the `Multiline` flag is present as a
replacement for the `$` text anchor.
It asserts that either the current thread is on one of the string
boundaries, or it consumes a `\n` or `\r` character.
It asserts that either the current thread is at the end of the string,
or it consumes a `\n` or `\r` character.
If a `\r` character is consumed, the PC will be advanced to the sibling
`Multiline_Close` opcode to optionally consume a `\n` character on the next
frame.
(0x0F) Multiline_Close
(0x10) Multiline_Close
This opcode is always present after `Multiline_Open`.
@@ -144,10 +152,10 @@ For more information, see: https://swtch.com/~rsc/regexp/regexp2.html
For example, Windows newlines are represented by the characters `\r\n`,
whereas UNIX newlines are `\n` and Macintosh newlines are `\r`.
(0x10) Wait_For_Byte
(0x11) Wait_For_Rune
(0x12) Wait_For_Rune_Class
(0x13) Wait_For_Rune_Class_Negated
(0x11) Wait_For_Byte
(0x12) Wait_For_Rune
(0x13) Wait_For_Rune_Class
(0x14) Wait_For_Rune_Class_Negated
These opcodes are an optimization around restarting threads on failed
matches when the beginning to a pattern is predictable and the Global flag
@@ -156,7 +164,7 @@ For more information, see: https://swtch.com/~rsc/regexp/regexp2.html
They will cause the VM to wait for the next rune to match before splitting,
as would happen in the un-optimized version.
(0x14) Match_All_And_Escape
(0x15) Match_All_And_Escape
This opcode is an optimized version of `.*$` or `.+$` that causes the
active thread to immediately work on escaping the program by following all
@@ -34,6 +34,7 @@ iterate_opcodes :: proc(iter: ^Opcode_Iterator) -> (opcode: Opcode, pc: int, ok:
case .Split: iter.pc += size_of(Opcode) + 2 * size_of(u16)
case .Save: iter.pc += size_of(Opcode) + size_of(u8)
case .Assert_Start: iter.pc += size_of(Opcode)
case .Assert_Start_Multiline: iter.pc += size_of(Opcode)
case .Assert_End: iter.pc += size_of(Opcode)
case .Assert_Word_Boundary: iter.pc += size_of(Opcode)
case .Assert_Non_Word_Boundary: iter.pc += size_of(Opcode)
@@ -64,6 +65,7 @@ opcode_to_name :: proc(opcode: Opcode) -> (str: string) {
case .Split: str = "Split"
case .Save: str = "Save"
case .Assert_Start: str = "Assert_Start"
case .Assert_Start_Multiline: str = "Assert_Start_Multiline"
case .Assert_End: str = "Assert_End"
case .Assert_Word_Boundary: str = "Assert_Word_Boundary"
case .Assert_Non_Word_Boundary: str = "Assert_Non_Word_Boundary"
@@ -37,16 +37,17 @@ Opcode :: enum u8 {
Split = 0x08, // | u16, u16
Save = 0x09, // | u8
Assert_Start = 0x0A, // |
Assert_End = 0x0B, // |
Assert_Word_Boundary = 0x0C, // |
Assert_Non_Word_Boundary = 0x0D, // |
Multiline_Open = 0x0E, // |
Multiline_Close = 0x0F, // |
Wait_For_Byte = 0x10, // | u8
Wait_For_Rune = 0x11, // | i32
Wait_For_Rune_Class = 0x12, // | u8
Wait_For_Rune_Class_Negated = 0x13, // | u8
Match_All_And_Escape = 0x14, // |
Assert_Start_Multiline = 0x0B, // |
Assert_End = 0x0C, // |
Assert_Word_Boundary = 0x0D, // |
Assert_Non_Word_Boundary = 0x0E, // |
Multiline_Open = 0x0F, // |
Multiline_Close = 0x10, // |
Wait_For_Byte = 0x11, // | u8
Wait_For_Rune = 0x12, // | i32
Wait_For_Rune_Class = 0x13, // | u8
Wait_For_Rune_Class_Negated = 0x14, // | u8
Match_All_And_Escape = 0x15, // |
}
Thread :: struct {
@@ -77,6 +78,8 @@ Machine :: struct {
current_rune_size: int,
next_rune: rune,
next_rune_size: int,
last_rune: rune,
}
@@ -169,6 +172,12 @@ add_thread :: proc(vm: ^Machine, saved: ^[2 * common.MAX_CAPTURE_GROUPS]int, pc:
pc += size_of(Opcode)
continue
}
case .Assert_Start_Multiline:
sp := vm.string_pointer+vm.current_rune_size
if sp == 0 || vm.last_rune == '\n' || vm.last_rune == '\r' {
pc += size_of(Opcode)
continue
}
case .Assert_End:
sp := vm.string_pointer+vm.current_rune_size
if sp == len(vm.memory) {
@@ -177,24 +186,12 @@ add_thread :: proc(vm: ^Machine, saved: ^[2 * common.MAX_CAPTURE_GROUPS]int, pc:
}
case .Multiline_Open:
sp := vm.string_pointer+vm.current_rune_size
if sp == 0 || sp == len(vm.memory) {
if vm.next_rune == '\r' || vm.next_rune == '\n' {
// The VM is currently on a newline at the string boundary,
// so consume the newline next frame.
when common.ODIN_DEBUG_REGEX {
io.write_string(common.debug_stream, "*** New thread added [PC:")
common.write_padded_hex(common.debug_stream, pc, 4)
io.write_string(common.debug_stream, "]\n")
}
vm.next_threads[vm.top_thread] = Thread{ pc = pc, saved = saved }
vm.top_thread += 1
} else {
// Skip the `Multiline_Close` opcode.
pc += 2 * size_of(Opcode)
continue
}
if sp == len(vm.memory) {
// Skip the `Multiline_Close` opcode.
pc += 2 * size_of(Opcode)
continue
} else {
// Not on a string boundary.
// Not at the end of the string.
// Try to consume a newline next frame in the other opcode loop.
when common.ODIN_DEBUG_REGEX {
io.write_string(common.debug_stream, "*** New thread added [PC:")
@@ -329,10 +326,10 @@ add_thread :: proc(vm: ^Machine, saved: ^[2 * common.MAX_CAPTURE_GROUPS]int, pc:
run :: proc(vm: ^Machine, $UNICODE_MODE: bool) -> (saved: ^[2 * common.MAX_CAPTURE_GROUPS]int, ok: bool) #no_bounds_check {
when UNICODE_MODE {
vm.next_rune, vm.next_rune_size = utf8.decode_rune_in_string(vm.memory)
vm.next_rune, vm.next_rune_size = utf8.decode_rune_in_string(vm.memory[vm.string_pointer:])
} else {
if len(vm.memory) > 0 {
vm.next_rune = cast(rune)vm.memory[0]
vm.next_rune = cast(rune)vm.memory[vm.string_pointer]
vm.next_rune_size = 1
}
}
@@ -613,6 +610,7 @@ run :: proc(vm: ^Machine, $UNICODE_MODE: bool) -> (saved: ^[2 * common.MAX_CAPTU
break
}
vm.last_rune = vm.current_rune
vm.string_pointer += vm.current_rune_size
}
@@ -652,4 +650,4 @@ destroy :: proc(vm: Machine, allocator := context.allocator) {
delete(vm.busy_map)
free(vm.threads)
free(vm.next_threads)
}
}
+4 -2
View File
@@ -285,6 +285,7 @@ scan_number :: proc(s: ^Scanner, ch: rune, seen_dot: bool) -> (rune, rune) {
case 'o': return "octal literal"
case 'z': return "dozenal literal"
case 'x': return "hexadecimal literal"
case 'h': return "hexadecimal literal"
}
return "decimal literal"
}
@@ -360,7 +361,8 @@ scan_number :: proc(s: ^Scanner, ch: rune, seen_dot: bool) -> (rune, rune) {
base, prefix = 12, 'z'
case 'h':
tok = Float
fallthrough
ch = advance(s)
base, prefix = 16, 'h'
case 'x':
ch = advance(s)
base, prefix = 16, 'x'
@@ -447,7 +449,7 @@ scan_string :: proc(s: ^Scanner, quote: rune) -> (n: int) {
ch := advance(s)
for ch != quote {
if ch == '\n' || ch < 0 {
error(s, "literal no terminated")
error(s, "literal not terminated")
return
}
if ch == '\\' {