remove Qt scripting; add common converters for QVariant; make WObjects gadgets instea...
authorKonrad Rosenbaum <konrad@silmor.de>
Sun, 17 Jul 2016 14:46:15 +0000 (16:46 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Sun, 17 Jul 2016 14:46:15 +0000 (16:46 +0200)
19 files changed:
.gitignore
qtbase/include/helper.h
qtbase/include/object.h
qtbase/src/helper.cpp
qtbase/src/helper_p.h [new file with mode: 0644]
qtbase/src/nullscript.cpp [deleted file]
qtbase/src/object.cpp
qtbase/wbase.pro
woc/qt/qt.pri
woc/qt/qtclass.cpp
woc/qt/qtclass.h
woc/qt/qtconst.h
woc/qt/qtctrans.cpp
woc/qt/qtctrans.h
woc/qt/qtfiles.qrc [deleted file]
woc/qt/qtout.cpp
woc/qt/qtout.h
woc/qt/qtstrans.cpp
woc/qt/qtstrans.h

index 512b7db..9ca99a4 100644 (file)
@@ -27,3 +27,4 @@ examples/clock/qtc/clock
 examples/clock/qts/clockserv
 examples/clock/qtc/clock.exe
 examples/clock/qts/clockserv.exe
+.qmake.stash
index df24b21..0a420c9 100644 (file)
@@ -19,6 +19,7 @@ class QDomNode;
 
 class WOLF_BASE_EXPORT WHelper:public QObject
 {
+       Q_OBJECT
        protected:
                /**helper for de-serializers: returns direct child elements with given tag name (necessary because QDomElement::elementsByTagName traverses all children)*/
                static QList<QDomElement>elementsByTagName(const QDomElement&,QString);
index 391baee..0ff7d0e 100644 (file)
@@ -8,27 +8,32 @@
 
 #include <QObject>
 #include <QList>
+#include <QCoreApplication>
 
 #include "nullable.h"
 #include "exception.h"
-#include "WHelper"
 
 class QDomElement;
 class QDomDocument;
-class QScriptValue;
-class QScriptEngine;
 
 /**base class of all web based objects*/
-class WOLF_BASE_EXPORT WObject:public WHelper
+class WOLF_BASE_EXPORT WObject
 {
+       Q_GADGET
        protected:
                WObject(){}
-               WObject(const WObject&):WHelper(){}
+               WObject(const WObject&){}
                WObject(const QDomElement&){}
                virtual ~WObject(){}
                virtual QDomElement toXml(QDomDocument&,QString name="Object");
                virtual WObject& operator=(const WObject&){return *this;}
                virtual void toXml(QDomDocument&,QDomElement&){}
+
+               /**helper for de-serializers: returns direct child elements with given tag name (necessary because QDomElement::elementsByTagName traverses all children)*/
+               static QList<QDomElement>elementsByTagName(const QDomElement&,QString);
+
+               /**helper for XML decoding: transforms string to boolean*/
+               bool str2bool(QString s);
 };
 
 /**this exception is thrown if the deserialization of an object fails on the XML parser level*/
@@ -46,19 +51,8 @@ class WOLF_BASE_EXPORT WDeserializerException:public WException
  wob(const QDomElement&w):wob ## Abstract(w){} \
  wob& operator=(const wob&w){wob ## Abstract::operator=(w);return *this;} \
  wob& operator=(const wob ## Abstract&w){wob ## Abstract::operator=(w);return *this;} \
- private:
-
-
-#define WOSCRIPT(wob) public: \
- static QScriptValue toScriptValue(QScriptEngine*,const wob &); \
- static void fromScriptValue(const QScriptValue&,wob &); \
- private:
+private:\
+ QString tr(const char*text,const char*comment=nullptr)const{return QCoreApplication::translate("" # wob ,text,comment);}
 
-#define WOSCRIPT_IMP(wob)
-/* QScriptValue wob::toScriptValue(QScriptEngine*engine,const wob &obj){\
-  return engine->newQObject(new wob (obj),QScriptEngine::ScriptOwnership);}\
- void wob::fromScriptValue(const QScriptValue&val,wob &obj){\
-  wob *xobj=qobject_cast< wob *>(val.toQObject());\
-  if(xobj!=0 && &obj!=xobj)obj = *xobj;}*/
 
 #endif
index 9023a52..28f3e7a 100644 (file)
@@ -5,28 +5,14 @@
 
 #include "WHelper"
 
-#include <QDomElement>
-#include <QDomNode>
+#include "helper_p.h"
 
 QList<QDomElement>WHelper::elementsByTagName(const QDomElement&root,QString tag)
 {
-       QDomNodeList cn=root.childNodes();
-       QList<QDomElement>ret;
-       for(int i=0;i<cn.size();i++){
-               QDomElement e=cn.at(i).toElement();
-               if(e.isNull())continue;
-               if(e.tagName()!=tag)continue;
-               ret<<e;
-       }
-       return ret;
+       return helper_elementsByTagName(root,tag);
 }
 
 bool WHelper::str2bool(QString s)
 {
-       s=s.trimmed().toLower();
-       bool ok;
-       int i=s.toInt(&ok);
-       if(ok)return i!=0;
-       if(s=="true" || s=="yes")return true;
-       else return false;
+       return helper_str2bool(s);
 }
diff --git a/qtbase/src/helper_p.h b/qtbase/src/helper_p.h
new file mode 100644 (file)
index 0000000..9a9481b
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef WOB_HELPER_PH
+#define WOB_HELPER_PH
+
+#include <QDomElement>
+#include <QDomNode>
+
+static inline QList<QDomElement>helper_elementsByTagName(const QDomElement&root,QString tag)
+{
+       QDomNodeList cn=root.childNodes();
+       QList<QDomElement>ret;
+       for(int i=0;i<cn.size();i++){
+               QDomElement e=cn.at(i).toElement();
+               if(e.isNull())continue;
+               if(e.tagName()!=tag)continue;
+               ret<<e;
+       }
+       return ret;
+}
+
+static inline bool helper_str2bool(QString s)
+{
+       s=s.trimmed().toLower();
+       bool ok;
+       int i=s.toInt(&ok);
+       if(ok)return i!=0;
+       if(s=="true" || s=="yes")return true;
+       else return false;
+}
+
+
+#endif
diff --git a/qtbase/src/nullscript.cpp b/qtbase/src/nullscript.cpp
deleted file mode 100644 (file)
index ce4a045..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-//start: nullscript.cpp
-//
-//this adapts PACK nullable values to be usable with QtScript
-//
-//currently this file is copied verbatim into the generated
-//interface code, in the future it may be included there 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>();
-}
-
-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);
-}
-
-
-//end: nullscript.cpp
index 490c017..e2a8a41 100644 (file)
@@ -15,6 +15,19 @@ QDomElement WObject::toXml(QDomDocument&doc,QString name)
        return doc.createElement(name);
 }
 
+#include "helper_p.h"
+
+QList<QDomElement>WObject::elementsByTagName(const QDomElement&root,QString tag)
+{
+       return helper_elementsByTagName(root,tag);
+}
+
+bool WObject::str2bool(QString s)
+{
+       return helper_str2bool(s);
+}
+
+
 static inline bool w(bool b){qDebug()<<"registering"<<b;return b;}
 
 static int itype0=
@@ -28,6 +41,7 @@ static int itype0=
        qRegisterMetaType<Nullable<bool> >();
 
 static bool btype0=
+       //NULLABLE
        //String/bytes to self
        QMetaType::registerConverter<Nullable<QString>,QString>(&Nullable<QString>::valueOrDefault)|
        QMetaType::registerConverter<Nullable<QByteArray>,QByteArray>(&Nullable<QByteArray>::valueOrDefault)|
@@ -54,4 +68,13 @@ static bool btype0=
        QMetaType::registerConverter<Nullable<qint64>,QString>([](Nullable<qint64> v)->QString{return QString::number(v.valueOrDefault());})|
        QMetaType::registerConverter<Nullable<quint32>,QString>([](Nullable<quint32> v)->QString{return QString::number(v.valueOrDefault());})|
        QMetaType::registerConverter<Nullable<quint64>,QString>([](Nullable<quint64> v)->QString{return QString::number(v.valueOrDefault());})|
+       //LIST
+       //string is predefined
+       //int/bool
+       QMetaType::registerConverter<QList<bool>,QVariantList>([](const QList<bool>&n){QVariantList r;for(auto v:n)r<<QVariant::fromValue(v);return r;})|
+       QMetaType::registerConverter<QList<qint32>,QVariantList>([](const QList<qint32>&n){QVariantList r;for(auto v:n)r<<QVariant::fromValue(v);return r;})|
+       QMetaType::registerConverter<QList<qint64>,QVariantList>([](const QList<qint64>&n){QVariantList r;for(auto v:n)r<<QVariant::fromValue(v);return r;})|
+       QMetaType::registerConverter<QList<quint32>,QVariantList>([](const QList<quint32>&n){QVariantList r;for(auto v:n)r<<QVariant::fromValue(v);return r;})|
+       QMetaType::registerConverter<QList<quint64>,QVariantList>([](const QList<quint64>&n){QVariantList r;for(auto v:n)r<<QVariant::fromValue(v);return r;})|
+       QMetaType::registerConverter<QList<int>,QVariantList>([](const QList<int>&n){QVariantList r;for(auto v:n)r<<QVariant::fromValue(v);return r;})|
        true;
index 22ccf7a..a63461e 100644 (file)
@@ -28,7 +28,8 @@ HEADERS += \
        include/server.h \
        src/server_p.h \
        src/wobnam.h \
-       src/wobnam_p.h
+       src/wobnam_p.h \
+       src/helper_p.h
 
 SOURCES += \
        src/object.cpp \
index e3c4ebd..b64e5cf 100644 (file)
@@ -12,6 +12,4 @@ HEADERS+= \
        qt/qtctrans.h \
        qt/qtstrans.cpp
 
-RESOURCES += qt/qtfiles.qrc
-
-INCLUDEPATH += qt
\ No newline at end of file
+INCLUDEPATH += qt
index d22c98b..e73f5d2 100644 (file)
@@ -60,7 +60,7 @@ void WocQtClass::newClass(const WocClass&cls)
        //class declaration
        QString cnb=cls.baseClass(m_parent->languageSpec(),m_parent->namePrefix()+"O");
        hcd+=doxyFormat(cls.docStrings());
-       hcd+="class "+m_parent->exportSymbol()+" "+cna+":public "+cnb+"\n{\n  Q_OBJECT\n";
+       hcd+="class "+m_parent->exportSymbol()+" "+cna+":public "+cnb+"\n{\n  Q_GADGET\n";
        hdr.write(hcd.toLatin1());
        
        //enums
@@ -75,17 +75,16 @@ void WocQtClass::newClass(const WocClass&cls)
        //deserializer (constructor)
        classDeserializer(cls,hdr,src,cna);
        
-       //scripting
-       classScripting(cls,hdr,src,cna,cn);
-       
        //meta types
        m_aux+="Q_DECLARE_METATYPE("+cna+")\n";
        m_aux+="Q_DECLARE_METATYPE(QList<"+cna+">)\n";
        m_aux+="Q_DECLARE_METATYPE(Nullable<"+cna+">)\n";
        scd="static int class_metatypeid=";
-       scd+="qRegisterMetaType<"+cna+">()+";
-       scd+="qRegisterMetaType<QList<"+cna+"> >()+";
-       scd+="qRegisterMetaType<Nullable<"+cna+"> >();\n";
+       scd+="\tqRegisterMetaType<"+cna+">()+";
+       scd+="\tqRegisterMetaType<QList<"+cna+"> >()+";
+       scd+="\tqRegisterMetaType<Nullable<"+cna+"> >();\n";
+       scd+="static bool class_converter=QMetaType::registerConverter<Nullable<"+cna+">,"+cna+">([](const Nullable<"+cna+">&n){return n.value();})|\n";
+       scd+="\tQMetaType::registerConverter<QList<"+cna+">,QVariantList>([](const QList<"+cna+">&n){QVariantList r;for(auto v:n)r<<QVariant::fromValue(v);return r;});\n";
        
        //end of class, aux stuff, meta types
        hdr.write(QByteArray("\n};\n"));
@@ -97,39 +96,6 @@ void WocQtClass::newClass(const WocClass&cls)
        src.write(QByteArray(SRCEND).replace("%",cna.toLatin1()));
 }
 
-void WocQtClass::classScripting(const WocClass& cls, MFile& hdr, MFile& src, QString cna,QString cn)
-{
-       Q_UNUSED(cna);Q_UNUSED(hdr);Q_UNUSED(cls);
-       if(!m_parent->doGenerateScripting())return;
-       //converters
-       QString hcd,scd;
-       if(cna==cn){
-               hcd+="  public:\n";
-               hcd+="\tstatic QScriptValue toScriptValue(QScriptEngine*,const "+cna+"&);\n";
-               hcd+="\tstatic void fromScriptValue(const QScriptValue&,"+cna+"&);\n";
-       }else{
-               scd+="#include \""+cn+"\"\n";
-       }
-       scd+="#include <QScriptValue>\n";
-       scd+="#include <QScriptEngine>\n";
-       scd+=doxyFormat("Convert "+cn+" to a value usable with the Qt script engine.");
-       scd+="QScriptValue "+cn+"::toScriptValue(QScriptEngine*engine,const "+cn+"&obj)\n{\n";
-       scd+="\treturn engine->newQObject(new "+cn+"(obj),QScriptEngine::ScriptOwnership);\n}\n";
-       scd+=doxyFormat("Convert from a Qt script engine value back to a "+cn+".");
-       scd+="void "+cn+"::fromScriptValue(const QScriptValue&val,"+cn+"&obj)\n{\n";
-       scd+="\t"+cn+"*xobj=qobject_cast<"+cn+"*>(val.toQObject());\n";
-       scd+="\tif(xobj!=0 && &obj!=xobj)obj = *xobj;\n}\n";
-       hdr.write(hcd.toLatin1());
-       src.write(scd.toLatin1());
-       //scripting registry
-       m_parent->addScriptInit(
-         "\tgval.setProperty(\""+cn+"\",engine->newQMetaObject(&"+cn+"::staticMetaObject));\n"
-         "\tqScriptRegisterMetaType(engine,"+cn+"::toScriptValue,"+cn+"::fromScriptValue);\n"
-         "\tqScriptRegisterSequenceMetaType<QList<"+cn+"> >(engine);\n"
-       );
-}
-
-
 void WocQtClass::classEnums(const WocClass&cls,MFile&hdr,MFile&src,QString cn)
 {
        QStringList k=cls.enumTypes();
index 97f0403..8ff5a25 100644 (file)
@@ -37,8 +37,6 @@ class WocQtClass:public QObject
                void classDeserializer(const WocClass&,MFile&,MFile&,QString);
                /**helper: generate serializers*/
                void classSerializers(const WocClass&,MFile&,MFile&,QString);
-               ///helper: generate scripting stuff
-               void classScripting(const WocClass&,MFile&,MFile&,QString,QString);
        signals:
                ///emitted if something is wrong, aborts the processor
                void errorFound();
index a46bb49..5162ffb 100644 (file)
@@ -21,7 +21,8 @@ static const QByteArray SRCSTART=
        "//DO NOT EDIT THIS FILE DIRECTLY, USE THE XML SOURCE!\n"
        "#include \"%\"\n"
        "#include <QDomElement>\n"
-       "#include <QDomDocument>\n";
+       "#include <QDomDocument>\n"
+       "#include <QVariant>\n";
 //end section of all source files
 static const QByteArray SRCEND="\n//END OF AUTOMATICALLY GENERATED FILE\n";
 
index 01cfac6..3a8c73f 100644 (file)
@@ -113,9 +113,6 @@ void WocQtClientTransaction::newTransaction(const WocTransaction&trn)
        //create getters
        genGetters(ct);
        
-       //create scripting
-       genScripting(ct);
-        
         //create log control
         genLogCtrl(ct);
        
@@ -304,31 +301,6 @@ void WocQtClientTransaction::genGetters(QtCTrans& ct)
        }
 }
 
