aboutsummaryrefslogtreecommitdiff
path: root/src/zeroscript/Object.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/zeroscript/Object.zig')
-rw-r--r--src/zeroscript/Object.zig35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/zeroscript/Object.zig b/src/zeroscript/Object.zig
new file mode 100644
index 0000000..064d48b
--- /dev/null
+++ b/src/zeroscript/Object.zig
@@ -0,0 +1,35 @@
+const mod = @import("root.zig");
+const Options = mod.Options;
+const Env = mod.Env;
+const AnyFuture = Env.AnyFuture;
+const Future = Env.Future;
+
+const Self = @This();
+
+pub inline fn get(self: *Self, env: *Env, key: anytype) AnyFuture {
+ return env.getProp(self, key);
+}
+
+pub inline fn set(self: *Self, env: *Env, key: anytype, value: anytype) Future(.undefined) {
+ return env.setProp(self, key, value);
+}
+
+pub inline fn delete(self: *Self, env: *Env, key: anytype) Future(.undefined) {
+ return env.deleteProp(self, key);
+}
+
+pub inline fn call(self: *Self, env: *Env, method: []const u8, args: anytype) AnyFuture {
+ return env.callMethod(self, method, args);
+}
+
+pub inline fn free(self: *Self, env: *Env) Future(.undefined) {
+ return env.free(self);
+}
+
+pub fn new(self: *Self, env: *Env) Future(.object) {
+ return env.new(self, .{});
+}
+
+pub fn global(tag: @EnumLiteral()) Options.Global {
+ return .{ .name = @tagName(tag), .type = *Self };
+}