From: konrad Date: Tue, 27 Jul 2010 20:31:55 +0000 (+0000) Subject: add stubs for qt/server and php/client X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=a6b385317e4284cd74fcd9a14f456c6a9b719964;p=web%2Fkonrad%2Fpack.git add stubs for qt/server and php/client 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 --- diff --git a/examples/clock/clock.wolf b/examples/clock/clock.wolf index 56d4cdb..6594ed4 100644 --- a/examples/clock/clock.wolf +++ b/examples/clock/clock.wolf @@ -7,6 +7,8 @@ + + @@ -25,8 +27,7 @@ - - + diff --git a/woc/phpclass.cpp b/woc/phpclass.cpp index 1019988..d7bb590 100644 --- a/woc/phpclass.cpp +++ b/woc/phpclass.cpp @@ -470,7 +470,7 @@ QString WocPHPClass::classMappings(const WocClass&cls) QMapmap=cls.mapping(k[i]); QStringList mapk=cls.mappingProperties(k[i]); for(int j=0;j"+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"); #define abstractClassName m_parent->abstractClassName #define trnClassName m_parent->trnClassName #define addLoad m_parent->addLoad +#define m_lang m_parent->m_lang #endif #endif diff --git a/woc/phpctrans.cpp b/woc/phpctrans.cpp index 3719a5e..53fc835 100644 --- a/woc/phpctrans.cpp +++ b/woc/phpctrans.cpp @@ -18,93 +18,20 @@ #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;iprivilegeNames(); - for(int i=0;ihandleException($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"; - if(trn.isListType(trn.inputType(sl[i])))code+="array()"; - else code+="false"; - } - code+=");\n"; - code+="\t$this->tinput=array("; - for(int i=0;i\""; - code+=trn.inputType(sl[i]); - code+="\""; - } - code+=");\n"; - - code+="\t$this->aoutput=array("; - sl=trn.outputNames(); - for(int i=0;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\""; - 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;iainput[\""+sl[i]+"\"];}\n"; - } - //setters - sl=trn.outputNames(); - for(int i=0;iaoutput[\""+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;ihandleException($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;inewTable(tbl); } - -WocPHPTransaction::WocPHPTransaction(WocPHPOut* p) -{ - m_parent=p; - connect(this,SIGNAL(errorFound()),p,SIGNAL(errorFound())); -} - diff --git a/woc/phpout.h b/woc/phpout.h index 21febb0..e9275d3 100644 --- a/woc/phpout.h +++ b/woc/phpout.h @@ -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 diff --git a/woc/phpstrans.cpp b/woc/phpstrans.cpp index eafbefe..0043a96 100644 --- a/woc/phpstrans.cpp +++ b/woc/phpstrans.cpp @@ -18,94 +18,19 @@ #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;iprivilegeNames(); - for(int i=0;ihandleException($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"; - if(trn.isListType(trn.inputType(sl[i])))code+="array()"; - else code+="false"; - } - code+=");\n"; - code+="\t$this->tinput=array("; - for(int i=0;i\""; - code+=trn.inputType(sl[i]); - code+="\""; - } - code+=");\n"; - - - code+="\t$this->aoutput=array("; - sl=trn.outputNames(); - for(int i=0;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\""; - 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;iainput[\""+sl[i]+"\"];}\n"; - } - //setters - sl=trn.outputNames(); - for(int i=0;iaoutput[\""+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;ihandleException($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, (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "phpout.h" +#include "phpctrans.h" + +#include +#include + +#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;iprivilegeNames(); + for(int i=0;ihandleRequest();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"; + if(trn.isListType(trn.inputType(sl[i])))code+="array()"; + else code+="false"; + } + code+=");\n"; + code+="\t$this->tinput=array("; + for(int i=0;i\""; + code+=trn.inputType(sl[i]); + code+="\""; + } + code+=");\n"; + + + code+="\t$this->aoutput=array("; + sl=trn.outputNames(); + for(int i=0;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\""; + 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;iainput[\""+sl[i]+"\"];}\n"; + } + //setters + sl=trn.outputNames(); + for(int i=0;iaoutput[\""+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, (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 diff --git a/woc/procclass.cpp b/woc/procclass.cpp index 2170fb3..f656fef 100644 --- a/woc/procclass.cpp +++ b/woc/procclass.cpp @@ -168,9 +168,13 @@ WocClass::WocClass(const QDomElement&cls) for(int k=0;k 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(); diff --git a/woc/proctrans.cpp b/woc/proctrans.cpp index 99ef997..6486a34 100644 --- a/woc/proctrans.cpp +++ b/woc/proctrans.cpp @@ -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"); diff --git a/woc/qtclass.cpp b/woc/qtclass.cpp index 8aff833..0ff8f0c 100644 --- a/woc/qtclass.cpp +++ b/woc/qtclass.cpp @@ -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"); diff --git a/woc/qtconst.h b/woc/qtconst.h index 214b216..f252ddd 100644 --- a/woc/qtconst.h +++ b/woc/qtconst.h @@ -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 diff --git a/woc/qtdb.cpp b/woc/qtdb.cpp index 217945a..6d93269 100644 --- a/woc/qtdb.cpp +++ b/woc/qtdb.cpp @@ -13,6 +13,8 @@ #include "qtout.h" #include "qtdb.h" +#include "qtconst.h" + WocQtTable::WocQtTable(WocQtOut*){} WocQtTable::~WocQtTable(){} void WocQtTable::finalize(){} diff --git a/woc/qtout.cpp b/woc/qtout.cpp index b4bf783..0c7de04 100644 --- a/woc/qtout.cpp +++ b/woc/qtout.cpp @@ -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) { diff --git a/woc/qtout.h b/woc/qtout.h index 18f6cb5..77781c2 100644 --- a/woc/qtout.h +++ b/woc/qtout.h @@ -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 diff --git a/woc/qtstrans.cpp b/woc/qtstrans.cpp index 8151e3d..3051cb2 100644 --- a/woc/qtstrans.cpp +++ b/woc/qtstrans.cpp @@ -13,6 +13,8 @@ #include "qtout.h" #include "qtstrans.h" +#include "qtconst.h" + WocQtServerTransaction::WocQtServerTransaction(WocQtOut*p) :WocQtTransaction(p) { diff --git a/woc/woc.pro b/woc/woc.pro index 4877b2c..839d05c 100644 --- a/woc/woc.pro +++ b/woc/woc.pro @@ -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 \