From: Brendan Hansen Date: Mon, 18 Oct 2021 22:24:30 +0000 (-0500) Subject: added 'ouit' module X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=4acb98797a2983ccfbdc075dce0a6691d4cfacf1;p=onyx.git added 'ouit' module --- diff --git a/bin/onyx b/bin/onyx index 9e067728..94c9ad5c 100755 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 index 00000000..060f0ab7 --- /dev/null +++ b/modules/ouit/module.onyx @@ -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 index 00000000..1d82b892 --- /dev/null +++ b/modules/ouit/ouit.js @@ -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 index 00000000..726d1078 --- /dev/null +++ b/modules/ouit/ouit.onyx @@ -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 index 00000000..95301910 --- /dev/null +++ b/modules/ouit/ouit_build.sh @@ -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" + diff --git a/src/checker.c b/src/checker.c index f4d2d26d..ef35a7f6 100644 --- a/src/checker.c +++ b/src/checker.c @@ -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];