add stubs for qt/server and php/client
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Tue, 27 Jul 2010 20:31:55 +0000 (20:31 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Tue, 27 Jul 2010 20:31:55 +0000 (20:31 +0000)
make lang differences for them
refactor php transaction generator

git-svn-id: https://silmor.de/svn/softmagic/pack/trunk@575 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

23 files changed:
examples/clock/clock.wolf
woc/phpclass.cpp
woc/phpconst.h
woc/phpctrans.cpp
woc/phpctrans.h
woc/phpdb.cpp
woc/phpout.cpp
woc/phpout.h
woc/phpstrans.cpp
woc/phpstrans.h
woc/phptrans.cpp [new file with mode: 0644]
woc/phptrans.h [new file with mode: 0644]
woc/procclass.cpp
woc/processor.cpp
woc/proctable.cpp
woc/proctrans.cpp
woc/qtclass.cpp
woc/qtconst.h
woc/qtdb.cpp
woc/qtout.cpp
woc/qtout.h
woc/qtstrans.cpp
woc/woc.pro

index 56d4cdb..6594ed4 100644 (file)
@@ -7,6 +7,8 @@
 
        <!-- configure output -->
        <QtClientOutput sourceDir="qtc" subDir="wob" priInclude="wob.pri" classPrefix="C" clean="yes" transactionBase="WTransaction"/>
+       <QtServerOutput sourceDir="qts" subDir="wob" priInclude="wob.pri" classPrefix="C" clean="yes" transactionBase="WTransaction"/>
+       <PHPClientOutput sourceDir="phpc" subDir="wob" extension=".php" clean="yes" transactionBase="WobTransaction"/>
        <PHPServerOutput sourceDir="phps" subDir="wob" extension=".php" clean="yes" transactionBase="WobTransaction"/>
        <HtmlOutput sourceDir="." subDir="html" clean="yes"/>
        
@@ -25,8 +27,7 @@
        
        <!-- transaction -->
        <Transaction name="GetTime" mode="open">
-               <Input>
-               </Input>
+               <Input/>
                <Call lang="php" method="Session::login($this);"/>
                <Output>
                        <Var name="time" type="Time"/>
index 1019988..d7bb590 100644 (file)
@@ -470,7 +470,7 @@ QString WocPHPClass::classMappings(const WocClass&cls)
                QMap<QString,QString>map=cls.mapping(k[i]);
                QStringList mapk=cls.mappingProperties(k[i]);
                for(int j=0;j<mapk.size();j++){
-                       QString meth=cls.mapMethod(k[i],mapk[j],"php");
+                       QString meth=cls.mapMethod(k[i],mapk[j],m_lang);
                        if(meth!="")code+="\t$data->prop_"+mapk[j]+"="+meth+";\n";
                        else code+="\t$data->prop_"+mapk[j]+"=$table->"+map[mapk[j]]+";\n";
                }
@@ -483,7 +483,7 @@ QString WocPHPClass::classMappings(const WocClass&cls)
                code+="public function toTable"+k[i]+"(&$table){\n";
                for(int j=0;j<mapk.size();j++){
                        //do not reverse translate method conversions
-                       QString meth=cls.mapMethod(k[i],mapk[j],"php").trimmed();
+                       QString meth=cls.mapMethod(k[i],mapk[j],m_lang).trimmed();
                        if(meth!="")continue;
                        //check that column exists
                        if(tab.hasColumn(map[mapk[j]])){
index 718dac7..d7b3036 100644 (file)
@@ -28,6 +28,7 @@ static const QByteArray PHPEND("\n//END OF AUTOGENERATED FILE\n?>");
 #define abstractClassName m_parent->abstractClassName
 #define trnClassName   m_parent->trnClassName
 #define addLoad                m_parent->addLoad
+#define m_lang         m_parent->m_lang
 #endif
 
 #endif
index 3719a5e..53fc835 100644 (file)
 
 #include "phpconst.h"
 
-static const QByteArray TRANSACTCLASS("class WobTransaction extends WobTransactionBase\n{\n");
-static const QByteArray TRANSACTSTART("  static public function handle(){\n    try{switch(WobTransactionBase::getTransactionName()){\n");
-static const QByteArray TRANSACTEND("\tdefault:WobTransactionBase::noSuchTransaction();break;\n    }}catch(WobTransactionError $er){$er->printXml();}\n  }\n");
-
-WocPHPClientTransaction::WocPHPClientTransaction(WocPHPOut*p ): WocPHPTransaction(p)
-{
-       //create Transaction file
-       m_transact.setFileName(m_basedir+"/"+m_subdir+"/transaction"+m_fileext);
-       if(!m_transact.open(QIODevice::ReadWrite|QIODevice::Truncate)){
-               qDebug("Error: PHP Server Generator - cannot create transaction processor file.");
-               emit errorFound();
-               return;
-       }
-       m_transact.write(PHPSTART);
-       m_transact.write(TRANSACTCLASS);
-       transInfo();
-       m_transact.write(TRANSACTSTART);
-       addLoad("WobTransaction","transaction");
-}
-
-void WocPHPClientTransaction::transInfo()
+WocPHPClientTransaction::WocPHPClientTransaction(WocPHPOut*p )
+       :WocPHPTransaction(p)
 {
-       WocProcessor*woc=WocProcessor::instance();
-       m_transact.write(QString("  static public function commVersion(){return \""+woc->verComm()+"\";}\n").toAscii());
-       m_transact.write(QString("  static public function needCommVersion(){return \""+woc->verNeedComm()+"\";}\n").toAscii());
-       m_transact.write(QString("  static public function version(){return \""+woc->verHR()+"\";}\n").toAscii());
-       m_transact.write(QString("  static public function svnVersion(){return \""+woc->svnRevision()+"\";}\n\n").toAscii());
-       m_transact.write(QString("  static public function svnRepositoryRoot(){return \""+woc->svnRepositoryRoot()+"\";}\n\n").toAscii());
-       m_transact.write(QString("  static public function svnRepositoryUrl(){return \""+woc->svnRepositoryUrl()+"\";}\n\n").toAscii());
 }
 
-void WocPHPClientTransaction::transInfo2()
-{
-       WocProcessor*woc=WocProcessor::instance();
-       //transaction names
-       QString code="  static public function transactionNames(){\n\treturn array(";
-       QStringList tns=woc->transactionNames();
-       for(int i=0;i<tns.size();i++){
-               if(i)code+=",";
-               code+="\n\t\ttranslate(\"_TransactionNames\",\""+tns[i]+"\")";
-       }
-       code+=");\n  }\n";
-       //privilege names
-       code+="static public function privilegeNames(){\n\treturn array(";
-       QStringList priv=woc->privilegeNames();
-       for(int i=0;i<priv.size();i++){
-               if(i)code+=",\n\t\t";else code+="\n\t\t";
-               code+="translate(\"_PrivilegeNames\",\""+priv[i]+"\")";
-       }
-       code+="\n\t);\n}\n";
-       
-       m_transact.write(code.toAscii());
-}
-
-void WocPHPClientTransaction::finalize()
-{
-       if(m_transact.isOpen()){
-               m_transact.write(TRANSACTEND);
-               transInfo2();
-               m_transact.write("};\n");
-               m_transact.write(PHPEND);
-               m_transact.close();
-       }
-}
-
-
-void WocPHPClientTransaction::newTransaction(const WocTransaction&trn)
+QString WocPHPClientTransaction::trnHandlers(const WocTransaction&trn)
 {
        //create file
        QString cn=trnClassName(trn);
        QString fn="wtr_"+trn.name();
-       addLoad(cn,fn);
-       fn=m_subdir+"/"+fn+m_fileext;
-       QFile tf(m_basedir+"/"+fn);
-       if(!tf.open(QIODevice::ReadWrite|QIODevice::Truncate)){
-               qDebug("Error: cannot create PHP object file %s.",fn.toAscii().data());
-               emit errorFound();
-               return;
-       }
-       tf.write(PHPSTART);
-       
+
        ////
        //generate code
-       QString code="/* TRANSLATOR "+cn+" */\nclass "+cn+" extends "+m_transbase+"{\n";
-       //constructor
-       code+=trnConstruct(trn);
-       tf.write(code.toAscii());
+       QString code;
        
        //request handler:
        code="public function handleRequest(){\n";
@@ -135,9 +62,9 @@ void WocPHPClientTransaction::newTransaction(const WocTransaction&trn)
        code+=trnInput(trn);
        
        //call
-       if(trn.hasCall("php")){
+       if(trn.hasCall(m_lang)){
                code+="\t/*call actual functionality:*/\n";
-               code+="\ttry{"+trn.callFunction("php")+"}catch(Exception $e){$this->handleException($e);}\n";
+               code+="\ttry{"+trn.callFunction(m_lang)+"}catch(Exception $e){$this->handleException($e);}\n";
        }else{
                code+="\t/*normally here would be the PHP call, but it is missing from the config*/\n";
                code+="\t$this->abortNotImplemented();\nreturn;\n";
@@ -148,68 +75,7 @@ void WocPHPClientTransaction::newTransaction(const WocTransaction&trn)
        code+=trnOutput(trn);
        
        code+="\t$this->commitTransaction();\n}\n";
-       tf.write(code.toAscii());
-       
-       //getters/setters
-       tf.write(trnGetSet(trn).toAscii());
-       
-       //direct execution
-       tf.write(trnExecute(trn).toAscii());
-       
-       //privileges
-       tf.write(trnPrivileges(trn).toAscii());
-       
-       //end
-       code="\n//end of class\n}\n";
-       tf.write(code.toAscii());
-       tf.write(PHPEND);
-       tf.close();
-       
-       ////
-       //generate loader code
-       code="\tcase \""+trn.name()+"\":$trn=new "+cn+";$trn->handleRequest();break;\n";
-       m_transact.write(code.toAscii());
-}
-
-QString WocPHPClientTransaction::trnConstruct(const WocTransaction&trn)
-{
-       QString code="public function __construct(){\n\tparent::__construct();\n";
-       code+="\t$this->ainput=array(";
-       QStringList sl=trn.inputNames();
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>";
-               if(trn.isListType(trn.inputType(sl[i])))code+="array()";
-               else code+="false";
-       }
-       code+=");\n";
-       code+="\t$this->tinput=array(";
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>\"";
-               code+=trn.inputType(sl[i]);
-               code+="\"";
-       }
-       code+=");\n";
-       
        
-       code+="\t$this->aoutput=array(";
-       sl=trn.outputNames();
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>";
-               if(trn.isListType(trn.outputType(sl[i])))code+="array()";
-               else code+="false";
-       }
-       code+=");\n";
-       code+="\t$this->toutput=array(";
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>\"";
-               code+=trn.outputType(sl[i]);
-               code+="\"";
-       }
-       code+=");\n}\n";
        return code;
 }
 
@@ -303,117 +169,3 @@ QString WocPHPClientTransaction::trnOutput(const WocTransaction&trn)
        code+="\t/*end of output*/\n";
        return code;
 }
