本文整理汇总了C++中XPCJSContextStack::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ XPCJSContextStack::Count方法的具体用法?C++ XPCJSContextStack::Count怎么用?C++ XPCJSContextStack::Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPCJSContextStack
的用法示例。
在下文中一共展示了XPCJSContextStack::Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetScriptContextFromJSContext
danger::AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
{
MOZ_ASSERT_IF(!allowNull, cx);
// Hold a strong ref to the nsIScriptContext, if any. This ensures that we
// only destroy the mContext of an nsJSContext when it is not on the cx stack
// (and therefore not in use). See nsJSContext::DestroyJSContext().
if (cx)
mScx = GetScriptContextFromJSContext(cx);
XPCJSContextStack *stack = XPCJSRuntime::Get()->GetJSContextStack();
if (!stack->Push(cx)) {
MOZ_CRASH();
}
mStackDepthAfterPush = stack->Count();
#ifdef DEBUG
mPushedContext = cx;
mCompartmentDepthOnEntry = cx ? js::GetEnterCompartmentDepth(cx) : 0;
#endif
// Enter a request and a compartment for the duration that the cx is on the
// stack if non-null.
if (cx) {
mAutoRequest.emplace(cx);
}
}
示例2: GetScriptContextFromJSContext
AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
{
MOZ_ASSERT_IF(!allowNull, cx);
// Hold a strong ref to the nsIScriptContext, if any. This ensures that we
// only destroy the mContext of an nsJSContext when it is not on the cx stack
// (and therefore not in use). See nsJSContext::DestroyJSContext().
if (cx)
mScx = GetScriptContextFromJSContext(cx);
XPCJSContextStack *stack = XPCJSRuntime::Get()->GetJSContextStack();
if (!stack->Push(cx)) {
MOZ_CRASH();
}
mStackDepthAfterPush = stack->Count();
#ifdef DEBUG
mPushedContext = cx;
mCompartmentDepthOnEntry = cx ? js::GetEnterCompartmentDepth(cx) : 0;
#endif
// Enter a request and a compartment for the duration that the cx is on the
// stack if non-null.
if (cx) {
mAutoRequest.construct(cx);
// DOM JSContexts don't store their default compartment object on the cx.
JSObject *compartmentObject = mScx ? mScx->GetWindowProxy()
: js::DefaultObjectForContextOrNull(cx);
if (compartmentObject)
mAutoCompartment.construct(cx, compartmentObject);
}
}