From 371308474ad0c6f01f64ab14166e32492a5f1c97 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Fri, 28 Aug 2026 15:56:39 +0200 Subject: implement more interfaces --- src/root.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/root.zig') diff --git a/src/root.zig b/src/root.zig index 0e3d9e4..471267f 100644 --- a/src/root.zig +++ b/src/root.zig @@ -4,7 +4,29 @@ pub const Object = @import("Object.zig"); pub const Interpreter = @import("Interpreter.zig"); pub const Dict = @import("Dict.zig"); pub const Str = @import("Str.zig"); +pub const Tuple = @import("Tuple.zig"); +pub const Fn = @import("function.zig").Fn; pub const Error = error { Exception, + IndexError, +}; + +pub const conversion = struct { + fn PtrFromCPtr(T: type) type { + const info = @typeInfo(T); + return *info.pointer.child; + } + + pub fn Ptr(value: anytype) Error!PtrFromCPtr(@TypeOf(value)) { + if (value) |ptr| { + return ptr; + } + + return error.Exception; + } + + pub fn success(value: c_int) Error!void { + if (value == -1) return error.Exception; + } }; -- cgit v1.2.3-70-g09d2