else obj=Nullable<QString>();
}
+static QScriptValue Int32_toScriptValue(QScriptEngine*,const Nullable<qint32>&obj)
+{
+ if(obj.isNull())return QScriptValue::NullValue;
+ else return QScriptValue(obj.value());
+}
+
+static void Int32_fromScriptValue(const QScriptValue&val,Nullable<qint32>&obj)
+{
+ if(val.isNull())obj=Nullable<qint32>();
+ if(val.isNumber())obj=val.toInt32();
+ else obj=Nullable<qint32>();
+}
+
+static QScriptValue UInt32_toScriptValue(QScriptEngine*,const Nullable<quint32>&obj)
+{
+ if(obj.isNull())return QScriptValue::NullValue;
+ else return QScriptValue(obj.value());
+}
+
+static void UInt32_fromScriptValue(const QScriptValue&val,Nullable<quint32>&obj)
+{
+ if(val.isNull())obj=Nullable<quint32>();
+ if(val.isNumber())obj=val.toUInt32();
+ else obj=Nullable<quint32>();
+}
+
+static QScriptValue Int64_toScriptValue(QScriptEngine*,const Nullable<qint64>&obj)
+{
+ if(obj.isNull())return QScriptValue::NullValue;
+ else return QScriptValue(qsreal(obj.value()));
+}
+
+static void Int64_fromScriptValue(const QScriptValue&val,Nullable<qint64>&obj)
+{
+ if(val.isNull())obj=Nullable<qint64>();
+ if(val.isNumber())obj=(qint64)val.toNumber();
+ else obj=Nullable<qint64>();
+}
+
+static QScriptValue UInt64_toScriptValue(QScriptEngine*,const Nullable<quint64>&obj)
+{
+ if(obj.isNull())return QScriptValue::NullValue;
+ else return QScriptValue(qsreal(obj.value()));
+}
+
+static void UInt64_fromScriptValue(const QScriptValue&val,Nullable<quint64>&obj)
+{
+ if(val.isNull())obj=Nullable<quint64>();
+ if(val.isNumber())obj=(quint64)val.toNumber();
+ else obj=Nullable<quint64>();
+}
+
+//TODO: copy the QByteArray wrapper from the Qt tutorials
+static QScriptValue BA_toScriptValue(QScriptEngine*engine,const Nullable<QByteArray>&obj)
+{
+ if(obj.isNull())return QScriptValue::NullValue;
+ else return engine->newVariant(obj.value());
+}
+
+static void BA_fromScriptValue(const QScriptValue&val,Nullable<QByteArray>&obj)
+{
+ if(val.isNull())obj=Nullable<QByteArray>();
+ if(val.isVariant())obj=val.toVariant().toByteArray();
+ else obj=Nullable<QByteArray>();
+}
+
+
//list of supported types
static void initNullableScripting(QScriptEngine*engine)
{
QScriptValue gval=engine->globalObject();
qScriptRegisterMetaType(engine,Bool_toScriptValue,Bool_fromScriptValue);
qScriptRegisterMetaType(engine,String_toScriptValue,String_fromScriptValue);
+ qScriptRegisterMetaType(engine,Int32_toScriptValue,Int32_fromScriptValue);
+ qScriptRegisterMetaType(engine,UInt32_toScriptValue,UInt32_fromScriptValue);
+ qScriptRegisterMetaType(engine,Int64_toScriptValue,Int64_fromScriptValue);
+ qScriptRegisterMetaType(engine,UInt64_toScriptValue,UInt64_fromScriptValue);
+ qScriptRegisterMetaType(engine,BA_toScriptValue,BA_fromScriptValue);
}