mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix fmt printing uintptr type
This commit is contained in:
+4
-3
@@ -38,6 +38,7 @@ Type_Info_Enum_Value :: union {
|
|||||||
rune,
|
rune,
|
||||||
i8, i16, i32, i64, i128, int,
|
i8, i16, i32, i64, i128, int,
|
||||||
u8, u16, u32, u64, u128, uint,
|
u8, u16, u32, u64, u128, uint,
|
||||||
|
uintptr,
|
||||||
f32, f64,
|
f32, f64,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -687,13 +688,13 @@ __string_decode_rune :: inline proc "contextless" (s: string) -> (rune, int) {
|
|||||||
return utf8.decode_rune(s);
|
return utf8.decode_rune(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
__bounds_check_error_loc :: proc "contextless" (using loc := #caller_location, index, count: int) {
|
__bounds_check_error_loc :: inline proc "contextless" (using loc := #caller_location, index, count: int) {
|
||||||
__bounds_check_error(file_path, int(line), int(column), index, count);
|
__bounds_check_error(file_path, int(line), int(column), index, count);
|
||||||
}
|
}
|
||||||
__slice_expr_error_loc :: proc "contextless" (using loc := #caller_location, low, high, max: int) {
|
__slice_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, low, high, max: int) {
|
||||||
__slice_expr_error(file_path, int(line), int(column), low, high, max);
|
__slice_expr_error(file_path, int(line), int(column), low, high, max);
|
||||||
}
|
}
|
||||||
__substring_expr_error_loc :: proc "contextless" (using loc := #caller_location, low, high: int) {
|
__substring_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, low, high: int) {
|
||||||
__substring_expr_error(file_path, int(line), int(column), low, high);
|
__substring_expr_error(file_path, int(line), int(column), low, high);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-11
@@ -4,23 +4,24 @@ U32_MIN :: u32(0);
|
|||||||
U64_MIN :: u64(0);
|
U64_MIN :: u64(0);
|
||||||
U128_MIN :: u128(0);
|
U128_MIN :: u128(0);
|
||||||
|
|
||||||
I8_MIN :: i8(-0x80);
|
|
||||||
I16_MIN :: i16(-0x8000);
|
|
||||||
I32_MIN :: i32(-0x8000_0000);
|
|
||||||
I64_MIN :: i64(-0x8000_0000_0000_0000);
|
|
||||||
I128_MIN :: i128(-0x8000_0000_0000_0000_0000_0000_0000_0000);
|
|
||||||
|
|
||||||
U8_MAX :: ~u8(0);
|
U8_MAX :: ~u8(0);
|
||||||
U16_MAX :: ~u16(0);
|
U16_MAX :: ~u16(0);
|
||||||
U32_MAX :: ~u32(0);
|
U32_MAX :: ~u32(0);
|
||||||
U64_MAX :: ~u64(0);
|
U64_MAX :: ~u64(0);
|
||||||
U128_MAX :: ~u128(0);
|
U128_MAX :: ~u128(0);
|
||||||
|
|
||||||
I8_MAX :: i8(0x7f);
|
I8_MIN :: i8( ~u8(0) >> 1);
|
||||||
I16_MAX :: i16(0x7fff);
|
I16_MIN :: i16( ~u16(0) >> 1);
|
||||||
I32_MAX :: i32(0x7fff_ffff);
|
I32_MIN :: i32( ~u32(0) >> 1);
|
||||||
I64_MAX :: i64(0x7fff_ffff_ffff_ffff);
|
I64_MIN :: i64( ~u64(0) >> 1);
|
||||||
I128_MAX :: i128(0x7fff_ffff_ffff_ffff_ffff_ffff_ffff_ffff);
|
I128_MIN :: i128(~u128(0) >> 1);
|
||||||
|
|
||||||
|
I8_MAX :: -I8_MIN - 1;
|
||||||
|
I16_MAX :: -I16_MIN - 1;
|
||||||
|
I32_MAX :: -I32_MIN - 1;
|
||||||
|
I64_MAX :: -I64_MIN - 1;
|
||||||
|
I128_MAX :: -I128_MIN - 1;
|
||||||
|
|
||||||
|
|
||||||
count_ones :: proc(i: u8) -> u8 { foreign __llvm_core @(link_name="llvm.ctpop.i8") __llvm_ctpop :: proc(u8) -> u8 ---; return __llvm_ctpop(i); }
|
count_ones :: proc(i: u8) -> u8 { foreign __llvm_core @(link_name="llvm.ctpop.i8") __llvm_ctpop :: proc(u8) -> u8 ---; return __llvm_ctpop(i); }
|
||||||
count_ones :: proc(i: i8) -> i8 { foreign __llvm_core @(link_name="llvm.ctpop.i8") __llvm_ctpop :: proc(i8) -> i8 ---; return __llvm_ctpop(i); }
|
count_ones :: proc(i: i8) -> i8 { foreign __llvm_core @(link_name="llvm.ctpop.i8") __llvm_ctpop :: proc(i8) -> i8 ---; return __llvm_ctpop(i); }
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) {
|
|||||||
switch {
|
switch {
|
||||||
case ti == type_info_of(int): write_string(buf, "int");
|
case ti == type_info_of(int): write_string(buf, "int");
|
||||||
case ti == type_info_of(uint): write_string(buf, "uint");
|
case ti == type_info_of(uint): write_string(buf, "uint");
|
||||||
|
case ti == type_info_of(uintptr): write_string(buf, "uintptr");
|
||||||
case:
|
case:
|
||||||
if info.signed do write_byte(buf, 'i');
|
if info.signed do write_byte(buf, 'i');
|
||||||
else do write_byte(buf, 'u');
|
else do write_byte(buf, 'u');
|
||||||
@@ -687,6 +688,7 @@ enum_value_to_string :: proc(v: any) -> (string, bool) {
|
|||||||
case u64: return get_str(v, e);
|
case u64: return get_str(v, e);
|
||||||
case u128: return get_str(v, e);
|
case u128: return get_str(v, e);
|
||||||
case uint: return get_str(v, e);
|
case uint: return get_str(v, e);
|
||||||
|
case uintptr: return get_str(v, e);
|
||||||
|
|
||||||
case f32: return get_str(v, e);
|
case f32: return get_str(v, e);
|
||||||
case f64: return get_str(v, e);
|
case f64: return get_str(v, e);
|
||||||
@@ -1017,6 +1019,8 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) {
|
|||||||
case i64: fmt_int(fi, u128(a), true, 64, verb);
|
case i64: fmt_int(fi, u128(a), true, 64, verb);
|
||||||
case i128: fmt_int(fi, u128(a), true, 128, verb);
|
case i128: fmt_int(fi, u128(a), true, 128, verb);
|
||||||
|
|
||||||
|
case uintptr: fmt_int(fi, u128(a), false, 8*size_of(uintptr), verb);
|
||||||
|
|
||||||
case uint: fmt_int(fi, u128(a), false, 8*size_of(uint), verb);
|
case uint: fmt_int(fi, u128(a), false, 8*size_of(uint), verb);
|
||||||
case u8: fmt_int(fi, u128(a), false, 8, verb);
|
case u8: fmt_int(fi, u128(a), false, 8, verb);
|
||||||
case u16: fmt_int(fi, u128(a), false, 16, verb);
|
case u16: fmt_int(fi, u128(a), false, 16, verb);
|
||||||
|
|||||||
+3
-2
@@ -27,6 +27,7 @@ Mat4 :: [4][4]f32;
|
|||||||
|
|
||||||
Complex :: complex64;
|
Complex :: complex64;
|
||||||
|
|
||||||
|
@(default_calling_convention="c")
|
||||||
foreign __llvm_core {
|
foreign __llvm_core {
|
||||||
@(link_name="llvm.sqrt.f32")
|
@(link_name="llvm.sqrt.f32")
|
||||||
sqrt :: proc(x: f32) -> f32 ---;
|
sqrt :: proc(x: f32) -> f32 ---;
|
||||||
@@ -54,8 +55,8 @@ foreign __llvm_core {
|
|||||||
fmuladd :: proc(a, b, c: f64) -> f64 ---;
|
fmuladd :: proc(a, b, c: f64) -> f64 ---;
|
||||||
}
|
}
|
||||||
|
|
||||||
tan :: proc(θ: f32) -> f32 do return sin(θ)/cos(θ);
|
tan :: proc "c" (θ: f32) -> f32 do return sin(θ)/cos(θ);
|
||||||
tan :: proc(θ: f64) -> f64 do return sin(θ)/cos(θ);
|
tan :: proc "c" (θ: f64) -> f64 do return sin(θ)/cos(θ);
|
||||||
|
|
||||||
lerp :: proc(a, b: $T, t: $E) -> (x: T) do return a*(1-t) + b*t;
|
lerp :: proc(a, b: $T, t: $E) -> (x: T) do return a*(1-t) + b*t;
|
||||||
|
|
||||||
|
|||||||
+25
-24
@@ -10,31 +10,32 @@ export "core:opengl_constants.odin"
|
|||||||
|
|
||||||
_ := compile_assert(ODIN_OS != "osx");
|
_ := compile_assert(ODIN_OS != "osx");
|
||||||
|
|
||||||
|
@(default_calling_convention="c", link_prefix="gl")
|
||||||
foreign lib {
|
foreign lib {
|
||||||
@(link_name="glClear") Clear :: proc(mask: u32) ---;
|
Clear :: proc(mask: u32) ---;
|
||||||
@(link_name="glClearColor") ClearColor :: proc(r, g, b, a: f32) ---;
|
ClearColor :: proc(r, g, b, a: f32) ---;
|
||||||
@(link_name="glBegin") Begin :: proc(mode: i32) ---;
|
Begin :: proc(mode: i32) ---;
|
||||||
@(link_name="glEnd") End :: proc() ---;
|
End :: proc() ---;
|
||||||
@(link_name="glFinish") Finish :: proc() ---;
|
Finish :: proc() ---;
|
||||||
@(link_name="glBlendFunc") BlendFunc :: proc(sfactor, dfactor: i32) ---;
|
BlendFunc :: proc(sfactor, dfactor: i32) ---;
|
||||||
@(link_name="glEnable") Enable :: proc(cap: i32) ---;
|
Enable :: proc(cap: i32) ---;
|
||||||
@(link_name="glDisable") Disable :: proc(cap: i32) ---;
|
Disable :: proc(cap: i32) ---;
|
||||||
@(link_name="glGenTextures") GenTextures :: proc(count: i32, result: ^u32) ---;
|
GenTextures :: proc(count: i32, result: ^u32) ---;
|
||||||
@(link_name="glDeleteTextures") DeleteTextures :: proc(count: i32, result: ^u32) ---;
|
DeleteTextures :: proc(count: i32, result: ^u32) ---;
|
||||||
@(link_name="glTexParameteri") TexParameteri :: proc(target, pname, param: i32) ---;
|
TexParameteri :: proc(target, pname, param: i32) ---;
|
||||||
@(link_name="glTexParameterf") TexParameterf :: proc(target: i32, pname: i32, param: f32) ---;
|
TexParameterf :: proc(target: i32, pname: i32, param: f32) ---;
|
||||||
@(link_name="glBindTexture") BindTexture :: proc(target: i32, texture: u32) ---;
|
BindTexture :: proc(target: i32, texture: u32) ---;
|
||||||
@(link_name="glLoadIdentity") LoadIdentity :: proc() ---;
|
LoadIdentity :: proc() ---;
|
||||||
@(link_name="glViewport") Viewport :: proc(x, y, width, height: i32) ---;
|
Viewport :: proc(x, y, width, height: i32) ---;
|
||||||
@(link_name="glOrtho") Ortho :: proc(left, right, bottom, top, near, far: f64) ---;
|
Ortho :: proc(left, right, bottom, top, near, far: f64) ---;
|
||||||
@(link_name="glColor3f") Color3f :: proc(r, g, b: f32) ---;
|
Color3f :: proc(r, g, b: f32) ---;
|
||||||
@(link_name="glVertex3f") Vertex3f :: proc(x, y, z: f32) ---;
|
Vertex3f :: proc(x, y, z: f32) ---;
|
||||||
@(link_name="glGetError") GetError :: proc() -> i32 ---;
|
GetError :: proc() -> i32 ---;
|
||||||
@(link_name="glGetString") GetString :: proc(name: i32) -> ^u8 ---;
|
GetString :: proc(name: i32) -> ^u8 ---;
|
||||||
@(link_name="glGetIntegerv") GetIntegerv :: proc(name: i32, v: ^i32) ---;
|
GetIntegerv :: proc(name: i32, v: ^i32) ---;
|
||||||
@(link_name="glTexCoord2f") TexCoord2f :: proc(x, y: f32) ---;
|
TexCoord2f :: proc(x, y: f32) ---;
|
||||||
@(link_name="glTexImage2D") TexImage2D :: proc(target, level, internal_format,
|
TexImage2D :: proc(target, level, internal_format: i32,
|
||||||
width, height, border,
|
width, height, border: i32,
|
||||||
format, type_: i32, pixels: rawptr) ---;
|
format, type_: i32, pixels: rawptr) ---;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
when ODIN_OS == "windows" {
|
when ODIN_OS == "windows" {
|
||||||
foreign import "system:opengl32.lib"
|
foreign import "system:opengl32.lib"
|
||||||
|
using import "core:sys/windows.odin"
|
||||||
}
|
}
|
||||||
using import "core:sys/windows.odin"
|
|
||||||
|
|
||||||
|
|
||||||
CONTEXT_MAJOR_VERSION_ARB :: 0x2091;
|
CONTEXT_MAJOR_VERSION_ARB :: 0x2091;
|
||||||
|
|||||||
+3
-7
@@ -25,11 +25,7 @@ Thread :: struct {
|
|||||||
create :: proc(procedure: Thread_Proc) -> ^Thread {
|
create :: proc(procedure: Thread_Proc) -> ^Thread {
|
||||||
win32_thread_id: u32;
|
win32_thread_id: u32;
|
||||||
|
|
||||||
__windows_thread_entry_proc :: proc "c" (data: rawptr) -> i32 {
|
__windows_thread_entry_proc :: proc "c" (t: ^Thread) -> i32 {
|
||||||
if data == nil do return 0;
|
|
||||||
|
|
||||||
t := cast(^Thread)data;
|
|
||||||
|
|
||||||
c := context;
|
c := context;
|
||||||
if t.use_init_context {
|
if t.use_init_context {
|
||||||
c = t.init_context;
|
c = t.init_context;
|
||||||
@@ -40,11 +36,11 @@ create :: proc(procedure: Thread_Proc) -> ^Thread {
|
|||||||
exit = t.procedure(t);
|
exit = t.procedure(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cast(i32)exit;
|
return i32(exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
win32_thread_proc := cast(rawptr)__windows_thread_entry_proc;
|
win32_thread_proc := rawptr(__windows_thread_entry_proc);
|
||||||
thread := new(Thread);
|
thread := new(Thread);
|
||||||
|
|
||||||
win32_thread := win32.create_thread(nil, 0, win32_thread_proc, thread, win32.CREATE_SUSPENDED, &win32_thread_id);
|
win32_thread := win32.create_thread(nil, 0, win32_thread_proc, thread, win32.CREATE_SUSPENDED, &win32_thread_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user