Commit c93753be authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 56e14190
......@@ -432,3 +432,43 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
}
return 0 /* + TODO variable part */, nil
}
func (p *StoreObject) NEODecode(data []byte) (int, error) {
p.Oid = BigEndian.Uint64(data[0:])
p.Serial = BigEndian.Uint64(data[8:])
p.Compression = bool((data[16:])[0])
p.Checksum[0] = (data[17:])[0]
p.Checksum[1] = (data[18:])[0]
p.Checksum[2] = (data[19:])[0]
p.Checksum[3] = (data[20:])[0]
p.Checksum[4] = (data[21:])[0]
p.Checksum[5] = (data[22:])[0]
p.Checksum[6] = (data[23:])[0]
p.Checksum[7] = (data[24:])[0]
p.Checksum[8] = (data[25:])[0]
p.Checksum[9] = (data[26:])[0]
p.Checksum[10] = (data[27:])[0]
p.Checksum[11] = (data[28:])[0]
p.Checksum[12] = (data[29:])[0]
p.Checksum[13] = (data[30:])[0]
p.Checksum[14] = (data[31:])[0]
p.Checksum[15] = (data[32:])[0]
p.Checksum[16] = (data[33:])[0]
p.Checksum[17] = (data[34:])[0]
p.Checksum[18] = (data[35:])[0]
p.Checksum[19] = (data[36:])[0]
{
l := BigEndian.Uint32(data[37:])
data = data[41:]
p.Data = make([]byte, l)
for i := 0; i < l; i++ {
a := &p.Data[i]
a = (data[0:])[0]
data = data[1:]
}
}
p.DataSerial = BigEndian.Uint64(data[0:])
p.Tid = BigEndian.Uint64(data[8:])
p.Unlock = bool((data[16:])[0])
return 17 /* + TODO variable part */, nil
}
......@@ -414,7 +414,6 @@ type AnswerGenerateOIDs struct {
}
/*
// Ask to store an object. Send an OID, an original serial, a current
// transaction ID, and data. C -> S.
// Answer if an object has been stored. If an object is in conflict,
......@@ -432,6 +431,7 @@ type StoreObject struct {
Unlock bool
}
/*
type AnswerStoreObject struct {
Conflicting bool
Oid Oid
......
......@@ -204,6 +204,7 @@ func (d *decoder) emitstrbytes(assignto string) {
d.n = 0
}
// TODO optimize for []byte
func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice) {
// len u32
// [len]item
......@@ -256,6 +257,19 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
d.emit("%s = %s", assignto, d.decodedBasic(obj, u))
case *types.Array:
// TODO optimize for [...]byte
var i int64 // XXX because `u.Len() int64`
for i = 0; i < u.Len(); i++ {
d.emitobjtype(fmt.Sprintf("%v[%v]", assignto, i), obj, u.Elem())
}
case *types.Struct:
for i := 0; i < u.NumFields(); i++ {
v := u.Field(i)
d.emitobjtype(assignto + "." + v.Name(), v, v.Type())
}
case *types.Slice:
d.emitslice(assignto, obj, u)
......@@ -263,11 +277,6 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
d.emitmap(assignto, obj, u)
case *types.Struct:
for i := 0; i < u.NumFields(); i++ {
v := u.Field(i)
d.emitobjtype(assignto + "." + v.Name(), v, v.Type())
}
default:
log.Fatalf("%v: %v has unsupported type %v (%v)", pos(obj),
......
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