mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
remove unused js.This
This commit is contained in:
@@ -377,24 +377,6 @@ fn getArgs(self: *const Caller, comptime F: type, comptime offset: usize, info:
|
|||||||
break :blk params[0 .. params.len - 1];
|
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
|
// we have neither a Page nor a JsObject. All params must be
|
||||||
// bound to a JavaScript value.
|
// bound to a JavaScript value.
|
||||||
break :blk params;
|
break :blk params;
|
||||||
@@ -446,8 +428,6 @@ fn getArgs(self: *const Caller, comptime F: type, comptime offset: usize, info:
|
|||||||
|
|
||||||
if (comptime isPage(param.type.?)) {
|
if (comptime isPage(param.type.?)) {
|
||||||
@compileError("Page must be the last parameter (or 2nd last if there's a JsThis): " ++ @typeName(F));
|
@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) {
|
} else if (i >= js_parameter_count) {
|
||||||
if (@typeInfo(param.type.?) != .optional) {
|
if (@typeInfo(param.type.?) != .optional) {
|
||||||
return error.InvalidArgument;
|
return error.InvalidArgument;
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
// Copyright (C) 2023-2025 Lightpanda (Selecy SAS)
|
|
||||||
//
|
|
||||||
// Francis Bouvier <francis@lightpanda.io>
|
|
||||||
// Pierre Tachoire <pierre@lightpanda.io>
|
|
||||||
//
|
|
||||||
// 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 <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
@@ -29,8 +29,6 @@ pub const Inspector = @import("Inspector.zig");
|
|||||||
pub const Snapshot = @import("Snapshot.zig");
|
pub const Snapshot = @import("Snapshot.zig");
|
||||||
pub const Platform = @import("Platform.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 Value = @import("Value.zig");
|
||||||
pub const Array = @import("Array.zig");
|
pub const Array = @import("Array.zig");
|
||||||
pub const String = @import("String.zig");
|
pub const String = @import("String.zig");
|
||||||
|
|||||||
Reference in New Issue
Block a user