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


C++ QScriptValueImpl类代码示例

本文整理汇总了C++中QScriptValueImpl的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueImpl类的具体用法?C++ QScriptValueImpl怎么用?C++ QScriptValueImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QScriptValueImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: return

QScriptValueImpl Object::method_propertyIsEnumerable(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *)
{
    bool result = false;

    if (context->thisObject().isObject() && (context->argumentCount() > 0)) {
        QScriptValueImpl arg = context->argument(0);

        QScriptNameIdImpl *id = 0;
        if (arg.isString())
            id = arg.stringValue();

        if (! id || ! id->unique) {
            QString str = arg.toString();
            id = eng->nameId(str);
        }

        QScript::Member member;
        QScriptValueImpl base;
        QScriptValueImpl self = context->thisObject();
        if (self.resolve(id, &member, &base, QScriptValue::ResolveLocal, QScript::Read)) {
            result = ! member.dontEnum();
            if (result) {
                QScriptValueImpl tmp;
                base.get(member, &tmp);
                result = tmp.isValid();
            }
        }
    }

    return (QScriptValueImpl(result));
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: addFunction

void Math::addFunction(QScriptValueImpl &object, const QString &name,
                       QScriptInternalFunctionSignature fun, int length,
                       const QScriptValue::PropertyFlags flags)
{
    QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(object.engine());
    QScriptValueImpl val = eng_p->createFunction(fun, length, object.classInfo(), name);
    object.setProperty(name, val, flags);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:8,代码来源:qscriptecmamath.cpp

示例3: data

/*!
  \since 4.4

  Sets the internal \a data of this QScriptValue object. You can use
  this function to set object-specific data that won't be directly
  accessible to scripts, but may be retrieved in C++ using the data()
  function.
*/
void QScriptValue::setData(const QScriptValue &data)
{
    if (!isObject())
        return;
    QScriptValueImpl self = QScriptValuePrivate::valueOf(*this);
    QScriptValueImpl data_p = QScriptValuePrivate::valueOf(data);
    self.setInternalValue(data_p);
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:16,代码来源:qscriptvalue.cpp

示例4: mark

void FunctionClassData::mark(const QScriptValueImpl &object, int generation)
{
    if (object.classInfo() != classInfo())
        return;
    QScriptFunction *fun = object.toFunction();
    QScriptEnginePrivate *eng = QScriptEnginePrivate::get(object.engine());
    fun->mark(eng, generation);
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:8,代码来源:qscriptecmafunction.cpp

示例5: QLatin1String

QScriptValueImpl Object::method_toString(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *)
{
    QScriptValueImpl glo = eng->globalObject();
    QString s = QLatin1String("[object ");
    QScriptValueImpl self = context->thisObject();
    s += self.classInfo()->name();
    s += QLatin1String("]");
    return (QScriptValueImpl(eng, s));
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例6: method_valueOf

QScriptValueImpl Number::method_valueOf(QScriptContextPrivate *context, QScriptEnginePrivate *, QScriptClassInfo *classInfo)
{
    QScriptValueImpl self = context->thisObject();
    if (self.classInfo() != classInfo)
        return context->throwError(QScriptContext::TypeError,
                                   QLatin1String("Number.prototype.valueOf"));

    return (self.internalValue());
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:9,代码来源:qscriptecmanumber.cpp

示例7: setScriptClass

/*!
  \since 4.4

  Returns the custom script class that this script object is an
  instance of, or 0 if the object is not of a custom class.

  \sa setScriptClass()
*/
QScriptClass *QScriptValue::scriptClass() const
{
    if (!isObject())
        return 0;
    QScriptValueImpl self = QScriptValuePrivate::valueOf(*this);
    QScriptClassInfo *info = self.classInfo();
    if ((info->type() & QScriptClassInfo::TypeMask) < QScriptClassInfo::CustomType)
        return 0;
    return QScriptClassPrivate::classFromInfo(info);
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:18,代码来源:qscriptvalue.cpp

示例8: QLatin1String

QScriptValueImpl Number::method_toLocaleString(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo)
{
    QScriptValueImpl self = context->thisObject();
    if (self.classInfo() != classInfo)
        return context->throwError(QScriptContext::TypeError,
                                   QLatin1String("Number.prototype.toLocaleString"));

    QString str = self.internalValue().toString();
    return (QScriptValueImpl(eng, str));
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:10,代码来源:qscriptecmanumber.cpp

示例9: QScriptValueImpl

QScriptValueImpl Function::method_toString(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *)
{
    QScriptValueImpl self = context->thisObject();
    if (QScriptFunction *foo = self.toFunction()) {
        QString code = foo->toString(context);
        return QScriptValueImpl(eng, code);
    }

    return context->throwError(QScriptContext::TypeError,
                               QLatin1String("Function.prototype.toString"));
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:11,代码来源:qscriptecmafunction.cpp

示例10: object

/*!
  \since 4.4

  Sets the custom script class of this script object to \a scriptClass.
  This can be used to "promote" a plain script object (e.g. created
  by the "new" operator in a script, or by QScriptEngine::newObject() in C++)
  to an object of a custom type.

  \sa scriptClass(), setData()
*/
void QScriptValue::setScriptClass(QScriptClass *scriptClass)
{
    if (!isObject() || !scriptClass)
        return;
    QScriptClassPrivate *cls_p = QScriptClassPrivate::get(scriptClass);
    QScriptClassInfo *info = cls_p->classInfo();
    if ((info->type() & QScriptClassInfo::TypeMask) < QScriptClassInfo::CustomType)
        return;
    QScriptValueImpl self = QScriptValuePrivate::valueOf(*this);
    self.setClassInfo(info);
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:21,代码来源:qscriptvalue.cpp

示例11: mark

void EnumerationClassData::mark(const QScriptValueImpl &object, int generation)
{
    Q_ASSERT(object.isValid());

    QScriptEnginePrivate *eng = object.engine();

    if (Enumeration::Instance *instance = Enumeration::Instance::get(object, classInfo())) {
        eng->markObject(instance->object, generation);
        if (instance->it)
            eng->markObject(instance->it->object(), generation);
    }
}
开发者ID:0sander,项目名称:qt-solutions,代码行数:12,代码来源:qscriptextenumeration.cpp

示例12: method_defineSetter

QScriptValueImpl Object::method_defineSetter(QScriptContextPrivate *context, QScriptEnginePrivate *eng,
                                             QScriptClassInfo *)
{
    QString propertyName = context->argument(0).toString();
    if (context->thisObject().propertyFlags(propertyName) & QScriptValue::ReadOnly)
        return context->throwError(QLatin1String("cannot redefine read-only property"));
    QScriptValueImpl setter = context->argument(1);
    if (!setter.isFunction())
        return context->throwError(QLatin1String("setter must be a function"));
    context->thisObject().setProperty(propertyName, setter, QScriptValue::PropertySetter);
    return eng->undefinedValue();
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例13: hasPrevious

bool QScriptValueIteratorImpl::hasPrevious()
{
    if (m_foundMember.isValid() && !m_foundForward) {
        // we have the information about the previous element already
        return true;
    }

    QScriptValueImpl obj = m_object;

    if (m_searchClassDataIterator) {
        Q_ASSERT(m_classDataIterator != 0);
        if (m_foundMember.isValid()) {
            // undo effect of hasNext()
            m_foundMember.invalidate();
            QScript::Member dummy;
            m_classDataIterator->previous(&dummy);
        }
        while (m_classDataIterator->hasPrevious()) {
            QScript::Member m;
            m_classDataIterator->previous(&m);
            if (acceptsMember(obj, m)) {
                m_foundObject = obj;
                m_foundMember = m;
                m_foundForward = false;
                return true;
            }
        }
        m_searchClassDataIterator = false;
        m_searchIndex = obj.memberCount();
        m_foundMember.invalidate();
    }

    // search object members
    int i = m_searchIndex - 1;
    if (m_foundMember.isValid()) {
        // undo effect of hasPrevious()
        m_foundMember.invalidate();
        --i;
    }
    for ( ; i >= 0; --i) {
        QScript::Member m;
        obj.member(i, &m);
        if (acceptsMember(obj, m)) {
            m_foundObject = obj;
            m_foundMember = m;
            m_foundForward = false;
            m_searchIndex = i;
            return true;
        }
    }

    return false;
}
开发者ID:0sander,项目名称:qt-solutions,代码行数:53,代码来源:qscriptvalueiteratorimpl.cpp

示例14: switch

QVariant QScriptValueImpl::toVariant() const
{
    switch (m_type) {
    case QScript::InvalidType:
        return QVariant();

    case QScript::UndefinedType:
    case QScript::NullType:
    case QScript::PointerType:
    case QScript::ReferenceType:
        break;

    case QScript::BooleanType:
        return QVariant(m_bool_value);

    case QScript::IntegerType:
        return QVariant(m_int_value);

    case QScript::NumberType:
        return QVariant(m_number_value);

    case QScript::StringType:
        return QVariant(m_string_value->s);

    case QScript::LazyStringType:
        return QVariant(*m_lazy_string_value);

    case QScript::ObjectType:
        if (isDate())
            return QVariant(toDateTime());

#ifndef QT_NO_REGEXP
        if (isRegExp())
            return QVariant(toRegExp());
#endif
        if (isVariant())
            return variantValue();

#ifndef QT_NO_QOBJECT
        if (isQObject())        
            return qVariantFromValue(toQObject());
#endif

        QScriptValueImpl v = engine()->toPrimitive(*this);
        if (!v.isObject())
            return v.toVariant();
        break;
    } // switch
    return QVariant();
}
开发者ID:,项目名称:,代码行数:50,代码来源:

示例15: QLatin1String

QScriptValueImpl Boolean::method_toString(QScriptContextPrivate *context,
                                          QScriptEnginePrivate *eng,
                                          QScriptClassInfo *classInfo)
{
    QScriptValueImpl self = context->thisObject();
    if (self.classInfo() != classInfo)
        return context->throwError(QScriptContext::TypeError,
                                   QLatin1String("Boolean.prototype.toString"));

    const QScript::IdTable *t = eng->idTable();
    bool v = self.internalValue().toBoolean();
    QScriptValueImpl result;
    eng->newNameId(&result, v ? t->id_true : t->id_false);
    return result;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:15,代码来源:qscriptecmaboolean.cpp


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