mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 959787 - Handlify several JSAPI interfaces that can GC, Part 6; r=jonco
This commit is contained in:
parent
dc3a39595c
commit
91ca6a1d69
@ -150,7 +150,7 @@ ConnectWorkerToNetd::RunTask(JSContext *aCx)
|
||||
// communication.
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
|
||||
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
|
||||
JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
|
||||
JS::Rooted<JSObject*> workerGlobal(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
return !!JS_DefineFunction(aCx, workerGlobal, "postNetdCommand",
|
||||
DoNetdCommand, 1, 0);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ ConnectWorkerToNFC::RunTask(JSContext* aCx)
|
||||
// communication.
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
|
||||
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
|
||||
JSObject* workerGlobal = JS::CurrentGlobalOrNull(aCx);
|
||||
JS::Rooted<JSObject*> workerGlobal(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
return !!JS_DefineFunction(aCx, workerGlobal,
|
||||
"postNfcMessage", PostToNFC, 1, 0);
|
||||
|
@ -141,7 +141,7 @@ ConnectWorkerToRIL::RunTask(JSContext *aCx)
|
||||
// communication.
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
|
||||
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
|
||||
JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
|
||||
JS::Rooted<JSObject*> workerGlobal(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
return !!JS_DefineFunction(aCx, workerGlobal,
|
||||
"postRILMessage", PostToRIL, 2, 0);
|
||||
|
@ -67,7 +67,7 @@ eval(const char *asciiChars, JSPrincipals *principals, JSPrincipals *originPrinc
|
||||
principals,
|
||||
originPrincipals,
|
||||
chars, len, "", 0,
|
||||
rval.address(),
|
||||
rval,
|
||||
JSVERSION_DEFAULT);
|
||||
delete[] chars;
|
||||
return ok;
|
||||
|
@ -4135,10 +4135,9 @@ JS_DefineFunctions(JSContext *cx, HandleObject obj, const JSFunctionSpec *fs)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSFunction *)
|
||||
JS_DefineFunction(JSContext *cx, JSObject *objArg, const char *name, JSNative call,
|
||||
JS_DefineFunction(JSContext *cx, HandleObject obj, const char *name, JSNative call,
|
||||
unsigned nargs, unsigned attrs)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
@ -4151,11 +4150,10 @@ JS_DefineFunction(JSContext *cx, JSObject *objArg, const char *name, JSNative ca
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSFunction *)
|
||||
JS_DefineUCFunction(JSContext *cx, JSObject *objArg,
|
||||
JS_DefineUCFunction(JSContext *cx, HandleObject obj,
|
||||
const jschar *name, size_t namelen, JSNative call,
|
||||
unsigned nargs, unsigned attrs)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
@ -4168,11 +4166,9 @@ JS_DefineUCFunction(JSContext *cx, JSObject *objArg,
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(JSFunction *)
|
||||
JS_DefineFunctionById(JSContext *cx, JSObject *objArg, jsid id_, JSNative call,
|
||||
JS_DefineFunctionById(JSContext *cx, HandleObject obj, HandleId id, JSNative call,
|
||||
unsigned nargs, unsigned attrs)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, id_);
|
||||
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
@ -4833,63 +4829,59 @@ JS::Evaluate(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &opti
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *objArg,
|
||||
JS_EvaluateUCScriptForPrincipals(JSContext *cx, HandleObject obj,
|
||||
JSPrincipals *principals,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval)
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
CompileOptions options(cx);
|
||||
options.setPrincipals(principals)
|
||||
.setFileAndLine(filename, lineno);
|
||||
|
||||
return Evaluate(cx, obj, options, chars, length, rval);
|
||||
return Evaluate(cx, obj, options, chars, length, rval.address());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *objArg,
|
||||
JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, HandleObject obj,
|
||||
JSPrincipals *principals,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval, JSVersion version)
|
||||
MutableHandleValue rval, JSVersion version)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
CompileOptions options(cx);
|
||||
options.setPrincipals(principals)
|
||||
.setFileAndLine(filename, lineno)
|
||||
.setVersion(version);
|
||||
|
||||
return Evaluate(cx, obj, options, chars, length, rval);
|
||||
return Evaluate(cx, obj, options, chars, length, rval.address());
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *objArg,
|
||||
JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, HandleObject obj,
|
||||
JSPrincipals *principals,
|
||||
JSPrincipals *originPrincipals,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval, JSVersion version)
|
||||
MutableHandleValue rval, JSVersion version)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
CompileOptions options(cx);
|
||||
options.setPrincipals(principals)
|
||||
.setOriginPrincipals(originPrincipals)
|
||||
.setFileAndLine(filename, lineno)
|
||||
.setVersion(version);
|
||||
|
||||
return Evaluate(cx, obj, options, chars, length, rval);
|
||||
return Evaluate(cx, obj, options, chars, length, rval.address());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScript(JSContext *cx, JSObject *objArg, const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno, jsval *rval)
|
||||
JS_EvaluateUCScript(JSContext *cx, HandleObject obj, const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno, MutableHandleValue rval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
CompileOptions options(cx);
|
||||
options.setFileAndLine(filename, lineno);
|
||||
|
||||
return Evaluate(cx, obj, options, chars, length, rval);
|
||||
return Evaluate(cx, obj, options, chars, length, rval.address());
|
||||
}
|
||||
|
||||
/* Ancient unsigned nbytes is part of API/ABI, so use size_t length local. */
|
||||
|
@ -3363,16 +3363,16 @@ extern JS_PUBLIC_API(bool)
|
||||
JS_DefineFunctions(JSContext *cx, JS::Handle<JSObject*> obj, const JSFunctionSpec *fs);
|
||||
|
||||
extern JS_PUBLIC_API(JSFunction *)
|
||||
JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call,
|
||||
JS_DefineFunction(JSContext *cx, JS::Handle<JSObject*> obj, const char *name, JSNative call,
|
||||
unsigned nargs, unsigned attrs);
|
||||
|
||||
extern JS_PUBLIC_API(JSFunction *)
|
||||
JS_DefineUCFunction(JSContext *cx, JSObject *obj,
|
||||
JS_DefineUCFunction(JSContext *cx, JS::Handle<JSObject*> obj,
|
||||
const jschar *name, size_t namelen, JSNative call,
|
||||
unsigned nargs, unsigned attrs);
|
||||
|
||||
extern JS_PUBLIC_API(JSFunction *)
|
||||
JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call,
|
||||
JS_DefineFunctionById(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JSNative call,
|
||||
unsigned nargs, unsigned attrs);
|
||||
|
||||
/*
|
||||
@ -3822,24 +3822,24 @@ JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
|
||||
jsval *rval, JSVersion version);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScript(JSContext *cx, JSObject *obj,
|
||||
JS_EvaluateUCScript(JSContext *cx, JS::Handle<JSObject*> obj,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval);
|
||||
JS::MutableHandle<JS::Value> rval);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj,
|
||||
JS_EvaluateUCScriptForPrincipals(JSContext *cx, JS::Handle<JSObject*> obj,
|
||||
JSPrincipals *principals,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval);
|
||||
JS::MutableHandle<JS::Value> rval);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
|
||||
JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JS::Handle<JSObject*> obj,
|
||||
JSPrincipals *principals,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval, JSVersion version);
|
||||
JS::MutableHandle<JS::Value> rval, JSVersion version);
|
||||
|
||||
/*
|
||||
* JSAPI clients may optionally specify the 'originPrincipals' of a script.
|
||||
@ -3850,12 +3850,13 @@ JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
|
||||
* value of principals is used as origin principals for the script.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *obj,
|
||||
JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JS::Handle<JSObject*> obj,
|
||||
JSPrincipals *principals,
|
||||
JSPrincipals *originPrincipals,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval, JSVersion version);
|
||||
JS::MutableHandle<JS::Value> rval,
|
||||
JSVersion version);
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -2535,7 +2535,7 @@ EvalInContext(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!JS_EvaluateUCScript(cx, sobj, src, srclen,
|
||||
script->filename(),
|
||||
lineno,
|
||||
rval.address())) {
|
||||
&rval)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,8 @@ AttachNewConstructorObject(JSContext *aCx, JS::HandleObject aGlobalObject)
|
||||
if (!xpcnativewrapper) {
|
||||
return false;
|
||||
}
|
||||
return JS_DefineFunction(aCx, JS_GetFunctionObject(xpcnativewrapper), "unwrap", UnwrapNW, 1,
|
||||
JS::RootedObject obj(aCx, JS_GetFunctionObject(xpcnativewrapper));
|
||||
return JS_DefineFunction(aCx, obj, "unwrap", UnwrapNW, 1,
|
||||
JSPROP_READONLY | JSPROP_PERMANENT) != nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user