当前位置: 首页>>代码示例>>C++>>正文


C++ QScriptValue::prototype方法代码示例

本文整理汇总了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;
} 
开发者ID:hummermania,项目名称:qdjango,代码行数:48,代码来源:QDjangoScript.cpp

示例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();
开发者ID:Blizzard,项目名称:qt4,代码行数:67,代码来源:qscriptdebuggercommandexecutor.cpp


注:本文中的QScriptValue::prototype方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。