const ext = @cImport({ @cInclude("SDL2/SDL.h"); }); const io = @import("./io.zig"); const stack = @import("./stack.zig"); const std = @import("std"); const sys = @import("./sys.zig"); /// /// Entry point. /// pub fn main() anyerror!void { return nosuspend await async sys.runGraphics(anyerror, run); } test { _ = io; _ = stack; _ = std; _ = sys; } fn run(ev: *sys.EventLoop, fs: *const sys.FileSystem, gr: *sys.GraphicsContext) anyerror!void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); { const file_access = try ev.open(.readonly, try fs.data.joinedPath(&.{"ona.lua"})); defer ev.close(file_access); const file_size = try file_access.size(ev); const allocator = gpa.allocator(); const buffer = try allocator.alloc(u8, file_size); defer allocator.free(buffer); if ((try ev.readFile(file_access, buffer)) != file_size) return error.ScriptLoadFailure; ev.log(.debug, buffer); } while (gr.poll()) |_| { gr.present(); } }