some more usability for non-machine transactions
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Mon, 24 May 2010 19:06:02 +0000 (19:06 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Mon, 24 May 2010 19:06:02 +0000 (19:06 +0000)
git-svn-id: https://silmor.de/svn/softmagic/pack/trunk@472 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

woc/phpout.cpp

index 55801e8..9916e33 100644 (file)
@@ -1006,6 +1006,7 @@ QString WocPHPServerOut::trnGetSet(const WocTransaction&trn)
        //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";
@@ -1052,20 +1053,36 @@ QString WocPHPServerOut::trnGetSet(const WocTransaction&trn)
 
 QString WocPHPServerOut::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+="\t$inst->do_execute();\n";
-       code+="\tself::$running=\"\";\n";
-       code+="\treturn $inst;\n}\n";
-       code+="private function do_execute(){"+trn.callFunction("php")+"}\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;
 }