From: Brendan Hansen Date: Fri, 16 Dec 2022 02:42:04 +0000 (-0600) Subject: bugfixes; added user_data to OnyxContext X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=bae1c89811db820ccfad78d050817e81fa3fb290;p=onyx.git bugfixes; added user_data to OnyxContext --- diff --git a/core/builtin.onyx b/core/builtin.onyx index 892e7117..b6afe460 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -59,8 +59,12 @@ OnyxContext :: struct { assert_handler : (msg: str, site: CallSite) -> void; thread_id : i32; + + user_data: rawptr; + user_data_type: type_expr; } + #if runtime.runtime != .Custom { #local default_logger :: (data: rawptr, msg: str) { use package core @@ -81,6 +85,17 @@ assert :: (cond: bool, msg: str, site := #callsite) { } } +#inject OnyxContext { + set_user_data :: macro (c: ^OnyxContext, data: ^$T) { + c.user_data = data; + c.user_data_type = T; + } + + get_user_data :: macro (c: ^OnyxContext, $T: type_expr) -> ^T { + if c.user_data_type != T do return null; + return ~~ c.user_data; + } +} // // Basic logging diff --git a/core/container/array.onyx b/core/container/array.onyx index 051075c6..c5aa3020 100644 --- a/core/container/array.onyx +++ b/core/container/array.onyx @@ -499,9 +499,9 @@ some :: #match #locked { macro (arr: [] $T, predicate_body: Code) -> bool { for arr { - if #unquote predicate_body do return false; + if #unquote predicate_body do return true; } - return true; + return false; } } diff --git a/misc/vscode/onyx-0.1.1.vsix b/misc/vscode/onyx-0.1.1.vsix new file mode 100644 index 00000000..3aded030 Binary files /dev/null and b/misc/vscode/onyx-0.1.1.vsix differ