zig proof of concept is working
This commit is contained in:
parent
02c1938a43
commit
bded79d363
|
@ -1,5 +1,6 @@
|
||||||
Calc
|
Calc
|
||||||
zig-out
|
zig-out
|
||||||
zig-cache
|
zig-cache
|
||||||
|
liborca.a
|
||||||
profile.dtrace
|
profile.dtrace
|
||||||
profile.spall
|
profile.spall
|
||||||
|
|
|
@ -6,6 +6,7 @@ set wasmFlags=--target=wasm32^
|
||||||
-fno-builtin ^
|
-fno-builtin ^
|
||||||
-Wl,--no-entry ^
|
-Wl,--no-entry ^
|
||||||
-Wl,--export-dynamic ^
|
-Wl,--export-dynamic ^
|
||||||
|
-Wl,--relocatable ^
|
||||||
-g ^
|
-g ^
|
||||||
-O2 ^
|
-O2 ^
|
||||||
-mbulk-memory ^
|
-mbulk-memory ^
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const oc = @import("orca");
|
const oc = @import("orca");
|
||||||
|
|
||||||
|
var counter: u32 = 0;
|
||||||
|
|
||||||
export fn oc_on_init() void {
|
export fn oc_on_init() void {
|
||||||
oc.log_info("oc_on_init!!!!\n");
|
oc.log_info("counter: {}", .{counter}, @src());
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn oc_on_frame_refresh() void {
|
export fn oc_on_frame_refresh() void {
|
||||||
oc.log_info("oc_on_frame_refresh!!!!\n");
|
counter += 1;
|
||||||
|
oc.log_info("counter: {}", .{counter}, @src());
|
||||||
|
|
||||||
|
if (counter == 10) {
|
||||||
|
oc.oc_request_quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export fn oc_on_terminate() void {
|
||||||
|
oc.log_info("byebye", .{}, @src());
|
||||||
}
|
}
|
||||||
|
|
16
src/orca.zig
16
src/orca.zig
|
@ -1,17 +1,15 @@
|
||||||
|
const std = @import("std");
|
||||||
const c = @cImport({
|
const c = @cImport({
|
||||||
@cDefine("__ORCA__", "");
|
@cDefine("__ORCA__", "");
|
||||||
@cInclude("orca.h");
|
@cInclude("orca.h");
|
||||||
});
|
});
|
||||||
|
|
||||||
// export var oc_rawEvent: c.oc_event = c.oc_rawEvent;
|
pub fn log_info(comptime fmt: []const u8, args: anytype, source: std.builtin.SourceLocation) void {
|
||||||
|
var format_buf: [512:0]u8 = undefined;
|
||||||
|
_ = std.fmt.bufPrintZ(&format_buf, fmt, args) catch 0; // just discard NoSpaceLeft error for now
|
||||||
|
|
||||||
pub fn log_info(fmt: []const u8) void {
|
var line: c_int = @intCast(source.line);
|
||||||
c.oc_log_ext(c.OC_LOG_LEVEL_INFO, "UnknownFunc", "UnknownFile", 0, fmt.ptr);
|
c.oc_log_ext(c.OC_LOG_LEVEL_INFO, source.fn_name.ptr, source.file.ptr, line, format_buf[0..].ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ORCA_API void oc_log_ext(oc_log_level level,
|
pub const oc_request_quit = c.oc_request_quit;
|
||||||
// const char* function,
|
|
||||||
// const char* file,
|
|
||||||
// int line,
|
|
||||||
// const char* fmt,
|
|
||||||
// ...);
|
|
||||||
|
|
Loading…
Reference in New Issue