-
-QString WocPHPClientTransaction::trnGetSet(const WocTransaction&trn)
-{
-       QString code;
-       //getters
-       QStringList sl=trn.inputNames();
-       for(int i=0;i<sl.size();i++){
-               code+="public function get"+sl[i]+"(){return $this->ainput[\""+sl[i]+"\"];}\n";
-       }
-       //setters
-       sl=trn.outputNames();
-       for(int i=0;i<sl.size();i++){
-               code+="public function result"+sl[i]+"(){return $this->aoutput[\""+sl[i]+"\"];}\n";
-               QString add;
-               QString t=trn.outputType(sl[i]);
-               code+="public function set"+sl[i]+"($v){\n";
-               if(trn.isListType(t)){
-                       add="public function add"+sl[i]+"($vv){\n";
-                       code+="\t$this->aoutput[\""+sl[i]+"\"]=array();\n";
-                       code+="\tforeach($v as $vv){\n";
-                       if(trn.isIntType(t)){
-                               code+="\t\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
-                               add+="\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
-                       }else
-                       if(trn.isBoolType(t)){
-                               code+="\t\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
-                               add+="\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
-                       }else
-                       if(trn.isObjectType(t)){
-                               code+="\t\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
-                               add+="\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
-                       }else{
-                               code+="\t\t$this->aoutput[\""+sl[i]+"\"][]=\"\".$vv;\n";
-                               add+="\t$this->aoutput[\""+sl[i]+"\"][]=\"\".$vv;\n";
-                       }
-                       code+="\t}\n";
-                       add+="}\n";
-               }else{
-                       if(trn.isIntType(t)){
-                               code+="\tif(is_numeric($v))$this->aoutput[\""+sl[i]+"\"]=$v+0;\n";
-                       }else
-                       if(trn.isBoolType(t)){
-                               code+="\tif(is_bool($v))$this->aoutput[\""+sl[i]+"\"]=$v!=false;\n";
-                       }else
-                       if(trn.isObjectType(t)){
-                               code+="\tif(is_a($v,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"]=$v;\n";
-                       }else{
-                               code+="\t$this->aoutput[\""+sl[i]+"\"]=\"\".$v;\n";
-                       }
-               }
-               code+="}\n"+add;
-       }
-       
-       
-       return code;
-}
-
-QString WocPHPClientTransaction::trnExecute(const WocTransaction&trn)
-{
-       //the execute function is split into a static and non-static part,
-       //since the code from the wolf file assumes to be inside the instance
-       QStringList in=trn.inputNames();
-       //static wrapper for execution
-       QString code="static public function execute(";
-       for(int i=0;i<in.size();i++){
-               if(i)code+=",";
-               code+="$"+in[i];
-       }
-       code+=")\n{\n\t$inst=new "+trnClassName(trn)+";\n";
-       code+="\t$inst->do_execute(";
-       for(int i=0;i<in.size();i++){
-               if(i)code+=",";
-               code+="$"+in[i];
-       }
-       code+=");\n";
-       code+="\treturn $inst;\n}\n";
-       //actual non-static implementation
-       code+="private function do_execute(";
-       for(int i=0;i<in.size();i++){
-               if(i)code+=",";
-               code+="$"+in[i];
-       }
-       code+=")\n{\n";
-       for(int i=0;i<in.size();i++)
-               code+="\t$this->ainput[\""+in[i]+"\"]=$"+in[i]+";\n";
-       code+="\tself::$running=\""+trn.name()+"\";\n";
-       code+="\ttry{"+trn.callFunction("php")+"}\n\tcatch(Exception $ex){\n";
-       code+="\t\tself::$running=\"\";\n\t\t$this->handleException($ex);\n\t}\n";
-       code+="\tself::$running=\"\";\n}\n";
-       return code;
-}
-
-QString WocPHPClientTransaction::trnPrivileges(const WocTransaction&trn)
-{
-       //privilege inventory
-       QString code;
-       code+="static public function privileges(){\n\treturn array(";
-       QString cn=trnClassName(trn);
-       QStringList priv=trn.privileges();
-       for(int i=0;i<priv.size();i++){
-               if(i)code+=",\n\t\t";else code+="\n\t\t";
-               code+="\""+priv[i]+"\"";
-       }
-       code+="\n\t);\n}\n";
-       //constants for use by custom code
-       for(int i=0;i<priv.size();i++)
-               code+="const Priv_"+priv[i]+"=\""+priv[i]+"\";\n";
-       //check method
-       code+="public function havePrivilege($priv){\n";
-       code+="\tif(!in_array($priv,self::privileges()))return false;\n";
-       code+="\treturn $this->isAuthorized(\""+trn.name()+":\".$priv);\n}\n";
-       
-       return code;
-}
index 546144e..0e1a700 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef WOC_PHPOUT_CTRANS_H
 #define WOC_PHPOUT_CTRANS_H
 
