本文整理汇总了C++中QScriptEngine::undefinedValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngine::undefinedValue方法的具体用法?C++ QScriptEngine::undefinedValue怎么用?C++ QScriptEngine::undefinedValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptEngine
的用法示例。
在下文中一共展示了QScriptEngine::undefinedValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newQObject
QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type)
{
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
if (!object)
return newObject(scriptEngine, this, new ObjectData(object, type));
if (QObjectPrivate::get(object)->wasDeleted)
return scriptEngine->undefinedValue();
QDeclarativeData *ddata = QDeclarativeData::get(object, true);
if (!ddata) {
return scriptEngine->undefinedValue();
} else if (!ddata->indestructible && !object->parent()) {
return newObject(scriptEngine, this, new ObjectData(object, type));
} else if (!ddata->scriptValue) {
ddata->scriptValue = new QScriptValue(newObject(scriptEngine, this, new ObjectData(object, type)));
return *ddata->scriptValue;
} else if (ddata->scriptValue->engine() == QDeclarativeEnginePrivate::getScriptEngine(engine)) {
return *ddata->scriptValue;
} else {
return newObject(scriptEngine, this, new ObjectData(object, type));
}
}
示例2: initAsType
void MetaCallArgument::initAsType(int callType, QDeclarativeEngine *e)
{
if (type != 0) { cleanup(); type = 0; }
if (callType == 0) return;
QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(e);
if (callType == qMetaTypeId<QScriptValue>()) {
new (&data) QScriptValue(engine->undefinedValue());
type = callType;
} else if (callType == QMetaType::Int ||
callType == QMetaType::UInt ||
callType == QMetaType::Bool ||
callType == QMetaType::Double ||
callType == QMetaType::Float) {
type = callType;
} else if (callType == QMetaType::QObjectStar) {
*((QObject **)&data) = 0;
type = callType;
} else if (callType == QMetaType::QString) {
new (&data) QString();
type = callType;
} else if (callType == qMetaTypeId<QVariant>()) {
type = callType;
new (&data) QVariant();
} else if (callType == qMetaTypeId<QList<QObject *> >()) {
type = callType;
new (&data) QList<QObject *>();
} else {
type = -1;
new (&data) QVariant(callType, (void *)0);
}
}
示例3: Employee_ctor
//! [37]
QScriptValue Employee_ctor(QScriptContext *context, QScriptEngine *engine)
{
QScriptValue super = context->callee().property("prototype").property("constructor");
super.call(context->thisObject(), QScriptValueList() << context->argument(0));
context->thisObject().setProperty("salary", context->argument(1));
return engine->undefinedValue();
}
示例4: QPointF_prototype_setX
QScriptValue QPointF_prototype_setX(QScriptContext *context, QScriptEngine *engine)
{
// Cast to a pointer to be able to modify the underlying C++ value
QPointF *point = qscriptvalue_cast<QPointF*>(context->thisObject());
if (!point)
return context->throwError(QScriptContext::TypeError, "QPointF.prototype.setX: this object is not a QPointF");
point->setX(context->argument(0).toNumber());
return engine->undefinedValue();
}
示例5: myPrintFunction
//! [45]
QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine)
{
QString result;
for (int i = 0; i < context->argumentCount(); ++i) {
if (i > 0)
result.append(" ");
result.append(context->argument(i).toString());
}
QScriptValue calleeData = context->callee().data();
QPlainTextEdit *edit = qobject_cast<QPlainTextEdit*>(calleeData.toQObject());
edit->appendPlainText(result);
return engine->undefinedValue();
}
示例6: get
QScriptValue FlatListModel::get(int index) const
{
QScriptEngine *scriptEngine = m_scriptEngine ? m_scriptEngine : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(m_listModel));
if (!scriptEngine)
return 0;
if (index < 0 || index >= m_values.count())
return scriptEngine->undefinedValue();
QScriptValue rv = scriptEngine->newObject();
QHash<int, QVariant> row = m_values.at(index);
for (QHash<int, QVariant>::ConstIterator iter = row.begin(); iter != row.end(); ++iter)
rv.setProperty(m_roles.value(iter.key()), qScriptValueFromValue(scriptEngine, iter.value()));
return rv;
}
示例7: get
QScriptValue NestedListModel::get(int index) const
{
QDeclarativeEngine *eng = qmlEngine(m_listModel);
if (!eng)
return 0;
if (index < 0 || index >= count()) {
QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(eng);
if (seng)
return seng->undefinedValue();
return 0;
}
ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
if (!node)
return 0;
return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng);
}
示例8: argumentsObjectInNative
void tst_QScriptContext::argumentsObjectInNative()
{
{
QScriptEngine eng;
QScriptValue fun = eng.newFunction(argumentsObjectInNative_test1);
QScriptValueList args;
args << QScriptValue(&eng, 123.0);
args << QScriptValue(&eng, QString::fromLatin1("456"));
QScriptValue result = fun.call(eng.undefinedValue(), args);
QVERIFY(!eng.hasUncaughtException());
QCOMPARE(result.toString(), QString::fromLatin1("success"));
}
{
QScriptEngine eng;
QScriptValue fun = eng.newFunction(argumentsObjectInNative_test1);
eng.globalObject().setProperty("func", fun);
QScriptValue result = eng.evaluate("func(123.0 , 456);");
QVERIFY(!eng.hasUncaughtException());
QCOMPARE(result.toString(), QString::fromLatin1("success"));
}
}
示例9: initAsType
void MetaCallArgument::initAsType(int callType, QDeclarativeEngine *e)
{
if (type != 0) { cleanup(); type = 0; }
if (callType == 0) return;
QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(e);
if (callType == qMetaTypeId<QScriptValue>()) {
qscriptValuePtr = new (&allocData) QScriptValue(engine->undefinedValue());
type = callType;
} else if (callType == QMetaType::Int ||
callType == QMetaType::UInt ||
callType == QMetaType::Bool ||
callType == QMetaType::Double ||
callType == QMetaType::Float) {
type = callType;
} else if (callType == QMetaType::QObjectStar) {
qobjectPtr = 0;
type = callType;
} else if (callType == QMetaType::QString) {
qstringPtr = new (&allocData) QString();
type = callType;
} else if (callType == qMetaTypeId<QVariant>()) {
type = callType;
qvariantPtr = new (&allocData) QVariant();
} else if (callType == qMetaTypeId<QList<QObject *> >()) {
type = callType;
qlistPtr = new (&allocData) QList<QObject *>();
} else if (callType == QMetaType::Void) {
// In Qt4 QMetaType::Void and QMetaType::UnknownType were both equals to 0 so QtQuick1
// doesn't always recognize the difference
return;
} else {
type = -1;
qvariantPtr = new (&allocData) QVariant(callType, (void *)0);
}
}