ona/src/main.zig
kayomn 5f4e4cc811
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
Implement more hash table logic
2022-10-15 11:38:22 +01:00

50 lines
1.1 KiB
Zig

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(app: *sys.AppContext, graphics: *sys.GraphicsContext) anyerror!void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
{
var file_access = try (try app.data().joinedPath(&.{"ona.lua"})).open(.readonly);
defer file_access.close();
const file_size = try file_access.queryLength();
const allocator = gpa.allocator();
const buffer = try allocator.alloc(u8, file_size);
defer allocator.free(buffer);
if ((try file_access.read(buffer)) != file_size)
return error.ScriptLoadFailure;
sys.Log.debug.write(buffer);
}
while (graphics.poll()) |_| {
graphics.present();
}
}