-#include "phpout.h"
+#include "phptrans.h"
 
 
 /**generates output for a PHP server side*/
@@ -22,30 +22,13 @@ class WocPHPClientTransaction:public WocPHPTransaction
        public:
                /**initializes the output object*/
                WocPHPClientTransaction(WocPHPOut*);
-       protected:
-               /**writes any last words after parsing finished*/
-               virtual void finalize();
-               /**creates a transaction*/
-               virtual void newTransaction(const WocTransaction&);
        private:
-
-               /**helper: create info functions (mainly version info) at the start*/
-               void transInfo();
-               /**helper: create info functions (mainly version info) at the end*/
-               void transInfo2();
-               
                /**helper: create transaction constructor*/
-               QString trnConstruct(const WocTransaction&);
+               QString trnHandlers(const WocTransaction&);
                /**helper: create transaction input parser*/
                QString trnInput(const WocTransaction&);
                /**helper: create transaction output serializer*/
                QString trnOutput(const WocTransaction&);
-               /**helper: create getters and setters*/
-               QString trnGetSet(const WocTransaction&);
-               /**helper: create direct execution code for web interface*/
-               QString trnExecute(const WocTransaction&);
-               /**helper: create privilege check code for web interface*/
-               QString trnPrivileges(const WocTransaction&);
 };
 
 #endif
index e99e938..c60f489 100644 (file)
@@ -159,7 +159,7 @@ void WocPHPTable::newTable(const WocTable&tbl)
        //create newKey function
        code+="public function newKey(){\n\tparent::newKey();\n";
        for(int i=0;i<cols.size();i++){
-               QString c=tbl.columnCall(cols[i],"php");
+               QString c=tbl.columnCall(cols[i],m_lang);
                if(c=="")continue;
                code+="\t$this->cdata[\""+cols[i]+"\"]="+c+";\n";
        }
index c204e26..eb2c54b 100644 (file)
@@ -28,11 +28,21 @@ static const QByteArray SCHEMAEND("}};\n");
 WocPHPServerOut::WocPHPServerOut(const QDomElement&el)
        :WocPHPOut(el)
 {
+       m_lang="php/server";
        pclass=new WocPHPClass(this);
        ptable=new WocPHPTable(this);
        ptrans=new WocPHPServerTransaction(this);
 }
 