-void WocQtClientTransaction::genScripting(QtCTrans& ct)
-{
-       if(!m_parent->doGenerateScripting())return;
-       //converters between transaction and script values
-       ct.hdi+="class QScriptValue;\n";
-       ct.hdi+="class QScriptEngine;\n";
-       ct.sri+="#include <QScriptValue>\n";
-       ct.sri+="#include <QScriptEngine>\n";
-       ct.hcd+="\t/// Wraps the transaction so it can be used from scripts.\n";
-       ct.hcd+="\tstatic QScriptValue toScriptValue(QScriptEngine*,const "+ct.cn+"&);\n";
-       ct.hcd+="\t/// Unwraps the transaction in the script value, so it can be used in C++ again.\n";
-       ct.hcd+="\tstatic void fromScriptValue(const QScriptValue&,"+ct.cn+"&);\n";
-       ct.scd+="QScriptValue "+ct.cn+"::toScriptValue(QScriptEngine*engine,const "+ct.cn+"&obj)\n{\n";
-       ct.scd+="\treturn engine->newQObject(new "+ct.cn+"(obj),QScriptEngine::ScriptOwnership);\n}\n";
-       ct.scd+="void "+ct.cn+"::fromScriptValue(const QScriptValue&val,"+ct.cn+"&obj)\n{\n";
-       ct.scd+="\t"+ct.cn+"*xobj=qobject_cast<"+ct.cn+"*>(val.toQObject());\n";
-       ct.scd+="\tif(xobj!=0 && &obj!=xobj)obj = *xobj;\n}\n";
-       //add to engine
-       m_parent->addScriptInit(
-        "\t{QScriptValue mo=engine->newQMetaObject(&"+ct.cn+"::staticMetaObject);\n"
-        "\tgval.setProperty(\""+ct.cn+"\",mo);\n"
-        "\tqScriptRegisterMetaType(engine,"+ct.cn+"::toScriptValue,"+ct.cn+"::fromScriptValue);}\n"
-       );
-}
-
 void WocQtClientTransaction::genLogCtrl(QtCTrans& ct)
 {
         if(ct.trn.logMode()==WocTransaction::LogAll)return;
@@ -518,7 +490,6 @@ void WocQtClientTransaction::trnList()
        code+="qRegisterMetaType<QList<"+m_parent->ifaceClassName()+"::RightList> >();\n";
        m_parent->addPostIface("Q_DECLARE_METATYPE("+m_parent->ifaceClassName()+"::RightList)\n");
        m_parent->addPostIface("Q_DECLARE_METATYPE(QList<"+ m_parent->ifaceClassName()+ "::RightList>)\n");
-       m_parent->addScriptInit("\tqScriptRegisterSequenceMetaType<QList<RightList> >(engine);\n");
        code+="QString "+m_parent->ifaceClassName()+"::rightToString(Right r)\n{\n\tswitch(r){\n";
        for(int i=0;i<r.size();i++)
                code+="\t\tcase R"+r[i]+":return \""+r[i]+"\";\n";
index 5c943bf..8d9849b 100644 (file)
@@ -43,8 +43,6 @@ class WocQtClientTransaction:public WocQtTransaction
                void genQuery(QtCTrans&);
                ///helper: generate getter methods
                void genGetters(QtCTrans&);
-               ///helper: generate QtScript glue code
-               void genScripting(QtCTrans&);
                 ///helper: generate log control
                 void genLogCtrl(QtCTrans&);
                ///helper: initialize data in the transaction wrapper
diff --git a/woc/qt/qtfiles.qrc b/woc/qt/qtfiles.qrc
deleted file mode 100644 (file)
index 05bb51c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE RCC>
-<!-- 
-// Copyright (C) 2009-2011 by Konrad Rosenbaum <konrad@silmor.de>
-// protected under the GNU GPL version 3 or at your option any newer.
-// See COPYING.GPL file that comes with this distribution.
- -->
-<RCC version="1.0">
-    <qresource>
-        <file alias="nullscript.cpp">../../qtbase/src/nullscript.cpp</file>
-    </qresource>
-</RCC>
index c7f95cc..68b2536 100644 (file)
@@ -27,7 +27,6 @@ WocQtOut::WocQtOut(QDomElement&el)
        m_prefix=el.attribute("classPrefix","Wob");
        m_cprefix=el.attribute("shareObjects",m_prefix);
        m_transbase=el.attribute("transactionBase","WTransaction");
-       m_genscript=str2bool(el.attribute("scriptable","0"));
         m_export=str2bool(el.attribute("enableExport","0"));
        //get/create directory
        QDir d(m_basedir+"/"+m_subdir);
@@ -65,8 +64,6 @@ WocQtOut::WocQtOut(QDomElement&el)
        m_iface.write(QByteArray("#include \"WInterface\"\n"));
        m_iface.write(QByteArray("#include <QStringList>\n"));
         m_iface.write(exportLines());
-       if(m_genscript)
-               m_iface.write(QByteArray("class QScriptEngine;\n"));
        addIfaceHeaderClass(doxyFormat(pn+" interface class."));
        addIfaceHeaderClass(QString("class "+exportSymbol()+" "+ifaceClassName()+":public WInterface\n{\n Q_OBJECT\n"));
        addIfaceHeaderClass(QString(" public:\n  "+ifaceClassName()+"(QString name=\""+pn+"\"):WInterface(name){}\n"));
@@ -89,9 +86,6 @@ WocQtOut::WocQtOut(QDomElement&el)
        addIfaceHeaderClass("  Q_INVOKABLE QString wocVersionInfo(WOb::VersionInfo)const;\n");
        m_ifacecpp.write(QString("QString "+ifaceClassName()+"::wocVersionInfo(WOb::VersionInfo vi)const{return WOCcopied_versionInfo(vi);}\n").toLatin1());
        
-       //init scripting
-       initScripting();
-       
        //create all includer
        m_hdr.setFileName(m_basedir+"/"+m_subdir+"/"+m_prefix+"IncludeAll");
        if(!m_hdr.open(QIODevice::WriteOnly|QIODevice::Truncate)){
@@ -110,13 +104,6 @@ void WocQtOut::finalize()
        if(qclass)qclass->finalize();
        if(qtable)qtable->finalize();
        if(qtrans)qtrans->finalize();
-       //finish scripting stuff
-       if(m_genscript){
-               addIfaceHeaderClass("  /// use this call to initialize a script engine that needs access to the interface\n");
-               addIfaceHeaderClass("  void initScriptEngine(QScriptEngine*);\n");
-               m_scriptcode+="}\n\n";
-               m_ifacecpp.write(m_scriptcode.toLatin1());
-       }
        //generate versionInfo
        initVersionH();
        //add interface class
@@ -270,25 +257,6 @@ WocQtTransaction::WocQtTransaction(WocQtOut*p)
        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::fromLatin1(nscr.readAll());
-       m_scriptcode+="\n\n";
-       nscr.close();
-       //initializer routine
-       m_scriptcode+="void "+ifaceClassName()+"::initScriptEngine(QScriptEngine*engine)\n{\n";
-       m_scriptcode+="\tQScriptValue gval=engine->newObject();\n";
-       m_scriptcode+="\tengine->globalObject().setProperty(\"wob\",gval);\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";
-}
-
 #ifndef NO_PACK_VERSION_H
 #include "../../vinfo/staticVersion.h"
 #endif
index 16a277f..9515317 100644 (file)
@@ -96,10 +96,6 @@ class WocQtOut:public WocOutput
                void addPostIface(QString);
                /**helper: returns the class name of the interface class*/
                QString ifaceClassName()const{return m_prefix+"Interface";}
-               /**helper: adds a line to the script initializer; this is ignored if scripting is inactive*/
-               void addScriptInit(QString s){m_scriptcode+=s;}
-               ///helper: returns true if sub-classes are supposed to create scripting code
-               inline bool doGenerateScripting()const{return m_genscript;}
                
                ///returns the class name prefix configured for this output
                inline QString namePrefix()const{return m_prefix;}
@@ -122,15 +118,13 @@ class WocQtOut:public WocOutput
                 QString exportSymbol()const;
                
        private:
-               ///internal: init the scripting env
-               void initScripting();
                ///internal: generate the static header for version info
                void initVersionH();
                
        private:
-               QString m_basedir,m_subdir,m_prefix,m_cprefix,m_transbase,m_postiface,m_scriptcode;
+               QString m_basedir,m_subdir,m_prefix,m_cprefix,m_transbase,m_postiface;
                 mutable QString m_exportsym;
-               bool m_clean,m_genscript,m_export;
+               bool m_clean,m_export;
                MFile m_pri,m_iface,m_ifacecpp,m_hdr;
                QString m_iface_prefix,m_iface_class;
        protected:
index b131a7b..0e7df8c 100644 (file)
@@ -97,9 +97,6 @@ void WocQtServerTransaction::newTransaction(const WocTransaction&trn)
        genGetters(ct);
        genSetters(ct);
        
-       //create scripting
-       genScripting(ct);
-        
         //create log control
         genLogCtrl(ct);
        
@@ -269,29 +266,6 @@ void WocQtServerTransaction::genSetters(QtSTrans& ct)
        }
 }
 
