diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2026-01-16 13:25:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-16 13:25:03 +0000 |
| commit | d46c547264c2be4ff46887d96354e653dbd6069d (patch) | |
| tree | 245f7cc22efcb64061069321a3671453cbcb78aa /core/flags | |
| parent | a2fa32a518357aefa11edd0978f48625be7dc9e5 (diff) | |
| parent | 57d02cb14850e7b241f5ec519ff5e44c6129a5fe (diff) | |
Merge pull request #6124 from laytan/nbio
Add `core:nbio`
Diffstat (limited to 'core/flags')
| -rw-r--r-- | core/flags/constants.odin | 3 | ||||
| -rw-r--r-- | core/flags/errors.odin | 8 | ||||
| -rw-r--r-- | core/flags/errors_bsd.odin | 9 | ||||
| -rw-r--r-- | core/flags/errors_nonbsd.odin | 12 | ||||
| -rw-r--r-- | core/flags/internal_rtti.odin | 14 | ||||
| -rw-r--r-- | core/flags/internal_rtti_nonbsd.odin | 32 |
6 files changed, 22 insertions, 56 deletions
diff --git a/core/flags/constants.odin b/core/flags/constants.odin index dc2663e2a..154ed3cec 100644 --- a/core/flags/constants.odin +++ b/core/flags/constants.odin @@ -11,8 +11,7 @@ NO_CORE_NAMED_TYPES :: #config(ODIN_CORE_FLAGS_NO_CORE_NAMED_TYPES, false) IMPORTING_TIME :: #config(ODIN_CORE_FLAGS_USE_TIME, time.IS_SUPPORTED) // Override support for parsing `net` types. -// TODO: Update this when the BSDs are supported. -IMPORTING_NET :: #config(ODIN_CORE_FLAGS_USE_NET, ODIN_OS == .Windows || ODIN_OS == .Linux || ODIN_OS == .Darwin || ODIN_OS == .FreeBSD) +IMPORTING_NET :: #config(ODIN_CORE_FLAGS_USE_NET, ODIN_OS == .Windows || ODIN_OS == .Linux || ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD) TAG_ARGS :: "args" SUBTAG_NAME :: "name" diff --git a/core/flags/errors.odin b/core/flags/errors.odin index 3d34a95d3..e9b2e18c8 100644 --- a/core/flags/errors.odin +++ b/core/flags/errors.odin @@ -1,5 +1,7 @@ package flags +import "base:runtime" +import "core:net" import "core:os" Parse_Error_Reason :: enum { @@ -24,6 +26,12 @@ Parse_Error :: struct { message: string, } +Unified_Parse_Error_Reason :: union #shared_nil { + Parse_Error_Reason, + runtime.Allocator_Error, + net.Parse_Endpoint_Error, +} + // Raised during parsing. // Provides more granular information than what just a string could hold. Open_File_Error :: struct { diff --git a/core/flags/errors_bsd.odin b/core/flags/errors_bsd.odin deleted file mode 100644 index 4d98d2ee4..000000000 --- a/core/flags/errors_bsd.odin +++ /dev/null @@ -1,9 +0,0 @@ -#+build netbsd, openbsd -package flags - -import "base:runtime" - -Unified_Parse_Error_Reason :: union #shared_nil { - Parse_Error_Reason, - runtime.Allocator_Error, -} diff --git a/core/flags/errors_nonbsd.odin b/core/flags/errors_nonbsd.odin deleted file mode 100644 index 28912b57f..000000000 --- a/core/flags/errors_nonbsd.odin +++ /dev/null @@ -1,12 +0,0 @@ -#+build !netbsd -#+build !openbsd -package flags - -import "base:runtime" -import "core:net" - -Unified_Parse_Error_Reason :: union #shared_nil { - Parse_Error_Reason, - runtime.Allocator_Error, - net.Parse_Endpoint_Error, -} diff --git a/core/flags/internal_rtti.odin b/core/flags/internal_rtti.odin index a1b050597..b3880afa0 100644 --- a/core/flags/internal_rtti.odin +++ b/core/flags/internal_rtti.odin @@ -5,6 +5,7 @@ import "base:intrinsics" import "base:runtime" import "core:fmt" import "core:mem" +import "core:net" import "core:os" import "core:reflect" import "core:strconv" @@ -310,7 +311,18 @@ parse_and_set_pointer_by_named_type :: proc(ptr: rawptr, str: string, data_type: } when IMPORTING_NET { - if try_net_parse_workaround(data_type, str, ptr, out_error) { + if data_type == net.Host_Or_Endpoint { + addr, net_error := net.parse_hostname_or_endpoint(str) + if net_error != nil { + // We pass along `net.Error` here. + out_error^ = Parse_Error { + net_error, + "Invalid Host/Endpoint.", + } + return + } + + (cast(^net.Host_Or_Endpoint)ptr)^ = addr return } } diff --git a/core/flags/internal_rtti_nonbsd.odin b/core/flags/internal_rtti_nonbsd.odin deleted file mode 100644 index e1286186b..000000000 --- a/core/flags/internal_rtti_nonbsd.odin +++ /dev/null @@ -1,32 +0,0 @@ -#+private -#+build !netbsd -#+build !openbsd -package flags - -import "core:net" - -// This proc exists purely as a workaround for import restrictions. -// Returns true if caller should return early. -try_net_parse_workaround :: #force_inline proc ( - data_type: typeid, - str: string, - ptr: rawptr, - out_error: ^Error, -) -> bool { - if data_type == net.Host_Or_Endpoint { - addr, net_error := net.parse_hostname_or_endpoint(str) - if net_error != nil { - // We pass along `net.Error` here. - out_error^ = Parse_Error { - net_error, - "Invalid Host/Endpoint.", - } - return true - } - - (cast(^net.Host_Or_Endpoint)ptr)^ = addr - return true - } - - return false -} |