mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-23 14:55:19 +00:00
Use RTTI to get the error_string for Windows
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
//+private
|
||||
package os2
|
||||
|
||||
import "base:runtime"
|
||||
import "core:slice"
|
||||
import win32 "core:sys/windows"
|
||||
|
||||
_error_string :: proc(errno: i32) -> string {
|
||||
@@ -8,6 +10,14 @@ _error_string :: proc(errno: i32) -> string {
|
||||
if e == 0 {
|
||||
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
|
||||
// FormatMessageW
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user