Commit d053cc5f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dd43cd5b
......@@ -1014,12 +1014,28 @@ overflow:
func (p *AnswerLockedTransactions) NEOEncodedLen() int {
var size uint32
// TODO map
{
size += 0
for key, v := range p.TidDict {
_ = key
_ = v
size += 16
}
}
return int(size) + 0
}
func (p *AnswerLockedTransactions) NEOEncode(data []byte) {
// TODO map
{
l := uint32(len(p.TidDict))
binary.BigEndian.PutUint32(data[0:], l)
data = data[4:]
for key, v := range p.TidDict {
binary.BigEndian.PutUint64(data[0:], uint64(key))
binary.BigEndian.PutUint64(data[8:], uint64(v))
data = data[16:]
}
}
}
func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) {
......@@ -2795,12 +2811,30 @@ overflow:
func (p *AnswerObjectUndoSerial) NEOEncodedLen() int {
var size uint32
// TODO map
{
size += 0
for key, v := range p.ObjectTIDDict {
_ = key
_ = v
size += 25
}
}
return int(size) + 0
}
func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) {
// TODO map
{
l := uint32(len(p.ObjectTIDDict))
binary.BigEndian.PutUint32(data[0:], l)
data = data[4:]
for key, v := range p.ObjectTIDDict {
binary.BigEndian.PutUint64(data[0:], uint64(key))
binary.BigEndian.PutUint64(data[8:], uint64(v.CurrentSerial))
binary.BigEndian.PutUint64(data[16:], uint64(v.UndoSerial))
(data[24:])[0] = bool2byte(v.IsCurrent)
data = data[25:]
}
}
}
func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
......@@ -2979,12 +3013,28 @@ overflow:
func (p *CheckReplicas) NEOEncodedLen() int {
var size uint32
// TODO map
{
size += 0
for key, v := range p.PartitionDict {
_ = key
_ = v
size += 8
}
}
return int(size) + 16
}
func (p *CheckReplicas) NEOEncode(data []byte) {
// TODO map
{
l := uint32(len(p.PartitionDict))
binary.BigEndian.PutUint32(data[0:], l)
data = data[4:]
for key, v := range p.PartitionDict {
binary.BigEndian.PutUint32(data[0:], key)
binary.BigEndian.PutUint32(data[4:], uint32(int32(v)))
data = data[8:]
}
}
binary.BigEndian.PutUint64(data[0:], uint64(p.MinTID))
binary.BigEndian.PutUint64(data[8:], uint64(p.MaxTID))
}
......
......@@ -357,13 +357,37 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
d.n = 0
}
// generate code to encode/decode map
// len u32
// [len](key, value)
func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e.emit("// TODO map")
e.emit("{")
if !e.SizeOnly {
e.emit("l := uint32(len(%s))", path)
e.genBasic("l", types.Typ[types.Uint32], nil, nil)
e.emit("data = data[%v:]", e.n)
} else {
e.emit("size += %v", e.n)
}
e.n = 0
// TODO if size(item)==const - size update in one go
e.emit("for key, v := range %s {", path)
codegenType("key", typ.Key(), obj, e)
codegenType("v", typ.Elem(), obj, e)
if !e.SizeOnly {
e.emit("data = data[%v:]", e.n) // XXX wrt map of map?
} else {
e.emit("_ = key") // FIXME remove
e.emit("_ = v") // FIXME remove
e.emit("size += %v", e.n)
}
e.emit("}")
// XXX vvv ?
e.emit("}")
e.n = 0
}
func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
// len u32
// [len](key, value)
d.emit("{")
d.genBasic("l:", types.Typ[types.Uint32], nil, nil)
d.emit("data = data[%v:]", d.n)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment