hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/bridge/convert.zig
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-04 16:03:42 +0200
committerhachem <im@hachem.wtf>2026-10-04 16:03:42 +0200
commit52dab7fc85d877e80e3032f0afabae906adebad8 (patch)
treeb6d56299b839413bb77b1b8c8fa9f7a682124a05 /bridge/convert.zig
parenta8a35a00a3c3c57cfbef2311d0348376c2e83208 (diff)
feat: fs tree and free list alloc
Diffstat (limited to 'bridge/convert.zig')
-rw-r--r--bridge/convert.zig18
1 files changed, 18 insertions, 0 deletions
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().?);
+}