Compare commits

..

3 Commits

Author SHA1 Message Date
kayomn f5fd24fb76 Clarify "meta" submodule doc comment and tidy up Function type
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
2022-10-23 18:16:10 +01:00
kayomn 196a3d1200 Fix typo in tests root 2022-10-23 18:15:48 +01:00
kayomn 16a9d62933 Fix typo in VS Code debug configuration 2022-10-23 18:15:25 +01:00
4 changed files with 10 additions and 11 deletions

2
.vscode/launch.json vendored
View File

@ -27,7 +27,7 @@
"arguments": "main.zig", "arguments": "main.zig",
"cwd": "${workspaceRoot}", "cwd": "${workspaceRoot}",
"valuesFormatting": "parseText", "valuesFormatting": "parseText",
"preLaunchTask": "Build Test", "preLaunchTask": "Build Tests",
}, },
] ]
} }

View File

@ -5,7 +5,7 @@
pub const io = @import("./io.zig"); pub const io = @import("./io.zig");
/// ///
/// Metaprogramming introspection utilities /// Metaprogramming introspection and generation utilities.
/// ///
pub const meta = @import("./meta.zig"); pub const meta = @import("./meta.zig");

View File

@ -12,13 +12,12 @@ pub fn FnReturn(comptime Fn: type) type {
} }
/// ///
/// Returns a single-input single-output closure type where `Input` represents the input type, /// Returns a single-input single-output closure type where `In` represents the input type, `Out`
/// `Output` represents the output type, and `captures_size` represents the size of the closure /// represents the output type, and `captures_size` represents the size of the closure context.
/// context.
/// ///
pub fn Function(comptime captures_size: usize, comptime Input: type, comptime Output: type) type { pub fn Function(comptime captures_size: usize, comptime In: type, comptime Out: type) type {
return struct { return struct {
applyErased: fn (*anyopaque, Input) Output, applyErased: fn (*anyopaque, In) Out,
context: [captures_size]u8, context: [captures_size]u8,
/// ///
@ -29,7 +28,7 @@ pub fn Function(comptime captures_size: usize, comptime Input: type, comptime Ou
/// ///
/// Applies `input` to `self`, producing a result according to the current context data. /// Applies `input` to `self`, producing a result according to the current context data.
/// ///
pub fn apply(self: *Self, input: Input) Output { pub fn apply(self: *Self, input: In) Out {
return self.applyErased(&self.context, input); return self.applyErased(&self.context, input);
} }
@ -39,7 +38,7 @@ pub fn Function(comptime captures_size: usize, comptime Input: type, comptime Ou
/// ///
/// The newly created [Self] is returned. /// The newly created [Self] is returned.
/// ///
pub fn capture(captures: anytype, comptime call: fn (@TypeOf(captures), Input) Output) Self { pub fn capture(captures: anytype, comptime call: fn (@TypeOf(captures), In) Out) Self {
const Captures = @TypeOf(captures); const Captures = @TypeOf(captures);
if (@sizeOf(Captures) > captures_size) if (@sizeOf(Captures) > captures_size)
@ -52,7 +51,7 @@ pub fn Function(comptime captures_size: usize, comptime Input: type, comptime Ou
.context = undefined, .context = undefined,
.applyErased = struct { .applyErased = struct {
fn do(erased: *anyopaque, input: Input) Output { fn do(erased: *anyopaque, input: In) Out {
return call(@ptrCast(*Captures, @alignCast( return call(@ptrCast(*Captures, @alignCast(
captures_align, erased)).*, input); captures_align, erased)).*, input);
} }

View File

@ -1,5 +1,5 @@
test { test {
_ = @import("./engine/main.zig"); _ = @import("./core/main.zig");
_ = @import("./oar/main.zig"); _ = @import("./oar/main.zig");
_ = @import("./ona/main.zig"); _ = @import("./ona/main.zig");
} }