Commit fdac1dfe authored by Levin Zimmermann's avatar Levin Zimmermann

Revert "proto/msgpack: Allow nil=false simplification"

This reverts commit d779695c.
parent ccdfd363
...@@ -1180,21 +1180,6 @@ func (d *decoderM) genBasic(assignto string, typ *types.Basic, userType types.Ty ...@@ -1180,21 +1180,6 @@ func (d *decoderM) genBasic(assignto string, typ *types.Basic, userType types.Ty
d.emit("}") d.emit("}")
} }
// mgetbool emits bool
mgetbool := func(optional bool) {
d.emit("switch op := msgpack.Op(data[%v]); op {", d.n)
d.emit("default: return 0, mdecodeOpErr(%q, op, msgpack.True, msgpack.False)", d.pathName(assignto))
d.emit("case msgpack.True: %s = true", assignto)
d.emit("case msgpack.False: %s = false", assignto)
if optional {
d.emit("case msgpack.Nil : %s = false", assignto)
}
d.emit("}")
d.n++
d.overflow.Add(1)
}
// IdTime can be nil ('None' in py), in this case we use // IdTime can be nil ('None' in py), in this case we use
// infinite -1, see // infinite -1, see
// https://lab.nexedi.com/kirr/neo/-/blob/1ad088c8/go/neo/proto/proto.go#L352-357 // https://lab.nexedi.com/kirr/neo/-/blob/1ad088c8/go/neo/proto/proto.go#L352-357
...@@ -1204,7 +1189,15 @@ func (d *decoderM) genBasic(assignto string, typ *types.Basic, userType types.Ty ...@@ -1204,7 +1189,15 @@ func (d *decoderM) genBasic(assignto string, typ *types.Basic, userType types.Ty
} }
switch typ.Kind() { switch typ.Kind() {
case types.Bool: mgetbool(true) case types.Bool:
d.emit("switch op := msgpack.Op(data[%v]); op {", d.n)
d.emit("default: return 0, mdecodeOpErr(%q, op, msgpack.True, msgpack.False)", d.pathName(assignto))
d.emit("case msgpack.True: %s = true", assignto)
d.emit("case msgpack.False: %s = false", assignto)
d.emit("}")
d.n++
d.overflow.Add(1)
case types.Int8: mgetint("", 8) case types.Int8: mgetint("", 8)
case types.Int16: mgetint("", 16) case types.Int16: mgetint("", 16)
......
...@@ -2446,8 +2446,6 @@ func (p *StartOperation) neoMsgDecodeM(data []byte) (int, error) { ...@@ -2446,8 +2446,6 @@ func (p *StartOperation) neoMsgDecodeM(data []byte) (int, error) {
p.Backup = true p.Backup = true
case msgpack.False: case msgpack.False:
p.Backup = false p.Backup = false
case msgpack.Nil:
p.Backup = false
} }
return 2, nil return 2, nil
...@@ -5121,8 +5119,6 @@ func (p *AnswerRebaseObject) neoMsgDecodeM(data []byte) (int, error) { ...@@ -5121,8 +5119,6 @@ func (p *AnswerRebaseObject) neoMsgDecodeM(data []byte) (int, error) {
p.Compression = true p.Compression = true
case msgpack.False: case msgpack.False:
p.Compression = false p.Compression = false
case msgpack.Nil:
p.Compression = false
} }
if op := msgpack.Op(data[1]); op != msgpack.Bin8 { if op := msgpack.Op(data[1]); op != msgpack.Bin8 {
return 0, mdecodeOpErr("AnswerRebaseObject.Checksum", op, msgpack.Bin8) return 0, mdecodeOpErr("AnswerRebaseObject.Checksum", op, msgpack.Bin8)
...@@ -5326,8 +5322,6 @@ func (p *StoreObject) neoMsgDecodeM(data []byte) (int, error) { ...@@ -5326,8 +5322,6 @@ func (p *StoreObject) neoMsgDecodeM(data []byte) (int, error) {
p.Compression = true p.Compression = true
case msgpack.False: case msgpack.False:
p.Compression = false p.Compression = false
case msgpack.Nil:
p.Compression = false
} }
if op := msgpack.Op(data[1]); op != msgpack.Bin8 { if op := msgpack.Op(data[1]); op != msgpack.Bin8 {
return 0, mdecodeOpErr("StoreObject.Checksum", op, msgpack.Bin8) return 0, mdecodeOpErr("StoreObject.Checksum", op, msgpack.Bin8)
...@@ -6360,8 +6354,6 @@ func (p *AnswerObject) neoMsgDecodeM(data []byte) (int, error) { ...@@ -6360,8 +6354,6 @@ func (p *AnswerObject) neoMsgDecodeM(data []byte) (int, error) {
p.Compression = true p.Compression = true
case msgpack.False: case msgpack.False:
p.Compression = false p.Compression = false
case msgpack.Nil:
p.Compression = false
} }
if op := msgpack.Op(data[1]); op != msgpack.Bin8 { if op := msgpack.Op(data[1]); op != msgpack.Bin8 {
return 0, mdecodeOpErr("AnswerObject.Checksum", op, msgpack.Bin8) return 0, mdecodeOpErr("AnswerObject.Checksum", op, msgpack.Bin8)
...@@ -6934,8 +6926,6 @@ func (p *AnswerTransactionInformation) neoMsgDecodeM(data []byte) (int, error) { ...@@ -6934,8 +6926,6 @@ func (p *AnswerTransactionInformation) neoMsgDecodeM(data []byte) (int, error) {
p.Packed = true p.Packed = true
case msgpack.False: case msgpack.False:
p.Packed = false p.Packed = false
case msgpack.Nil:
p.Packed = false
} }
{ {
data = data[1:] data = data[1:]
...@@ -8260,8 +8250,6 @@ func (p *TweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) { ...@@ -8260,8 +8250,6 @@ func (p *TweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) {
p.DryRun = true p.DryRun = true
case msgpack.False: case msgpack.False:
p.DryRun = false p.DryRun = false
case msgpack.Nil:
p.DryRun = false
} }
{ {
data = data[1:] data = data[1:]
...@@ -8437,8 +8425,6 @@ func (p *AnswerTweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) { ...@@ -8437,8 +8425,6 @@ func (p *AnswerTweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) {
p.Changed = true p.Changed = true
case msgpack.False: case msgpack.False:
p.Changed = false p.Changed = false
case msgpack.Nil:
p.Changed = false
} }
{ {
data = data[1:] data = data[1:]
...@@ -8790,8 +8776,6 @@ func (p *Repair) neoMsgDecodeM(data []byte) (int, error) { ...@@ -8790,8 +8776,6 @@ func (p *Repair) neoMsgDecodeM(data []byte) (int, error) {
p.repairFlags.DryRun = true p.repairFlags.DryRun = true
case msgpack.False: case msgpack.False:
p.repairFlags.DryRun = false p.repairFlags.DryRun = false
case msgpack.Nil:
p.repairFlags.DryRun = false
} }
return 3 + int(nread), nil return 3 + int(nread), nil
...@@ -8865,8 +8849,6 @@ func (p *RepairOne) neoMsgDecodeM(data []byte) (int, error) { ...@@ -8865,8 +8849,6 @@ func (p *RepairOne) neoMsgDecodeM(data []byte) (int, error) {
p.repairFlags.DryRun = true p.repairFlags.DryRun = true
case msgpack.False: case msgpack.False:
p.repairFlags.DryRun = false p.repairFlags.DryRun = false
case msgpack.Nil:
p.repairFlags.DryRun = false
} }
return 3, nil return 3, nil
...@@ -9488,8 +9470,6 @@ func (p *AnswerObjectUndoSerial) neoMsgDecodeM(data []byte) (int, error) { ...@@ -9488,8 +9470,6 @@ func (p *AnswerObjectUndoSerial) neoMsgDecodeM(data []byte) (int, error) {
mv.IsCurrent = true mv.IsCurrent = true
case msgpack.False: case msgpack.False:
mv.IsCurrent = false mv.IsCurrent = false
case msgpack.Nil:
mv.IsCurrent = false
} }
m[key] = mv m[key] = mv
data = data[1:] data = data[1:]
...@@ -9901,8 +9881,6 @@ func (p *AnswerPack) neoMsgDecodeM(data []byte) (int, error) { ...@@ -9901,8 +9881,6 @@ func (p *AnswerPack) neoMsgDecodeM(data []byte) (int, error) {
p.Status = true p.Status = true
case msgpack.False: case msgpack.False:
p.Status = false p.Status = false
case msgpack.Nil:
p.Status = false
} }
return 2, nil return 2, nil
...@@ -13176,8 +13154,6 @@ func (p *AddTransaction) neoMsgDecodeM(data []byte) (int, error) { ...@@ -13176,8 +13154,6 @@ func (p *AddTransaction) neoMsgDecodeM(data []byte) (int, error) {
p.Packed = true p.Packed = true
case msgpack.False: case msgpack.False:
p.Packed = false p.Packed = false
case msgpack.Nil:
p.Packed = false
} }
if data[1] == byte(msgpack.Nil) { if data[1] == byte(msgpack.Nil) {
p.TTid = zodb.Tid(18446744073709551615) p.TTid = zodb.Tid(18446744073709551615)
...@@ -13389,8 +13365,6 @@ func (p *AddObject) neoMsgDecodeM(data []byte) (int, error) { ...@@ -13389,8 +13365,6 @@ func (p *AddObject) neoMsgDecodeM(data []byte) (int, error) {
p.Compression = true p.Compression = true
case msgpack.False: case msgpack.False:
p.Compression = false p.Compression = false
case msgpack.Nil:
p.Compression = false
} }
if op := msgpack.Op(data[1]); op != msgpack.Bin8 { if op := msgpack.Op(data[1]); op != msgpack.Bin8 {
return 0, mdecodeOpErr("AddObject.Checksum", op, msgpack.Bin8) return 0, mdecodeOpErr("AddObject.Checksum", op, msgpack.Bin8)
......
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