mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1363200 - JSAPI for realms: JS_SetVersionForCompartment() -> JS::SetVersionForCurrentRealm(). r=sfink
--HG-- extra : rebase_source : 8b0d53210fe827a648251395e038cb7b9eb616e9
This commit is contained in:
parent
8399e3ecd5
commit
5df09661ff
@ -181,8 +181,7 @@ Version(JSContext *cx,
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(JS_GetVersion(cx));
|
||||
if (args.get(0).isInt32())
|
||||
JS_SetVersionForCompartment(js::GetContextCompartment(cx),
|
||||
JSVersion(args[0].toInt32()));
|
||||
JS::SetVersionForCurrentRealm(cx, JSVersion(args[0].toInt32()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,17 @@ GetRealmErrorPrototype(JSContext* cx);
|
||||
extern JS_PUBLIC_API(JSObject*)
|
||||
GetRealmIteratorPrototype(JSContext* cx);
|
||||
|
||||
/**
|
||||
* Change the JS language version for the current Realm. This is discouraged,
|
||||
* but necessary to support the `version()` builtin function in the js and xpc
|
||||
* shells.
|
||||
*
|
||||
* It would be nice to put this in jsfriendapi, but the linkage requirements
|
||||
* of the shells make that impossible.
|
||||
*/
|
||||
JS_PUBLIC_API(void)
|
||||
SetVersionForCurrentRealm(JSContext* cx, JSVersion version);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif // js_Realm_h
|
||||
|
@ -588,12 +588,6 @@ JS_GetVersion(JSContext* cx)
|
||||
return VersionNumber(cx->findVersion());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetVersionForCompartment(JSCompartment* compartment, JSVersion version)
|
||||
{
|
||||
compartment->behaviors().setVersion(version);
|
||||
}
|
||||
|
||||
static const struct v2smap {
|
||||
JSVersion version;
|
||||
const char* string;
|
||||
|
@ -1138,17 +1138,6 @@ class MOZ_RAII JSAutoRequest
|
||||
extern JS_PUBLIC_API(JSVersion)
|
||||
JS_GetVersion(JSContext* cx);
|
||||
|
||||
/**
|
||||
* Mutate the version on the compartment. This is generally discouraged, but
|
||||
* necessary to support the version mutation in the js and xpc shell command
|
||||
* set.
|
||||
*
|
||||
* It would be nice to put this in jsfriendapi, but the linkage requirements
|
||||
* of the shells make that impossible.
|
||||
*/
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetVersionForCompartment(JSCompartment* compartment, JSVersion version);
|
||||
|
||||
extern JS_PUBLIC_API(const char*)
|
||||
JS_VersionToString(JSVersion version);
|
||||
|
||||
|
@ -992,7 +992,7 @@ Version(JSContext* cx, unsigned argc, Value* vp)
|
||||
"version");
|
||||
return false;
|
||||
}
|
||||
JS_SetVersionForCompartment(js::GetContextCompartment(cx), JSVersion(v));
|
||||
SetVersionForCurrentRealm(cx, JSVersion(v));
|
||||
args.rval().setInt32(origVersion);
|
||||
}
|
||||
return true;
|
||||
|
@ -69,3 +69,10 @@ JS::GetRealmIteratorPrototype(JSContext* cx)
|
||||
CHECK_REQUEST(cx);
|
||||
return GlobalObject::getOrCreateIteratorPrototype(cx, cx->global());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::SetVersionForCurrentRealm(JSContext* cx, JSVersion version)
|
||||
{
|
||||
JSCompartment* compartment = GetContextCompartment(cx);
|
||||
compartment->behaviors().setVersion(version);
|
||||
}
|
||||
|
@ -392,8 +392,7 @@ Version(JSContext* cx, unsigned argc, Value* vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(JS_GetVersion(cx));
|
||||
if (args.get(0).isInt32())
|
||||
JS_SetVersionForCompartment(js::GetContextCompartment(cx),
|
||||
JSVersion(args[0].toInt32()));
|
||||
SetVersionForCurrentRealm(cx, JSVersion(args[0].toInt32()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1086,8 +1085,7 @@ ProcessArgs(AutoJSAPI& jsapi, char** argv, int argc, XPCShellDirProvider* aDirPr
|
||||
if (++i == argc) {
|
||||
return printUsageAndSetExitCode();
|
||||
}
|
||||
JS_SetVersionForCompartment(js::GetContextCompartment(cx),
|
||||
JSVersion(atoi(argv[i])));
|
||||
SetVersionForCurrentRealm(cx, JSVersion(atoi(argv[i])));
|
||||
break;
|
||||
case 'W':
|
||||
reportWarnings = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user