+WocPHPClientOut::WocPHPClientOut(const QDomElement& el)
+       :WocPHPOut(el)
+{
+       m_lang="php/client";
+       pclass=new WocPHPClass(this);
+       ptrans=new WocPHPClientTransaction(this);
+}
+
+
 WocPHPOut::WocPHPOut(const QDomElement&el)
 {
        pclass=0;ptable=0;ptrans=0;
@@ -94,10 +104,3 @@ void WocPHPOut::newTable(const WocTable& tbl)
 {
        if(ptable)ptable->newTable(tbl);
 }
-
-WocPHPTransaction::WocPHPTransaction(WocPHPOut* p)
-{
-       m_parent=p;
-       connect(this,SIGNAL(errorFound()),p,SIGNAL(errorFound()));
-}
-
index 21febb0..e9275d3 100644 (file)
@@ -22,22 +22,10 @@ class QDomElement;
 class WocPHPOut;
 class WocPHPClass;
 class WocPHPTable;
+class WocPHPTransaction;
 class WocPHPClientTransaction;
 class WocPHPServerTransaction;
 
-class WocPHPTransaction:public QObject
-{
-       Q_OBJECT
-       public:
-               WocPHPTransaction(WocPHPOut*);
-               virtual void finalize()=0;
-               virtual void newTransaction(const WocTransaction&)=0;
-       protected:
-               WocPHPOut*m_parent;
-       signals:
-               void errorFound();
-};
-
 /**generates output for a PHP server side*/
 class WocPHPOut:public WocOutput
 {
@@ -61,7 +49,7 @@ class WocPHPOut:public WocOutput
                friend class WocPHPServerTransaction;
                
                QString m_basedir,m_subdir,m_fileext;
-               QString m_transbase;
+               QString m_transbase,m_lang;
                QFile m_loader,m_schema,m_transact;
                
                /**helper: adds a loader line for a class to autoload.php*/
@@ -87,4 +75,11 @@ class WocPHPServerOut:public WocPHPOut
                WocPHPServerOut(const QDomElement&);
 };
 
+class WocPHPClientOut:public WocPHPOut
+{
+       public:
+               /**initializes the output object*/
+               WocPHPClientOut(const QDomElement&);
+};
+
 #endif
index eafbefe..0043a96 100644 (file)
 
 #include "phpconst.h"
 
-static const QByteArray TRANSACTCLASS("class WobTransaction extends WobTransactionBase\n{\n");
-static const QByteArray TRANSACTSTART("  static public function handle(){\n    try{switch(WobTransactionBase::getTransactionName()){\n");
-static const QByteArray TRANSACTEND("\tdefault:WobTransactionBase::noSuchTransaction();break;\n    }}catch(WobTransactionError $er){$er->printXml();}\n  }\n");
-
-WocPHPServerTransaction::WocPHPServerTransaction(WocPHPOut*p ): WocPHPTransaction(p)
-{
-       //create Transaction file
-       m_transact.setFileName(m_basedir+"/"+m_subdir+"/transaction"+m_fileext);
-       if(!m_transact.open(QIODevice::ReadWrite|QIODevice::Truncate)){
-               qDebug("Error: PHP Server Generator - cannot create transaction processor file.");
-               emit errorFound();
-               return;
-       }
-       m_transact.write(PHPSTART);
-       m_transact.write(TRANSACTCLASS);
-       transInfo();
-       m_transact.write(TRANSACTSTART);
-       addLoad("WobTransaction","transaction");
-}
-
-void WocPHPServerTransaction::transInfo()
+WocPHPServerTransaction::WocPHPServerTransaction(WocPHPOut*p )
+       :WocPHPTransaction(p)
 {
-       WocProcessor*woc=WocProcessor::instance();
-       m_transact.write(QString("  static public function commVersion(){return \""+woc->verComm()+"\";}\n").toAscii());
-       m_transact.write(QString("  static public function needCommVersion(){return \""+woc->verNeedComm()+"\";}\n").toAscii());
-       m_transact.write(QString("  static public function version(){return \""+woc->verHR()+"\";}\n").toAscii());
-       m_transact.write(QString("  static public function svnVersion(){return \""+woc->svnRevision()+"\";}\n\n").toAscii());
-       m_transact.write(QString("  static public function svnRepositoryRoot(){return \""+woc->svnRepositoryRoot()+"\";}\n\n").toAscii());
-       m_transact.write(QString("  static public function svnRepositoryUrl(){return \""+woc->svnRepositoryUrl()+"\";}\n\n").toAscii());
 }
 
-void WocPHPServerTransaction::transInfo2()
-{
-       WocProcessor*woc=WocProcessor::instance();
-       //transaction names
-       QString code="  static public function transactionNames(){\n\treturn array(";
-       QStringList tns=woc->transactionNames();
-       for(int i=0;i<tns.size();i++){
-               if(i)code+=",";
-               code+="\n\t\ttranslate(\"_TransactionNames\",\""+tns[i]+"\")";
-       }
-       code+=");\n  }\n";
-       //privilege names
-       code+="static public function privilegeNames(){\n\treturn array(";
-       QStringList priv=woc->privilegeNames();
-       for(int i=0;i<priv.size();i++){
-               if(i)code+=",\n\t\t";else code+="\n\t\t";
-               code+="translate(\"_PrivilegeNames\",\""+priv[i]+"\")";
-       }
-       code+="\n\t);\n}\n";
-       
-       m_transact.write(code.toAscii());
-}
-
-void WocPHPServerTransaction::finalize()
-{
-       if(m_transact.isOpen()){
-               m_transact.write(TRANSACTEND);
-               transInfo2();
-               m_transact.write("};\n");
-               m_transact.write(PHPEND);
-               m_transact.close();
-       }
-}
-
-
-void WocPHPServerTransaction::newTransaction(const WocTransaction&trn)
+QString WocPHPServerTransaction::trnHandlers(const WocTransaction&trn)
 {
        //create file
        QString cn=trnClassName(trn);
        QString fn="wtr_"+trn.name();
-       addLoad(cn,fn);
-       fn=m_subdir+"/"+fn+m_fileext;
-       QFile tf(m_basedir+"/"+fn);
-       if(!tf.open(QIODevice::ReadWrite|QIODevice::Truncate)){
-               qDebug("Error: cannot create PHP object file %s.",fn.toAscii().data());
-               emit errorFound();
-               return;
-       }
-       tf.write(PHPSTART);
-       
        ////
        //generate code
-       QString code="/* TRANSLATOR "+cn+" */\nclass "+cn+" extends "+m_transbase+"{\n";
-       //constructor
-       code+=trnConstruct(trn);
-       tf.write(code.toAscii());
-       
+       QString code;
        //request handler:
        code="public function handleRequest(){\n";
        code+="\t$this->startTransaction("+QString(trn.isDbUpdating()?"true":"false")+");\n";
@@ -135,9 +60,9 @@ void WocPHPServerTransaction::newTransaction(const WocTransaction&trn)
        code+=trnInput(trn);
        
        //call
-       if(trn.hasCall("php")){
+       if(trn.hasCall(m_lang)){
                code+="\t/*call actual functionality:*/\n";
-               code+="\ttry{"+trn.callFunction("php")+"}catch(Exception $e){$this->handleException($e);}\n";
+               code+="\ttry{"+trn.callFunction(m_lang)+"}catch(Exception $e){$this->handleException($e);}\n";
        }else{
                code+="\t/*normally here would be the PHP call, but it is missing from the config*/\n";
                code+="\t$this->abortNotImplemented();\nreturn;\n";
@@ -148,68 +73,10 @@ void WocPHPServerTransaction::newTransaction(const WocTransaction&trn)
        code+=trnOutput(trn);
        
        code+="\t$this->commitTransaction();\n}\n";
-       tf.write(code.toAscii());
-       
-       //getters/setters
-       tf.write(trnGetSet(trn).toAscii());
        
        //direct execution
-       tf.write(trnExecute(trn).toAscii());
-       
-       //privileges
-       tf.write(trnPrivileges(trn).toAscii());
-       
-       //end
-       code="\n//end of class\n}\n";
-       tf.write(code.toAscii());
-       tf.write(PHPEND);
-       tf.close();
-       
-       ////
-       //generate loader code
-       code="\tcase \""+trn.name()+"\":$trn=new "+cn+";$trn->handleRequest();break;\n";
-       m_transact.write(code.toAscii());
-}
+       code+=trnExecute(trn).toAscii();
 
-QString WocPHPServerTransaction::trnConstruct(const WocTransaction&trn)
-{
-       QString code="public function __construct(){\n\tparent::__construct();\n";
-       code+="\t$this->ainput=array(";
-       QStringList sl=trn.inputNames();
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>";
-               if(trn.isListType(trn.inputType(sl[i])))code+="array()";
-               else code+="false";
-       }
-       code+=");\n";
-       code+="\t$this->tinput=array(";
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>\"";
-               code+=trn.inputType(sl[i]);
-               code+="\"";
-       }
-       code+=");\n";
-       
-       
-       code+="\t$this->aoutput=array(";
-       sl=trn.outputNames();
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>";
-               if(trn.isListType(trn.outputType(sl[i])))code+="array()";
-               else code+="false";
-       }
-       code+=");\n";
-       code+="\t$this->toutput=array(";
-       for(int i=0;i<sl.size();i++){
-               if(i)code+=",";
-               code+="\""+sl[i]+"\"=>\"";
-               code+=trn.outputType(sl[i]);
-               code+="\"";
-       }
-       code+=");\n}\n";
        return code;
 }
 
