match to switch; Optional semicolons after "import" statements

This commit is contained in:
Ginger Bill
2017-10-01 17:09:57 +01:00
parent f38c8875b2
commit c1e720a49b
33 changed files with 641 additions and 451 deletions
+13 -15
View File
@@ -1,9 +1,9 @@
#shared_global_scope;
#shared_global_scope
import "core:os.odin";
import "core:fmt.odin"; // TODO(bill): Remove the need for `fmt` here
import "core:utf8.odin";
import "core:raw.odin";
import "core:os.odin"
import "core:fmt.odin" // TODO(bill): Remove the need for `fmt` here
import "core:utf8.odin"
import "core:raw.odin"
// Naming Conventions:
// In general, Ada_Case for types and snake_case for values
@@ -43,7 +43,6 @@ Type_Info_Enum_Value :: union {
f32, f64,
};
// Variant Types
Type_Info_Named :: struct #ordered {name: string, base: ^Type_Info};
Type_Info_Integer :: struct #ordered {signed: bool};
@@ -106,7 +105,6 @@ Type_Info_Bit_Field :: struct #ordered {
Type_Info :: struct #ordered {
// Fields
size: int,
align: int,
@@ -217,7 +215,7 @@ type_info_base :: proc(info: ^Type_Info) -> ^Type_Info {
if info == nil do return nil;
base := info;
match i in base.variant {
switch i in base.variant {
case Type_Info_Named: base = i.base;
}
return base;
@@ -228,7 +226,7 @@ type_info_base_without_enum :: proc(info: ^Type_Info) -> ^Type_Info {
if info == nil do return nil;
base := info;
match i in base.variant {
switch i in base.variant {
case Type_Info_Named: base = i.base;
case Type_Info_Enum: base = i.base;
}
@@ -444,9 +442,9 @@ __get_map_header :: proc(m: ^$T/map[$K]$V) -> __Map_Header #cc_contextless {
__get_map_key :: proc(key: $K) -> __Map_Key #cc_contextless {
map_key: __Map_Key;
ti := type_info_base_without_enum(type_info_of(K));
match _ in ti.variant {
switch _ in ti.variant {
case Type_Info_Integer:
match 8*size_of(key) {
switch 8*size_of(key) {
case 8: map_key.hash = u128(( ^u8)(&key)^);
case 16: map_key.hash = u128(( ^u16)(&key)^);
case 32: map_key.hash = u128(( ^u32)(&key)^);
@@ -459,7 +457,7 @@ __get_map_key :: proc(key: $K) -> __Map_Key #cc_contextless {
case Type_Info_Pointer:
map_key.hash = u128(uint((^rawptr)(&key)^));
case Type_Info_Float:
match 8*size_of(key) {
switch 8*size_of(key) {
case 32: map_key.hash = u128((^u32)(&key)^);
case 64: map_key.hash = u128((^u64)(&key)^);
case: panic("Unhandled float size");
@@ -575,7 +573,7 @@ default_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
old_memory: rawptr, old_size: int, flags: u64) -> rawptr {
using Allocator_Mode;
match mode {
switch mode {
case Alloc:
return os.heap_alloc(size);
@@ -626,7 +624,7 @@ panic :: proc(message := "", using location := #caller_location) #cc_contextless
__string_eq :: proc(a, b: string) -> bool #cc_contextless {
match {
switch {
case len(a) != len(b): return false;
case len(a) == 0: return true;
case &a[0] == &b[0]: return true;
@@ -731,7 +729,7 @@ __mem_copy_non_overlapping :: proc(dst, src: rawptr, len: int) -> rawptr #cc_con
__mem_compare :: proc(a, b: ^u8, n: int) -> int #cc_contextless {
for i in 0..n {
match {
switch {
case (a+i)^ < (b+i)^: return -1;
case (a+i)^ > (b+i)^: return +1;
}
+1 -1
View File
@@ -1,4 +1,4 @@
#shared_global_scope;
#shared_global_scope
__multi3 :: proc(a, b: u128) -> u128 #cc_c #link_name "__multi3" {
bits_in_dword_2 :: size_of(i64) * 4;
+1 -1
View File
@@ -2,7 +2,7 @@
// Inline vs external file?
when ODIN_OS == "windows" {
import win32 "core:sys/windows.odin";
import win32 "core:sys/windows.odin"
}
_ :: compile_assert(ODIN_ARCH == "amd64"); // TODO(bill): x86 version
+1 -1
View File
@@ -171,7 +171,7 @@ shift :: proc(a: ^Decimal, k: int) {
uint_size :: 8*size_of(uint);
max_shift :: uint_size-4;
match {
switch {
case a.count == 0:
// no need to update
case k > 0:
+33 -33
View File
@@ -1,9 +1,9 @@
import "core:os.odin";
import "core:mem.odin";
import "core:utf8.odin";
import "core:types.odin";
import "core:strconv.odin";
import "core:raw.odin";
import "core:os.odin"
import "core:mem.odin"
import "core:utf8.odin"
import "core:types.odin"
import "core:strconv.odin"
import "core:raw.odin"
_BUFFER_SIZE :: 1<<12;
@@ -36,14 +36,14 @@ Fmt_Info :: struct {
string_buffer_data :: proc(buf: ^String_Buffer) -> []u8 {
match b in buf {
switch b in buf {
case []u8: return b[..];
case [dynamic]u8: return b[..];
}
return nil;
}
string_buffer_data :: proc(buf: String_Buffer) -> []u8 {
match b in buf {
switch b in buf {
case []u8: return b[..];
case [dynamic]u8: return b[..];
}
@@ -58,13 +58,13 @@ write_string :: proc(buf: ^String_Buffer, s: string) {
write_bytes(buf, cast([]u8)s);
}
write_bytes :: proc(buf: ^String_Buffer, data: []u8) {
match b in buf {
switch b in buf {
case []u8: append(b, ...data);
case [dynamic]u8: append(b, ...data);
}
}
write_byte :: proc(buf: ^String_Buffer, data: u8) {
match b in buf {
switch b in buf {
case []u8: append(b, data);
case [dynamic]u8: append(b, data);
}
@@ -179,11 +179,11 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) {
return;
}
match info in ti.variant {
switch info in ti.variant {
case Type_Info_Named:
write_string(buf, info.name);
case Type_Info_Integer:
match {
switch {
case ti == type_info_of(int): write_string(buf, "int");
case ti == type_info_of(uint): write_string(buf, "uint");
case:
@@ -194,13 +194,13 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) {
case Type_Info_Rune:
write_string(buf, "rune");
case Type_Info_Float:
match ti.size {
switch ti.size {
case 2: write_string(buf, "f16");
case 4: write_string(buf, "f32");
case 8: write_string(buf, "f64");
}
case Type_Info_Complex:
match ti.size {
switch ti.size {
case 4: write_string(buf, "complex32");
case 8: write_string(buf, "complex64");
case 16: write_string(buf, "complex128");
@@ -388,7 +388,7 @@ int_from_arg :: proc(args: []any, arg_index: int) -> (int, int, bool) {
if arg_index < len(args) {
arg := args[arg_index];
arg.type_info = type_info_base(arg.type_info);
match i in arg {
switch i in arg {
case int: num = i;
case i8: num = int(i);
case i16: num = int(i);
@@ -423,7 +423,7 @@ fmt_bad_verb :: proc(using fi: ^Fmt_Info, verb: rune) {
}
fmt_bool :: proc(using fi: ^Fmt_Info, b: bool, verb: rune) {
match verb {
switch verb {
case 't', 'v':
s := "false";
if b do s = "true";
@@ -475,7 +475,7 @@ _fmt_int :: proc(fi: ^Fmt_Info, u: u128, base: int, is_signed: bool, bit_size: i
}
}
match base {
switch base {
case 2, 8, 10, 12, 16:
break;
case:
@@ -493,7 +493,7 @@ _fmt_int :: proc(fi: ^Fmt_Info, u: u128, base: int, is_signed: bool, bit_size: i
if fi.hash && fi.zero {
c: u8;
match base {
switch base {
case 2: c = 'b';
case 8: c = 'o';
case 10: c = 'd';
@@ -517,7 +517,7 @@ __DIGITS_LOWER := "0123456789abcdefx";
__DIGITS_UPPER := "0123456789ABCDEFX";
fmt_rune :: proc(fi: ^Fmt_Info, r: rune, verb: rune) {
match verb {
switch verb {
case 'c', 'r', 'v':
write_rune(fi.buf, r);
case:
@@ -526,7 +526,7 @@ fmt_rune :: proc(fi: ^Fmt_Info, r: rune, verb: rune) {
}
fmt_int :: proc(fi: ^Fmt_Info, u: u128, is_signed: bool, bit_size: int, verb: rune) {
match verb {
switch verb {
case 'v': _fmt_int(fi, u, 10, is_signed, bit_size, __DIGITS_LOWER);
case 'b': _fmt_int(fi, u, 2, is_signed, bit_size, __DIGITS_LOWER);
case 'o': _fmt_int(fi, u, 8, is_signed, bit_size, __DIGITS_LOWER);
@@ -568,7 +568,7 @@ _pad :: proc(fi: ^Fmt_Info, s: string) {
}
fmt_float :: proc(fi: ^Fmt_Info, v: f64, bit_size: int, verb: rune) {
match verb {
switch verb {
// case 'e', 'E', 'f', 'F', 'g', 'G', 'v':
// case 'f', 'F', 'v':
@@ -611,7 +611,7 @@ fmt_float :: proc(fi: ^Fmt_Info, v: f64, bit_size: int, verb: rune) {
}
}
fmt_string :: proc(fi: ^Fmt_Info, s: string, verb: rune) {
match verb {
switch verb {
case 's', 'v':
write_string(fi.buf, s);
@@ -633,7 +633,7 @@ fmt_string :: proc(fi: ^Fmt_Info, s: string, verb: rune) {
}
fmt_pointer :: proc(fi: ^Fmt_Info, p: rawptr, verb: rune) {
match verb {
switch verb {
case 'p', 'v':
// Okay
case:
@@ -650,7 +650,7 @@ fmt_pointer :: proc(fi: ^Fmt_Info, p: rawptr, verb: rune) {
enum_value_to_string :: proc(v: any) -> (string, bool) {
v.type_info = type_info_base(v.type_info);
match e in v.type_info.variant {
switch e in v.type_info.variant {
case: return "", false;
case Type_Info_Enum:
get_str :: proc(i: $T, e: Type_Info_Enum) -> (string, bool) {
@@ -673,7 +673,7 @@ enum_value_to_string :: proc(v: any) -> (string, bool) {
}
a := any{v.data, type_info_base(e.base)};
match v in a {
switch v in a {
case rune: return get_str(v, e);
case i8: return get_str(v, e);
case i16: return get_str(v, e);
@@ -716,10 +716,10 @@ fmt_enum :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
return;
}
match e in v.type_info.variant {
switch e in v.type_info.variant {
case: fmt_bad_verb(fi, verb);
case Type_Info_Enum:
match verb {
switch verb {
case: fmt_bad_verb(fi, verb);
case 'd', 'f':
fmt_arg(fi, any{v.data, type_info_base(e.base)}, verb);
@@ -738,9 +738,9 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
return;
}
match info in v.type_info.variant {
switch info in v.type_info.variant {
case Type_Info_Named:
match b in info.base.variant {
switch b in info.base.variant {
case Type_Info_Struct:
if verb != 'v' {
fmt_bad_verb(fi, verb);
@@ -939,7 +939,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
}
fmt_complex :: proc(fi: ^Fmt_Info, c: complex128, bits: int, verb: rune) {
match verb {
switch verb {
case 'f', 'F', 'v':
r, i := real(c), imag(c);
fmt_float(fi, r, bits/2, verb);
@@ -972,7 +972,7 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) {
if verb == 'T' {
ti := arg.type_info;
match a in arg {
switch a in arg {
case ^Type_Info: ti = a;
}
write_type(fi.buf, ti);
@@ -982,7 +982,7 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) {
base_arg := arg;
base_arg.type_info = type_info_base(base_arg.type_info);
match a in base_arg {
switch a in base_arg {
case any: fmt_arg(fi, a, verb);
case bool: fmt_bool(fi, a, verb);
case rune: fmt_rune(fi, a, verb);
@@ -1073,7 +1073,7 @@ sbprintf :: proc(b: ^String_Buffer, fmt: string, args: ...any) -> string {
i += 1;
prefix_loop: for ; i < end; i += 1 {
match fmt[i] {
switch fmt[i] {
case '+':
fi.plus = true;
case '-':
+4 -4
View File
@@ -1,4 +1,4 @@
import "core:mem.odin";
import "core:mem.odin"
adler32 :: proc(data: []u8) -> u32 {
ADLER_CONST :: 65521;
@@ -80,7 +80,7 @@ murmur32 :: proc(data: []u8) -> u32 {
tail := data[nblocks*4 ..];
k1: u32;
match len(tail)&3 {
switch len(tail)&3 {
case 3:
k1 ~= u32(tail[2]) << 16;
fallthrough;
@@ -127,7 +127,7 @@ murmur64 :: proc(data: []u8) -> u64 {
h *= m;
}
match len(data)&7 {
switch len(data)&7 {
case 7: h ~= u64(data[6]) << 48; fallthrough;
case 6: h ~= u64(data[5]) << 40; fallthrough;
case 5: h ~= u64(data[4]) << 32; fallthrough;
@@ -186,7 +186,7 @@ murmur64 :: proc(data: []u8) -> u64 {
// TODO(bill): Fix this
#no_bounds_check data8 := slice_to_bytes(data32[i..])[..3];
match len {
switch len {
case 3:
h2 ~= u32(data8[2]) << 16;
fallthrough;
+4 -4
View File
@@ -1,4 +1,4 @@
import "core:raw.odin";
import "core:raw.odin"
foreign __llvm_core {
swap :: proc(b: u16) -> u16 #link_name "llvm.bswap.i16" ---;
@@ -137,7 +137,7 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
using Allocator_Mode;
arena := cast(^Arena)allocator_data;
match mode {
switch mode {
case Alloc:
total_size := size + alignment;
@@ -200,7 +200,7 @@ align_of_type_info :: proc(type_info: ^Type_Info) -> int {
WORD_SIZE :: size_of(int);
MAX_ALIGN :: size_of([vector 64]f64); // TODO(bill): Should these constants be builtin constants?
match info in type_info.variant {
switch info in type_info.variant {
case Type_Info_Named:
return align_of_type_info(info.base);
case Type_Info_Integer:
@@ -252,7 +252,7 @@ align_formula :: proc(size, align: int) -> int {
size_of_type_info :: proc(type_info: ^Type_Info) -> int {
WORD_SIZE :: size_of(int);
match info in type_info.variant {
switch info in type_info.variant {
case Type_Info_Named:
return size_of_type_info(info.base);
case Type_Info_Integer:
+6 -6
View File
@@ -1,12 +1,12 @@
when ODIN_OS == "windows" do foreign_system_library lib "opengl32.lib";
when ODIN_OS == "linux" do foreign_system_library lib "gl";
when ODIN_OS == "windows" {
import win32 "core:sys/windows.odin";
import "core:sys/wgl.odin";
foreign_system_library lib "opengl32.lib"
import win32 "core:sys/windows.odin"
import "core:sys/wgl.odin"
} else when ODIN_OS == "linux" {
foreign_system_library lib "gl"
}
export "core:opengl_constants.odin";
export "core:opengl_constants.odin"
_ := compile_assert(ODIN_OS != "osx");
+3 -3
View File
@@ -1,7 +1,7 @@
foreign_system_library dl "dl";
foreign_system_library libc "c";
foreign_system_library dl "dl"
foreign_system_library libc "c"
import "core:strings.odin";
import "core:strings.odin"
Handle :: i32;
File_Time :: u64;
+6 -6
View File
@@ -1,5 +1,5 @@
import win32 "core:sys/windows.odin";
import "core:mem.odin";
import win32 "core:sys/windows.odin"
import "core:mem.odin"
Handle :: int;
File_Time :: u64;
@@ -60,7 +60,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: u32 = 0) -> (Handle, Errn
if len(path) == 0 do return INVALID_HANDLE, ERROR_FILE_NOT_FOUND;
access: u32;
match mode & (O_RDONLY|O_WRONLY|O_RDWR) {
switch mode & (O_RDONLY|O_WRONLY|O_RDWR) {
case O_RDONLY: access = win32.FILE_GENERIC_READ;
case O_WRONLY: access = win32.FILE_GENERIC_WRITE;
case O_RDWR: access = win32.FILE_GENERIC_READ | win32.FILE_GENERIC_WRITE;
@@ -82,7 +82,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: u32 = 0) -> (Handle, Errn
}
create_mode: u32;
match {
switch {
case mode&(O_CREAT|O_EXCL) == (O_CREAT | O_EXCL):
create_mode = win32.CREATE_NEW;
case mode&(O_CREAT|O_TRUNC) == (O_CREAT | O_TRUNC):
@@ -156,7 +156,7 @@ read :: proc(fd: Handle, data: []u8) -> (int, Errno) {
seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
w: u32;
match whence {
switch whence {
case 0: w = win32.FILE_BEGIN;
case 1: w = win32.FILE_CURRENT;
case 2: w = win32.FILE_END;
@@ -272,7 +272,7 @@ _alloc_command_line_arguments :: proc() -> []string {
i, j := 0, 0;
for str[j] != 0 {
match {
switch {
case str[j] < 0x80:
if i+1 > len do return "";
buf[i] = u8(str[j]); i += 1;
+3 -3
View File
@@ -1,7 +1,7 @@
foreign_system_library dl "dl";
foreign_system_library libc "c";
foreign_system_library dl "dl"
foreign_system_library libc "c"
import "core:strings.odin";
import "core:strings.odin"
Handle :: i32;
File_Time :: u64;
+3 -3
View File
@@ -187,7 +187,7 @@ merge_sort :: proc(array: $A/[]$T) {
compare_ints :: proc(a, b: int) -> int {
match delta := a - b; {
switch delta := a - b; {
case delta < 0: return -1;
case delta > 0: return +1;
}
@@ -195,14 +195,14 @@ compare_ints :: proc(a, b: int) -> int {
}
compare_f32s :: proc(a, b: f32) -> int {
match delta := a - b; {
switch delta := a - b; {
case delta < 0: return -1;
case delta > 0: return +1;
}
return 0;
}
compare_f64s :: proc(a, b: f64) -> int {
match delta := a - b; {
switch delta := a - b; {
case delta < 0: return -1;
case delta > 0: return +1;
}
+15 -15
View File
@@ -1,4 +1,4 @@
using import "core:decimal.odin";
using import "core:decimal.odin"
Int_Flag :: enum {
Prefix = 1<<0,
@@ -8,7 +8,7 @@ Int_Flag :: enum {
parse_bool :: proc(s: string) -> (result: bool = false, ok: bool) {
match s {
switch s {
case "1", "t", "T", "true", "TRUE", "True":
return true, true;
case "0", "f", "F", "false", "FALSE", "False":
@@ -20,7 +20,7 @@ parse_bool :: proc(s: string) -> (result: bool = false, ok: bool) {
_digit_value :: proc(r: rune) -> int {
ri := int(r);
v: int = 16;
match r {
switch r {
case '0'...'9': v = ri-'0';
case 'a'...'z': v = ri-'a'+10;
case 'A'...'Z': v = ri-'A'+10;
@@ -31,7 +31,7 @@ _digit_value :: proc(r: rune) -> int {
parse_i128 :: proc(s: string) -> i128 {
neg := false;
if len(s) > 1 {
match s[0] {
switch s[0] {
case '-':
neg = true;
s = s[1..];
@@ -43,7 +43,7 @@ parse_i128 :: proc(s: string) -> i128 {
base: i128 = 10;
if len(s) > 2 && s[0] == '0' {
match s[1] {
switch s[1] {
case 'b': base = 2; s = s[2..];
case 'o': base = 8; s = s[2..];
case 'd': base = 10; s = s[2..];
@@ -80,7 +80,7 @@ parse_u128 :: proc(s: string) -> u128 {
base := u128(10);
if len(s) > 2 && s[0] == '0' {
match s[1] {
switch s[1] {
case 'b': base = 2; s = s[2..];
case 'o': base = 8; s = s[2..];
case 'd': base = 10; s = s[2..];
@@ -115,7 +115,7 @@ parse_f64 :: proc(s: string) -> f64 {
i := 0;
sign: f64 = 1;
match s[i] {
switch s[i] {
case '-': i += 1; sign = -1;
case '+': i += 1;
}
@@ -153,7 +153,7 @@ parse_f64 :: proc(s: string) -> f64 {
i += 1;
if i < len(s) {
match s[i] {
switch s[i] {
case '-': i += 1; frac = true;
case '+': i += 1;
}
@@ -223,7 +223,7 @@ _f64_info := FloatInfo{52, 11, -1023};
generic_ftoa :: proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8 {
bits: u64;
flt: ^FloatInfo;
match bit_size {
switch bit_size {
case 32:
bits = u64(transmute(u32)f32(val));
flt = &_f32_info;
@@ -238,7 +238,7 @@ generic_ftoa :: proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8
exp := int(bits>>flt.mantbits) & (1<<flt.expbits - 1);
mant := bits & (u64(1) << flt.mantbits - 1);
match exp {
switch exp {
case 1<<flt.expbits - 1:
s: string;
if mant != 0 {
@@ -269,13 +269,13 @@ generic_ftoa :: proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8
if shortest {
round_shortest(d, mant, exp, flt);
digs = DecimalSlice{digits = d.digits[..], count = d.count, decimal_point = d.decimal_point};
match fmt {
switch fmt {
case 'e', 'E': prec = digs.count-1;
case 'f', 'F': prec = max(digs.count-digs.decimal_point, 0);
case 'g', 'G': prec = digs.count;
}
} else {
match fmt {
switch fmt {
case 'e', 'E': round(d, prec+1);
case 'f', 'F': round(d, d.decimal_point+prec);
case 'g', 'G':
@@ -293,7 +293,7 @@ generic_ftoa :: proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8
format_digits :: proc(buf: []u8, shortest: bool, neg: bool, digs: DecimalSlice, prec: int, fmt: u8) -> []u8 {
match fmt {
switch fmt {
case 'f', 'F':
append(&buf, neg ? '-' : '+');
@@ -410,7 +410,7 @@ digits := "0123456789abcdefghijklmnopqrstuvwxyz";
is_integer_negative :: proc(u: u128, is_signed: bool, bit_size: int) -> (unsigned: u128, neg: bool) {
neg := false;
if is_signed {
match bit_size {
switch bit_size {
case 8:
i := i8(u);
neg = i < 0;
@@ -456,7 +456,7 @@ append_bits :: proc(buf: []u8, u: u128, base: int, is_signed: bool, bit_size: in
if flags&Int_Flag.Prefix != 0 {
ok := true;
match base {
switch base {
case 2: i-=1; a[i] = 'b';
case 8: i-=1; a[i] = 'o';
case 10: i-=1; a[i] = 'd';
+1 -1
View File
@@ -1,4 +1,4 @@
import "core:mem.odin";
import "core:mem.odin"
new_string :: proc(s: string) -> string {
c := make([]u8, len(s)+1);
+2 -2
View File
@@ -1,5 +1,5 @@
import "core:atomics.odin";
import "core:os.odin";
import "core:atomics.odin"
import "core:os.odin"
Semaphore :: struct {
// _handle: win32.Handle,
+4 -2
View File
@@ -1,5 +1,7 @@
when ODIN_OS == "windows" do import win32 "core:sys/windows.odin";
import "core:atomics.odin";
when ODIN_OS == "windows" {
import win32 "core:sys/windows.odin";
}
import "core:atomics.odin"
Semaphore :: struct {
_handle: win32.Handle,
+4 -2
View File
@@ -1,5 +1,7 @@
when ODIN_OS == "windows" do foreign_system_library "opengl32.lib";
using import "core:sys/windows.odin";
when ODIN_OS == "windows" {
foreign_system_library "opengl32.lib"
}
using import "core:sys/windows.odin"
CONTEXT_MAJOR_VERSION_ARB :: 0x2091;
+5 -5
View File
@@ -1,9 +1,9 @@
when ODIN_OS == "windows" {
foreign_system_library "kernel32.lib";
foreign_system_library "user32.lib";
foreign_system_library "gdi32.lib";
foreign_system_library "winmm.lib";
foreign_system_library "shell32.lib";
foreign_system_library "kernel32.lib"
foreign_system_library "user32.lib"
foreign_system_library "gdi32.lib"
foreign_system_library "winmm.lib"
foreign_system_library "shell32.lib"
}
Handle :: rawptr;
+1 -1
View File
@@ -1,7 +1,7 @@
_ :: compile_assert(ODIN_OS == "windows");
when ODIN_OS == "windows" {
import win32 "core:sys/windows.odin";
import win32 "core:sys/windows.odin"
}
Thread_Proc :: #type proc(^Thread) -> int;
+1 -1
View File
@@ -1,6 +1,6 @@
is_signed :: proc(info: ^Type_Info) -> bool {
if info == nil do return false;
match i in type_info_base(info).variant {
switch i in type_info_base(info).variant {
case Type_Info_Integer: return i.signed;
case Type_Info_Float: return true;
}
+1 -1
View File
@@ -35,7 +35,7 @@ encode :: proc(d: []u16, s: []rune) {
n = 0;
for r in s {
match r {
switch r {
case 0.._surr1, _surr3.._surr_self:
d[n] = u16(r);
n += 1;
+1 -1
View File
@@ -254,7 +254,7 @@ rune_count :: proc(s: []u8) -> int {
rune_size :: proc(r: rune) -> int {
match {
switch {
case r < 0: return -1;
case r <= 1<<7 - 1: return 1;
case r <= 1<<11 - 1: return 2;