本文整理汇总了C++中jsc::JSObject::isVariableObject方法的典型用法代码示例。如果您正苦于以下问题:C++ JSObject::isVariableObject方法的具体用法?C++ JSObject::isVariableObject怎么用?C++ JSObject::isVariableObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsc::JSObject
的用法示例。
在下文中一共展示了JSObject::isVariableObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setActivationObject
/*!
Sets the activation object of this QScriptContext to be the given \a
activation.
If \a activation is not an object, this function does nothing.
\note For a context corresponding to a JavaScript function, this is only
guaranteed to work if there was an QScriptEngineAgent active on the
engine while the function was evaluated.
*/
void QScriptContext::setActivationObject(const QScriptValue &activation)
{
if (!activation.isObject())
return;
else if (activation.engine() != engine()) {
qWarning("QScriptContext::setActivationObject() failed: "
"cannot set an object created in "
"a different engine");
return;
}
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
QScript::APIShim shim(engine);
JSC::JSObject *object = JSC::asObject(engine->scriptValueToJSCValue(activation));
if (object == engine->originalGlobalObjectProxy)
object = engine->originalGlobalObject();
uint flags = QScriptEnginePrivate::contextFlags(frame);
if ((flags & QScriptEnginePrivate::NativeContext) && !(flags & QScriptEnginePrivate::HasScopeContext)) {
//For native functions, we create a scope node
JSC::JSObject *scope = object;
if (!scope->isVariableObject()) {
// Create a QScriptActivationObject that acts as a proxy
scope = new (frame) QScript::QScriptActivationObject(frame, scope);
}
frame->setScopeChain(frame->scopeChain()->copy()->push(scope));
QScriptEnginePrivate::setContextFlags(frame, flags | QScriptEnginePrivate::HasScopeContext);
return;
}
// else replace the first activation object in the scope chain
JSC::ScopeChainNode *node = frame->scopeChain();
while (node != 0) {
if (node->object && node->object->isVariableObject()) {
if (!object->isVariableObject()) {
if (node->object->inherits(&QScript::QScriptActivationObject::info)) {
static_cast<QScript::QScriptActivationObject*>(node->object)->setDelegate(object);
} else {
// Create a QScriptActivationObject that acts as a proxy
node->object = new (frame) QScript::QScriptActivationObject(frame, object);
}
} else {
node->object = object;
}
break;
}
node = node->next;
}
}