mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 02:40:05 +00:00
distinct keyword for type declarations
This commit is contained in:
+24
-24
@@ -1,38 +1,38 @@
|
||||
CHAR_BIT :: 8;
|
||||
|
||||
c_bool :: #alias bool;
|
||||
c_char :: #alias u8;
|
||||
c_byte :: #alias u8;
|
||||
c_schar :: #alias i8;
|
||||
c_uchar :: #alias u8;
|
||||
c_short :: #alias i16;
|
||||
c_ushort :: #alias u16;
|
||||
c_int :: #alias i32;
|
||||
c_uint :: #alias u32;
|
||||
c_bool :: bool;
|
||||
c_char :: u8;
|
||||
c_byte :: u8;
|
||||
c_schar :: i8;
|
||||
c_uchar :: u8;
|
||||
c_short :: i16;
|
||||
c_ushort :: u16;
|
||||
c_int :: i32;
|
||||
c_uint :: u32;
|
||||
|
||||
when ODIN_OS == "windows" || size_of(rawptr) == 4 {
|
||||
c_long :: #alias i32;
|
||||
c_long :: i32;
|
||||
} else {
|
||||
c_long :: #alias i64;
|
||||
c_long :: i64;
|
||||
}
|
||||
|
||||
when ODIN_OS == "windows" || size_of(rawptr) == 4 {
|
||||
c_ulong :: #alias u32;
|
||||
c_ulong :: u32;
|
||||
} else {
|
||||
c_ulong :: #alias u64;
|
||||
c_ulong :: u64;
|
||||
}
|
||||
|
||||
c_longlong :: #alias i64;
|
||||
c_ulonglong :: #alias u64;
|
||||
c_float :: #alias f32;
|
||||
c_double :: #alias f64;
|
||||
c_complex_float :: #alias complex64;
|
||||
c_complex_double :: #alias complex128;
|
||||
c_longlong :: i64;
|
||||
c_ulonglong :: u64;
|
||||
c_float :: f32;
|
||||
c_double :: f64;
|
||||
c_complex_float :: complex64;
|
||||
c_complex_double :: complex128;
|
||||
|
||||
_ :: compile_assert(size_of(uintptr) == size_of(int));
|
||||
|
||||
c_size_t :: #alias uint;
|
||||
c_ssize_t :: #alias int;
|
||||
c_ptrdiff_t :: #alias int;
|
||||
c_uintptr_t :: #alias uintptr;
|
||||
c_intptr_t :: #alias int;
|
||||
c_size_t :: uint;
|
||||
c_ssize_t :: int;
|
||||
c_ptrdiff_t :: int;
|
||||
c_uintptr_t :: uintptr;
|
||||
c_intptr_t :: int;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import "core:raw.odin"
|
||||
|
||||
_BUFFER_SIZE :: 1<<12;
|
||||
|
||||
String_Buffer :: [dynamic]byte;
|
||||
String_Buffer :: distinct [dynamic]byte;
|
||||
|
||||
Fmt_Info :: struct {
|
||||
minus: bool,
|
||||
|
||||
+6
-6
@@ -14,14 +14,14 @@ EPSILON :: 1.19209290e-7;
|
||||
τ :: TAU;
|
||||
π :: PI;
|
||||
|
||||
Vec2 :: [2]f32;
|
||||
Vec3 :: [3]f32;
|
||||
Vec4 :: [4]f32;
|
||||
Vec2 :: distinct [2]f32;
|
||||
Vec3 :: distinct [3]f32;
|
||||
Vec4 :: distinct [4]f32;
|
||||
|
||||
// Column major
|
||||
Mat2 :: [2][2]f32;
|
||||
Mat3 :: [3][3]f32;
|
||||
Mat4 :: [4][4]f32;
|
||||
Mat2 :: distinct [2][2]f32;
|
||||
Mat3 :: distinct [3][3]f32;
|
||||
Mat4 :: distinct [4][4]f32;
|
||||
|
||||
Quat :: struct {x, y, z: f32, w: f32 = 1};
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ allocation_header :: proc(data: rawptr) -> ^AllocationHeader {
|
||||
}
|
||||
|
||||
|
||||
Fixed_Byte_Buffer :: [dynamic]byte;
|
||||
Fixed_Byte_Buffer :: distinct [dynamic]byte;
|
||||
|
||||
make_fixed_byte_buffer :: proc(backing: []byte) -> Fixed_Byte_Buffer {
|
||||
s := transmute(raw.Slice)backing;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
foreign import api "system:api"
|
||||
|
||||
Handle :: int;
|
||||
Errno :: int;
|
||||
Handle :: distinct int;
|
||||
Errno :: distinct int;
|
||||
|
||||
O_RDONLY :: 1;
|
||||
O_WRONLY :: 2;
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@ foreign import libc "system:c"
|
||||
import "core:strings.odin"
|
||||
import "core:mem.odin"
|
||||
|
||||
Handle :: i32;
|
||||
File_Time :: u64;
|
||||
Errno :: i32;
|
||||
Handle :: distinct i32;
|
||||
File_Time :: distinct u64;
|
||||
Errno :: distinct i32;
|
||||
|
||||
|
||||
O_RDONLY :: 0x00000;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import win32 "core:sys/windows.odin"
|
||||
import "core:mem.odin"
|
||||
|
||||
Handle :: uintptr;
|
||||
File_Time :: u64;
|
||||
Handle :: distinct uintptr;
|
||||
File_Time :: distinct u64;
|
||||
Errno :: distinct int;
|
||||
|
||||
|
||||
INVALID_HANDLE :: ~Handle(0);
|
||||
@@ -22,7 +23,6 @@ O_SYNC :: 0x01000;
|
||||
O_ASYNC :: 0x02000;
|
||||
O_CLOEXEC :: 0x80000;
|
||||
|
||||
Errno :: int;
|
||||
|
||||
ERROR_NONE: Errno : 0;
|
||||
ERROR_FILE_NOT_FOUND: Errno : 2;
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@ foreign import libc "system:c"
|
||||
import "core:strings.odin"
|
||||
import "core:mem.odin"
|
||||
|
||||
Handle :: i32;
|
||||
File_Time :: u64;
|
||||
Errno :: int;
|
||||
Handle :: distinct i32;
|
||||
File_Time :: distinct u64;
|
||||
Errno :: distinct int;
|
||||
|
||||
|
||||
O_RDONLY :: 0x00000;
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ CONTEXT_FORWARD_COMPATIBLE_BIT_ARB :: 0x0002;
|
||||
CONTEXT_CORE_PROFILE_BIT_ARB :: 0x00000001;
|
||||
CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002;
|
||||
|
||||
Hglrc :: Handle;
|
||||
Color_Ref :: u32;
|
||||
Hglrc :: distinct Handle;
|
||||
Color_Ref :: distinct u32;
|
||||
|
||||
Layer_Plane_Descriptor :: struct {
|
||||
size: u16,
|
||||
|
||||
+34
-34
@@ -6,27 +6,27 @@ when ODIN_OS == "windows" {
|
||||
foreign import "system:shell32.lib"
|
||||
}
|
||||
|
||||
Handle :: rawptr;
|
||||
Hwnd :: Handle;
|
||||
Hdc :: Handle;
|
||||
Hinstance :: Handle;
|
||||
Hicon :: Handle;
|
||||
Hcursor :: Handle;
|
||||
Hmenu :: Handle;
|
||||
Hbrush :: Handle;
|
||||
Hgdiobj :: Handle;
|
||||
Hmodule :: Handle;
|
||||
Hmonitor :: Handle;
|
||||
Hrawinput :: Handle;
|
||||
HKL :: Handle;
|
||||
Wparam :: uint;
|
||||
Lparam :: int;
|
||||
Lresult :: int;
|
||||
Wnd_Proc :: #type proc "c" (Hwnd, u32, Wparam, Lparam) -> Lresult;
|
||||
Handle :: distinct rawptr;
|
||||
Hwnd :: distinct Handle;
|
||||
Hdc :: distinct Handle;
|
||||
Hinstance :: distinct Handle;
|
||||
Hicon :: distinct Handle;
|
||||
Hcursor :: distinct Handle;
|
||||
Hmenu :: distinct Handle;
|
||||
Hbrush :: distinct Handle;
|
||||
Hgdiobj :: distinct Handle;
|
||||
Hmodule :: distinct Handle;
|
||||
Hmonitor :: distinct Handle;
|
||||
Hrawinput :: distinct Handle;
|
||||
HKL :: distinct Handle;
|
||||
Wparam :: distinct uint;
|
||||
Lparam :: distinct int;
|
||||
Lresult :: distinct int;
|
||||
Wnd_Proc :: distinct #type proc "c" (Hwnd, u32, Wparam, Lparam) -> Lresult;
|
||||
|
||||
Long_Ptr :: int;
|
||||
Long_Ptr :: distinct int;
|
||||
|
||||
Bool :: b32;
|
||||
Bool :: distinct b32;
|
||||
|
||||
Point :: struct {
|
||||
x, y: i32,
|
||||
@@ -126,7 +126,7 @@ Security_Attributes :: struct {
|
||||
|
||||
Process_Information :: struct {
|
||||
process: Handle,
|
||||
thread: Handle,
|
||||
thread: Handle,
|
||||
process_id: u32,
|
||||
thread_id: u32
|
||||
}
|
||||
@@ -471,7 +471,7 @@ PFD_DEPTH_DONTCARE :: 0x20000000;
|
||||
PFD_DOUBLEBUFFER_DONTCARE :: 0x40000000;
|
||||
PFD_STEREO_DONTCARE :: 0x80000000;
|
||||
|
||||
GET_FILEEX_INFO_LEVELS :: i32;
|
||||
GET_FILEEX_INFO_LEVELS :: distinct i32;
|
||||
GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0;
|
||||
GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1;
|
||||
|
||||
@@ -498,14 +498,14 @@ MOVEFILE_WRITE_THROUGH :: 0x00000008;
|
||||
MOVEFILE_CREATE_HARDLINK :: 0x00000010;
|
||||
MOVEFILE_FAIL_IF_NOT_TRACKABLE :: 0x00000020;
|
||||
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME :: 0x00000001;
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME :: 0x00000002;
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES :: 0x00000004;
|
||||
FILE_NOTIFY_CHANGE_SIZE :: 0x00000008;
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE :: 0x00000010;
|
||||
FILE_NOTIFY_CHANGE_LAST_ACCESS :: 0x00000020;
|
||||
FILE_NOTIFY_CHANGE_CREATION :: 0x00000040;
|
||||
FILE_NOTIFY_CHANGE_SECURITY :: 0x00000100;
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME :: 0x00000001;
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME :: 0x00000002;
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES :: 0x00000004;
|
||||
FILE_NOTIFY_CHANGE_SIZE :: 0x00000008;
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE :: 0x00000010;
|
||||
FILE_NOTIFY_CHANGE_LAST_ACCESS :: 0x00000020;
|
||||
FILE_NOTIFY_CHANGE_CREATION :: 0x00000040;
|
||||
FILE_NOTIFY_CHANGE_SECURITY :: 0x00000100;
|
||||
|
||||
FILE_FLAG_WRITE_THROUGH :: 0x80000000;
|
||||
FILE_FLAG_OVERLAPPED :: 0x40000000;
|
||||
@@ -537,9 +537,9 @@ CP_UTF8 :: 65001; // UTF-8 translation
|
||||
@(default_calling_convention = "std")
|
||||
foreign kernel32 {
|
||||
@(link_name="GetLastError") get_last_error :: proc() -> i32 ---;
|
||||
@(link_name="CreateProcessA") create_process_a :: proc(application_name, command_line: ^byte,
|
||||
process_attributes, thread_attributes: ^Security_Attributes,
|
||||
inherit_handle: Bool, creation_flags: u32, environment: rawptr,
|
||||
@(link_name="CreateProcessA") create_process_a :: proc(application_name, command_line: ^byte,
|
||||
process_attributes, thread_attributes: ^Security_Attributes,
|
||||
inherit_handle: Bool, creation_flags: u32, environment: rawptr,
|
||||
current_direcotry: ^byte, startup_info : ^Startup_Info,
|
||||
process_information : ^Process_Information) -> Bool ---;
|
||||
@(link_name="GetExitCodeProcess") get_exit_code_process :: proc(process: Handle, exit: ^u32) -> Bool ---;
|
||||
@@ -606,7 +606,7 @@ foreign kernel32 {
|
||||
@(link_name="FindNextChangeNotification") find_next_change_notification :: proc(h: Handle) -> Bool ---;
|
||||
@(link_name="FindCloseChangeNotification") find_close_change_notification :: proc(h: Handle) -> Bool ---;
|
||||
|
||||
@(link_name="ReadDirectoryChangesW") read_directory_changes_w :: proc(dir: Handle, buf: rawptr, buf_length: u32,
|
||||
@(link_name="ReadDirectoryChangesW") read_directory_changes_w :: proc(dir: Handle, buf: rawptr, buf_length: u32,
|
||||
watch_subtree: Bool, notify_filter: u32,
|
||||
bytes_returned: ^u32, overlapped: ^Overlapped,
|
||||
completion: rawptr) -> Bool ---;
|
||||
@@ -615,7 +615,7 @@ foreign kernel32 {
|
||||
wchar_str: ^u16, wchar: i32,
|
||||
multi_str: ^byte, multi: i32,
|
||||
default_char: ^byte, used_default_char: ^Bool) -> i32 ---;
|
||||
|
||||
|
||||
@(link_name="CreateSemaphoreA") create_semaphore_a :: proc(attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: ^byte) -> Handle ---;
|
||||
@(link_name="ReleaseSemaphore") release_semaphore :: proc(semaphore: Handle, release_count: i32, previous_count: ^i32) -> Bool ---;
|
||||
@(link_name="WaitForSingleObject") wait_for_single_object :: proc(handle: Handle, milliseconds: u32) -> u32 ---;
|
||||
|
||||
Reference in New Issue
Block a user