} switch (valTypeId) { case QMetaType::UnknownType: case QMetaType::Void: return QScriptValue(this, QScriptValue::UndefinedValue); case QMetaType::Nullptr: return QScriptValue(this, QScriptValue::NullValue); case QMetaType::Bool: return QScriptValue(this, val.toBool()); case QMetaType::Int: case QMetaType::Long: case QMetaType::Short: return QScriptValue(this, val.toInt()); case QMetaType::UInt: case QMetaType::ULong: case QMetaType::UShort: return QScriptValue(this, val.toUInt()); case QMetaType::Float: case QMetaType::LongLong: case QMetaType::ULongLong: case QMetaType::Double: return QScriptValue(this, val.toFloat()); case QMetaType::QString: case QMetaType::QByteArray: return QScriptValue(this, val.toString()); case QMetaType::QVariant: return castVariantToValue(val.value<QVariant>()); case QMetaType::QObjectStar: { QObject* obj = val.value<QObject*>(); if (obj == nullptr) return QScriptValue(this, QScriptValue::NullValue); return ScriptObjectQtProxy::newQObject(this, obj); } case QMetaType::QDateTime: return static_cast<QScriptEngine*>(this)->newDate(val.value<QDateTime>()); case QMetaType::QDate: return static_cast<QScriptEngine*>(this)->newDate(val.value<QDate>().startOfDay()); default: // check to see if this is a pointer to a QObject-derived object if (QMetaType::typeFlags(valTypeId) & (QMetaType::PointerToQObject | QMetaType::TrackingPointerToQObject)) { QObject* obj = val.value<QObject*>(); if (obj == nullptr) return QScriptValue(this, QScriptValue::NullValue); return ScriptObjectQtProxy::newQObject(this, obj); } // have we set a prototype'd variant? { _customTypeProtect.lockForRead(); CustomPrototypeMap::const_iterator lookup = _customPrototypes.find(valTypeId); if (lookup != _customPrototypes.cend()) { return ScriptVariantQtProxy::newVariant(this, val, lookup.value()); } _customTypeProtect.unlock(); } // just do a generic variant return QScriptEngine::newVariant(val); }}Lines 501–557 of 557. Previous lines
} switch (valTypeId) { case QMetaType::UnknownType: case QMetaType::Void: return QScriptValue(this, QScriptValue::UndefinedValue); case QMetaType::Nullptr: return QScriptValue(this, QScriptValue::NullValue); case QMetaType::Bool: return QScriptValue(this, val.toBool()); case QMetaType::Int: case QMetaType::Long: case QMetaType::Short: return QScriptValue(this, val.toInt()); case QMetaType::UInt: case QMetaType::ULong: case QMetaType::UShort: return QScriptValue(this, val.toUInt()); case QMetaType::Float: case QMetaType::LongLong: case QMetaType::ULongLong: case QMetaType::Double: return QScriptValue(this, val.toFloat()); case QMetaType::QString: case QMetaType::QByteArray: return QScriptValue(this, val.toString()); case QMetaType::QVariant: return castVariantToValue(val.value<QVariant>()); case QMetaType::QObjectStar: { QObject* obj = val.value<QObject*>(); if (obj == nullptr) return QScriptValue(this, QScriptValue::NullValue); return ScriptObjectQtProxy::newQObject(this, obj); } case QMetaType::QDateTime: return static_cast<QScriptEngine*>(this)->newDate(val.value<QDateTime>()); case QMetaType::QDate: return static_cast<QScriptEngine*>(this)->newDate(val.value<QDate>().startOfDay()); default: // check to see if this is a pointer to a QObject-derived object if (QMetaType::typeFlags(valTypeId) & (QMetaType::PointerToQObject | QMetaType::TrackingPointerToQObject)) { QObject* obj = val.value<QObject*>(); if (obj == nullptr) return QScriptValue(this, QScriptValue::NullValue); return ScriptObjectQtProxy::newQObject(this, obj); } // have we set a prototype'd variant? { _customTypeProtect.lockForRead(); CustomPrototypeMap::const_iterator lookup = _customPrototypes.find(valTypeId); if (lookup != _customPrototypes.cend()) { return ScriptVariantQtProxy::newVariant(this, val, lookup.value()); } _customTypeProtect.unlock(); } // just do a generic variant return QScriptEngine::newVariant(val); } }