mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
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:
parent
2c2b9296bc
commit
ebc4aaed13
@ -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)
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user