@@ -304,62 +171,6 @@ QString WocPHPServerTransaction::trnOutput(const WocTransaction&trn)
        return code;
 }
 
-QString WocPHPServerTransaction::trnGetSet(const WocTransaction&trn)
-{
-       QString code;
-       //getters
-       QStringList sl=trn.inputNames();
-       for(int i=0;i<sl.size();i++){
-               code+="public function get"+sl[i]+"(){return $this->ainput[\""+sl[i]+"\"];}\n";
-       }
-       //setters
-       sl=trn.outputNames();
-       for(int i=0;i<sl.size();i++){
-               code+="public function result"+sl[i]+"(){return $this->aoutput[\""+sl[i]+"\"];}\n";
-               QString add;
-               QString t=trn.outputType(sl[i]);
-               code+="public function set"+sl[i]+"($v){\n";
-               if(trn.isListType(t)){
-                       add="public function add"+sl[i]+"($vv){\n";
-                       code+="\t$this->aoutput[\""+sl[i]+"\"]=array();\n";
-                       code+="\tforeach($v as $vv){\n";
-                       if(trn.isIntType(t)){
-                               code+="\t\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
-                               add+="\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
-                       }else
-                       if(trn.isBoolType(t)){
-                               code+="\t\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
-                               add+="\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
-                       }else
-                       if(trn.isObjectType(t)){
-                               code+="\t\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
-                               add+="\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
-                       }else{
-                               code+="\t\t$this->aoutput[\""+sl[i]+"\"][]=\"\".$vv;\n";
-                               add+="\t$this->aoutput[\""+sl[i]+"\"][]=\"\".$vv;\n";
-                       }
-                       code+="\t}\n";
-                       add+="}\n";
-               }else{
-                       if(trn.isIntType(t)){
-                               code+="\tif(is_numeric($v))$this->aoutput[\""+sl[i]+"\"]=$v+0;\n";
-                       }else
-                       if(trn.isBoolType(t)){
-                               code+="\tif(is_bool($v))$this->aoutput[\""+sl[i]+"\"]=$v!=false;\n";
-                       }else
-                       if(trn.isObjectType(t)){
-                               code+="\tif(is_a($v,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"]=$v;\n";
-                       }else{
-                               code+="\t$this->aoutput[\""+sl[i]+"\"]=\"\".$v;\n";
-                       }
-               }
-               code+="}\n"+add;
-       }
-       
-       
-       return code;
-}
-
 QString WocPHPServerTransaction::trnExecute(const WocTransaction&trn)
 {
        //the execute function is split into a static and non-static part,
@@ -389,31 +200,8 @@ QString WocPHPServerTransaction::trnExecute(const WocTransaction&trn)
        for(int i=0;i<in.size();i++)
                code+="\t$this->ainput[\""+in[i]+"\"]=$"+in[i]+";\n";
        code+="\tself::$running=\""+trn.name()+"\";\n";
-       code+="\ttry{"+trn.callFunction("php")+"}\n\tcatch(Exception $ex){\n";
+       code+="\ttry{"+trn.callFunction(m_lang)+"}\n\tcatch(Exception $ex){\n";
        code+="\t\tself::$running=\"\";\n\t\t$this->handleException($ex);\n\t}\n";
        code+="\tself::$running=\"\";\n}\n";
        return code;
 }
-
-QString WocPHPServerTransaction::trnPrivileges(const WocTransaction&trn)
-{
-       //privilege inventory
-       QString code;
-       code+="static public function privileges(){\n\treturn array(";
-       QString cn=trnClassName(trn);
-       QStringList priv=trn.privileges();
-       for(int i=0;i<priv.size();i++){
-               if(i)code+=",\n\t\t";else code+="\n\t\t";
-               code+="\""+priv[i]+"\"";
-       }
-       code+="\n\t);\n}\n";
-       //constants for use by custom code
-       for(int i=0;i<priv.size();i++)
-               code+="const Priv_"+priv[i]+"=\""+priv[i]+"\";\n";
-       //check method
-       code+="public function havePrivilege($priv){\n";
-       code+="\tif(!in_array($priv,self::privileges()))return false;\n";
-       code+="\treturn $this->isAuthorized(\""+trn.name()+":\".$priv);\n}\n";
-       
-       return code;
-}
index f8816ca..05a1399 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef WOC_PHPOUT_STRANS_H
 #define WOC_PHPOUT_STRANS_H
 
