mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Use RTTI to get the error_string for Windows
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
//+private
|
//+private
|
||||||
package os2
|
package os2
|
||||||
|
|
||||||
|
import "base:runtime"
|
||||||
|
import "core:slice"
|
||||||
import win32 "core:sys/windows"
|
import win32 "core:sys/windows"
|
||||||
|
|
||||||
_error_string :: proc(errno: i32) -> string {
|
_error_string :: proc(errno: i32) -> string {
|
||||||
@@ -8,6 +10,14 @@ _error_string :: proc(errno: i32) -> string {
|
|||||||
if e == 0 {
|
if e == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err := runtime.Type_Info_Enum_Value(e)
|
||||||
|
|
||||||
|
ti := &runtime.type_info_base(type_info_of(win32.System_Error)).variant.(runtime.Type_Info_Enum)
|
||||||
|
if idx, ok := slice.binary_search(ti.values, err); ok {
|
||||||
|
return ti.names[idx]
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(bill): _error_string for windows
|
// TODO(bill): _error_string for windows
|
||||||
// FormatMessageW
|
// FormatMessageW
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Reference in New Issue
Block a user