本文整理汇总了C++中CodeFile::recover方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeFile::recover方法的具体用法?C++ CodeFile::recover怎么用?C++ CodeFile::recover使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeFile
的用法示例。
在下文中一共展示了CodeFile::recover方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateEnum
static void generateEnum(CodeFile& f, Enum* e)
{
f.output("public enum %s : byte", e->getNameC());
f.indent("{");
for(size_t i = 0; i < e->items_.size(); i++)
f.output("%s,", e->items_[i].c_str());
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)", e->getNameC());
f.indent("{");
f.output("byte e = 0;");
f.output("if(!read(r, ref e, 0)) return false;");
f.output("v = (%s)e;", e->getNameC());
f.output("return true;");
f.recover("}");
f.recover("}");
f.output("public static partial class ProtocolWriter");
f.indent("{");
f.output("public static void write(bintalk.IWriter w, %s v)", e->getNameC());
f.indent("{");
f.output("write(w, (byte)v);");
f.recover("}");
f.recover("}");
f.recover("}");
}
示例2: generateStruct
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());
}
示例3: generateServiceDispatcher
static void generateServiceDispatcher(CodeFile& f, Service* s)
{
f.output("public static class %sDispatcher", s->getNameC());
f.indent("{");
// deserializations.
for(size_t i = 0; i < s->methods_.size(); i++)
generateMethodDispatcher(f, s, s->methods_[i]);
// dispatch function.
f.output("public static bool dispatch(bintalk.IReader __r__, %sProxy __p__)", s->getNameC());
f.indent("{");
f.output("ushort __mid__ = 0;");
f.output("if(!bintalk.ProtocolReader.readMid(__r__, ref __mid__)) return false;");
f.output("if(__p__.filterMethod((%sProxyMID)__mid__)) return false;", s->getNameC());
f.output("switch(__mid__)");
f.indent("{");
for(size_t m = 0; m < s->methods_.size(); m++)
{
Method& method = s->methods_[m];
f.output("case %d:", method.mid_);
f.indent("{");
f.output("if(!%s(__r__, __p__)) return false;", method.getNameC());
f.recover("}");
f.output("break;");
}
f.output("default:");
f.indent("{");
f.output("return false;");
f.recover("}");
f.recover("}");
f.output("return true;");
f.recover("}");
f.recover("}");
}
示例4: generateServiceProxy
static void generateServiceProxy(CodeFile& f, Service* s)
{
f.output("public enum %sProxyMID", s->getNameC());
f.indent("{");
for(size_t i = 0; i < s->methods_.size(); i++)
f.output("%s,", s->methods_[i].name_.c_str());
f.recover("}");
f.output("public interface %sProxy", s->getNameC());
f.indent("{");
f.output("bool filterMethod(%sProxyMID mid);", s->getNameC());
for(size_t i = 0; i < s->methods_.size(); i++)
generateProxyAbstractMethod(f, s->methods_[i]);
f.recover("}");
}
示例5: generateStruct
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("}");
}
示例6: generateMethodDispatcher
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("}");
}
示例7: generateStruct
static void generateStruct(CodeFile& f, Struct* s)
{
f.output("BTK_Writer.type_%s = function(v, b)", s->getNameC());
f.indent();
generateFieldContainerSCode(f, s);
f.recover();
f.output("end");
f.output("BTK_Reader.type_%s = function(b, p)", s->getNameC());
f.indent();
f.output("local v = {}");
generateFieldContainerDSCode(f, s);
f.output("return v, p");
f.recover();
f.output("end");
}
示例8: generateEnum
static void generateEnum(CodeFile& f, Enum* e)
{
f.output("class %s(object):", e->getNameC());
f.indent();
for(size_t i = 0; i < e->items_.size(); i++)
f.output("%s = %d", e->items_[i].c_str(), i);
f.recover();
}
示例9: generateServiceStub
static void generateServiceStub(CodeFile& f, Service* s)
{
f.output("class %sStub(object):", s->getNameC());
f.indent();
for(size_t i = 0; i < s->methods_.size(); i++)
generateServiceStubMethod(f, s->methods_[i]);
f.recover();
}
示例10: generateServiceStub
static void generateServiceStub(CodeFile& f, Service* s)
{
f.output("public abstract class %sStub", s->getNameC());
f.indent("{");
f.output("protected abstract bintalk.IWriter methodBegin();");
f.output("protected abstract void methodEnd();");
// methods.
for(size_t i = 0; i < s->methods_.size(); i++)
generateStubMethod(f, s, s->methods_[i]);
f.recover();
f.output("}");
}
示例11: generateServiceDispatcher
static void generateServiceDispatcher(CodeFile& f, Service* s)
{
f.output("class %sMID(object):", s->getNameC());
f.indent();
for(size_t i = 0; i < s->methods_.size(); i++)
f.output("%s = %d", s->methods_[i].name_.c_str(), s->methods_[i].mid_);
f.recover();
f.output("%sDispatcher = []", s->getNameC());
for(size_t i = 0; i < s->methods_.size(); i++)
generateServiceDispatcherMethod(f, s, s->methods_[i]);
f.output("def dispatch%s(__b__, __p__, __proxy__):", s->getNameC());
f.indent();
f.output("__id__, __p__ = protocol_reader.read_mid(__b__, __p__)");
f.output("if __proxy__.filterMID(__id__) == True:");
f.indent();
f.output("return __p__");
f.recover();
f.output("return %sDispatcher[__id__](__b__, __p__, __proxy__)", s->getNameC());
f.recover();
}
示例12: generateServiceDispatcherMethod
static void generateServiceDispatcherMethod(CodeFile& f, Service* s, Method& m)
{
f.output("def %s_%s(__b__, __p__, __proxy__):", s->getNameC(), m.getNameC());
f.indent();
generateFieldContainerDSCode(f, &m, false);
f.listBegin(",", false, "__proxy__.%s(", m.getNameC());
for(size_t i = 0; i < m.fields_.size(); i++)
f.listItem("%s", m.fields_[i].getNameC());
f.listEnd(")");
f.output("return __p__");
f.recover();
f.output("%sDispatcher.append(%s_%s)", s->getNameC(), s->getNameC(), m.getNameC());
}
示例13: generateFieldSCode
static void generateFieldSCode(CodeFile& f, Field& field)
{
if(field.isArray())
{
f.indent("{");
f.output("bintalk.ProtocolWriter.writeDynSize(__w__, (uint)%s.Count);", field.getNameC());
f.output("foreach(%s __vi__ in %s) bintalk.ProtocolWriter.write(__w__, __vi__);",
getFieldInnerTypeName(field),
field.getNameC());
f.recover("}");
}
else
f.output("bintalk.ProtocolWriter.write(__w__, %s);", field.getNameC());
}
示例14: generateServiceStubMethod
static void generateServiceStubMethod(CodeFile& f, Method& m)
{
f.listBegin(",", false, "def %s(", m.getNameC());
f.listItem("self");
for(size_t i = 0; i < m.fields_.size(); i++)
{
Field& field = m.fields_[i];
f.listItem("%s", field.getNameC());
}
f.listEnd("):");
f.indent();
f.output("__b__ = []");
f.output("protocol_writer.write_mid(%d, __b__)", m.mid_);
generateFieldContainerSCode(f, &m, false);
f.output("self.call(__b__)");
f.recover();
}
示例15: generateStubMethod
static void generateStubMethod(CodeFile& f, Service* s, Method& m)
{
f.listBegin(",", false, "public void %s(", m.getNameC());
for(size_t i = 0; i < m.fields_.size(); i++)
{
Field& field = m.fields_[i];
std::string tn;
getFieldTypeName(field, tn);
f.listItem("%s %s", tn.c_str(), field.getNameC());
}
f.listEnd(")");
f.indent("{");
f.output("bintalk.IWriter __w__ = methodBegin();");
f.output("bintalk.ProtocolWriter.writeMid(__w__, %d);", m.mid_);
generateFieldContainerSCode(f, &m);
f.output("methodEnd();");
f.recover("}");
}