From 3442f99a492542212c545c328fca8fb723ab5bb9 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 31 Dec 2025 12:41:27 +0800 Subject: [PATCH] remove unused js.This --- src/browser/js/Caller.zig | 20 -------------------- src/browser/js/This.zig | 40 --------------------------------------- src/browser/js/js.zig | 2 -- 3 files changed, 62 deletions(-) delete mode 100644 src/browser/js/This.zig diff --git a/src/browser/js/Caller.zig b/src/browser/js/Caller.zig index 51fa23ea..8e60dab7 100644 --- a/src/browser/js/Caller.zig +++ b/src/browser/js/Caller.zig @@ -377,24 +377,6 @@ fn getArgs(self: *const Caller, comptime F: type, comptime offset: usize, info: break :blk params[0 .. params.len - 1]; } - // If the last parameter is a special JsThis, set it, and exclude it - // from our params slice, because we don't want to bind it to - // a JS argument - if (comptime params[params.len - 1].type.? == js.This) { - @field(args, tupleFieldName(params.len - 1 + offset)) = .{ .obj = .{ - .context = context, - .js_obj = info.getThis(), - } }; - - // AND the 2nd last parameter is state - if (params.len > 1 and comptime isPage(params[params.len - 2].type.?)) { - @field(args, tupleFieldName(params.len - 2 + offset)) = self.context.page; - break :blk params[0 .. params.len - 2]; - } - - break :blk params[0 .. params.len - 1]; - } - // we have neither a Page nor a JsObject. All params must be // bound to a JavaScript value. break :blk params; @@ -446,8 +428,6 @@ fn getArgs(self: *const Caller, comptime F: type, comptime offset: usize, info: if (comptime isPage(param.type.?)) { @compileError("Page must be the last parameter (or 2nd last if there's a JsThis): " ++ @typeName(F)); - } else if (comptime param.type.? == js.This) { - @compileError("JsThis must be the last parameter: " ++ @typeName(F)); } else if (i >= js_parameter_count) { if (@typeInfo(param.type.?) != .optional) { return error.InvalidArgument; diff --git a/src/browser/js/This.zig b/src/browser/js/This.zig deleted file mode 100644 index e86e97e3..00000000 --- a/src/browser/js/This.zig +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) -// -// Francis Bouvier -// Pierre Tachoire -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -const std = @import("std"); -const js = @import("js.zig"); - -// This only exists so that we know whether a function wants the opaque -// JS argument (js.Object), or if it wants the receiver as an opaque -// value. -// js.Object is normally used when a method wants an opaque JS object -// that it'll pass into a callback. -// This is used when the function wants to do advanced manipulation -// of the v8.Object bound to the instance. For example, postAttach is an -// example of using This. - -const This = @This(); -obj: js.Object, - -pub fn setIndex(self: This, index: u32, value: anytype, opts: js.Object.SetOpts) !void { - return self.obj.setIndex(index, value, opts); -} - -pub fn set(self: This, key: []const u8, value: anytype, opts: js.Object.SetOpts) !void { - return self.obj.set(key, value, opts); -} diff --git a/src/browser/js/js.zig b/src/browser/js/js.zig index 45c1c327..733768c9 100644 --- a/src/browser/js/js.zig +++ b/src/browser/js/js.zig @@ -29,8 +29,6 @@ pub const Inspector = @import("Inspector.zig"); pub const Snapshot = @import("Snapshot.zig"); pub const Platform = @import("Platform.zig"); -// TODO: Is "This" really necessary? -pub const This = @import("This.zig"); pub const Value = @import("Value.zig"); pub const Array = @import("Array.zig"); pub const String = @import("String.zig");