本文整理汇总了C++中QSObject::invoke方法的典型用法代码示例。如果您正苦于以下问题:C++ QSObject::invoke方法的具体用法?C++ QSObject::invoke怎么用?C++ QSObject::invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSObject
的用法示例。
在下文中一共展示了QSObject::invoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call
bool QSEngineImp::call( QSObject *scope, const QString &func,
const QSList &args )
{
init();
QSObject t;
if ( !scope || !scope->isValid() ) {
t = env()->globalObject();
scope = &t;
}
QSObject v = scope->getQualified(func);
Q_ASSERT(v.isValid());
if ( !v.isDefined() ) {
if (func != QString::fromLatin1("main")) {
errType = ReferenceError;
errMsgs.append( QString::fromLatin1("Unknown function: ") + func );
errLines.append( 0 );
}
return false;
}
if ( !v.isFunction() ) {
errType = TypeError;
errMsgs.append( func + QString::fromLatin1(" is not a function. Call failed.") );
errLines.append( 0 );
return false;
}
QSObject res = v.invoke( QSMember(), args );
if ( env()->isExceptionMode() ) {
QSObject err = env()->exception();
errType = 99; /* TODO */
errLines.append(QSErrorClass::errorLine(&err));
errMsgs.append(QSErrorClass::errorName(&err) + QString::fromLatin1(". ") + QSErrorClass::errorMessage(&err));
#ifdef QSDEBUGGER
if (dbg)
dbg->setSourceId(QSErrorClass::errorSourceId(&err));
#endif
env()->clearException();
return false;
} else {
errType = 0;
errLines.clear();
errMsgs.clear();
// return value
retVal = res;
return true;
}
}
示例2: invoke
QSObject QSFuncRefClass::invoke( QSObject * objPtr,
const QSMember & ) const
{
Q_ASSERT( objPtr->isA( this ) );
QSReferenceData * data = (QSReferenceData*) objPtr->shVal();
QSObject base = data->base;
QSMember bmem = data->member;
env()->pushScopeBlock();
ScopeChain::const_iterator it = data->context.begin();
while( it!=data->context.end() ) {
env()->pushScope( *it );
it++;
}
QSObject retVal = base.invoke( bmem, *(env()->arguments()) );
env()->popScopeBlock();
return retVal;
}