Commit 2571af8d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent bee7e8f5
......@@ -58,13 +58,14 @@ func (e *mdecodeError) Error() string {
// mOpError represents decode error when decoder faces unexpected operation.
type mOpError struct {
op, opOk msgpack.Op // op we got and what was expected
op msgpack.Op // op we got
expectedv []msgpack.Op // expected was any op from expectedv
}
func (e *mOpError) Error() string {
return fmt.Sprintf("expected opcode %02x; got %02x", e.opOk, e.op)
return fmt.Sprintf("got opcode %02x; expected any from %02x", e.op, e.expectedv)
}
func mdecodeOpErr(path string, op, opOk msgpack.Op) error {
return mdecodeErr(path+"/op", &mOpError{op, opOk})
func mdecodeOpErr(path string, op msgpack.Op, expectedv ...msgpack.Op) error {
return mdecodeErr(path+"/op", &mOpError{op, expectedv})
}
// mLen8Error represents decode error when decoder faces unexpected length in Bin8.
......
......@@ -1161,11 +1161,9 @@ func (d *decoderM) genBasic(assignto string, typ *types.Basic, userType types.Ty
case types.Bool:
// XXX move -> mgetbool ?
d.emit("switch op := msgpack.Op(data[%v]); op {", d.n)
// XXX vvv False also ok
d.emit("default: return 0, mdecodeOpErr(%q, op, msgpack.True)", d.pathName(assignto))
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)
// XXX also support 0|1 ?
d.emit("}")
d.n++
......
......@@ -2177,7 +2177,7 @@ func (p *StartOperation) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[1]); op {
default:
return 0, mdecodeOpErr("StartOperation.Backup", op, msgpack.True)
return 0, mdecodeOpErr("StartOperation.Backup", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Backup = true
case msgpack.False:
......@@ -4172,7 +4172,7 @@ func (p *AnswerRebaseObject) neoMsgDecodeM(data []byte) (int, error) {
p.ConflictSerial = zodb.Tid(binary.BigEndian.Uint64(data[13:]))
switch op := msgpack.Op(data[21]); op {
default:
return 0, mdecodeOpErr("AnswerRebaseObject.Compression", op, msgpack.True)
return 0, mdecodeOpErr("AnswerRebaseObject.Compression", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Compression = true
case msgpack.False:
......@@ -4311,7 +4311,7 @@ func (p *StoreObject) neoMsgDecodeM(data []byte) (int, error) {
p.Serial = zodb.Tid(binary.BigEndian.Uint64(data[13:]))
switch op := msgpack.Op(data[21]); op {
default:
return 0, mdecodeOpErr("StoreObject.Compression", op, msgpack.True)
return 0, mdecodeOpErr("StoreObject.Compression", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Compression = true
case msgpack.False:
......@@ -5081,7 +5081,7 @@ func (p *AnswerObject) neoMsgDecodeM(data []byte) (int, error) {
p.NextSerial = zodb.Tid(binary.BigEndian.Uint64(data[23:]))
switch op := msgpack.Op(data[31]); op {
default:
return 0, mdecodeOpErr("AnswerObject.Compression", op, msgpack.True)
return 0, mdecodeOpErr("AnswerObject.Compression", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Compression = true
case msgpack.False:
......@@ -5571,7 +5571,7 @@ func (p *AnswerTransactionInformation) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[0]); op {
default:
return 0, mdecodeOpErr("AnswerTransactionInformation.Packed", op, msgpack.True)
return 0, mdecodeOpErr("AnswerTransactionInformation.Packed", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Packed = true
case msgpack.False:
......@@ -6753,7 +6753,7 @@ func (p *TweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[1]); op {
default:
return 0, mdecodeOpErr("TweakPartitionTable.DryRun", op, msgpack.True)
return 0, mdecodeOpErr("TweakPartitionTable.DryRun", op, msgpack.True, msgpack.False)
case msgpack.True:
p.DryRun = true
case msgpack.False:
......@@ -6921,7 +6921,7 @@ func (p *AnswerTweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[1]); op {
default:
return 0, mdecodeOpErr("AnswerTweakPartitionTable.Changed", op, msgpack.True)
return 0, mdecodeOpErr("AnswerTweakPartitionTable.Changed", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Changed = true
case msgpack.False:
......@@ -7241,7 +7241,7 @@ func (p *Repair) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[1]); op {
default:
return 0, mdecodeOpErr("Repair.repairFlags.DryRun", op, msgpack.True)
return 0, mdecodeOpErr("Repair.repairFlags.DryRun", op, msgpack.True, msgpack.False)
case msgpack.True:
p.repairFlags.DryRun = true
case msgpack.False:
......@@ -7300,7 +7300,7 @@ func (p *RepairOne) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[2]); op {
default:
return 0, mdecodeOpErr("RepairOne.repairFlags.DryRun", op, msgpack.True)
return 0, mdecodeOpErr("RepairOne.repairFlags.DryRun", op, msgpack.True, msgpack.False)
case msgpack.True:
p.repairFlags.DryRun = true
case msgpack.False:
......@@ -7783,7 +7783,7 @@ func (p *AnswerObjectUndoSerial) neoMsgDecodeM(data []byte) (int, error) {
mv.UndoSerial = zodb.Tid(binary.BigEndian.Uint64(data[23:]))
switch op := msgpack.Op(data[31]); op {
default:
return 0, mdecodeOpErr("AnswerObjectUndoSerial.IsCurrent", op, msgpack.True)
return 0, mdecodeOpErr("AnswerObjectUndoSerial.IsCurrent", op, msgpack.True, msgpack.False)
case msgpack.True:
mv.IsCurrent = true
case msgpack.False:
......@@ -8105,7 +8105,7 @@ func (p *AnswerPack) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[1]); op {
default:
return 0, mdecodeOpErr("AnswerPack.Status", op, msgpack.True)
return 0, mdecodeOpErr("AnswerPack.Status", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Status = true
case msgpack.False:
......@@ -10590,7 +10590,7 @@ func (p *AddTransaction) neoMsgDecodeM(data []byte) (int, error) {
}
switch op := msgpack.Op(data[0]); op {
default:
return 0, mdecodeOpErr("AddTransaction.Packed", op, msgpack.True)
return 0, mdecodeOpErr("AddTransaction.Packed", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Packed = true
case msgpack.False:
......@@ -10738,7 +10738,7 @@ func (p *AddObject) neoMsgDecodeM(data []byte) (int, error) {
p.Serial = zodb.Tid(binary.BigEndian.Uint64(data[13:]))
switch op := msgpack.Op(data[21]); op {
default:
return 0, mdecodeOpErr("AddObject.Compression", op, msgpack.True)
return 0, mdecodeOpErr("AddObject.Compression", op, msgpack.True, msgpack.False)
case msgpack.True:
p.Compression = true
case msgpack.False:
......
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