From dd24e86dad0402917b1713d1afeefaf65c3d1e51 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 15 Oct 2026 21:57:59 +0200 Subject: zilch: reusing results in processing loop --- src/zilch/Object.zig | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/zilch/Object.zig') diff --git a/src/zilch/Object.zig b/src/zilch/Object.zig index 6c0eeee..194c43b 100644 --- a/src/zilch/Object.zig +++ b/src/zilch/Object.zig @@ -8,19 +8,19 @@ const Function = Env.Function; const Self = @This(); pub inline fn get(self: *Self, env: *Env, key: anytype) AnyFuture { - return env.call(bindings.get_prop, .{ self, key }); + return env.call(bindings.get, .{ self, key }); } pub inline fn set(self: *Self, env: *Env, key: anytype, value: anytype) Future(.undefined) { - return .fromAny(env.call(bindings.set_prop, .{ self, key, value })); + return .fromAny(env.call(bindings.set, .{ self, key, value })); } pub inline fn delete(self: *Self, env: *Env, key: anytype) Future(.undefined) { - return .fromAny(env.call(bindings.delete_prop, .{ self, key })); + return .fromAny(env.call(bindings.delete, .{ self, key })); } pub inline fn call(self: *Self, env: *Env, method: []const u8, args: anytype) AnyFuture { - return env.call(bindings.call_method, .{ self, method } ++ args); + return env.call(bindings.call, .{ self, method } ++ args); } pub inline fn free(self: *Self, env: *Env) Future(.undefined) { @@ -35,38 +35,38 @@ pub fn global(tag: @EnumLiteral()) Options.Global { return .{ .name = @tagName(tag), .type = *Self }; } -const bindings = struct { - const get_prop: Function = .from( +pub const bindings = struct { + pub const get: Function = .from( \\function(target, key) { \\ return target[key]; \\} ); - const set_prop: Function = .from( + pub const set: Function = .from( \\function(target, key, value) { \\ target[key] = value; \\} ); - const delete_prop: Function = .from( + pub const delete: Function = .from( \\function(target, key) { \\ delete target[key]; \\} ); - const call_method: Function = .from( + pub const call: Function = .from( \\function(target, method, ...args) { \\ return target[method](...args); \\} ); - const new: Function = .from( + pub const new: Function = .from( \\function(target, ...args) { \\ return new target(...args); \\} ); - const free: Function = .from( + pub const free: Function = .from( \\function(target) { \\ const id = target[ZsId]; \\ delete target[ZsId]; @@ -76,10 +76,10 @@ const bindings = struct { }; pub const functions = [_]Function{ - bindings.get_prop, - bindings.set_prop, - bindings.delete_prop, - bindings.call_method, + bindings.get, + bindings.set, + bindings.delete, + bindings.call, bindings.new, bindings.free, }; -- cgit v1.2.3-70-g09d2