pushPopVar(ofileImpS, 1, "tx.push", nl->get(i)->node(1), nl->get(i)->node(2)->name());
}
ofileImpS.writeLine("return err;\n");
}
void GenBoap::produceFuncAdd(Node* n){
BString s;
BIter i;
switch(n->nodeType()){
case Node::TLIST:
for(n->nodes().start(i); !n->nodes().isEnd(i); n->nodes().next(i)){
produceFuncAdd(n->nodes()[i]);
}
break;
case Node::TFUNC:
s = s + "ofuncList.append(BoapFuncEntry(" + ofuncNum + ", ";
s = s + "(BoapFunc)&" + ointerface + "Service::do" + n->name() + "));\n";
ofileImpS.writeLine(s);
ofuncNum++;
break;
default:
break;
}
}
void GenBoap::produceImpS(Node* n){
BString s;
BIter i;
switch(n->nodeType()){
case Node::TMODULE:
omodule = n->name();
ofileImpS.writeLine(BString("namespace ") + omodule + " {\n");
ofileImpS.indentMore();
for(n->nodes().start(i); !n->nodes().isEnd(i); n->nodes().next(i)){
produceImpS(n->nodes()[i]);
}
ofileImpS.indentLess();
ofileImpS.writeLine("}\n");
break;
case Node::TINTERFACE:
ointerface = n->name();
ofuncNum = 16;
ofileImpS.writeLine(ointerface + "Service::" + ointerface + "Service(BoapServer& server, BString name) : BoapServiceObject(server, name){\n");
ofileImpS.indentMore();
ofileImpS.writeLine(BString("oapiVersion = ") + oapiVersion + ";\n");
for(n->nodes().start(i); !n->nodes().isEnd(i); n->nodes().next(i)){
produceFuncAdd(n->nodes()[i]);
}
ofileImpS.indentLess();
ofileImpS.writeLine("}\n");
ofuncNum = 16;
for(n->nodes().start(i); !n->nodes().isEnd(i); n->nodes().next(i)){
produceImpS(n->nodes()[i]);
}
break;
case Node::TLIST:
for(n->nodes().start(i); !n->nodes().isEnd(i); n->nodes().next(i)){
produceImpS(n->nodes()[i]);
}
break;
case Node::TFUNC:
s = "BError ";
s = s + ointerface + "Service::do" + n->name();
s = s + "(BoapServerConnection* conn, BoapPacket& rx, BoapPacket& tx){\n";
ofileImpS.writeLine(s);
ofileImpS.indentMore();
produceFuncS(n);
ofileImpS.indentLess();
ofileImpS.writeLine("}\n\n");
ofuncNum++;
break;
case Node::TAPIVERSION:
oapiVersion = n->name().retInt();
break;
default:
break;
}
}
BError GenBoap::produceHeaderIntC(){
BError err;
BString fileName = ofileName + "C.h";
BString fileNameUpper = ofileName + "C_H";
fileNameUpper.toUpper();
ofileIntC.printf("/*******************************************************************************\n");
ofileIntC.printf(" *\t%s\tProduced by Bidl\n", fileName.retStr());
ofileIntC.printf(" *******************************************************************************\n");
ofileIntC.printf(" */\n");
ofileIntC.printf("\n");
ofileIntC.printf("#ifndef %s\n", fileNameUpper.retStr());
ofileIntC.printf("#define %s 1\n\n", fileNameUpper.retStr());
ofileIntC.printf("#include <stdlib.h>\n");
ofileIntC.printf("#include <stdint.h>\n");
ofileIntC.printf("#include <Boap.h>\n");
ofileIntC.printf("#include <BString.h>\n");
ofileIntC.printf("#include <BList.h>\n");
ofileIntC.printf("#include <BArray.h>\n");
#ifdef ZAP1
ofileIntC.printf("#include <BObjDate.h>\n");
ofileIntC.printf("#include <BObjData.h>\n");
#endif
#if !DODATA
ofileIntC.printf("#include <%s>\n\n", (ofileName + "D.h").retStr());
#endif
ofileIntC.printf("\n");
return err;
}
BError GenBoap::produceHeaderIntS(){
BError err;
BString fileName = ofileName + "S.h";
BString fileNameUpper = ofileName + "S_H";
fileNameUpper.toUpper();
ofileIntS.printf("/*******************************************************************************\n");
ofileIntS.printf(" *\t%s\tProduced by Bidl\n", fileName.retStr());
ofileIntS.printf(" *******************************************************************************\n");
ofileIntS.printf(" */\n");
ofileIntS.printf("\n");
ofileIntS.printf("#ifndef %s\n", fileNameUpper.retStr());
ofileIntS.printf("#define %s 1\n\n", fileNameUpper.retStr());
ofileIntS.printf("#include <stdint.h>\n");
ofileIntS.printf("#include <Boap.h>\n");
ofileIntS.printf("#include <BString.h>\n\n");
ofileIntS.printf("#include <%sC.h>\n", ofileName.retStr());
ofileIntS.printf("\n");