mach/platform: check for App functions in all platforms
This commit is contained in:
parent
21c49ff9be
commit
ff126c0054
3 changed files with 13 additions and 4 deletions
6
src/platform/common.zig
Normal file
6
src/platform/common.zig
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
pub fn checkApplication(comptime App: type) void {
|
||||||
|
// TODO: check signature
|
||||||
|
if (!@hasDecl(App, "init")) @compileError("App must export 'pub fn init(app: *App, engine: *mach.Engine) !void'");
|
||||||
|
if (!@hasDecl(App, "deinit")) @compileError("App must export 'pub fn deinit(app: *App, engine: *mach.Engine) void'");
|
||||||
|
if (!@hasDecl(App, "update")) @compileError("App must export 'pub fn update(app: *App, engine: *mach.Engine) !bool'");
|
||||||
|
}
|
||||||
|
|
@ -390,11 +390,9 @@ pub const GpuDriver = struct {
|
||||||
|
|
||||||
pub const BackingTimer = std.time.Timer;
|
pub const BackingTimer = std.time.Timer;
|
||||||
|
|
||||||
// TODO: check signatures
|
const common = @import("common.zig");
|
||||||
comptime {
|
comptime {
|
||||||
if (!@hasDecl(App, "init")) @compileError("App must export 'pub fn init(app: *App, engine: *mach.Engine) !void'");
|
common.checkApplication(App);
|
||||||
if (!@hasDecl(App, "deinit")) @compileError("App must export 'pub fn deinit(app: *App, engine: *mach.Engine) void'");
|
|
||||||
if (!@hasDecl(App, "update")) @compileError("App must export 'pub fn update(app: *App, engine: *mach.Engine) !bool'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,11 @@ pub const BackingTimer = struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const common = @import("common.zig");
|
||||||
|
comptime {
|
||||||
|
common.checkApplication(App);
|
||||||
|
}
|
||||||
|
|
||||||
var app: App = undefined;
|
var app: App = undefined;
|
||||||
var engine: Engine = undefined;
|
var engine: Engine = undefined;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue