From 52dab7fc85d877e80e3032f0afabae906adebad8 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 4 Oct 2026 16:03:42 +0200 Subject: feat: fs tree and free list alloc --- bridge/convert.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 bridge/convert.zig (limited to 'bridge/convert.zig') diff --git a/bridge/convert.zig b/bridge/convert.zig new file mode 100644 index 0000000..5718428 --- /dev/null +++ b/bridge/convert.zig @@ -0,0 +1,18 @@ +const std = @import("std"); +const revo = @import("revo"); + +pub const HostResult = revo.baselib.host.HostResult; +pub const Data = revo.Value; + +// revos only number type is f64 which is really fucking annoying +pub fn f64ToInt(comptime T: type, n: f64) ?T { + if (!std.math.isFinite(n)) return null; + const min_f: f64 = @floatFromInt(std.math.minInt(T)); + const max_f: f64 = @floatFromInt(std.math.maxInt(T)); + if (n < min_f or n > max_f) return null; + return @intFromFloat(n); +} + +pub fn argInt(comptime T: type, args: []const revo.Value, i: usize) ?T { + return f64ToInt(T, args[i].asNumOpt().?); +} -- cgit v1.3