示例#1
0
 public string Accept(TMap type, string bufName)
 {
     return($@"func (_buf2 *serialization.ByteBuf) (_v2 {type.Apply(GoTypeNameVisitor.Ins)}, err2 error) {{
         _v2 = make({type.Apply(GoTypeNameVisitor.Ins)})
         var n int
         if n, err2 = _buf2.ReadSize(); err2 != nil {{return}}
         for i := 0 ; i < n ; i++ {{
             var _key {type.KeyType.Apply(GoTypeNameVisitor.Ins)}
             if _key, err2 = {type.KeyType.Apply(this, "_buf2")}; err2 != nil {{return}}
             var _value {type.ValueType.Apply(GoTypeNameVisitor.Ins)}
             if _value, err2 = {type.ValueType.Apply(this, "_buf2")}; err2 != nil {{return}}
             _v2[_key] = _value
         }}
         return
         }}({bufName})");
 }
 public string Accept(TMap type, string bufName, string fieldName)
 {
     return($"{{int n = System.Math.Min({bufName}.ReadSize(), {bufName}.Size);{fieldName} = new {type.Apply(CsDefineTypeName.Ins)}(n * 3 / 2);for(var i = 0 ; i < n ; i++) {{ {type.KeyType.Apply(CsDefineTypeName.Ins)} _k;  {type.KeyType.Apply(this, bufName, "_k")} {type.ValueType.Apply(CsDefineTypeName.Ins)} _v;  {type.ValueType.Apply(this, bufName, "_v")}     {fieldName}.Add(_k, _v);}}}}");
 }
 public string Accept(TMap type, string bufName, string fieldName)
 {
     return($"{{int n = Math.min({bufName}.readSize(), {bufName}.size());{fieldName} = new {type.Apply(JavaDefineTypeName.Ins)}(n * 3 / 2);for(int i = 0 ; i < n ; i++) {{ {type.KeyType.Apply(JavaBoxDefineTypeName.Ins)} _k;  {type.KeyType.Apply(this, bufName, "_k")} {type.ValueType.Apply(JavaBoxDefineTypeName.Ins)} _v;  {type.ValueType.Apply(this, bufName, "_v")}     {fieldName}.put(_k, _v);}}}}");
 }
示例#4
0
 public string Accept(TMap type, string jsonVarName, string fieldName)
 {
     return($"{fieldName} = new {type.Apply(TsDefineTypeName.Ins)}(); for(var _entry_ of {jsonVarName}) {{ let _k:{type.KeyType.Apply(TsDefineTypeName.Ins)};  {type.KeyType.Apply(this, "_entry_[0]", "_k")}  let _v:{type.ValueType.Apply(TsDefineTypeName.Ins)};  {type.ValueType.Apply(this, "_entry_[1]", "_v")}     {fieldName}.set(_k, _v);  }}");
 }
示例#5
0
 public string Accept(TMap type, string fieldName, string logType)
 {
     return($"{fieldName} = new {type.Apply(DbCsDefineTypeVisitor.Ins)}(_v => new {logType}(this, _v));");
 }