Compare commits
3 Commits
813df95e02
...
f5fd24fb76
Author | SHA1 | Date |
---|---|---|
kayomn | f5fd24fb76 | |
kayomn | 196a3d1200 | |
kayomn | 16a9d62933 |
|
@ -27,7 +27,7 @@
|
|||
"arguments": "main.zig",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"valuesFormatting": "parseText",
|
||||
"preLaunchTask": "Build Test",
|
||||
"preLaunchTask": "Build Tests",
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
pub const io = @import("./io.zig");
|
||||
|
||||
///
|
||||
/// Metaprogramming introspection utilities
|
||||
/// Metaprogramming introspection and generation utilities.
|
||||
///
|
||||
pub const meta = @import("./meta.zig");
|
||||
|
||||
|
|
|
@ -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,
|
||||
/// `Output` represents the output type, and `captures_size` represents the size of the closure
|
||||
/// context.
|
||||
/// Returns a single-input single-output closure type where `In` represents the input type, `Out`
|
||||
/// represents the output type, and `captures_size` represents the size of the closure 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 {
|
||||
applyErased: fn (*anyopaque, Input) Output,
|
||||
applyErased: fn (*anyopaque, In) Out,
|
||||
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.
|
||||
///
|
||||
pub fn apply(self: *Self, input: Input) Output {
|
||||
pub fn apply(self: *Self, input: In) Out {
|
||||
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.
|
||||
///
|
||||
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);
|
||||
|
||||
if (@sizeOf(Captures) > captures_size)
|
||||
|
@ -52,7 +51,7 @@ pub fn Function(comptime captures_size: usize, comptime Input: type, comptime Ou
|
|||
.context = undefined,
|
||||
|
||||
.applyErased = struct {
|
||||
fn do(erased: *anyopaque, input: Input) Output {
|
||||
fn do(erased: *anyopaque, input: In) Out {
|
||||
return call(@ptrCast(*Captures, @alignCast(
|
||||
captures_align, erased)).*, input);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
test {
|
||||
_ = @import("./engine/main.zig");
|
||||
_ = @import("./core/main.zig");
|
||||
_ = @import("./oar/main.zig");
|
||||
_ = @import("./ona/main.zig");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue