Merge pull request #2379 from lightpanda-io/setter_and_static_arity

Give setters an arity of 1
This commit is contained in:
Karl Seguin
2026-05-08 06:45:00 +08:00
committed by GitHub
2 changed files with 4 additions and 1 deletions

View File

@@ -651,6 +651,7 @@ fn attachClass(comptime JsApi: type, isolate: *v8.Isolate, template: *const v8.F
const cb = v8.v8__FunctionTemplate__New__Config(isolate, &.{
.callback = setter,
.signature = getter_signature,
.length = 1,
}).?;
const setter_name_str = "set " ++ name;
const setter_name_v8 = v8.v8__String__NewFromUtf8(isolate, setter_name_str.ptr, v8.kNormal, @intCast(setter_name_str.len));

View File

@@ -153,7 +153,9 @@ pub const Function = struct {
.cache = opts.cache,
.static = opts.static,
.wpt_only = opts.wpt_only,
.arity = getArity(@TypeOf(func), 1),
// Non-static methods receive `self` as their first param; static
// methods don't, so don't skip the first param for them.
.arity = getArity(@TypeOf(func), if (opts.static) 0 else 1),
.func = if (opts.noop) noopFunction else struct {
fn wrap(handle: ?*const v8.FunctionCallbackInfo) callconv(.c) void {
Caller.Function.call(T, handle.?, func, opts);