-void WocQtServerTransaction::genScripting(QtSTrans& ct)
-{
-       if(!m_parent->doGenerateScripting())return;
-       //converters between transaction and script values
-       ct.hdi+="class QScriptValue;\n";
-       ct.hdi+="class QScriptEngine;\n";
-       ct.sri+="#include <QScriptValue>\n";
-       ct.sri+="#include <QScriptEngine>\n";
-       ct.hcd+="\tstatic QScriptValue toScriptValue(QScriptEngine*,const "+ct.cn+"&);\n";
-       ct.hcd+="\tstatic void fromScriptValue(const QScriptValue&,"+ct.cn+"&);\n";
-       ct.scd+="QScriptValue "+ct.cn+"::toScriptValue(QScriptEngine*engine,const "+ct.cn+"&obj)\n{\n";
-       ct.scd+="\treturn engine->newQObject(new "+ct.cn+"(obj),QScriptEngine::ScriptOwnership);\n}\n";
-       ct.scd+="void "+ct.cn+"::fromScriptValue(const QScriptValue&val,"+ct.cn+"&obj)\n{\n";
-       ct.scd+="\t"+ct.cn+"*xobj=qobject_cast<"+ct.cn+"*>(val.toQObject());\n";
-       ct.scd+="\tif(xobj!=0 && &obj!=xobj)obj = *xobj;\n}\n";
-       //add to engine
-       m_parent->addScriptInit(
-        "\t{QScriptValue mo=engine->newQMetaObject(&"+ct.cn+"::staticMetaObject);\n"
-        "\tgval.setProperty(\""+ct.cn+"\",mo);\n"
-        "\tqScriptRegisterMetaType(engine,"+ct.cn+"::toScriptValue,"+ct.cn+"::fromScriptValue);}\n"
-       );
-}
-
 void WocQtServerTransaction::genLogCtrl(QtSTrans& ct)
 {
         if(ct.trn.logMode()==WocTransaction::LogAll)return;
@@ -464,7 +438,6 @@ void WocQtServerTransaction::trnList()
        code+="qRegisterMetaType<QList<"+m_parent->ifaceClassName()+"::RightList> >();\n";
        m_parent->addPostIface("Q_DECLARE_METATYPE("+m_parent->ifaceClassName()+"::RightList)\n");
        m_parent->addPostIface("Q_DECLARE_METATYPE(QList<"+ m_parent->ifaceClassName()+ "::RightList>)\n");
-       m_parent->addScriptInit("\tqScriptRegisterSequenceMetaType<QList<RightList> >(engine);\n");
        
        //implement rights
        code+="QString "+m_parent->ifaceClassName()+"::rightToString(Right r)\n{\n\tswitch(r){\n";
index 656a59d..ab5d1cb 100644 (file)
@@ -40,8 +40,6 @@ class WocQtServerTransaction:public WocQtTransaction
                void genGetters(QtSTrans&);
                ///helper: generate setter methods
                void genSetters(QtSTrans&);
-               ///helper: generate QtScript glue code
-               void genScripting(QtSTrans&);
                 ///helper: generate log control
                 void genLogCtrl(QtSTrans&);
 };