本文整理汇总了C++中QSObject::isDefined方法的典型用法代码示例。如果您正苦于以下问题:C++ QSObject::isDefined方法的具体用法?C++ QSObject::isDefined怎么用?C++ QSObject::isDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSObject
的用法示例。
在下文中一共展示了QSObject::isDefined方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getQualified
QSObject QSObject::getQualified(const QString &name) const
{
QSObject obj = *this;
QString s = name;
// break up dotted notation ns like P1.P2.P3
while (!s.isEmpty()) {
int pos = s.find('.');
if (pos < 0)
pos = s.length();
// don't overwrite any existing objects, reuse them
QString cname = s.left(pos);
QSObject tmpobj = obj.get(cname);
// Search the class hieriarchy for member if undefined
if (!tmpobj.isDefined()) {
QSClass *base = obj.objectType()->base();
while (base && !tmpobj.isDefined()) {
tmpobj = base->get(&obj, cname);
base = base->base();
}
if (!tmpobj.isDefined())
return env()->createUndefined();
}
obj = tmpobj;
s = s.mid(pos + 1);
}
return obj;
}
示例2: 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;
}
}
示例3: varInfo
QString Debugger::varInfo(const QString &ident) const
{
if (!eng)
return QString();
int dot = ident.find('.');
if (dot < 0)
dot = ident.length();
QString sub = ident.mid(0, dot);
QSObject obj;
// resolve base
if (sub == QString::fromLatin1("||Global||")) {
obj = env()->globalObject();
} else if (sub == QString::fromLatin1("||Activation||")) {
obj = env()->currentScope();
} else if (sub == QString::fromLatin1("this")) {
obj = env()->thisValue();
} else {
obj = env()->resolveValue(ident);
if (!obj.isValid())
return QString();
}
// look up each part of a.b.c.
while (dot < (int)ident.length()) {
int olddot = dot;
dot = ident.find('.', olddot + 1);
if (dot < 0)
dot = ident.length();
sub = ident.mid(olddot + 1, dot - olddot - 1);
obj = obj.get(sub);
if (!obj.isDefined())
break;
}
return sub + QString::fromLatin1("=") + obj.debugString();
}