-#include "phpout.h"
+#include "phptrans.h"
 
 
 /**generates output for a PHP server side*/
@@ -22,30 +22,15 @@ class WocPHPServerTransaction:public WocPHPTransaction
        public:
                /**initializes the output object*/
                WocPHPServerTransaction(WocPHPOut*);
-       protected:
-               /**writes any last words after parsing finished*/
-               virtual void finalize();
-               /**creates a transaction*/
-               virtual void newTransaction(const WocTransaction&);
        private:
-
-               /**helper: create info functions (mainly version info) at the start*/
-               void transInfo();
-               /**helper: create info functions (mainly version info) at the end*/
-               void transInfo2();
-               
-               /**helper: create transaction constructor*/
-               QString trnConstruct(const WocTransaction&);
+               /**helper: create handlers*/
+               virtual QString trnHandlers(const WocTransaction&);
                /**helper: create transaction input parser*/
                QString trnInput(const WocTransaction&);
                /**helper: create transaction output serializer*/
                QString trnOutput(const WocTransaction&);
-               /**helper: create getters and setters*/
-               QString trnGetSet(const WocTransaction&);
                /**helper: create direct execution code for web interface*/
                QString trnExecute(const WocTransaction&);
-               /**helper: create privilege check code for web interface*/
-               QString trnPrivileges(const WocTransaction&);
 };
 
 #endif
