From 27760c137926ba940afe27bc7f8676a5b6ec5bfb Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Thu, 6 Jun 2024 22:30:35 +0000 Subject: [PATCH] Bug 1882127 - Add js::NewFunctionByIdWithReservedWithProto. r=jandem Differential Revision: https://phabricator.services.mozilla.com/D202820 UltraBlame original commit: f537b9d36bb279bfe2949345fdb042f8e07f0575 --- js/src/jsfriendapi.cpp | 121 +++++++++++++++++++++++++++++++++++++++++ js/src/jsfriendapi.h | 27 +++++++++ 2 files changed, 148 insertions(+) diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index e3fba17be2d5e..2041c801adeae 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -2748,6 +2748,127 @@ FUNCTION_EXTENDED ; } JS_PUBLIC_API +JSFunction +* +js +: +: +NewFunctionByIdWithReservedAndProto +( +JSContext +* +cx +JSNative +native +HandleObject +proto +unsigned +nargs +unsigned +flags +jsid +id +) +{ +MOZ_ASSERT +( +id +. +isAtom +( +) +) +; +MOZ_ASSERT +( +! +cx +- +> +zone +( +) +- +> +isAtomsZone +( +) +) +; +MOZ_ASSERT +( +native +) +; +CHECK_THREAD +( +cx +) +; +cx +- +> +check +( +id +) +; +Rooted +< +JSAtom +* +> +atom +( +cx +id +. +toAtom +( +) +) +; +FunctionFlags +funflags += +( +flags +& +JSFUN_CONSTRUCTOR +) +? +FunctionFlags +: +: +NATIVE_CTOR +: +FunctionFlags +: +: +NATIVE_FUN +; +return +NewFunctionWithProto +( +cx +native +nargs +funflags +nullptr +atom +proto +gc +: +: +AllocKind +: +: +FUNCTION_EXTENDED +TenuredObject +) +; +} +JS_PUBLIC_API const Value & diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 5d0606486f40f..e602d9d5de209 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -1358,6 +1358,33 @@ id ) ; JS_PUBLIC_API +JSFunction +* +NewFunctionByIdWithReservedAndProto +( +JSContext +* +cx +JSNative +native +JS +: +: +Handle +< +JSObject +* +> +proto +unsigned +nargs +unsigned +flags +jsid +id +) +; +JS_PUBLIC_API const JS :