本文整理汇总了C++中QScriptValue::prototype方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValue::prototype方法的具体用法?C++ QScriptValue::prototype怎么用?C++ QScriptValue::prototype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValue
的用法示例。
在下文中一共展示了QScriptValue::prototype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDjangoWhereFromScriptValue
QDjangoWhere QDjangoWhereFromScriptValue(QScriptEngine *engine, const QScriptValue &obj)
{
if (obj.prototype().equals(engine->defaultPrototype(qMetaTypeId<QDjangoWhere>()))) {
return engine->fromScriptValue<QDjangoWhere>(obj);
}
QDjangoWhere where;
QScriptValueIterator it(obj);
while (it.hasNext()) {
it.next();
QString key = it.name();
QDjangoWhere::Operation op = QDjangoWhere::Equals;
if (key.endsWith(QLatin1String("__lt"))) {
key.chop(4);
op = QDjangoWhere::LessThan;
}
else if (key.endsWith(QLatin1String("__lte"))) {
key.chop(5);
op = QDjangoWhere::LessOrEquals;
}
else if (key.endsWith(QLatin1String("__gt"))) {
key.chop(4);
op = QDjangoWhere::GreaterThan;
}
else if (key.endsWith(QLatin1String("__gte"))) {
key.chop(5);
op = QDjangoWhere::GreaterOrEquals;
}
else if (key.endsWith(QLatin1String("__startswith"))) {
key.chop(12);
op = QDjangoWhere::StartsWith;
}
else if (key.endsWith(QLatin1String("__endswith"))) {
key.chop(10);
op = QDjangoWhere::EndsWith;
}
else if (key.endsWith(QLatin1String("__contains"))) {
key.chop(10);
op = QDjangoWhere::Contains;
}
else if (key.endsWith(QLatin1String("__in"))) {
key.chop(4);
op = QDjangoWhere::IsIn;
}
where = where && QDjangoWhere(key, op, it.value().toVariant());
}
return where;
}
示例2: execute
//.........这里部分代码省略.........
obj = oo;
break;
}
}
}
for (int i = 1; obj.isObject() && (i < path.size()-1); ++i)
obj = obj.property(path.at(i));
if (obj.isValid())
objects.append(obj);
} else {
objects << ctx->scopeChain();
QStringList keywords;
keywords.append(QString::fromLatin1("this"));
keywords.append(QString::fromLatin1("true"));
keywords.append(QString::fromLatin1("false"));
keywords.append(QString::fromLatin1("null"));
for (int i = 0; i < keywords.size(); ++i) {
const QString &kwd = keywords.at(i);
if (isPrefixOf(prefix, kwd))
matches.insert(kwd);
}
}
for (int i = 0; i < objects.size(); ++i) {
QScriptValue obj = objects.at(i);
while (obj.isObject()) {
QScriptValueIterator it(obj);
while (it.hasNext()) {
it.next();
QString propertyName = it.name();
if (isPrefixOf(prefix, propertyName))
matches.insert(propertyName);
}
obj = obj.prototype();
}
}
QStringList matchesList = matches.toList();
qStableSort(matchesList);
response.setResult(matchesList);
} break;
case QScriptDebuggerCommand::NewScriptObjectSnapshot: {
int id = backend->newScriptObjectSnapshot();
response.setResult(id);
} break;
case QScriptDebuggerCommand::ScriptObjectSnapshotCapture: {
int id = command.snapshotId();
QScriptObjectSnapshot *snap = backend->scriptObjectSnapshot(id);
Q_ASSERT(snap != 0);
QScriptDebuggerValue object = command.scriptValue();
Q_ASSERT(object.type() == QScriptDebuggerValue::ObjectValue);
QScriptEngine *engine = backend->engine();
QScriptValue realObject = object.toScriptValue(engine);
Q_ASSERT(realObject.isObject());
QScriptObjectSnapshot::Delta delta = snap->capture(realObject);
QScriptDebuggerObjectSnapshotDelta result;
result.removedProperties = delta.removedProperties;
bool didIgnoreExceptions = backend->ignoreExceptions();
backend->setIgnoreExceptions(true);
for (int i = 0; i < delta.changedProperties.size(); ++i) {
const QScriptValueProperty &src = delta.changedProperties.at(i);
bool hadException = engine->hasUncaughtException();
QString str = src.value().toString();
if (!hadException && engine->hasUncaughtException())
engine->clearExceptions();