diff --git a/woc/phptrans.cpp b/woc/phptrans.cpp
new file mode 100644 (file)
index 0000000..a0976db
--- /dev/null
@@ -0,0 +1,251 @@
+//
+// C++ Implementation: phpout
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "phpout.h"
+#include "phpctrans.h"
+
+#include <QDir>
+#include <QDomElement>
+
+#include "phpconst.h"
+
+static const QByteArray TRANSACTCLASS("class WobTransaction extends WobTransactionBase\n{\n");
+static const QByteArray TRANSACTSTART("  static public function handle(){\n    try{switch(WobTransactionBase::getTransactionName()){\n");
+static const QByteArray TRANSACTEND("\tdefault:WobTransactionBase::noSuchTransaction();break;\n    }}catch(WobTransactionError $er){$er->printXml();}\n  }\n");
+
+WocPHPTransaction::WocPHPTransaction(WocPHPOut*p ): QObject(p)
+{
+       m_parent=p;
+       connect(this,SIGNAL(errorFound()),p,SIGNAL(errorFound()));
+       //create Transaction file
+       m_transact.setFileName(m_basedir+"/"+m_subdir+"/transaction"+m_fileext);
+       if(!m_transact.open(QIODevice::ReadWrite|QIODevice::Truncate)){
+               qDebug("Error: PHP Server Generator - cannot create transaction processor file.");
+               emit errorFound();
+               return;
+       }
+       m_transact.write(PHPSTART);
+       m_transact.write(TRANSACTCLASS);
+       transInfo();
+       m_transact.write(TRANSACTSTART);
+       addLoad("WobTransaction","transaction");
+}
+
+void WocPHPTransaction::transInfo()
+{
+       WocProcessor*woc=WocProcessor::instance();
+       m_transact.write(QString("  static public function commVersion(){return \""+woc->verComm()+"\";}\n").toAscii());
+       m_transact.write(QString("  static public function needCommVersion(){return \""+woc->verNeedComm()+"\";}\n").toAscii());
+       m_transact.write(QString("  static public function version(){return \""+woc->verHR()+"\";}\n").toAscii());
+       m_transact.write(QString("  static public function svnVersion(){return \""+woc->svnRevision()+"\";}\n\n").toAscii());
+       m_transact.write(QString("  static public function svnRepositoryRoot(){return \""+woc->svnRepositoryRoot()+"\";}\n\n").toAscii());
+       m_transact.write(QString("  static public function svnRepositoryUrl(){return \""+woc->svnRepositoryUrl()+"\";}\n\n").toAscii());
+}
+
+void WocPHPTransaction::transInfo2()
+{
+       WocProcessor*woc=WocProcessor::instance();
+       //transaction names
+       QString code="  static public function transactionNames(){\n\treturn array(";
+       QStringList tns=woc->transactionNames();
+       for(int i=0;i<tns.size();i++){
+               if(i)code+=",";
+               code+="\n\t\ttranslate(\"_TransactionNames\",\""+tns[i]+"\")";
+       }
+       code+=");\n  }\n";
+       //privilege names
+       code+="static public function privilegeNames(){\n\treturn array(";
+       QStringList priv=woc->privilegeNames();
+       for(int i=0;i<priv.size();i++){
+               if(i)code+=",\n\t\t";else code+="\n\t\t";
+               code+="translate(\"_PrivilegeNames\",\""+priv[i]+"\")";
+       }
+       code+="\n\t);\n}\n";
+       
+       m_transact.write(code.toAscii());
+}
+
+void WocPHPTransaction::finalize()
+{
+       if(m_transact.isOpen()){
+               m_transact.write(TRANSACTEND);
+               transInfo2();
+               m_transact.write("};\n");
+               m_transact.write(PHPEND);
+               m_transact.close();
+       }
+}
+
+
+void WocPHPTransaction::newTransaction(const WocTransaction&trn)
+{
+       //create file
+       QString cn=trnClassName(trn);
+       QString fn="wtr_"+trn.name();
+       addLoad(cn,fn);
+       fn=m_subdir+"/"+fn+m_fileext;
+       QFile tf(m_basedir+"/"+fn);
+       if(!tf.open(QIODevice::ReadWrite|QIODevice::Truncate)){
+               qDebug("Error: cannot create PHP object file %s.",fn.toAscii().data());
+               emit errorFound();
+               return;
+       }
+       tf.write(PHPSTART);
+       
+       ////
+       //generate code
+       QString code="/* TRANSLATOR "+cn+" */\nclass "+cn+" extends "+m_transbase+"{\n";
+       //constructor
+       code+=trnConstruct(trn);
+       tf.write(code.toAscii());
+       
+       //request handler:
+       code+=trnHandlers(trn);
+
+       //getters/setters
+       tf.write(trnGetSet(trn).toAscii());
+       
+       //privileges
+       tf.write(trnPrivileges(trn).toAscii());
+       
+       //end
+       code="\n//end of class\n}\n";
+       tf.write(code.toAscii());
+       tf.write(PHPEND);
+       tf.close();
+       
+       ////
+       //generate loader code
+       code="\tcase \""+trn.name()+"\":$trn=new "+cn+";$trn->handleRequest();break;\n";
+       m_transact.write(code.toAscii());
+}
+
+QString WocPHPTransaction::trnConstruct(const WocTransaction&trn)
+{
+       QString code="public function __construct(){\n\tparent::__construct();\n";
+       code+="\t$this->ainput=array(";
+       QStringList sl=trn.inputNames();
+       for(int i=0;i<sl.size();i++){
+               if(i)code+=",";
+               code+="\""+sl[i]+"\"=>";
+               if(trn.isListType(trn.inputType(sl[i])))code+="array()";
+               else code+="false";
+       }
+       code+=");\n";
+       code+="\t$this->tinput=array(";
+       for(int i=0;i<sl.size();i++){
+               if(i)code+=",";
+               code+="\""+sl[i]+"\"=>\"";
+               code+=trn.inputType(sl[i]);
+               code+="\"";
+       }
+       code+=");\n";
+       
+       
+       code+="\t$this->aoutput=array(";
+       sl=trn.outputNames();
+       for(int i=0;i<sl.size();i++){
+               if(i)code+=",";
+               code+="\""+sl[i]+"\"=>";
+               if(trn.isListType(trn.outputType(sl[i])))code+="array()";
+               else code+="false";
+       }
+       code+=");\n";
+       code+="\t$this->toutput=array(";
+       for(int i=0;i<sl.size();i++){
+               if(i)code+=",";
+               code+="\""+sl[i]+"\"=>\"";
+               code+=trn.outputType(sl[i]);
+               code+="\"";
+       }
+       code+=");\n}\n";
+       return code;
+}
+
+QString WocPHPTransaction::trnGetSet(const WocTransaction&trn)
+{
+       QString code;
+       //getters
+       QStringList sl=trn.inputNames();
+       for(int i=0;i<sl.size();i++){
+               code+="public function get"+sl[i]+"(){return $this->ainput[\""+sl[i]+"\"];}\n";
+       }
+       //setters
+       sl=trn.outputNames();
+       for(int i=0;i<sl.size();i++){
+               code+="public function result"+sl[i]+"(){return $this->aoutput[\""+sl[i]+"\"];}\n";
+               QString add;
+               QString t=trn.outputType(sl[i]);
+               code+="public function set"+sl[i]+"($v){\n";
+               if(trn.isListType(t)){
+                       add="public function add"+sl[i]+"($vv){\n";
+                       code+="\t$this->aoutput[\""+sl[i]+"\"]=array();\n";
+                       code+="\tforeach($v as $vv){\n";
+                       if(trn.isIntType(t)){
+                               code+="\t\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
+                               add+="\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
+                       }else
+                       if(trn.isBoolType(t)){
+                               code+="\t\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
+                               add+="\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
+                       }else
+                       if(trn.isObjectType(t)){
+                               code+="\t\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
+                               add+="\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
+                       }else{
+                               code+="\t\t$this->aoutput[\""+sl[i]+"\"][]=\"\".$vv;\n";
+                               add+="\t$this->aoutput[\""+sl[i]+"\"][]=\"\".$vv;\n";
+                       }
+                       code+="\t}\n";
+                       add+="}\n";
+               }else{
+                       if(trn.isIntType(t)){
+                               code+="\tif(is_numeric($v))$this->aoutput[\""+sl[i]+"\"]=$v+0;\n";
+                       }else
+                       if(trn.isBoolType(t)){
+                               code+="\tif(is_bool($v))$this->aoutput[\""+sl[i]+"\"]=$v!=false;\n";
+                       }else
+                       if(trn.isObjectType(t)){
+                               code+="\tif(is_a($v,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"]=$v;\n";
+                       }else{
+                               code+="\t$this->aoutput[\""+sl[i]+"\"]=\"\".$v;\n";
+                       }
+               }
+               code+="}\n"+add;
+       }
+       
+       
+       return code;
+}
+
+QString WocPHPTransaction::trnPrivileges(const WocTransaction&trn)
+{
+       //privilege inventory
+       QString code;
+       code+="static public function privileges(){\n\treturn array(";
+       QString cn=trnClassName(trn);
+       QStringList priv=trn.privileges();
+       for(int i=0;i<priv.size();i++){
+               if(i)code+=",\n\t\t";else code+="\n\t\t";
+               code+="\""+priv[i]+"\"";
+       }
+       code+="\n\t);\n}\n";
+       //constants for use by custom code
+       for(int i=0;i<priv.size();i++)
+               code+="const Priv_"+priv[i]+"=\""+priv[i]+"\";\n";
+       //check method
+       code+="public function havePrivilege($priv){\n";
+       code+="\tif(!in_array($priv,self::privileges()))return false;\n";
+       code+="\treturn $this->isAuthorized(\""+trn.name()+":\".$priv);\n}\n";
+       
+       return code;
+}
diff --git a/woc/phptrans.h b/woc/phptrans.h
new file mode 100644 (file)
index 0000000..13eaf9f
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// C++ Interface: phpout
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef WOC_PHPOUT_TRANS_H
+#define WOC_PHPOUT_TRANS_H
+
+#include "phpout.h"
+
+
+/**generates output for a PHP server side*/
+class WocPHPTransaction:public QObject
+{
+       Q_OBJECT
+       public:
+               /**initializes the output object*/
+               WocPHPTransaction(WocPHPOut*);
+               /**writes any last words after parsing finished*/
+               virtual void finalize();
+               /**creates a transaction*/
+               virtual void newTransaction(const WocTransaction&);
+       private:
+
+               /**helper: create info functions (mainly version info) at the start*/
+               virtual void transInfo();
+               /**helper: create info functions (mainly version info) at the end*/
+               virtual void transInfo2();
+               
+               /**helper: create transaction constructor*/
+               virtual QString trnConstruct(const WocTransaction&);
+               /**helper: create handlers*/
+               virtual QString trnHandlers(const WocTransaction&)=0;
+               /**helper: create getters and setters*/
+               virtual QString trnGetSet(const WocTransaction&);
+               /**helper: create privilege check code for web interface*/
+               virtual QString trnPrivileges(const WocTransaction&);
+       protected:
+               WocPHPOut*m_parent;
+       signals:
+               void errorFound();
+};
+
+#endif
index 2170fb3..f656fef 100644 (file)
@@ -168,9 +168,13 @@ WocClass::WocClass(const QDomElement&cls)
                        for(int k=0;k<nl3.size();k++){
                                QDomElement el3=nl3.at(k).toElement();
                                if(el3.isNull())continue;
-                               QString lang=el3.attribute("lang");
+                               QString lang=el3.attribute("lang").trimmed();
                                QString meth=el3.attribute("method","false");
                                sm.method.insert(lang,meth);
+                               if(!lang.contains("/")){
+                                       sm.method.insert(lang+"/client",meth);
+                                       sm.method.insert(lang+"/server",meth);
+                               }
                        }
                        map.append(sm);
                }
