static void generateMethodDispatcher(CodeFile& f, Service* s, Method& m) { f.output("public static bool %s(bintalk.IReader __r__, %sProxy __p__)", m.getNameC(), s->getNameC()); f.indent("{"); for(size_t i = 0; i < m.fields_.size(); i++) { Field& field = m.fields_[i]; std::string tn; getFieldTypeName(field, tn); std::string dft; getFieldDefault(field, dft); f.output("%s %s= %s;", tn.c_str(), field.getNameC(), dft.c_str()); } generateFieldContainerDSCode(f, &m); f.listBegin(",", false, "return __p__.%s(", m.getNameC()); for(size_t i = 0; i < m.fields_.size(); i++) { Field& field = m.fields_[i]; f.listItem("%s", field.getNameC()); } f.listEnd(");"); f.recover("}"); }
static void generateStruct(CodeFile& f, Struct* s) { f.output("class %s(object):", s->getNameC()); f.indent(); f.output("def __init__(self):"); f.indent(); for(size_t i = 0; i < s->fields_.size(); i++) { Field& field = s->fields_[i]; f.output("self.%s = %s", field.getNameC(), getFieldDefault(field)); } f.recover(); f.output("def serialize(self, __b__):"); f.indent(); generateFieldContainerSCode(f, s, true); f.recover(); f.output("def deserialize(self, __b__, __p__):"); f.indent(); generateFieldContainerDSCode(f, s, true); f.output("return __p__"); f.recover(); f.recover(); f.output("def %sWriter(v, b):", s->getNameC()); f.indent(); f.output("v.serialize(b)"); f.recover(); f.output("protocol_writer.type_%s = %sWriter", s->getNameC(), s->getNameC()); f.output("def %sReader(b, p, valMax):", s->getNameC()); f.indent(); f.output("v = %s()", s->getNameC()); f.output("p = v.deserialize(b, p)"); f.output("return v, p"); f.recover(); f.output("protocol_reader.type_%s = %sReader", s->getNameC(), s->getNameC()); }
static void generateStruct(CodeFile& f, Struct* s) { f.output("public class %s", s->getNameC()); f.indent("{"); // fields. for(size_t i = 0; i < s->fields_.size(); i++) { Field& field = s->fields_[i]; std::string tn; getFieldTypeName(field, tn); std::string dft; getFieldDefault(field, dft); f.output("public %s %s= %s;", tn.c_str(), field.getNameC(), dft.c_str()); } // serialize code. f.output("public void serialize(bintalk.IWriter __w__)"); f.indent("{"); generateFieldContainerSCode(f, s); f.recover("}"); // deserialize code. f.output("public bool deserialize(bintalk.IReader __r__)"); f.indent("{"); generateFieldContainerDSCode(f, s); f.output("return true;"); f.recover("}"); f.recover("}"); //////////////////////////////////////////////////////////////////////////////// f.output("namespace bintalk"); f.indent("{"); f.output("public static partial class ProtocolReader"); f.indent("{"); f.output("public static bool read(bintalk.IReader r, ref %s v, uint maxValue)", s->getNameC()); f.indent("{"); f.output("return v.deserialize(r);"); f.recover("}"); f.recover("}"); f.output("public static partial class ProtocolWriter"); f.indent("{"); f.output("public static void write(bintalk.IWriter w, %s v)", s->getNameC()); f.indent("{"); f.output("v.serialize(w);"); f.recover("}"); f.recover("}"); f.recover("}"); }
QVariant LS3DatastoreXML::getField(int record, QString field) const { if (dbIsLoaded()) { return data->getField(record, field); } else return QVariant(getFieldDefault(field)); }
QVariant LS3Datastore::getFieldDefault(int field) const { return getFieldDefault(fieldName(field)); }