From b3be2cdf9d00692f61e90de0047fa922f5503c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20=28counter=29?= <49562770+awwdev@users.noreply.github.com> Date: Fri, 9 Dec 2022 18:14:47 +0100 Subject: [PATCH 1/6] Aliasing some procs to avoid code repetition Aliasing some procedures within package reflect so they reference procedures from package runtime. This avoids redundancy and potential deviation. Not 100% sure about the ODIN_DISALLOW_RTTI part but I think it should be congruent as well. --- core/reflect/reflect.odin | 43 +++++++-------------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/core/reflect/reflect.odin b/core/reflect/reflect.odin index 8aab77399..0312ffd95 100644 --- a/core/reflect/reflect.odin +++ b/core/reflect/reflect.odin @@ -123,46 +123,17 @@ backing_type_kind :: proc(T: typeid) -> Type_Kind { } -type_info_base :: proc(info: ^Type_Info) -> ^Type_Info { - if info == nil { return nil } - - base := info - loop: for { - #partial switch i in base.variant { - case Type_Info_Named: base = i.base - case: break loop - } - } - return base -} - - -type_info_core :: proc(info: ^Type_Info) -> ^Type_Info { - if info == nil { return nil } - - base := info - loop: for { - #partial switch i in base.variant { - case Type_Info_Named: base = i.base - case Type_Info_Enum: base = i.base - case: break loop - } - } - return base -} +type_info_base :: runtime.type_info_base +type_info_core :: runtime.type_info_core type_info_base_without_enum :: type_info_core -typeid_base :: proc(id: typeid) -> typeid { - ti := type_info_of(id) - ti = type_info_base(ti) - return ti.id +when !ODIN_DISALLOW_RTTI { + typeid_base :: runtime.typeid_base + typeid_core :: runtime.typeid_core + typeid_base_without_enum :: typeid_core } -typeid_core :: proc(id: typeid) -> typeid { - ti := type_info_base_without_enum(type_info_of(id)) - return ti.id -} -typeid_base_without_enum :: typeid_core + any_base :: proc(v: any) -> any { v := v From 7fbee880617a74c234d462683b1b4865885ab454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20=28counter=29?= <49562770+awwdev@users.noreply.github.com> Date: Fri, 9 Dec 2022 19:20:03 +0100 Subject: [PATCH 2/6] Fix typo err: runtime.Allocator to Allocator_Error --- core/slice/map.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/slice/map.odin b/core/slice/map.odin index 22f0db9b9..50d6dbd37 100644 --- a/core/slice/map.odin +++ b/core/slice/map.odin @@ -37,7 +37,7 @@ Map_Entry_Info :: struct($Key, $Value: typeid) { } -map_entries :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (entries: []Map_Entry(K, V), err: runtime.Allocator) { +map_entries :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (entries: []Map_Entry(K, V), err: runtime.Allocator_Error) { entries = make(type_of(entries), len(m), allocator) or_return i := 0 for key, value in m { From 588c52a8549aa8e8c07213d4e86750bc95c2dab2 Mon Sep 17 00:00:00 2001 From: Tetralux Date: Sun, 11 Dec 2022 09:10:17 +0000 Subject: [PATCH 3/6] [runtime] Fix typo in shrink_dynamic_array() --- core/runtime/core_builtin.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index 6792734d2..cbcb162a8 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -615,7 +615,7 @@ shrink_dynamic_array :: proc(array: ^$T/[dynamic]$E, new_cap := -1, loc := #call old_size := a.cap * size_of(E) new_size := new_cap * size_of(E) - new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) + new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), a.allocator, loc) if err != nil { return } From 1ddbe16d2807ef14e949fa884481aa467437bf9e Mon Sep 17 00:00:00 2001 From: hikari Date: Tue, 13 Dec 2022 10:25:18 +0200 Subject: [PATCH 4/6] sys/windows: add GetMonitorInfoW --- core/sys/windows/types.odin | 19 +++++++++++++++++++ core/sys/windows/user32.odin | 1 + 2 files changed, 20 insertions(+) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 9a2a21070..210c39aaa 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -1554,6 +1554,25 @@ WA_INACTIVE :: 0 WA_ACTIVE :: 1 WA_CLICKACTIVE :: 2 +// Struct pointed to by WM_GETMINMAXINFO lParam +MINMAXINFO :: struct { + ptReserved: POINT, + ptMaxSize: POINT, + ptMaxPosition: POINT, + ptMinTrackSize: POINT, + ptMaxTrackSize: POINT, +} +PMINMAXINFO :: ^MINMAXINFO +LPMINMAXINFO :: PMINMAXINFO + +MONITORINFO :: struct { + cbSize: DWORD, + rcMonitor: RECT, + rcWork: RECT, + dwFlags: DWORD, +} +LPMONITORINFO :: ^MONITORINFO + // SetWindowsHook() codes WH_MIN :: -1 WH_MSGFILTER :: -1 diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 9a30e6454..61f2a3dac 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -100,6 +100,7 @@ foreign user32 { AdjustWindowRectExForDpi :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD, dpi: UINT) -> BOOL --- SystemParametersInfoW :: proc(uiAction, uiParam: UINT, pvParam: PVOID, fWinIni: UINT) -> BOOL --- + GetMonitorInfoW :: proc(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL --- GetWindowDC :: proc(hWnd: HWND) -> HDC --- GetDC :: proc(hWnd: HWND) -> HDC --- From 70e48e39a487f34bf0f9404d6a63d4bb9bbfda7d Mon Sep 17 00:00:00 2001 From: Said Al Attrach Date: Tue, 13 Dec 2022 12:18:58 +0100 Subject: [PATCH 5/6] Fix typo in linalg.any --- core/math/linalg/extended.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/linalg/extended.odin b/core/math/linalg/extended.odin index f6da366ba..b78697cbd 100644 --- a/core/math/linalg/extended.odin +++ b/core/math/linalg/extended.odin @@ -531,7 +531,7 @@ not_equal :: proc{not_equal_single, not_equal_array} any :: proc(x: $A/[$N]bool) -> (out: bool) { for e in x { - if x { + if e { return true } } From 9d50a0490530f8c602ece4c9bd56f316e169b66a Mon Sep 17 00:00:00 2001 From: Thomas Stibor Date: Thu, 15 Dec 2022 09:23:43 +0100 Subject: [PATCH 6/6] Update odinfmt with new filepath.Walk_Proc signature Commit f9f4551e8d2d1e86dcf902c5c4f630cbb638ea83 introduced the additional parameter: `user_data: rawptr` to `filepath.Walk_Proc` callback. This commit updates odinfmt to meet this new additional parameter. --- tools/odinfmt/main.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/odinfmt/main.odin b/tools/odinfmt/main.odin index 48e3b7212..9b9cbac0b 100644 --- a/tools/odinfmt/main.odin +++ b/tools/odinfmt/main.odin @@ -55,7 +55,7 @@ format_file :: proc(filepath: string) -> (string, bool) { files: [dynamic]string; -walk_files :: proc(info: os.File_Info, in_err: os.Errno) -> (err: os.Errno, skip_dir: bool) { +walk_files :: proc(info: os.File_Info, in_err: os.Errno, user_data: rawptr) -> (err: os.Errno, skip_dir: bool) { if info.is_dir { return 0, false; } @@ -111,7 +111,7 @@ main :: proc() { } } } else if os.is_dir(path) { - filepath.walk(path, walk_files); + filepath.walk(path, walk_files, nil); for file in files {