bugfixes; added user_data to OnyxContext
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 16 Dec 2022 02:42:04 +0000 (20:42 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 16 Dec 2022 02:42:04 +0000 (20:42 -0600)
core/builtin.onyx
core/container/array.onyx
misc/vscode/onyx-0.1.1.vsix [new file with mode: 0644]

index 892e7117a06874bcd7edeeff24ca4a0e38e5c264..b6afe460172e884d3af0614ed062376cf9022a6f 100644 (file)
@@ -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
index 051075c63505e15fc9502b9b46340511004b71b2..c5aa3020b85563d3c3806df36a20d6757e0829a8 100644 (file)
@@ -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 (file)
index 0000000..3aded03
Binary files /dev/null and b/misc/vscode/onyx-0.1.1.vsix differ