diff --git a/src/main.zig b/src/main.zig
index 33288c1..90f67c5 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -19,10 +19,10 @@
const SourceLocation = std.builtin.SourceLocation;
const Struct = std.builtin.Type.Struct;
const StructField = std.builtin.Type.StructField;
+const Tuple = std.meta.Tuple;
const assert = std.debug.assert;
const c = @cImport(@cInclude("janet.h"));
const expectEqual = std.testing.expectEqual;
-const formatIntBuf = std.fmt.formatIntBuf;
const log10 = std.math.log10;
const std = @import("std");
const zeroes = std.mem.zeroes;
@@ -108,27 +108,13 @@ pub fn def(env: *Table, comptime fun: anytype, reg: struct {
if (function.is_var_args)
@compileError("fun is variadic");
const n = function.params.len;
- comptime var fields: [n]StructField = undefined;
- comptime for (&fields, 0.., function.params) |*field, i, param| {
- const digits = if (i == 0) 1 else log10(i) + 1;
- var name: [digits]u8 = undefined;
- assert(formatIntBuf(&name, i, 10, .lower, .{}) == digits);
- field.name = &name;
- field.type = param.type.?;
- field.default_value = null;
- field.is_comptime = false;
- field.alignment = 0;
- };
- const Tuple = Struct{
- .layout = .Auto,
- .fields = &fields,
- .decls = &.{},
- .is_tuple = true,
- };
+ comptime var fields: [n]type = undefined;
+ inline for (&fields, function.params) |*field, param|
+ field.* = param.type.?;
const cfun = struct {
fn cfun(argc: i32, argv: [*c]Value) callconv(.C) Value {
c.janet_fixarity(argc, n);
- var args: @Type(.{ .Struct = Tuple }) = undefined;
+ var args: Tuple(&fields) = undefined;
inline for (&args, function.params, 0..) |*arg, param, i|
arg.* = get(param.type.?, argv, i);
const result = @call(.auto, fun, args);
|