Bug 1283855 part 16 - Make source hook functions take JSContext instead of JSRuntime. r=mrrrgn

--HG--
extra : rebase_source : 8311b02e6facb3d3b08ead519c06dd8d3319ad0f
This commit is contained in:
Jan de Mooij 2016-07-05 16:49:39 +02:00
parent 2c2b9296bc
commit ebc4aaed13
4 changed files with 14 additions and 14 deletions

View File

@ -52,15 +52,15 @@ PerThreadDataFriendFields::PerThreadDataFriendFields()
} }
JS_FRIEND_API(void) JS_FRIEND_API(void)
js::SetSourceHook(JSRuntime* rt, mozilla::UniquePtr<SourceHook> hook) js::SetSourceHook(JSContext* cx, mozilla::UniquePtr<SourceHook> hook)
{ {
rt->sourceHook = Move(hook); cx->sourceHook = Move(hook);
} }
JS_FRIEND_API(mozilla::UniquePtr<SourceHook>) JS_FRIEND_API(mozilla::UniquePtr<SourceHook>)
js::ForgetSourceHook(JSRuntime* rt) js::ForgetSourceHook(JSContext* cx)
{ {
return Move(rt->sourceHook); return Move(cx->sourceHook);
} }
JS_FRIEND_API(void) JS_FRIEND_API(void)

View File

@ -446,17 +446,17 @@ class SourceHook {
}; };
/** /**
* Have |rt| use |hook| to retrieve lazily-retrieved source code. See the * Have |cx| use |hook| to retrieve lazily-retrieved source code. See the
* comments for SourceHook. The runtime takes ownership of the hook, and * comments for SourceHook. The context takes ownership of the hook, and
* will delete it when the runtime itself is deleted, or when a new hook is * will delete it when the context itself is deleted, or when a new hook is
* set. * set.
*/ */
extern JS_FRIEND_API(void) extern JS_FRIEND_API(void)
SetSourceHook(JSRuntime* rt, mozilla::UniquePtr<SourceHook> hook); SetSourceHook(JSContext* cx, mozilla::UniquePtr<SourceHook> hook);
/** Remove |rt|'s source hook, and return it. The caller now owns the hook. */ /** Remove |cx|'s source hook, and return it. The caller now owns the hook. */
extern JS_FRIEND_API(mozilla::UniquePtr<SourceHook>) extern JS_FRIEND_API(mozilla::UniquePtr<SourceHook>)
ForgetSourceHook(JSRuntime* rt); ForgetSourceHook(JSContext* cx);
extern JS_FRIEND_API(JS::Zone*) extern JS_FRIEND_API(JS::Zone*)
GetCompartmentZone(JSCompartment* comp); GetCompartmentZone(JSCompartment* comp);

View File

@ -4462,12 +4462,12 @@ WithSourceHook(JSContext* cx, unsigned argc, Value* vp)
if (!hook) if (!hook)
return false; return false;
mozilla::UniquePtr<SourceHook> savedHook = js::ForgetSourceHook(cx->runtime()); mozilla::UniquePtr<SourceHook> savedHook = js::ForgetSourceHook(cx);
js::SetSourceHook(cx->runtime(), Move(hook)); js::SetSourceHook(cx, Move(hook));
RootedObject fun(cx, &args[1].toObject()); RootedObject fun(cx, &args[1].toObject());
bool result = Call(cx, UndefinedHandleValue, fun, JS::HandleValueArray::empty(), args.rval()); bool result = Call(cx, UndefinedHandleValue, fun, JS::HandleValueArray::empty(), args.rval());
js::SetSourceHook(cx->runtime(), Move(savedHook)); js::SetSourceHook(cx, Move(savedHook));
return result; return result;
} }

View File

@ -3592,7 +3592,7 @@ XPCJSRuntime::Initialize()
// JS::CompileFunction). In practice, this means content scripts and event // JS::CompileFunction). In practice, this means content scripts and event
// handlers. // handlers.
UniquePtr<XPCJSSourceHook> hook(new XPCJSSourceHook); UniquePtr<XPCJSSourceHook> hook(new XPCJSSourceHook);
js::SetSourceHook(runtime, Move(hook)); js::SetSourceHook(cx, Move(hook));
// Set up locale information and callbacks for the newly-created runtime so // Set up locale information and callbacks for the newly-created runtime so
// that the various toLocaleString() methods, localeCompare(), and other // that the various toLocaleString() methods, localeCompare(), and other