added 'ouit' module
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 18 Oct 2021 22:24:30 +0000 (17:24 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 18 Oct 2021 22:24:30 +0000 (17:24 -0500)
bin/onyx
modules/ouit/module.onyx [new file with mode: 0644]
modules/ouit/ouit.js [new file with mode: 0644]
modules/ouit/ouit.onyx [new file with mode: 0644]
modules/ouit/ouit_build.sh [new file with mode: 0755]
src/checker.c

index 9e067728a473052842973a1678efc863f8730d74..94c9ad5ce00980d0a81d74cf8f7ba45daa22b6d2 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
diff --git a/modules/ouit/module.onyx b/modules/ouit/module.onyx
new file mode 100644 (file)
index 0000000..060f0ab
--- /dev/null
@@ -0,0 +1,20 @@
+package ouit
+
+/*
+
+Ouit ("Wheat") - The Onyx User-Interface Template
+
+An all-encompassing user-interface template for Onyx program thats makes
+it easy to setup a web-based user interface.
+
+*/
+
+#load "core/std"
+
+#load "modules/bmfont/module"
+#load "modules/immediate_mode/module"
+#load "modules/js_events/module"
+#load "modules/ui/module"
+#load "modules/webgl2/module"
+
+#load "./ouit"
\ No newline at end of file
diff --git a/modules/ouit/ouit.js b/modules/ouit/ouit.js
new file mode 100644 (file)
index 0000000..1d82b89
--- /dev/null
@@ -0,0 +1,18 @@
+window.ONYX_MODULES = window.ONYX_MODULES || [];
+
+window.ONYX_MODULES.push({
+    module_name: "ouit",
+
+    loop: function() {
+        function loop() {
+            window.ONYX_INSTANCE.exports.ouit_loop();
+            window.requestAnimationFrame(loop);
+        }
+
+        window.requestAnimationFrame(loop);
+    },
+
+    time_now: function() {
+        return Date.now();
+    },
+});
\ No newline at end of file
diff --git a/modules/ouit/ouit.onyx b/modules/ouit/ouit.onyx
new file mode 100644 (file)
index 0000000..726d107
--- /dev/null
@@ -0,0 +1,45 @@
+package ouit
+
+#private_file {
+    gl     :: package gl
+    gfx    :: package immediate_mode
+    events :: package js_events
+}
+
+start :: () -> void #foreign "ouit" "loop" ---
+
+init :: (canvas_name: str,
+    he: typeof ouit_handle_event,
+    u:  typeof ouit_update,
+    d:  typeof ouit_draw) {
+
+    gl.init(canvas_name);
+    events.init();
+    gfx.immediate_renderer_init();
+
+    ouit_handle_event = he;
+    ouit_update       = u;
+    ouit_draw         = d;
+}
+
+#private {
+    ouit_handle_event : (^events.Event) -> void;
+    ouit_update       : (dt: f32)       -> void;
+    ouit_draw         : ()              -> void;
+}
+
+#export "ouit_loop" () {
+    time_now :: () -> i32 #foreign "ouit" "time_now" --- ;
+
+    #persist last_time := 0;
+    if last_time == 0 do last_time = time_now();
+
+    now := time_now();
+    dt  := cast(f32) (now - last_time) / 1000.0f;
+    last_time = now;
+
+    for event: events.consume() do ouit_handle_event(event);
+
+    ouit_update(dt);
+    ouit_draw();
+}
\ No newline at end of file
diff --git a/modules/ouit/ouit_build.sh b/modules/ouit/ouit_build.sh
new file mode 100755 (executable)
index 0000000..9530191
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+ONYX_FOLDER="$HOME/dev/c/onyx"
+
+[ ! -s "./modules" ]    && ln -s "$ONYX_FOLDER/modules" $(pwd)/modules
+[ ! -s "./js" ]         && ln -s "$ONYX_FOLDER/bin"     $(pwd)/js
+[ ! -f "./index.html" ] && cp "$ONYX_FOLDER/modules/ouit/index.html" .
+
+onyx -r js -V --use-multi-threading --use-post-mvp-features -o ouit.wasm "$1"
+
index f4d2d26d0852f6126fcbf98f02eef00d96fe4919..ef35a7f672d19aa65a1b4e9c45c66efa854ec712 100644 (file)
@@ -801,6 +801,9 @@ CheckStatus check_binaryop_compare(AstBinaryOp** pbinop) {
     Type* ltype = binop->left->type;
     Type* rtype = binop->right->type;
 
+    if (ltype == NULL) YIELD(binop->token->pos, "Waiting for left-type to be known.");
+    if (rtype == NULL) YIELD(binop->token->pos, "Waiting for right-type to be known.");
+
     if (ltype->kind == Type_Kind_Pointer) ltype = &basic_types[Basic_Kind_Rawptr];
     if (rtype->kind == Type_Kind_Pointer) rtype = &basic_types[Basic_Kind_Rawptr];