aboutsummaryrefslogtreecommitdiff
path: root/src/z/Env
diff options
context:
space:
mode:
Diffstat (limited to 'src/z/Env')
-rw-r--r--src/z/Env/Object.zig29
-rw-r--r--src/z/Env/root.zig7
2 files changed, 31 insertions, 5 deletions
diff --git a/src/z/Env/Object.zig b/src/z/Env/Object.zig
new file mode 100644
index 0000000..77afa1f
--- /dev/null
+++ b/src/z/Env/Object.zig
@@ -0,0 +1,29 @@
+const Env = @import("root.zig");
+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: @EnumLiteral(), args: anytype) AnyFuture {
+ return env.callMethod(self, @tagName(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, .{});
+}
diff --git a/src/z/Env/root.zig b/src/z/Env/root.zig
index 99b47c5..5a08362 100644
--- a/src/z/Env/root.zig
+++ b/src/z/Env/root.zig
@@ -1,6 +1,5 @@
const std = @import("std");
-const mod = @import("../root.zig");
const js = @import("js.zig");
const Self = @This();
@@ -10,9 +9,7 @@ const future = @import("future.zig");
pub const AnyFuture = future.AnyFuture;
pub const Future = future.Future;
pub const Value = @import("value.zig").Value;
-pub const Object = extern struct {};
-
-pub const window: *Object = @ptrFromInt(1);
+pub const Object = @import("Object.zig");
calls: std.ArrayList(Call) = .empty,
values: std.ArrayList(Value) = .empty,
@@ -56,7 +53,7 @@ pub fn setProp(
pub fn deleteProp(
self: *Self,
object: *Object,
- key: []const u8,
+ key: anytype,
) Future(.undefined) {
self.calls.append(self.gpa, .{
.kind = .del_prop,