mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 959787 - Handlify some friend and debug APIs r=sfink r=bholley
This commit is contained in:
parent
524071f389
commit
dd7bb24003
@ -1765,7 +1765,7 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
|
||||
cache->SetPreservingWrapper(preserving);
|
||||
|
||||
if (propertyHolder) {
|
||||
JSObject* copyTo;
|
||||
JS::Rooted<JSObject*> copyTo(aCx);
|
||||
if (isProxy) {
|
||||
copyTo = DOMProxyHandler::EnsureExpandoObject(aCx, aObj);
|
||||
} else {
|
||||
|
@ -678,7 +678,6 @@ jsd_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
JS::RootedValue val(cx, jsdval->val);
|
||||
JSFunction* fun = nullptr;
|
||||
JS::RootedScript script(cx);
|
||||
JSDScript* jsdscript;
|
||||
|
||||
@ -688,7 +687,7 @@ jsd_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(val));
|
||||
AutoSaveExceptionState as(cx);
|
||||
fun = JSD_GetValueFunction(jsdc, jsdval);
|
||||
JS::RootedFunction fun(cx, JSD_GetValueFunction(jsdc, jsdval));
|
||||
if (fun)
|
||||
script = JS_GetFunctionScript(cx, fun);
|
||||
}
|
||||
|
@ -225,8 +225,8 @@ JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep);
|
||||
/************************************************************************/
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id,
|
||||
JSWatchPointHandler handler, JSObject *closure);
|
||||
JS_SetWatchPoint(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
||||
JSWatchPointHandler handler, JS::HandleObject closure);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id,
|
||||
@ -272,7 +272,7 @@ extern JS_PUBLIC_API(void)
|
||||
JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark);
|
||||
|
||||
extern JS_PUBLIC_API(JSScript *)
|
||||
JS_GetFunctionScript(JSContext *cx, JSFunction *fun);
|
||||
JS_GetFunctionScript(JSContext *cx, JS::HandleFunction fun);
|
||||
|
||||
extern JS_PUBLIC_API(JSNative)
|
||||
JS_GetFunctionNative(JSContext *cx, JSFunction *fun);
|
||||
@ -360,7 +360,7 @@ typedef struct JSPropertyDescArray {
|
||||
typedef struct JSScopeProperty JSScopeProperty;
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda);
|
||||
JS_GetPropertyDescArray(JSContext *cx, JS::HandleObject obj, JSPropertyDescArray *pda);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
|
||||
@ -529,7 +529,7 @@ JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj);
|
||||
|
||||
/* Defined in vm/Debugger.cpp. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DefineDebuggerObject(JSContext *cx, JSObject *obj);
|
||||
JS_DefineDebuggerObject(JSContext *cx, JS::HandleObject obj);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_DumpPCCounts(JSContext *cx, JSScript *script);
|
||||
|
@ -655,7 +655,8 @@ NondeterministicGetWeakMapKeys(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
RootedObject arr(cx);
|
||||
if (!JS_NondeterministicGetWeakMapKeys(cx, &args[0].toObject(), arr.address()))
|
||||
RootedObject mapObj(cx, &args[0].toObject());
|
||||
if (!JS_NondeterministicGetWeakMapKeys(cx, mapObj, &arr))
|
||||
return false;
|
||||
if (!arr) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,
|
||||
|
@ -126,7 +126,7 @@ BEGIN_TEST(test_cloneScriptWithPrincipals)
|
||||
JS::RootedObject cloned(cx);
|
||||
CHECK(cloned = JS_CloneFunctionObject(cx, obj, B));
|
||||
|
||||
JSFunction *fun;
|
||||
JS::RootedFunction fun(cx);
|
||||
JS::RootedValue clonedValue(cx, JS::ObjectValue(*cloned));
|
||||
CHECK(fun = JS_ValueToFunction(cx, clonedValue));
|
||||
|
||||
|
@ -89,7 +89,8 @@ testInner(const char *asciiChars, JSPrincipals *principal, JSPrincipals *originP
|
||||
JS::RootedValue rval(cx);
|
||||
CHECK(eval(asciiChars, principal, originPrincipal, &rval));
|
||||
|
||||
JSScript *script = JS_GetFunctionScript(cx, &rval.toObject().as<JSFunction>());
|
||||
JS::RootedFunction fun(cx, &rval.toObject().as<JSFunction>());
|
||||
JSScript *script = JS_GetFunctionScript(cx, fun);
|
||||
CHECK(JS_GetScriptPrincipals(script) == principal);
|
||||
CHECK(JS_GetScriptOriginPrincipals(script) == originPrincipal);
|
||||
|
||||
|
@ -54,7 +54,8 @@ FreezeThaw(JSContext *cx, JS::HandleScript script)
|
||||
static JSScript *
|
||||
GetScript(JSContext *cx, JS::HandleObject funobj)
|
||||
{
|
||||
return JS_GetFunctionScript(cx, JS_GetObjectFunction(funobj));
|
||||
JS::RootedFunction fun(cx, JS_GetObjectFunction(funobj));
|
||||
return JS_GetFunctionScript(cx, fun);
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
|
@ -80,7 +80,7 @@ JS_SetIsWorkerRuntime(JSRuntime *rt)
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
JS_FindCompilationScope(JSContext *cx, JSObject *objArg)
|
||||
JS_FindCompilationScope(JSContext *cx, HandleObject objArg)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
|
||||
@ -109,10 +109,8 @@ JS_GetObjectFunction(JSObject *obj)
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_SplicePrototype(JSContext *cx, JSObject *objArg, JSObject *protoArg)
|
||||
JS_SplicePrototype(JSContext *cx, HandleObject obj, HandleObject proto)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedObject proto(cx, protoArg);
|
||||
/*
|
||||
* Change the prototype of an object which hasn't been used anywhere
|
||||
* and does not share its type with another object. Unlike JS_SetPrototype,
|
||||
@ -133,10 +131,9 @@ JS_SplicePrototype(JSContext *cx, JSObject *objArg, JSObject *protoArg)
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
JS_NewObjectWithUniqueType(JSContext *cx, const JSClass *clasp, JSObject *protoArg, JSObject *parentArg)
|
||||
JS_NewObjectWithUniqueType(JSContext *cx, const JSClass *clasp, HandleObject proto,
|
||||
HandleObject parent)
|
||||
{
|
||||
RootedObject proto(cx, protoArg);
|
||||
RootedObject parent(cx, parentArg);
|
||||
/*
|
||||
* Create our object with a null proto and then splice in the correct proto
|
||||
* after we setSingletonType, so that we don't pollute the default
|
||||
@ -288,9 +285,8 @@ DefineHelpProperty(JSContext *cx, HandleObject obj, const char *prop, const char
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *objArg, const JSFunctionSpecWithHelp *fs)
|
||||
JS_DefineFunctionsWithHelp(JSContext *cx, HandleObject obj, const JSFunctionSpecWithHelp *fs)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
|
@ -53,16 +53,17 @@ extern JS_FRIEND_API(void)
|
||||
JS_SetIsWorkerRuntime(JSRuntime *rt);
|
||||
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_FindCompilationScope(JSContext *cx, JSObject *obj);
|
||||
JS_FindCompilationScope(JSContext *cx, JS::HandleObject obj);
|
||||
|
||||
extern JS_FRIEND_API(JSFunction *)
|
||||
JS_GetObjectFunction(JSObject *obj);
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_SplicePrototype(JSContext *cx, JSObject *obj, JSObject *proto);
|
||||
JS_SplicePrototype(JSContext *cx, JS::HandleObject obj, JS::HandleObject proto);
|
||||
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_NewObjectWithUniqueType(JSContext *cx, const JSClass *clasp, JSObject *proto, JSObject *parent);
|
||||
JS_NewObjectWithUniqueType(JSContext *cx, const JSClass *clasp, JS::HandleObject proto,
|
||||
JS::HandleObject parent);
|
||||
|
||||
extern JS_FRIEND_API(uint32_t)
|
||||
JS_ObjectCountDynamicSlots(JS::HandleObject obj);
|
||||
@ -74,7 +75,7 @@ extern JS_FRIEND_API(size_t)
|
||||
JS_GetCustomIteratorCount(JSContext *cx);
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *obj, JSObject **ret);
|
||||
JS_NondeterministicGetWeakMapKeys(JSContext *cx, JS::HandleObject obj, JS::MutableHandleObject ret);
|
||||
|
||||
/*
|
||||
* Determine whether the given object is backed by a DeadObjectProxy.
|
||||
@ -185,7 +186,7 @@ js_DumpChars(const jschar *s, size_t n);
|
||||
* restrictions on the compartment of |cx|.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj);
|
||||
JS_CopyPropertiesFrom(JSContext *cx, JS::HandleObject target, JS::HandleObject obj);
|
||||
|
||||
/*
|
||||
* Single-property version of the above. This function asserts that an |own|
|
||||
@ -222,7 +223,7 @@ struct JSFunctionSpecWithHelp {
|
||||
{nullptr, nullptr, 0, 0, nullptr, nullptr}
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj, const JSFunctionSpecWithHelp *fs);
|
||||
JS_DefineFunctionsWithHelp(JSContext *cx, JS::HandleObject obj, const JSFunctionSpecWithHelp *fs);
|
||||
|
||||
namespace js {
|
||||
|
||||
|
@ -1748,10 +1748,8 @@ JS_CopyPropertyFrom(JSContext *cx, HandleId id, HandleObject target,
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_CopyPropertiesFrom(JSContext *cx, JSObject *targetArg, JSObject *objArg)
|
||||
JS_CopyPropertiesFrom(JSContext *cx, HandleObject target, HandleObject obj)
|
||||
{
|
||||
RootedObject target(cx, targetArg);
|
||||
RootedObject obj(cx, objArg);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
AutoIdVector props(cx);
|
||||
|
@ -350,12 +350,12 @@ WeakMap_set(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *objArg, JSObject **ret)
|
||||
JS_NondeterministicGetWeakMapKeys(JSContext *cx, HandleObject objArg, MutableHandleObject ret)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
obj = UncheckedUnwrap(obj);
|
||||
if (!obj || !obj->is<WeakMapObject>()) {
|
||||
*ret = nullptr;
|
||||
ret.set(nullptr);
|
||||
return true;
|
||||
}
|
||||
RootedObject arr(cx, NewDenseEmptyArray(cx));
|
||||
@ -373,7 +373,7 @@ JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *objArg, JSObject **re
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*ret = arr;
|
||||
ret.set(arr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5895,10 +5895,8 @@ static const JSFunctionSpec DebuggerEnv_methods[] = {
|
||||
/*** Glue ****************************************************************************************/
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DefineDebuggerObject(JSContext *cx, JSObject *obj_)
|
||||
JS_DefineDebuggerObject(JSContext *cx, HandleObject obj)
|
||||
{
|
||||
RootedObject obj(cx, obj_);
|
||||
|
||||
RootedObject
|
||||
objProto(cx),
|
||||
debugCtor(cx),
|
||||
|
@ -159,7 +159,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
|
||||
{
|
||||
friend class Breakpoint;
|
||||
friend class mozilla::LinkedListElement<Debugger>;
|
||||
friend bool (::JS_DefineDebuggerObject)(JSContext *cx, JSObject *obj);
|
||||
friend bool (::JS_DefineDebuggerObject)(JSContext *cx, JS::HandleObject obj);
|
||||
|
||||
public:
|
||||
enum Hook {
|
||||
|
@ -294,13 +294,11 @@ JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *hoop, void **closurep)
|
||||
/************************************************************************/
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_SetWatchPoint(JSContext *cx, JSObject *obj_, jsid id_,
|
||||
JSWatchPointHandler handler, JSObject *closure_)
|
||||
JS_SetWatchPoint(JSContext *cx, HandleObject origobj, HandleId id,
|
||||
JSWatchPointHandler handler, HandleObject closure)
|
||||
{
|
||||
assertSameCompartment(cx, obj_);
|
||||
assertSameCompartment(cx, origobj);
|
||||
|
||||
RootedId id(cx, id_);
|
||||
RootedObject origobj(cx, obj_), closure(cx, closure_);
|
||||
RootedObject obj(cx, GetInnerObject(cx, origobj));
|
||||
if (!obj)
|
||||
return false;
|
||||
@ -496,14 +494,13 @@ JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mem)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSScript *)
|
||||
JS_GetFunctionScript(JSContext *cx, JSFunction *fun)
|
||||
JS_GetFunctionScript(JSContext *cx, HandleFunction fun)
|
||||
{
|
||||
if (fun->isNative())
|
||||
return nullptr;
|
||||
if (fun->isInterpretedLazy()) {
|
||||
RootedFunction rootedFun(cx, fun);
|
||||
AutoCompartment funCompartment(cx, rootedFun);
|
||||
JSScript *script = rootedFun->getOrCreateScript(cx);
|
||||
AutoCompartment funCompartment(cx, fun);
|
||||
JSScript *script = fun->getOrCreateScript(cx);
|
||||
if (!script)
|
||||
MOZ_CRASH();
|
||||
return script;
|
||||
@ -659,10 +656,8 @@ GetPropertyDesc(JSContext *cx, JSObject *obj_, HandleShape shape, JSPropertyDesc
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj_, JSPropertyDescArray *pda)
|
||||
JS_GetPropertyDescArray(JSContext *cx, JS::HandleObject obj, JSPropertyDescArray *pda)
|
||||
{
|
||||
RootedObject obj(cx, obj_);
|
||||
|
||||
assertSameCompartment(cx, obj);
|
||||
uint32_t i = 0;
|
||||
JSPropertyDesc *pd = nullptr;
|
||||
@ -995,7 +990,7 @@ class AutoPropertyDescArray
|
||||
JS_PutPropertyDescArray(cx_, &descArray_);
|
||||
}
|
||||
|
||||
void fetch(JSObject *obj) {
|
||||
void fetch(JS::HandleObject obj) {
|
||||
JS_ASSERT(!descArray_.array);
|
||||
if (!JS_GetPropertyDescArray(cx_, obj, &descArray_))
|
||||
descArray_.array = nullptr;
|
||||
@ -1059,8 +1054,10 @@ FormatFrame(JSContext *cx, const NonBuiltinScriptFrameIter &iter, char *buf, int
|
||||
AutoPropertyDescArray thisProps(cx);
|
||||
if (iter.computeThis(cx)) {
|
||||
thisVal = iter.thisv();
|
||||
if (showThisProps && !thisVal.isPrimitive())
|
||||
thisProps.fetch(&thisVal.toObject());
|
||||
if (showThisProps && !thisVal.isPrimitive()) {
|
||||
RootedObject thisObj(cx, &thisVal.toObject());
|
||||
thisProps.fetch(thisObj);
|
||||
}
|
||||
}
|
||||
|
||||
// print the frame number and function name
|
||||
|
@ -2881,7 +2881,8 @@ nsXPCComponents_Utils::NondeterministicGetWeakMapKeys(HandleValue aMap,
|
||||
return NS_OK;
|
||||
}
|
||||
RootedObject objRet(aCx);
|
||||
if (!JS_NondeterministicGetWeakMapKeys(aCx, &aMap.toObject(), objRet.address()))
|
||||
RootedObject mapObj(aCx, &aMap.toObject());
|
||||
if (!JS_NondeterministicGetWeakMapKeys(aCx, mapObj, &objRet))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
aKeys.set(objRet ? ObjectValue(*objRet) : UndefinedValue());
|
||||
return NS_OK;
|
||||
|
@ -194,7 +194,8 @@ XPCWrappedNative::WrapNewGlobal(xpcObjectHelper &nativeHelper,
|
||||
|
||||
// Set up the prototype on the global.
|
||||
MOZ_ASSERT(proto->GetJSProtoObject());
|
||||
bool success = JS_SplicePrototype(cx, global, proto->GetJSProtoObject());
|
||||
RootedObject protoObj(cx, proto->GetJSProtoObject());
|
||||
bool success = JS_SplicePrototype(cx, global, protoObj);
|
||||
if (!success)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -1354,8 +1354,11 @@ WriteScriptOrFunction(nsIObjectOutputStream *stream, JSContext *cx,
|
||||
// Exactly one of script or functionObj must be given
|
||||
MOZ_ASSERT(!scriptArg != !functionObj);
|
||||
|
||||
RootedScript script(cx, scriptArg ? scriptArg :
|
||||
JS_GetFunctionScript(cx, JS_GetObjectFunction(functionObj)));
|
||||
RootedScript script(cx, scriptArg);
|
||||
if (!script) {
|
||||
RootedFunction fun(cx, JS_GetObjectFunction(functionObj));
|
||||
script.set(JS_GetFunctionScript(cx, fun));
|
||||
}
|
||||
|
||||
nsIPrincipal *principal =
|
||||
nsJSPrincipals::get(JS_GetScriptPrincipals(script));
|
||||
|
@ -487,8 +487,8 @@ XrayTraits::cloneExpandoChain(JSContext *cx, HandleObject dst, HandleObject src)
|
||||
.toObjectOrNull());
|
||||
if (!JS_WrapObject(cx, &exclusive))
|
||||
return false;
|
||||
JSObject *newHead = attachExpandoObject(cx, dst, GetExpandoObjectPrincipal(oldHead),
|
||||
exclusive);
|
||||
RootedObject newHead(cx, attachExpandoObject(cx, dst, GetExpandoObjectPrincipal(oldHead),
|
||||
exclusive));
|
||||
if (!JS_CopyPropertiesFrom(cx, newHead, oldHead))
|
||||
return false;
|
||||
oldHead = JS_GetReservedSlot(oldHead, JSSLOT_EXPANDO_NEXT).toObjectOrNull();
|
||||
|
Loading…
Reference in New Issue
Block a user