@@ -190,7 +194,11 @@ WocClass::WocClass(const QDomElement&cls)
        nl=elementsByTagName(cls,"Abstract");
        for(int i=0;i<nl.size();i++){
                QString s=nl.at(i).toElement().attribute("lang").trimmed();
-               if(s!="")m_cabstract<<s;
+               if(s!=""){
+                       m_cabstract<<s;
+                       if(!s.contains("/"))
+                               m_cabstract<<(s+"/client")<<(s+"/server");
+               }
        }
 }
 
index bb224c1..11cea42 100644 (file)
@@ -151,6 +151,14 @@ bool WocProcessor::processFile(QString fn)
                        new WocQtClientOut(el);
                        if(m_error)return false;
                }else
+               if(tn=="QtServerOutput"){
+                       new WocQtServerOut(el);
+                       if(m_error)return false;
+               }else
+               if(tn=="PHPClientOutput"){
+                       new WocPHPClientOut(el);
+                       if(m_error)return false;
+               }else
                if(tn=="PHPServerOutput"){
                        new WocPHPServerOut(el);
                        if(m_error)return false;
index 8122163..c521ee8 100644 (file)
@@ -205,6 +205,10 @@ QPair<bool,WocTable::s_col> WocTable::parseColumn(const QDomElement&el,QString m
                QString lang=el2.attribute("lang");
                QString meth=el2.attribute("method","false");
                cl.methodcalls.insert(lang,meth);
+               if(!lang.contains("/")){
+                       cl.methodcalls.insert(lang+"/client",meth);
+                       cl.methodcalls.insert(lang+"/server",meth);
+               }
        }
        //docu
        QDomNodeList nl3=el.childNodes();
index 99ef997..6486a34 100644 (file)
@@ -97,6 +97,10 @@ WocTransaction::WocTransaction(const QDomElement&root)
                }
                QString mt=el.attribute("method");
                m_call.insert(nm,mt);
+               if(!nm.contains("/")){
+                       m_call.insert(nm+"/client",mt);
+                       m_call.insert(nm+"/server",mt);
+               }
        }
        //output
        nl=elementsByTagName(root,"Output");
index 8aff833..0ff8f0c 100644 (file)
@@ -37,7 +37,7 @@ void WocQtClass::newClass(const WocClass&cls)
 {
        QString cn=m_prefix+"O"+cls.name();
        QString cna=cn;
-       if(cls.isAbstract("qt"))cna+="Abstract";
+       if(cls.isAbstract(m_lang))cna+="Abstract";
        addFile(cna);
        MFile hdr(m_basedir+"/"+m_subdir+"/"+cna+".h");
        MFile src(m_basedir+"/"+m_subdir+"/"+cna+".cpp");
index 214b216..f252ddd 100644 (file)
@@ -45,6 +45,7 @@ static const QByteArray SRCEND="\n//END OF AUTOMATICALLY GENERATED FILE\n";
 #define qttype         m_parent->qttype
 #define qtobjtype      m_parent->qtobjtype
 #define addFile                m_parent->addFile
+#define m_lang         m_parent->m_lang
 #endif
 
 #endif
index 217945a..6d93269 100644 (file)
@@ -13,6 +13,8 @@
 #include "qtout.h"
 #include "qtdb.h"
 
+#include "qtconst.h"
+
 WocQtTable::WocQtTable(WocQtOut*){}
 WocQtTable::~WocQtTable(){}
 void WocQtTable::finalize(){}
index b4bf783..0c7de04 100644 (file)
@@ -189,10 +189,21 @@ QString WocQtOut::qtobjtype(const WocTransaction&trn,QString v,InOut io)
 WocQtClientOut::WocQtClientOut(QDomElement&el)
        :WocQtOut(el)
 {
+       m_lang="qt/client";
        qclass=new WocQtClass(this);
        qtrans=new WocQtClientTransaction(this);
 }
 
+WocQtServerOut::WocQtServerOut(QDomElement& el)
+       :WocQtOut(el)
+{
+       m_lang="qt/server";
+       qclass=new WocQtClass(this);
+       qtrans=new WocQtServerTransaction(this);
+       qtable=new WocQtTable(this);
+}
+
+
 WocQtTransaction::WocQtTransaction(WocQtOut*p)
        :m_parent(p)
 {
index 18f6cb5..77781c2 100644 (file)
@@ -54,7 +54,7 @@ class WocQtOut:public WocOutput
                friend class WocQtTransaction;
                friend class WocQtTable;
                
-               QString m_basedir,m_subdir,m_prefix,m_transbase;
+               QString m_basedir,m_subdir,m_prefix,m_transbase,m_lang;
                MFile m_pri,m_iface,m_ifacecpp,m_hdr;
                bool m_clean;
                
@@ -79,4 +79,10 @@ class WocQtClientOut:public WocQtOut
                WocQtClientOut(QDomElement&);
 };
 
+class WocQtServerOut:public WocQtOut
+{
+       public:
+               WocQtServerOut(QDomElement&);
+};
+
 #endif
index 8151e3d..3051cb2 100644 (file)
@@ -13,6 +13,8 @@
 #include "qtout.h"
 #include "qtstrans.h"
 
+#include "qtconst.h"
+
 WocQtServerTransaction::WocQtServerTransaction(WocQtOut*p)
        :WocQtTransaction(p)
 {
index 4877b2c..839d05c 100644 (file)
@@ -24,6 +24,7 @@ SOURCES+= \
        qtstrans.cpp \
        phpout.cpp \
        phpclass.cpp \
+       phptrans.cpp \
        phpctrans.cpp \
        phpstrans.cpp \
        phpdb.cpp \
@@ -38,6 +39,7 @@ HEADERS+= \
        phpout.h \
        phpdb.h \
        phpclass.h \
+       phptrans.h \
        phpctrans.h \
        phpstrans.h \
        qtout.h \