#include<QString>
#include<QMetaType>
//convenience wrappers
-typedef Nullable<bool> Bool;Q_DECLARE_METATYPE(Bool)
-typedef Nullable<int> Int;
-typedef Nullable<qint32> Int32;Q_DECLARE_METATYPE(Int32)
-typedef Nullable<qint64> Int64;Q_DECLARE_METATYPE(Int64)
-typedef Nullable<quint32> UInt32;Q_DECLARE_METATYPE(UInt32)
-typedef Nullable<quint64> UInt64;Q_DECLARE_METATYPE(UInt64)
-typedef Nullable<QString> NString;Q_DECLARE_METATYPE(NString)
-typedef Nullable<QByteArray> NByteArray;Q_DECLARE_METATYPE(NByteArray)
+Q_DECLARE_METATYPE(Nullable<bool>)
+Q_DECLARE_METATYPE(Nullable<qint32>)
+Q_DECLARE_METATYPE(Nullable<qint64>)
+Q_DECLARE_METATYPE(Nullable<quint32>)
+Q_DECLARE_METATYPE(Nullable<quint64>)
+Q_DECLARE_METATYPE(Nullable<QString>)
+Q_DECLARE_METATYPE(Nullable<QByteArray>)
-inline bool operator==(Int64 i1,int i2){return i1.operator==(i2);}
-inline bool operator==(UInt32 i1,int i2){return i1.operator==(i2);}
-inline bool operator==(UInt64 i1,int i2){return i1.operator==(i2);}
-inline bool operator==(UInt64 i1,unsigned int i2){return i1.operator==(i2);}
+inline bool operator==(Nullable<qint64> i1,int i2){return i1.operator==(i2);}
+inline bool operator==(Nullable<quint32> i1,int i2){return i1.operator==(i2);}
+inline bool operator==(Nullable<quint64> i1,int i2){return i1.operator==(i2);}
+inline bool operator==(Nullable<quint64> i1,unsigned int i2){return i1.operator==(i2);}
#endif
--- /dev/null
+//start: nullscript.cpp
+//currently this file is copied verbatim into the generated
+//interface code, in the future it may be included here instead
+
+#include <QScriptEngine>
+#include <Nullable>
+
+static QScriptValue Bool_toScriptValue(QScriptEngine*,const Nullable<bool>&obj)
+{
+ if(obj.isNull())return QScriptValue::NullValue;
+ else return QScriptValue(obj.value());
+}
+
+static void Bool_fromScriptValue(const QScriptValue&val,Nullable<bool>&obj)
+{
+ if(val.isNull())obj=Nullable<bool>();
+ if(val.isBool())obj=val.toBool();
+ else obj=Nullable<bool>();
+}
+
+static QScriptValue String_toScriptValue(QScriptEngine*,const Nullable<QString>&obj)
+{
+ if(obj.isNull())return QScriptValue::NullValue;
+ else return QScriptValue(obj.value());
+}
+
+static void String_fromScriptValue(const QScriptValue&val,Nullable<QString>&obj)
+{
+ if(val.isNull())obj=Nullable<QString>();
+ if(val.isString())obj=val.toString();
+ else obj=Nullable<QString>();
+}
+
+//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);
+}
+
+
+//end: nullscript.cpp
#include "Nullable"
static int itype0=
- qRegisterMetaType<Int32>()+
- qRegisterMetaType<Int64>()+
- qRegisterMetaType<UInt32>()+
- qRegisterMetaType<UInt64>()+
- qRegisterMetaType<NString>()+
- qRegisterMetaType<NByteArray>()+
- qRegisterMetaType<Bool>();
+ qRegisterMetaType<Nullable<qint32> >()+
+ qRegisterMetaType<Nullable<qint64> >()+
+ qRegisterMetaType<Nullable<quint32> >()+
+ qRegisterMetaType<Nullable<quint64> >()+
+ qRegisterMetaType<Nullable<QString> >()+
+ qRegisterMetaType<Nullable<QByteArray> >()+
+ qRegisterMetaType<Nullable<bool> >();
--- /dev/null
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource>
+ <file alias="nullscript.cpp">../../qtbase/src/nullscript.cpp</file>
+ </qresource>
+</RCC>
m_iface.write(QString(" Q_INVOKABLE static QString svnRepositoryUrl(){return \""+woc->svnRepositoryUrl()+"\";}\n\n").toAscii());
//init scripting
- m_scriptcode="#include <QScriptEngine>\n";
- m_scriptcode+="void "+ifaceClassName()+"::initScriptEngine(QScriptEngine*engine)\n{\n";
- m_scriptcode+="\tQScriptValue gval=engine->globalObject();\n";
- m_scriptcode+="\tgval.setProperty(\"Interface\",engine->newQMetaObject(this->metaObject()));\n";
- m_scriptcode+="\tgval.setProperty(\"interface\",engine->newQObject(this,QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater));\n";
+ initScripting();
//create all includer
m_hdr.setFileName(m_basedir+"/"+m_subdir+"/"+m_prefix+"IncludeAll");
{
connect(this,SIGNAL(errorFound()),p,SIGNAL(errorFound()));
}
+
+void WocQtOut::initScripting()
+{
+// m_scriptcode="#include <QScriptEngine>\n";
+ //script converters for nullables
+ QFile nscr(":/nullscript.cpp");nscr.open(QIODevice::ReadOnly);
+ m_scriptcode+=QString::fromAscii(nscr.readAll());
+ m_scriptcode+="\n\n";
+ nscr.close();
+ //initializer routine
+ m_scriptcode+="void "+ifaceClassName()+"::initScriptEngine(QScriptEngine*engine)\n{\n";
+ m_scriptcode+="\tQScriptValue gval=engine->globalObject();\n";
+ //register interfacce itself
+ m_scriptcode+="\tgval.setProperty(\"Interface\",engine->newQMetaObject(this->metaObject()));\n";
+ m_scriptcode+="\tgval.setProperty(\"interface\",engine->newQObject(this,QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater));\n";
+ //register nullables
+ m_scriptcode+="\tinitNullableScripting(engine);\n";
+}
void addScriptInit(QString s){m_scriptcode+=s;}
///helper: returns true if sub-classes are supposed to create scripting code
bool doGenerateScripting()const{return m_genscript;}
+ ///internal: init the scripting env
+ void initScripting();
WocQtClass*qclass;
WocQtTable*qtable;
htmlout.h \
mfile.h \
domquery.h
+
+RESOURCES += qt/qtfiles.qrc
include(proc/proc.pri)
include(php/php.pri)