Commit b057ca72 authored by Kirill Smelkov's avatar Kirill Smelkov

X dirty fix (?) for slice-of-slice case

parent a4f12a18
...@@ -45,8 +45,9 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) { ...@@ -45,8 +45,9 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) {
data = data[8:] data = data[8:]
p.CellList = make([]neo.CellInfo, l) p.CellList = make([]neo.CellInfo, l)
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
p.CellList[i].UUID = int32(BigEndian.Uint32(data[0:])) a := &p.CellList[i]
p.CellList[i].CellState = int32(BigEndian.Uint32(data[4:])) a.UUID = int32(BigEndian.Uint32(data[0:]))
a.CellState = int32(BigEndian.Uint32(data[4:]))
data = data[8:] data = data[8:]
} }
} }
...@@ -139,17 +140,18 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -139,17 +140,18 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
UUID neo.UUID UUID neo.UUID
}, l) }, l)
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
a := &p.KnownMasterList[i]
{ {
l := BigEndian.Uint32(data[0:]) l := BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if len(data) < l { if len(data) < l {
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
} }
p.KnownMasterList[i].Address.Host = string(data[:l]) a.Address.Host = string(data[:l])
data = data[l:] data = data[l:]
} }
p.KnownMasterList[i].Address.Port = BigEndian.Uint16(data[0:]) a.Address.Port = BigEndian.Uint16(data[0:])
p.KnownMasterList[i].UUID = int32(BigEndian.Uint32(data[2:])) a.UUID = int32(BigEndian.Uint32(data[2:]))
data = data[6:] data = data[6:]
} }
} }
...@@ -205,14 +207,16 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -205,14 +207,16 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) {
data = data[12:] data = data[12:]
p.RowList = make([]neo.RowInfo, l) p.RowList = make([]neo.RowInfo, l)
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
p.RowList[i].Offset = BigEndian.Uint32(data[0:]) a := &p.RowList[i]
a.Offset = BigEndian.Uint32(data[0:])
{ {
l := BigEndian.Uint32(data[4:]) l := BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
p.RowList[i].CellList = make([]neo.CellInfo, l) a.CellList = make([]neo.CellInfo, l)
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
p.RowList[i].CellList[i].UUID = int32(BigEndian.Uint32(data[0:])) a := &a.CellList[i]
p.RowList[i].CellList[i].CellState = int32(BigEndian.Uint32(data[4:])) a.UUID = int32(BigEndian.Uint32(data[0:]))
a.CellState = int32(BigEndian.Uint32(data[4:]))
data = data[8:] data = data[8:]
} }
} }
......
...@@ -214,8 +214,9 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice) ...@@ -214,8 +214,9 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
// TODO if size(item)==const - check l in one go // TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }") //d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
d.emit("for i := 0; i < l; i++ {") d.emit("for i := 0; i < l; i++ {")
d.emit("a := &%s[i]", assignto)
d.n = 0 d.n = 0
d.emitobjtype(assignto + "[i]", obj, typ.Elem()) // XXX also obj.Elem() ? d.emitobjtype("a", obj, typ.Elem()) // XXX also obj.Elem() ?
d.emit("data = data[%v:]", d.n) // FIXME wrt slice of slice ? d.emit("data = data[%v:]", d.n) // FIXME wrt slice of slice ?
d.emit("}") d.emit("}")
//d.emit("%v = string(data[:l])", assignto) //d.emit("%v = string(data[:l])", assignto)
......
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