50 lines
1.4 KiB
Zig
50 lines
1.4 KiB
Zig
const std = @import("std");
|
|
|
|
// hand bombed zig version of the api
|
|
pub const Verbosity = enum(c_int) {
|
|
verbose,
|
|
info,
|
|
warn,
|
|
err,
|
|
};
|
|
|
|
/// desc: a thing representing a zig slice
|
|
pub const Slice = extern struct {
|
|
ptr: [*c]const u8,
|
|
len: usize,
|
|
|
|
pub fn make(s: []const u8) @This() {
|
|
return .{ .ptr = s.ptr, .len = s.len };
|
|
}
|
|
|
|
pub fn bytes(self: @This()) []const u8 {
|
|
var s: []const u8 = undefined;
|
|
s.len = self.len;
|
|
s.ptr = @ptrCast(self.ptr);
|
|
return s;
|
|
}
|
|
};
|
|
|
|
const expected_version: u32 = 0;
|
|
|
|
const core_api = extern struct {
|
|
version: u32,
|
|
get_engine: *const fn () callconv(.c) ?*anyopaque,
|
|
get_tag_registry: *const fn () callconv(.c) ?*anyopaque,
|
|
start: *const fn () callconv(.c) void,
|
|
shutdown: *const fn () callconv(.c) void,
|
|
declare_logging_category: *const fn (name: Slice, default_verbosity: Verbosity) callconv(.c) u32,
|
|
log_puts: *const fn (category: u32, verbosity: Verbosity, string: Slice) callconv(.c) void,
|
|
};
|
|
|
|
var core: *core_api = undefined;
|
|
// -- end of handbomb
|
|
|
|
pub export fn entrypoint(_core: *core_api) callconv(.c) i32 {
|
|
core = _core;
|
|
const category = core.declare_logging_category(Slice.make("test"), .warn);
|
|
core.log_puts(category, .info, Slice.make("Game startup is called"));
|
|
core.log_puts(category, .info, Slice.make("Game startup is called2"));
|
|
return 0;
|
|
}
|