本文整理汇总了C++中QScriptObject::delegate方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptObject::delegate方法的具体用法?C++ QScriptObject::delegate怎么用?C++ QScriptObject::delegate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptObject
的用法示例。
在下文中一共展示了QScriptObject::delegate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
QScriptDeclarativeClass::Object *QScriptDeclarativeClass::object(const QScriptValue &v)
{
QScriptValuePrivate *d = QScriptValuePrivate::get(v);
if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
return 0;
QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
QScriptObjectDelegate *delegate = scriptObject->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
return 0;
return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->object();
}
示例2: compareToObject
bool DeclarativeObjectDelegate::compareToObject(QScriptObject *o, JSC::ExecState *exec, JSC::JSObject *o2)
{
if (!o2->inherits(&QScriptObject::info))
return false;
QScriptObject *scriptObject = static_cast<QScriptObject*>(o2);
QScriptObjectDelegate *delegate = scriptObject->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
return false;
DeclarativeObjectDelegate *other = static_cast<DeclarativeObjectDelegate*>(delegate);
if (m_class != other->m_class)
return false;
else
return m_class->compare(m_object, other->m_object);
}
示例3: construct
JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObject *callee,
const JSC::ArgList &args)
{
Q_ASSERT(callee->inherits(&QScriptObject::info));
QScriptObject *obj = static_cast<QScriptObject*>(callee);
QScriptObjectDelegate *delegate = obj->delegate();
QScriptClass *scriptClass = static_cast<ClassObjectDelegate*>(delegate)->scriptClass();
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
//JSC::ExecState *oldFrame = eng_p->currentFrame;
eng_p->pushContext(exec, JSC::JSValue(), args, callee, true);
QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue defaultObject = ctx->thisObject();
QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx)));
if (!result.isObject())
result = defaultObject;
return JSC::asObject(eng_p->scriptValueToJSCValue(result));
}
示例4: throwError
JSC::JSValue JSC_HOST_CALL ClassObjectDelegate::call(JSC::ExecState *exec, JSC::JSObject *callee,
JSC::JSValue thisValue, const JSC::ArgList &args)
{
if (!callee->inherits(&QScriptObject::info))
return JSC::throwError(exec, JSC::TypeError, "callee is not a ClassObject object");
QScriptObject *obj = static_cast<QScriptObject*>(callee);
QScriptObjectDelegate *delegate = obj->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::ClassObject))
return JSC::throwError(exec, JSC::TypeError, "callee is not a ClassObject object");
QScriptClass *scriptClass = static_cast<ClassObjectDelegate*>(delegate)->scriptClass();
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
JSC::ExecState *oldFrame = eng_p->currentFrame;
eng_p->pushContext(exec, thisValue, args, callee);
QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj);
QVariant result = scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx));
eng_p->popContext();
eng_p->currentFrame = oldFrame;
return QScriptEnginePrivate::jscValueFromVariant(exec, result);
}
示例5: call
JSC::JSValue DeclarativeObjectDelegate::call(JSC::ExecState *exec, JSC::JSObject *callee,
JSC::JSValue thisValue, const JSC::ArgList &args)
{
if (!callee->inherits(&QScriptObject::info))
return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
QScriptObject *obj = static_cast<QScriptObject*>(callee);
QScriptObjectDelegate *delegate = obj->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
QScriptDeclarativeClass *scriptClass = static_cast<DeclarativeObjectDelegate*>(delegate)->m_class;
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
QScript::SaveFrameHelper saveFrame(eng_p, exec);
eng_p->pushContext(exec, thisValue, args, callee);
QScriptContext *ctxt = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj);
QScriptDeclarativeClass::Value result =
scriptClass->call(static_cast<DeclarativeObjectDelegate*>(delegate)->m_object, ctxt);
eng_p->popContext();
return (JSC::JSValue &)(result);
}