Prepare moving vom from v.io/v23 to v.io/core/veyron/lib (part 2)
diff --git a/lib/vom/binary_decoder.go b/lib/vom/binary_decoder.go
new file mode 100644
index 0000000..8ce9dce
--- /dev/null
+++ b/lib/vom/binary_decoder.go
@@ -0,0 +1,521 @@
+package vom
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+
+ "v.io/v23/vdl"
+)
+
+var (
+ errDecodeZeroTypeID = errors.New("vom: type ID 0")
+ errIndexOutOfRange = errors.New("vom: index out of range")
+)
+
+type binaryDecoder struct {
+ buf *decbuf
+ recvTypes *decoderTypes
+}
+
+func newBinaryDecoder(buf *decbuf, types *decoderTypes) *binaryDecoder {
+ return &binaryDecoder{buf, types}
+}
+
+func (d *binaryDecoder) Decode(target vdl.Target) error {
+ valType, err := d.decodeValueType()
+ if err != nil {
+ return err
+ }
+ return d.decodeValueMsg(valType, target)
+}
+
+func (d *binaryDecoder) DecodeRaw(raw *RawValue) error {
+ valType, err := d.decodeValueType()
+ if err != nil {
+ return err
+ }
+ valLen, err := d.decodeValueByteLen(valType)
+ if err != nil {
+ return err
+ }
+ raw.recvTypes = d.recvTypes
+ raw.valType = valType
+ if cap(raw.data) >= valLen {
+ raw.data = raw.data[:valLen]
+ } else {
+ raw.data = make([]byte, valLen)
+ }
+ return d.buf.ReadFull(raw.data)
+}
+
+func (d *binaryDecoder) Ignore() error {
+ valType, err := d.decodeValueType()
+ if err != nil {
+ return err
+ }
+ valLen, err := d.decodeValueByteLen(valType)
+ if err != nil {
+ return err
+ }
+ return d.buf.Skip(valLen)
+}
+
+// decodeValueType returns the type of the next value message. Any type
+// definition messages it encounters along the way are decoded and added to
+// recvTypes.
+func (d *binaryDecoder) decodeValueType() (*vdl.Type, error) {
+ for {
+ id, err := binaryDecodeInt(d.buf)
+ if err != nil {
+ return nil, err
+ }
+ switch {
+ case id == 0:
+ return nil, errDecodeZeroTypeID
+ case id > 0:
+ // This is a value message, the typeID is +id.
+ tid := typeID(+id)
+ tt, err := d.recvTypes.LookupOrBuildType(tid)
+ if err != nil {
+ return nil, err
+ }
+ return tt, nil
+ }
+ // This is a type message, the typeID is -id.
+ tid := typeID(-id)
+ // Decode the wireType like a regular value, and store it in recvTypes. The
+ // type will actually be built when a value message arrives using this tid.
+ var wt wireType
+ target, err := vdl.ReflectTarget(reflect.ValueOf(&wt))
+ if err != nil {
+ return nil, err
+ }
+ if err := d.decodeValueMsg(wireTypeType, target); err != nil {
+ return nil, err
+ }
+ if err := d.recvTypes.AddWireType(tid, wt); err != nil {
+ return nil, err
+ }
+ }
+}
+
+// decodeValueByteLen returns the byte length of the next value.
+func (d *binaryDecoder) decodeValueByteLen(tt *vdl.Type) (int, error) {
+ if hasBinaryMsgLen(tt) {
+ // Use the explicit message length.
+ msgLen, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return 0, err
+ }
+ return msgLen, nil
+ }
+ // No explicit message length, but the length can be computed.
+ switch {
+ case tt.Kind() == vdl.Byte:
+ // Single byte is always encoded as 1 byte.
+ return 1, nil
+ case tt.Kind() == vdl.Array && tt.IsBytes():
+ // Byte arrays are exactly their length and encoded with 1-byte header.
+ return tt.Len() + 1, nil
+ case tt.Kind() == vdl.String || tt.IsBytes():
+ // Strings and byte lists are encoded with a length header.
+ strlen, bytelen, err := binaryPeekUint(d.buf)
+ switch {
+ case err != nil:
+ return 0, err
+ case strlen > maxBinaryMsgLen:
+ return 0, errMsgLen
+ }
+ return int(strlen) + bytelen, nil
+ default:
+ // Must be a primitive, which is encoded as an underlying uint.
+ return binaryPeekUintByteLen(d.buf)
+ }
+}
+
+// decodeValueMsg decodes the rest of the message assuming type t, handling the
+// optional message length.
+func (d *binaryDecoder) decodeValueMsg(tt *vdl.Type, target vdl.Target) error {
+ if hasBinaryMsgLen(tt) {
+ msgLen, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return err
+ }
+ d.buf.SetLimit(msgLen)
+ }
+ err := d.decodeValue(tt, target)
+ leftover := d.buf.RemoveLimit()
+ switch {
+ case err != nil:
+ return err
+ case leftover > 0:
+ return fmt.Errorf("vom: %d leftover bytes", leftover)
+ }
+ return nil
+}
+
+// decodeValue decodes the rest of the message assuming type tt.
+func (d *binaryDecoder) decodeValue(tt *vdl.Type, target vdl.Target) error {
+ ttFrom := tt
+ if tt.Kind() == vdl.Optional {
+ // If the type is optional, we expect to see either WireCtrlNil or the actual
+ // value, but not both. And thus, we can just peek for the WireCtrlNil here.
+ switch ctrl, err := binaryPeekControl(d.buf); {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlNil:
+ d.buf.Skip(1)
+ return target.FromNil(ttFrom)
+ }
+ tt = tt.Elem()
+ }
+ if tt.IsBytes() {
+ len, err := binaryDecodeLenOrArrayLen(d.buf, tt)
+ if err != nil {
+ return err
+ }
+ bytes, err := d.buf.ReadBuf(len)
+ if err != nil {
+ return err
+ }
+ return target.FromBytes(bytes, ttFrom)
+ }
+ switch kind := tt.Kind(); kind {
+ case vdl.Bool:
+ v, err := binaryDecodeBool(d.buf)
+ if err != nil {
+ return err
+ }
+ return target.FromBool(v, ttFrom)
+ case vdl.Byte:
+ v, err := d.buf.ReadByte()
+ if err != nil {
+ return err
+ }
+ return target.FromUint(uint64(v), ttFrom)
+ case vdl.Uint16, vdl.Uint32, vdl.Uint64:
+ v, err := binaryDecodeUint(d.buf)
+ if err != nil {
+ return err
+ }
+ return target.FromUint(v, ttFrom)
+ case vdl.Int16, vdl.Int32, vdl.Int64:
+ v, err := binaryDecodeInt(d.buf)
+ if err != nil {
+ return err
+ }
+ return target.FromInt(v, ttFrom)
+ case vdl.Float32, vdl.Float64:
+ v, err := binaryDecodeFloat(d.buf)
+ if err != nil {
+ return err
+ }
+ return target.FromFloat(v, ttFrom)
+ case vdl.Complex64, vdl.Complex128:
+ re, err := binaryDecodeFloat(d.buf)
+ if err != nil {
+ return err
+ }
+ im, err := binaryDecodeFloat(d.buf)
+ if err != nil {
+ return err
+ }
+ return target.FromComplex(complex(re, im), ttFrom)
+ case vdl.String:
+ v, err := binaryDecodeString(d.buf)
+ if err != nil {
+ return err
+ }
+ return target.FromString(v, ttFrom)
+ case vdl.Enum:
+ index, err := binaryDecodeUint(d.buf)
+ switch {
+ case err != nil:
+ return err
+ case index >= uint64(tt.NumEnumLabel()):
+ return errIndexOutOfRange
+ }
+ return target.FromEnumLabel(tt.EnumLabel(int(index)), ttFrom)
+ case vdl.TypeObject:
+ id, err := binaryDecodeUint(d.buf)
+ if err != nil {
+ return err
+ }
+ typeobj, err := d.recvTypes.LookupOrBuildType(typeID(id))
+ if err != nil {
+ return err
+ }
+ return target.FromTypeObject(typeobj)
+ case vdl.Array, vdl.List:
+ len, err := binaryDecodeLenOrArrayLen(d.buf, tt)
+ if err != nil {
+ return err
+ }
+ listTarget, err := target.StartList(ttFrom, len)
+ if err != nil {
+ return err
+ }
+ for ix := 0; ix < len; ix++ {
+ elem, err := listTarget.StartElem(ix)
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(tt.Elem(), elem); err != nil {
+ return err
+ }
+ if err := listTarget.FinishElem(elem); err != nil {
+ return err
+ }
+ }
+ return target.FinishList(listTarget)
+ case vdl.Set:
+ len, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return err
+ }
+ setTarget, err := target.StartSet(ttFrom, len)
+ if err != nil {
+ return err
+ }
+ for ix := 0; ix < len; ix++ {
+ key, err := setTarget.StartKey()
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(tt.Key(), key); err != nil {
+ return err
+ }
+ switch err := setTarget.FinishKey(key); {
+ case err == vdl.ErrFieldNoExist:
+ continue
+ case err != nil:
+ return err
+ }
+ }
+ return target.FinishSet(setTarget)
+ case vdl.Map:
+ len, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return err
+ }
+ mapTarget, err := target.StartMap(ttFrom, len)
+ if err != nil {
+ return err
+ }
+ for ix := 0; ix < len; ix++ {
+ key, err := mapTarget.StartKey()
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(tt.Key(), key); err != nil {
+ return err
+ }
+ switch field, err := mapTarget.FinishKeyStartField(key); {
+ case err == vdl.ErrFieldNoExist:
+ if err := d.ignoreValue(tt.Elem()); err != nil {
+ return err
+ }
+ case err != nil:
+ return err
+ default:
+ if err := d.decodeValue(tt.Elem(), field); err != nil {
+ return err
+ }
+ if err := mapTarget.FinishField(key, field); err != nil {
+ return err
+ }
+ }
+ }
+ return target.FinishMap(mapTarget)
+ case vdl.Struct:
+ fieldsTarget, err := target.StartFields(ttFrom)
+ if err != nil {
+ return err
+ }
+ // Loop through decoding the 0-based field index and corresponding field.
+ decodedFields := make([]bool, tt.NumField())
+ for {
+ index, ctrl, err := binaryDecodeUintWithControl(d.buf)
+ switch {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlEOF:
+ // Fill not-yet-decoded fields with their zero values.
+ for index, decoded := range decodedFields {
+ if decoded {
+ continue
+ }
+ ttfield := tt.Field(index)
+ switch key, field, err := fieldsTarget.StartField(ttfield.Name); {
+ case err == vdl.ErrFieldNoExist:
+ // Ignore it.
+ case err != nil:
+ return err
+ default:
+ if err := vdl.FromValue(field, vdl.ZeroValue(ttfield.Type)); err != nil {
+ return err
+ }
+ if err := fieldsTarget.FinishField(key, field); err != nil {
+ return err
+ }
+ }
+ }
+ return target.FinishFields(fieldsTarget)
+ case ctrl != 0:
+ return fmt.Errorf("vom: unexpected control byte 0x%x", ctrl)
+ case index >= uint64(tt.NumField()):
+ return errIndexOutOfRange
+ }
+ ttfield := tt.Field(int(index))
+ switch key, field, err := fieldsTarget.StartField(ttfield.Name); {
+ case err == vdl.ErrFieldNoExist:
+ if err := d.ignoreValue(ttfield.Type); err != nil {
+ return err
+ }
+ case err != nil:
+ return err
+ default:
+ if err := d.decodeValue(ttfield.Type, field); err != nil {
+ return err
+ }
+ if err := fieldsTarget.FinishField(key, field); err != nil {
+ return err
+ }
+ }
+ decodedFields[index] = true
+ }
+ case vdl.Union:
+ fieldsTarget, err := target.StartFields(ttFrom)
+ if err != nil {
+ return err
+ }
+ index, err := binaryDecodeUint(d.buf)
+ switch {
+ case err != nil:
+ return err
+ case index >= uint64(tt.NumField()):
+ return errIndexOutOfRange
+ }
+ ttfield := tt.Field(int(index))
+ key, field, err := fieldsTarget.StartField(ttfield.Name)
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(ttfield.Type, field); err != nil {
+ return err
+ }
+ if err := fieldsTarget.FinishField(key, field); err != nil {
+ return err
+ }
+ return target.FinishFields(fieldsTarget)
+ case vdl.Any:
+ switch id, ctrl, err := binaryDecodeUintWithControl(d.buf); {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlNil:
+ return target.FromNil(vdl.AnyType)
+ case ctrl != 0:
+ return fmt.Errorf("vom: unexpected control byte 0x%x", ctrl)
+ default:
+ elemType, err := d.recvTypes.LookupOrBuildType(typeID(id))
+ if err != nil {
+ return err
+ }
+ return d.decodeValue(elemType, target)
+ }
+ default:
+ panic(fmt.Errorf("vom: decodeValue unhandled type %v", tt))
+ }
+}
+
+// ignoreValue ignores the rest of the value of type t. This is used to ignore
+// unknown struct fields.
+func (d *binaryDecoder) ignoreValue(tt *vdl.Type) error {
+ if tt.IsBytes() {
+ len, err := binaryDecodeLenOrArrayLen(d.buf, tt)
+ if err != nil {
+ return err
+ }
+ return d.buf.Skip(len)
+ }
+ switch kind := tt.Kind(); kind {
+ case vdl.Bool, vdl.Byte:
+ return d.buf.Skip(1)
+ case vdl.Uint16, vdl.Uint32, vdl.Uint64, vdl.Int16, vdl.Int32, vdl.Int64, vdl.Float32, vdl.Float64, vdl.Enum, vdl.TypeObject:
+ // The underlying encoding of all these types is based on uint.
+ return binaryIgnoreUint(d.buf)
+ case vdl.Complex64, vdl.Complex128:
+ // Complex is encoded as two floats, so we can simply ignore two uints.
+ if err := binaryIgnoreUint(d.buf); err != nil {
+ return err
+ }
+ return binaryIgnoreUint(d.buf)
+ case vdl.String:
+ return binaryIgnoreString(d.buf)
+ case vdl.Array, vdl.List, vdl.Set, vdl.Map:
+ len, err := binaryDecodeLenOrArrayLen(d.buf, tt)
+ if err != nil {
+ return err
+ }
+ for ix := 0; ix < len; ix++ {
+ if kind == vdl.Set || kind == vdl.Map {
+ if err := d.ignoreValue(tt.Key()); err != nil {
+ return err
+ }
+ }
+ if kind == vdl.Array || kind == vdl.List || kind == vdl.Map {
+ if err := d.ignoreValue(tt.Elem()); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+ case vdl.Struct:
+ // Loop through decoding the 0-based field index and corresponding field.
+ for {
+ switch index, ctrl, err := binaryDecodeUintWithControl(d.buf); {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlEOF:
+ return nil
+ case ctrl != 0:
+ return fmt.Errorf("vom: unexpected control byte 0x%x", ctrl)
+ case index >= uint64(tt.NumField()):
+ return errIndexOutOfRange
+ default:
+ ttfield := tt.Field(int(index))
+ if err := d.ignoreValue(ttfield.Type); err != nil {
+ return err
+ }
+ }
+ }
+ case vdl.Union:
+ switch index, err := binaryDecodeUint(d.buf); {
+ case err != nil:
+ return err
+ case index >= uint64(tt.NumField()):
+ return errIndexOutOfRange
+ default:
+ ttfield := tt.Field(int(index))
+ return d.ignoreValue(ttfield.Type)
+ }
+ case vdl.Any:
+ switch id, ctrl, err := binaryDecodeUintWithControl(d.buf); {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlNil:
+ return nil
+ case ctrl != 0:
+ return fmt.Errorf("vom: unexpected control byte 0x%x", ctrl)
+ default:
+ elemType, err := d.recvTypes.LookupOrBuildType(typeID(id))
+ if err != nil {
+ return err
+ }
+ return d.ignoreValue(elemType)
+ }
+ default:
+ panic(fmt.Errorf("vom: ignoreValue unhandled type %v", tt))
+ }
+}
diff --git a/lib/vom/binary_encoder.go b/lib/vom/binary_encoder.go
new file mode 100644
index 0000000..430fd4f
--- /dev/null
+++ b/lib/vom/binary_encoder.go
@@ -0,0 +1,589 @@
+package vom
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "reflect"
+
+ "v.io/v23/vdl"
+)
+
+var (
+ errEncodeNilType = errors.New("no value encoded (encoder finished with nil type)")
+ errEncodeZeroTypeID = errors.New("encoder finished with type ID 0")
+ errEncodeBadTypeStack = errors.New("encoder has bad type stack")
+
+ // Make sure binaryEncoder implements the vdl *Target interfaces.
+ _ vdl.Target = (*binaryEncoder)(nil)
+ _ vdl.ListTarget = (*binaryEncoder)(nil)
+ _ vdl.SetTarget = (*binaryEncoder)(nil)
+ _ vdl.MapTarget = (*binaryEncoder)(nil)
+ _ vdl.FieldsTarget = (*binaryEncoder)(nil)
+)
+
+type binaryEncoder struct {
+ writer io.Writer
+ // The binary encoder uses a 2-buffer strategy for writing. We use bufT to
+ // encode type definitions, and write them out to the writer directly. We use
+ // buf to buffer up the encoded value. The buf buffering is necessary so
+ // that we can compute the total message length, and also to ensure that all
+ // dynamic types are written before the value.
+ buf, bufT *encbuf
+ // We maintain a typeStack, where typeStack[0] holds the type of the top-level
+ // value being encoded, and subsequent layers of the stack holds type information
+ // for composites and subtypes. Each entry also holds the start position of the
+ // encoding buffer, which will be used to ignore zero value fields in structs.
+ // typeStackT is used for encoding type definitions.
+ typeStack, typeStackT []typeStackEntry
+ // The binary encoder maintains all types it has sent in sentTypes.
+ sentTypes *encoderTypes
+}
+
+type typeStackEntry struct {
+ tt *vdl.Type
+ pos int
+}
+
+func newBinaryEncoder(w io.Writer, et *encoderTypes) *binaryEncoder {
+ return &binaryEncoder{
+ writer: w,
+ buf: newEncbuf(),
+ bufT: newEncbuf(),
+ typeStack: make([]typeStackEntry, 0, 10),
+ typeStackT: make([]typeStackEntry, 0, 10),
+ sentTypes: et,
+ }
+}
+
+// paddingLen must be large enough to hold the header in writeMsg.
+const paddingLen = maxEncodedUintBytes * 2
+
+func (e *binaryEncoder) StartEncode() error {
+ e.buf.Reset()
+ e.buf.Grow(paddingLen)
+ e.typeStack = e.typeStack[:0]
+ return nil
+}
+
+func (e *binaryEncoder) FinishEncode() error {
+ switch {
+ case len(e.typeStack) > 1:
+ return errEncodeBadTypeStack
+ case len(e.typeStack) == 0:
+ return errEncodeNilType
+ }
+ encType := e.typeStack[0].tt
+ id := e.sentTypes.LookupID(encType)
+ if id == 0 {
+ return errEncodeZeroTypeID
+ }
+ return e.writeMsg(e.buf, +int64(id), hasBinaryMsgLen(encType))
+}
+
+func (e *binaryEncoder) writeMsg(buf *encbuf, id int64, encodeLen bool) error {
+ // Binary messages always start with a signed id, sometimes followed by the
+ // byte length of the rest of the message. We only know the byte length after
+ // we've encoded the rest of the message. To make this reasonably efficient,
+ // the buffer is initialized with enough padding to hold the id and length,
+ // and we go back and fill them in here.
+ //
+ // The binaryEncode*End methods fill in the trailing bytes of the buffer and
+ // return the start index of the encoded data. Thus the binaryEncode*End
+ // calls here are in the opposite order they appear in the encoded message.
+ msg := buf.Bytes()
+ header := msg[:paddingLen]
+ if encodeLen {
+ start := binaryEncodeUintEnd(header, uint64(len(msg)-paddingLen))
+ header = header[:start]
+ }
+ start := binaryEncodeIntEnd(header, id)
+ _, err := e.writer.Write(msg[start:])
+ return err
+}
+
+// encodeUnsentTypes encodes the wire type corresponding to tt into the type
+// buffer e.bufT. It does this recursively in depth-first order, encoding any
+// children of the type before the type itself. Type ids are allocated in the
+// order that we recurse and consequentially may be sent out of sequential
+// order if type information for children is sent (before the parent type).
+func (e *binaryEncoder) encodeUnsentTypes(tt *vdl.Type) (typeID, error) {
+ if isWireTypeType(tt) {
+ // Ignore types for wire type definition.
+ return 0, nil
+ }
+ // Lookup a type ID for tt or assign a new one.
+ tid, isNew := e.sentTypes.LookupOrAssignID(tt)
+ if !isNew {
+ return tid, nil
+ }
+
+ // Construct the wireType.
+ var wt wireType
+ switch kind := tt.Kind(); kind {
+ case vdl.Bool, vdl.Byte, vdl.String, vdl.Uint16, vdl.Uint32, vdl.Uint64, vdl.Int16, vdl.Int32, vdl.Int64, vdl.Float32, vdl.Float64, vdl.Complex64, vdl.Complex128:
+ wt = wireTypeNamedT{wireNamed{tt.Name(), bootstrapKindToID[kind]}}
+ case vdl.Enum:
+ wireEnum := wireEnum{tt.Name(), make([]string, tt.NumEnumLabel())}
+ for ix := 0; ix < tt.NumEnumLabel(); ix++ {
+ wireEnum.Labels[ix] = tt.EnumLabel(ix)
+ }
+ wt = wireTypeEnumT{wireEnum}
+ case vdl.Array:
+ elm, err := e.encodeUnsentTypes(tt.Elem())
+ if err != nil {
+ return 0, err
+ }
+ wt = wireTypeArrayT{wireArray{tt.Name(), elm, uint64(tt.Len())}}
+ case vdl.List:
+ elm, err := e.encodeUnsentTypes(tt.Elem())
+ if err != nil {
+ return 0, err
+ }
+ wt = wireTypeListT{wireList{tt.Name(), elm}}
+ case vdl.Set:
+ key, err := e.encodeUnsentTypes(tt.Key())
+ if err != nil {
+ return 0, err
+ }
+ wt = wireTypeSetT{wireSet{tt.Name(), key}}
+ case vdl.Map:
+ key, err := e.encodeUnsentTypes(tt.Key())
+ if err != nil {
+ return 0, err
+ }
+ elm, err := e.encodeUnsentTypes(tt.Elem())
+ if err != nil {
+ return 0, err
+ }
+ wt = wireTypeMapT{wireMap{tt.Name(), key, elm}}
+ case vdl.Struct:
+ wireStruct := wireStruct{tt.Name(), make([]wireField, tt.NumField())}
+ for ix := 0; ix < tt.NumField(); ix++ {
+ field, err := e.encodeUnsentTypes(tt.Field(ix).Type)
+ if err != nil {
+ return 0, err
+ }
+ wireStruct.Fields[ix] = wireField{tt.Field(ix).Name, field}
+ }
+ wt = wireTypeStructT{wireStruct}
+ case vdl.Union:
+ wireUnion := wireUnion{tt.Name(), make([]wireField, tt.NumField())}
+ for ix := 0; ix < tt.NumField(); ix++ {
+ field, err := e.encodeUnsentTypes(tt.Field(ix).Type)
+ if err != nil {
+ return 0, err
+ }
+ wireUnion.Fields[ix] = wireField{tt.Field(ix).Name, field}
+ }
+ wt = wireTypeUnionT{wireUnion}
+ case vdl.Optional:
+ elm, err := e.encodeUnsentTypes(tt.Elem())
+ if err != nil {
+ return 0, err
+ }
+ wt = wireTypeOptionalT{wireOptional{tt.Name(), elm}}
+ default:
+ panic(fmt.Errorf("vom: encodeUnsentTypes unhandled type %v", tt))
+ }
+
+ // Encode and write the wire type definition.
+ //
+ // We use the same encoding routines as values for wire types. Since the type
+ // encoding can happen any time in the middle of value encoding, we save the
+ // status for value encoding such as buf and type stack. This assumes wireType
+ // encoding below will never call this recursively. This is true for now since
+ // wireType type and its all child types are internal built-in types and we do
+ // not send those types.
+ //
+ // TODO(jhahn): clean this up to be simpler to understand, easier to ensure that
+ // vdl.FromReflect doesn't end up calling us recursively.
+ e.buf, e.bufT = e.bufT, e.buf
+ e.typeStack, e.typeStackT = e.typeStackT, e.typeStack
+
+ e.buf.Reset()
+ e.buf.Grow(paddingLen)
+ e.typeStack = e.typeStack[:0]
+
+ if err := vdl.FromReflect(e, reflect.ValueOf(wt)); err != nil {
+ return 0, err
+ }
+
+ switch {
+ case len(e.typeStack) > 1:
+ return 0, errEncodeBadTypeStack
+ case len(e.typeStack) == 0:
+ return 0, errEncodeNilType
+ }
+ encType := e.typeStack[0].tt
+ if err := e.writeMsg(e.buf, -int64(tid), hasBinaryMsgLen(encType)); err != nil {
+ return 0, err
+ }
+
+ e.typeStack, e.typeStackT = e.typeStackT, e.typeStack
+ e.buf, e.bufT = e.bufT, e.buf
+ return tid, nil
+}
+
+func errTypeMismatch(t *vdl.Type, kinds ...vdl.Kind) error {
+ return fmt.Errorf("encoder type mismatch, got %q, want %v", t, kinds)
+}
+
+// prepareType prepares to encode a non-nil value of type tt, checking to make
+// sure it has one of the specified kinds, and encoding any unsent types.
+func (e *binaryEncoder) prepareType(t *vdl.Type, kinds ...vdl.Kind) error {
+ for _, k := range kinds {
+ if t.Kind() == k || t.Kind() == vdl.Optional && t.Elem().Kind() == k {
+ return e.prepareTypeHelper(t, false)
+ }
+ }
+ return errTypeMismatch(t, kinds...)
+}
+
+// prepareTypeHelper encodes any unsent types, and manages the type stack. If
+// fromNil is true, we skip encoding the typeid for any type, since we'll be
+// encoding a nil instead.
+func (e *binaryEncoder) prepareTypeHelper(tt *vdl.Type, fromNil bool) error {
+ tid, err := e.encodeUnsentTypes(tt)
+ if err != nil {
+ return err
+ }
+ top := e.topType()
+ // Handle the type id for Any values.
+ switch {
+ case top == nil:
+ // Encoding the top-level. We postpone encoding of the tid until writeMsg
+ // is called, to handle positive and negative ids, and the message length.
+ top = tt
+ e.pushType(top)
+ case top.Kind() == vdl.Any:
+ if !fromNil {
+ binaryEncodeUint(e.buf, uint64(tid))
+ }
+ }
+ return nil
+}
+
+func (e *binaryEncoder) pushType(tt *vdl.Type) {
+ e.typeStack = append(e.typeStack, typeStackEntry{tt, e.buf.Len()})
+}
+
+func (e *binaryEncoder) popType() error {
+ if len(e.typeStack) == 0 {
+ return errEncodeBadTypeStack
+ }
+ e.typeStack = e.typeStack[:len(e.typeStack)-1]
+ return nil
+}
+
+func (e *binaryEncoder) topType() *vdl.Type {
+ if len(e.typeStack) == 0 {
+ return nil
+ }
+ return e.typeStack[len(e.typeStack)-1].tt
+}
+
+func (e *binaryEncoder) topTypeAndPos() (*vdl.Type, int) {
+ if len(e.typeStack) == 0 {
+ return nil, -1
+ }
+ entry := e.typeStack[len(e.typeStack)-1]
+ return entry.tt, entry.pos
+}
+
+// canIgnoreField returns true if a zero-value field can be ignored.
+func (e *binaryEncoder) canIgnoreField() bool {
+ if len(e.typeStack) < 2 {
+ return false
+ }
+ secondTop := e.typeStack[len(e.typeStack)-2].tt
+ return secondTop.Kind() == vdl.Struct || (secondTop.Kind() == vdl.Optional && secondTop.Elem().Kind() == vdl.Struct)
+}
+
+// ignoreField ignores the encoding output for the current field.
+func (e *binaryEncoder) ignoreField() {
+ e.buf.Truncate(e.typeStack[len(e.typeStack)-1].pos)
+}
+
+func (e *binaryEncoder) FromBool(src bool, tt *vdl.Type) error {
+ if err := e.prepareType(tt, vdl.Bool); err != nil {
+ return err
+ }
+ if src == false && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeBool(e.buf, src)
+ return nil
+}
+
+func (e *binaryEncoder) FromUint(src uint64, tt *vdl.Type) error {
+ if err := e.prepareType(tt, vdl.Byte, vdl.Uint16, vdl.Uint32, vdl.Uint64); err != nil {
+ return err
+ }
+ if src == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ if tt.Kind() == vdl.Byte {
+ e.buf.WriteByte(byte(src))
+ } else {
+ binaryEncodeUint(e.buf, src)
+ }
+ return nil
+}
+
+func (e *binaryEncoder) FromInt(src int64, tt *vdl.Type) error {
+ if err := e.prepareType(tt, vdl.Int16, vdl.Int32, vdl.Int64); err != nil {
+ return err
+ }
+ if src == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeInt(e.buf, src)
+ return nil
+}
+
+func (e *binaryEncoder) FromFloat(src float64, tt *vdl.Type) error {
+ if err := e.prepareType(tt, vdl.Float32, vdl.Float64); err != nil {
+ return err
+ }
+ if src == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeFloat(e.buf, src)
+ return nil
+}
+
+func (e *binaryEncoder) FromComplex(src complex128, tt *vdl.Type) error {
+ if err := e.prepareType(tt, vdl.Complex64, vdl.Complex128); err != nil {
+ return err
+ }
+ if src == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeFloat(e.buf, real(src))
+ binaryEncodeFloat(e.buf, imag(src))
+ return nil
+}
+
+func (e *binaryEncoder) FromBytes(src []byte, tt *vdl.Type) error {
+ if !tt.IsBytes() {
+ return fmt.Errorf("encoder type mismatch, got %q, want bytes", tt)
+ }
+ if err := e.prepareTypeHelper(tt, false); err != nil {
+ return err
+ }
+ if tt.Kind() == vdl.List {
+ if len(src) == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeUint(e.buf, uint64(len(src)))
+ } else {
+ // We always encode array length to 0.
+ binaryEncodeUint(e.buf, 0)
+ }
+
+ e.buf.Write(src)
+ return nil
+}
+
+func (e *binaryEncoder) FromString(src string, tt *vdl.Type) error {
+ if err := e.prepareType(tt, vdl.String); err != nil {
+ return err
+ }
+ if len(src) == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeString(e.buf, src)
+ return nil
+}
+
+func (e *binaryEncoder) FromEnumLabel(src string, tt *vdl.Type) error {
+ if err := e.prepareType(tt, vdl.Enum); err != nil {
+ return err
+ }
+ index := tt.EnumIndex(src)
+ if index < 0 {
+ return fmt.Errorf("enum label %q doesn't exist in type %q", src, tt)
+ }
+ if index == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeUint(e.buf, uint64(index))
+ return nil
+}
+
+func (e *binaryEncoder) FromTypeObject(src *vdl.Type) error {
+ if err := e.prepareType(vdl.TypeObjectType, vdl.TypeObject); err != nil {
+ return err
+ }
+ id, err := e.encodeUnsentTypes(src)
+ if err != nil {
+ return err
+ }
+ if src == vdl.AnyType && e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeUint(e.buf, uint64(id))
+ return nil
+}
+
+func (e *binaryEncoder) FromNil(tt *vdl.Type) error {
+ if !tt.CanBeNil() {
+ return errTypeMismatch(tt, vdl.Any, vdl.Optional)
+ }
+ if err := e.prepareTypeHelper(tt, true); err != nil {
+ return err
+ }
+ if e.canIgnoreField() {
+ e.ignoreField()
+ return nil
+ }
+ binaryEncodeControl(e.buf, WireCtrlNil)
+ return nil
+}
+
+func (e *binaryEncoder) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {
+ if err := e.prepareType(tt, vdl.Array, vdl.List); err != nil {
+ return nil, err
+ }
+ if tt.Kind() == vdl.List {
+ if len == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ } else {
+ binaryEncodeUint(e.buf, uint64(len))
+ }
+ } else {
+ // We always encode array length to 0.
+ binaryEncodeUint(e.buf, 0)
+ }
+ e.pushType(tt)
+ return e, nil
+}
+
+func (e *binaryEncoder) StartSet(tt *vdl.Type, len int) (vdl.SetTarget, error) {
+ if err := e.prepareType(tt, vdl.Set); err != nil {
+ return nil, err
+ }
+ if len == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ } else {
+ binaryEncodeUint(e.buf, uint64(len))
+ }
+ e.pushType(tt)
+ return e, nil
+}
+
+func (e *binaryEncoder) StartMap(tt *vdl.Type, len int) (vdl.MapTarget, error) {
+ if err := e.prepareType(tt, vdl.Map); err != nil {
+ return nil, err
+ }
+ if len == 0 && e.canIgnoreField() {
+ e.ignoreField()
+ } else {
+ binaryEncodeUint(e.buf, uint64(len))
+ }
+ e.pushType(tt)
+ return e, nil
+}
+
+func (e *binaryEncoder) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
+ if err := e.prepareType(tt, vdl.Struct, vdl.Union); err != nil {
+ return nil, err
+ }
+ e.pushType(tt)
+ return e, nil
+}
+
+func (e *binaryEncoder) FinishList(vdl.ListTarget) error {
+ return e.popType()
+}
+
+func (e *binaryEncoder) FinishSet(vdl.SetTarget) error {
+ return e.popType()
+}
+
+func (e *binaryEncoder) FinishMap(vdl.MapTarget) error {
+ return e.popType()
+}
+
+func (e *binaryEncoder) FinishFields(vdl.FieldsTarget) error {
+ top, pos := e.topTypeAndPos()
+ // Pop the type stack first to let canIgnoreField() see the correct
+ // parent type.
+ if err := e.popType(); err != nil {
+ return err
+ }
+ if top.Kind() == vdl.Struct || (top.Kind() == vdl.Optional && top.Elem().Kind() == vdl.Struct) {
+ // Write the struct terminator; don't write for union.
+ if pos == e.buf.Len() && top.Kind() != vdl.Optional && e.canIgnoreField() {
+ // Ignore the zero value only if it is not optional since we should
+ // distinguish between empty and non-existent value. If we arrive here,
+ // it means the current struct is empty, but not non-existent.
+ e.ignoreField()
+ } else {
+ binaryEncodeControl(e.buf, WireCtrlEOF)
+ }
+ }
+ return nil
+}
+
+func (e *binaryEncoder) StartElem(index int) (vdl.Target, error) {
+ e.pushType(e.topType().Elem())
+ return e, nil
+}
+
+func (e *binaryEncoder) FinishElem(elem vdl.Target) error {
+ return e.popType()
+}
+
+func (e *binaryEncoder) StartKey() (vdl.Target, error) {
+ e.pushType(e.topType().Key())
+ return e, nil
+}
+
+func (e *binaryEncoder) FinishKey(key vdl.Target) error {
+ return e.popType()
+}
+
+func (e *binaryEncoder) FinishKeyStartField(key vdl.Target) (vdl.Target, error) {
+ if err := e.popType(); err != nil {
+ return nil, err
+ }
+ e.pushType(e.topType().Elem())
+ return e, nil
+}
+
+func (e *binaryEncoder) StartField(name string) (_, _ vdl.Target, _ error) {
+ top := e.topType()
+ if top == nil {
+ return nil, nil, errEncodeBadTypeStack
+ }
+ if top.Kind() == vdl.Optional {
+ top = top.Elem()
+ }
+ if k := top.Kind(); k != vdl.Struct && k != vdl.Union {
+ return nil, nil, errTypeMismatch(top, vdl.Struct, vdl.Union)
+ }
+ // Struct and Union are encoded as a sequence of fields, in any order. Each
+ // field starts with its absolute 1-based index, followed by the value. Union
+ // always consists of a single field, while structs use a 0 terminator.
+ if vfield, index := top.FieldByName(name); index >= 0 {
+ e.pushType(vfield.Type)
+ binaryEncodeUint(e.buf, uint64(index))
+ return nil, e, nil
+ }
+ return nil, nil, fmt.Errorf("field name %q doesn't exist in top type %q", name, top)
+}
+
+func (e *binaryEncoder) FinishField(key, field vdl.Target) error {
+ return e.popType()
+}
diff --git a/lib/vom/binary_util.go b/lib/vom/binary_util.go
new file mode 100644
index 0000000..6a22e0a
--- /dev/null
+++ b/lib/vom/binary_util.go
@@ -0,0 +1,445 @@
+package vom
+
+import (
+ "errors"
+ "fmt"
+ "math"
+
+ "v.io/v23/vdl"
+)
+
+// Binary encoding and decoding routines. The binary format is identical to the
+// encoding/gob package, and much of the implementation is similar.
+
+const (
+ uint64Size = 8
+ maxEncodedUintBytes = uint64Size + 1 // +1 for length byte
+ maxBinaryMsgLen = 1 << 30 // 1GiB limit to each message
+
+ // Every binary stream starts with this magic byte, to distinguish the binary
+ // encoding from the JSON encoding. Note that every valid JSON encoding must
+ // start with an ASCII character, or the BOM U+FEFF, and this magic byte is
+ // unambiguous regardless of the endianness of the JSON encoding.
+ binaryMagicByte byte = 0x80
+)
+
+var (
+ errInvalid = errors.New("vom: invalid encoding")
+ errMsgLen = fmt.Errorf("vom: message larger than %d bytes", maxBinaryMsgLen)
+ errUintOverflow = errors.New("vom: scalar larger than 8 bytes")
+)
+
+// hasBinaryMsgLen returns true iff the type t is encoded with a top-level
+// message length.
+func hasBinaryMsgLen(t *vdl.Type) bool {
+ if t.IsBytes() {
+ return false
+ }
+ switch t.Kind() {
+ case vdl.Complex64, vdl.Complex128, vdl.Array, vdl.List, vdl.Set, vdl.Map, vdl.Struct, vdl.Any, vdl.Union, vdl.Optional:
+ return true
+ }
+ return false
+}
+
+func binaryEncodeControl(buf *encbuf, v byte) {
+ if v < 0x80 || v > 0xef {
+ panic(fmt.Errorf("invalid control code: %d", v))
+ }
+ buf.WriteByte(v)
+}
+
+// If the byte is not a control, this will return 0.
+func binaryPeekControl(buf *decbuf) (byte, error) {
+ v, err := buf.PeekByte()
+ if err != nil {
+ return 0, err
+ }
+ if v < 0x80 || v > 0xef {
+ return 0, nil
+ }
+ return v, nil
+}
+
+// Bools are encoded as a byte where 0 = false and anything else is true.
+func binaryEncodeBool(buf *encbuf, v bool) {
+ if v {
+ buf.WriteByte(1)
+ } else {
+ buf.WriteByte(0)
+ }
+}
+
+func binaryDecodeBool(buf *decbuf) (bool, error) {
+ v, err := buf.ReadByte()
+ if err != nil {
+ return false, err
+ }
+ if v > 0x7f {
+ return false, errInvalid
+ }
+ return v != 0, nil
+}
+
+// Unsigned integers are the basis for all other primitive values. This is a
+// two-state encoding. If the number is less than 128 (0 through 0x7f), its
+// value is written directly. Otherwise the value is written in big-endian byte
+// order preceded by the negated byte length.
+func binaryEncodeUint(buf *encbuf, v uint64) {
+ switch {
+ case v <= 0x7f:
+ buf.Grow(1)[0] = byte(v)
+ case v <= 0xff:
+ buf := buf.Grow(2)
+ buf[0] = 0xff
+ buf[1] = byte(v)
+ case v <= 0xffff:
+ buf := buf.Grow(3)
+ buf[0] = 0xfe
+ buf[1] = byte(v >> 8)
+ buf[2] = byte(v)
+ case v <= 0xffffff:
+ buf := buf.Grow(4)
+ buf[0] = 0xfd
+ buf[1] = byte(v >> 16)
+ buf[2] = byte(v >> 8)
+ buf[3] = byte(v)
+ case v <= 0xffffffff:
+ buf := buf.Grow(5)
+ buf[0] = 0xfc
+ buf[1] = byte(v >> 24)
+ buf[2] = byte(v >> 16)
+ buf[3] = byte(v >> 8)
+ buf[4] = byte(v)
+ case v <= 0xffffffffff:
+ buf := buf.Grow(6)
+ buf[0] = 0xfb
+ buf[1] = byte(v >> 32)
+ buf[2] = byte(v >> 24)
+ buf[3] = byte(v >> 16)
+ buf[4] = byte(v >> 8)
+ buf[5] = byte(v)
+ case v <= 0xffffffffffff:
+ buf := buf.Grow(7)
+ buf[0] = 0xfa
+ buf[1] = byte(v >> 40)
+ buf[2] = byte(v >> 32)
+ buf[3] = byte(v >> 24)
+ buf[4] = byte(v >> 16)
+ buf[5] = byte(v >> 8)
+ buf[6] = byte(v)
+ case v <= 0xffffffffffffff:
+ buf := buf.Grow(8)
+ buf[0] = 0xf9
+ buf[1] = byte(v >> 48)
+ buf[2] = byte(v >> 40)
+ buf[3] = byte(v >> 32)
+ buf[4] = byte(v >> 24)
+ buf[5] = byte(v >> 16)
+ buf[6] = byte(v >> 8)
+ buf[7] = byte(v)
+ default:
+ buf := buf.Grow(9)
+ buf[0] = 0xf8
+ buf[1] = byte(v >> 56)
+ buf[2] = byte(v >> 48)
+ buf[3] = byte(v >> 40)
+ buf[4] = byte(v >> 32)
+ buf[5] = byte(v >> 24)
+ buf[6] = byte(v >> 16)
+ buf[7] = byte(v >> 8)
+ buf[8] = byte(v)
+ }
+}
+
+// binaryEncodeUintEnd writes into the trailing part of buf and returns the start
+// index of the encoded data.
+//
+// REQUIRES: buf is big enough to hold the encoded value.
+func binaryEncodeUintEnd(buf []byte, v uint64) int {
+ end := len(buf) - 1
+ switch {
+ case v <= 0x7f:
+ buf[end] = byte(v)
+ return end
+ case v <= 0xff:
+ buf[end-1] = 0xff
+ buf[end] = byte(v)
+ return end - 1
+ case v <= 0xffff:
+ buf[end-2] = 0xfe
+ buf[end-1] = byte(v >> 8)
+ buf[end] = byte(v)
+ return end - 2
+ case v <= 0xffffff:
+ buf[end-3] = 0xfd
+ buf[end-2] = byte(v >> 16)
+ buf[end-1] = byte(v >> 8)
+ buf[end] = byte(v)
+ return end - 3
+ case v <= 0xffffffff:
+ buf[end-4] = 0xfc
+ buf[end-3] = byte(v >> 24)
+ buf[end-2] = byte(v >> 16)
+ buf[end-1] = byte(v >> 8)
+ buf[end] = byte(v)
+ return end - 4
+ case v <= 0xffffffffff:
+ buf[end-5] = 0xfb
+ buf[end-4] = byte(v >> 32)
+ buf[end-3] = byte(v >> 24)
+ buf[end-2] = byte(v >> 16)
+ buf[end-1] = byte(v >> 8)
+ buf[end] = byte(v)
+ return end - 5
+ case v <= 0xffffffffffff:
+ buf[end-6] = 0xfa
+ buf[end-5] = byte(v >> 40)
+ buf[end-4] = byte(v >> 32)
+ buf[end-3] = byte(v >> 24)
+ buf[end-2] = byte(v >> 16)
+ buf[end-1] = byte(v >> 8)
+ buf[end] = byte(v)
+ return end - 6
+ case v <= 0xffffffffffffff:
+ buf[end-7] = 0xf9
+ buf[end-6] = byte(v >> 48)
+ buf[end-5] = byte(v >> 40)
+ buf[end-4] = byte(v >> 32)
+ buf[end-3] = byte(v >> 24)
+ buf[end-2] = byte(v >> 16)
+ buf[end-1] = byte(v >> 8)
+ buf[end] = byte(v)
+ return end - 7
+ default:
+ buf[end-8] = 0xf8
+ buf[end-7] = byte(v >> 56)
+ buf[end-6] = byte(v >> 48)
+ buf[end-5] = byte(v >> 40)
+ buf[end-4] = byte(v >> 32)
+ buf[end-3] = byte(v >> 24)
+ buf[end-2] = byte(v >> 16)
+ buf[end-1] = byte(v >> 8)
+ buf[end] = byte(v)
+ return end - 8
+ }
+}
+
+func binaryDecodeUint(buf *decbuf) (uint64, error) {
+ v, bytelen, err := binaryPeekUint(buf)
+ if err != nil {
+ return 0, err
+ }
+ return v, buf.Skip(bytelen)
+}
+
+func binaryPeekUint(buf *decbuf) (uint64, int, error) {
+ firstByte, err := buf.PeekByte()
+ if err != nil {
+ return 0, 0, err
+ }
+ // Handle single-byte encoding.
+ if firstByte <= 0x7f {
+ return uint64(firstByte), 1, nil
+ }
+ // Verify not a control code.
+ if firstByte <= 0xdf {
+ return 0, 0, errInvalid
+ }
+ // Handle multi-byte encoding.
+ byteLen := int(-int8(firstByte))
+ if byteLen < 1 || byteLen > uint64Size {
+ return 0, 0, errUintOverflow
+ }
+ byteLen++ // account for initial len byte
+ bytes, err := buf.PeekAtLeast(byteLen)
+ if err != nil {
+ return 0, 0, err
+ }
+ var v uint64
+ for _, b := range bytes[1:byteLen] {
+ v = v<<8 | uint64(b)
+ }
+ return v, byteLen, nil
+}
+
+func binaryDecodeUintWithControl(buf *decbuf) (uint64, byte, error) {
+ v, c, bytelen, err := binaryPeekUintWithControl(buf)
+ if err != nil {
+ return 0, 0, err
+ }
+ return v, c, buf.Skip(bytelen)
+}
+
+func binaryPeekUintWithControl(buf *decbuf) (uint64, byte, int, error) {
+ firstByte, err := buf.PeekByte()
+ if err != nil {
+ return 0, 0, 0, err
+ }
+ // Handle single-byte encoding.
+ if firstByte <= 0x7f {
+ return uint64(firstByte), 0, 1, nil
+ }
+ // Handle control code.
+ if firstByte <= 0xef {
+ return 0, byte(firstByte), 1, nil
+ }
+ // Handle multi-byte encoding.
+ byteLen := int(-int8(firstByte))
+ if byteLen < 1 || byteLen > uint64Size {
+ return 0, 0, 0, errUintOverflow
+ }
+ byteLen++ // account for initial len byte
+ bytes, err := buf.PeekAtLeast(byteLen)
+ if err != nil {
+ return 0, 0, 0, err
+ }
+ var v uint64
+ for _, b := range bytes[1:byteLen] {
+ v = v<<8 | uint64(b)
+ }
+ return v, 0, byteLen, nil
+}
+
+func binaryPeekUintByteLen(buf *decbuf) (int, error) {
+ firstByte, err := buf.PeekByte()
+ if err != nil {
+ return 0, err
+ }
+ if firstByte <= 0xef {
+ return 1, nil
+ }
+ byteLen := int(-int8(firstByte))
+ if byteLen > uint64Size {
+ return 0, errUintOverflow
+ }
+ return 1 + byteLen, nil
+}
+
+func binaryIgnoreUint(buf *decbuf) error {
+ byteLen, err := binaryPeekUintByteLen(buf)
+ if err != nil {
+ return err
+ }
+ return buf.Skip(byteLen)
+}
+
+func binaryDecodeLen(buf *decbuf) (int, error) {
+ ulen, err := binaryDecodeUint(buf)
+ switch {
+ case err != nil:
+ return 0, err
+ case ulen > maxBinaryMsgLen:
+ return 0, errMsgLen
+ }
+ return int(ulen), nil
+}
+
+func binaryDecodeLenOrArrayLen(buf *decbuf, t *vdl.Type) (int, error) {
+ len, err := binaryDecodeLen(buf)
+ if err != nil {
+ return 0, err
+ }
+ if t.Kind() == vdl.Array {
+ if len != 0 {
+ return 0, errInvalid
+ }
+ return t.Len(), nil
+ }
+ return len, nil
+}
+
+// Signed integers are encoded as unsigned integers, where the low bit says
+// whether to complement the other bits to recover the int.
+func binaryEncodeInt(buf *encbuf, v int64) {
+ var uval uint64
+ if v < 0 {
+ uval = uint64(^v<<1) | 1
+ } else {
+ uval = uint64(v << 1)
+ }
+ binaryEncodeUint(buf, uval)
+}
+
+// binaryEncodeIntEnd writes into the trailing part of buf and returns the start
+// index of the encoded data.
+//
+// REQUIRES: buf is big enough to hold the encoded value.
+func binaryEncodeIntEnd(buf []byte, v int64) int {
+ var uval uint64
+ if v < 0 {
+ uval = uint64(^v<<1) | 1
+ } else {
+ uval = uint64(v << 1)
+ }
+ return binaryEncodeUintEnd(buf, uval)
+}
+
+func binaryDecodeInt(buf *decbuf) (int64, error) {
+ uval, err := binaryDecodeUint(buf)
+ if err != nil {
+ return 0, err
+ }
+ if uval&1 == 1 {
+ return ^int64(uval >> 1), nil
+ }
+ return int64(uval >> 1), nil
+}
+
+// Floating point numbers are encoded as byte-reversed ieee754.
+func binaryEncodeFloat(buf *encbuf, v float64) {
+ ieee := math.Float64bits(v)
+ // Manually-unrolled byte-reversing.
+ uval := (ieee&0xff)<<56 |
+ (ieee&0xff00)<<40 |
+ (ieee&0xff0000)<<24 |
+ (ieee&0xff000000)<<8 |
+ (ieee&0xff00000000)>>8 |
+ (ieee&0xff0000000000)>>24 |
+ (ieee&0xff000000000000)>>40 |
+ (ieee&0xff00000000000000)>>56
+ binaryEncodeUint(buf, uval)
+}
+
+func binaryDecodeFloat(buf *decbuf) (float64, error) {
+ uval, err := binaryDecodeUint(buf)
+ if err != nil {
+ return 0, err
+ }
+ // Manually-unrolled byte-reversing.
+ ieee := (uval&0xff)<<56 |
+ (uval&0xff00)<<40 |
+ (uval&0xff0000)<<24 |
+ (uval&0xff000000)<<8 |
+ (uval&0xff00000000)>>8 |
+ (uval&0xff0000000000)>>24 |
+ (uval&0xff000000000000)>>40 |
+ (uval&0xff00000000000000)>>56
+ return math.Float64frombits(ieee), nil
+}
+
+// Strings are encoded as the byte count followed by uninterpreted bytes.
+func binaryEncodeString(buf *encbuf, s string) {
+ binaryEncodeUint(buf, uint64(len(s)))
+ buf.WriteString(s)
+}
+
+func binaryDecodeString(buf *decbuf) (string, error) {
+ len, err := binaryDecodeLen(buf)
+ if err != nil {
+ return "", err
+ }
+ bytes, err := buf.ReadBuf(len)
+ if err != nil {
+ return "", err
+ }
+ return string(bytes), nil
+}
+
+func binaryIgnoreString(buf *decbuf) error {
+ len, err := binaryDecodeLen(buf)
+ if err != nil {
+ return err
+ }
+ return buf.Skip(len)
+}
diff --git a/lib/vom/binary_util_test.go b/lib/vom/binary_util_test.go
new file mode 100644
index 0000000..bc465a5
--- /dev/null
+++ b/lib/vom/binary_util_test.go
@@ -0,0 +1,161 @@
+package vom
+
+import (
+ "fmt"
+ "io"
+ "math"
+ "reflect"
+ "strings"
+ "testing"
+)
+
+func TestBinaryEncodeDecode(t *testing.T) {
+ tests := []struct {
+ v interface{}
+ hex string
+ }{
+ {false, "00"},
+ {true, "01"},
+
+ {byte(0x80), "80"},
+ {byte(0xbf), "bf"},
+ {byte(0xc0), "c0"},
+ {byte(0xdf), "df"},
+ {byte(0xe0), "e0"},
+ {byte(0xef), "ef"},
+
+ {uint64(0), "00"},
+ {uint64(1), "01"},
+ {uint64(2), "02"},
+ {uint64(127), "7f"},
+ {uint64(128), "ff80"},
+ {uint64(255), "ffff"},
+ {uint64(256), "fe0100"},
+ {uint64(257), "fe0101"},
+ {uint64(0xffff), "feffff"},
+ {uint64(0xffffff), "fdffffff"},
+ {uint64(0xffffffff), "fcffffffff"},
+ {uint64(0xffffffffff), "fbffffffffff"},
+ {uint64(0xffffffffffff), "faffffffffffff"},
+ {uint64(0xffffffffffffff), "f9ffffffffffffff"},
+ {uint64(0xffffffffffffffff), "f8ffffffffffffffff"},
+
+ {int64(0), "00"},
+ {int64(1), "02"},
+ {int64(2), "04"},
+ {int64(63), "7e"},
+ {int64(64), "ff80"},
+ {int64(65), "ff82"},
+ {int64(127), "fffe"},
+ {int64(128), "fe0100"},
+ {int64(129), "fe0102"},
+ {int64(math.MaxInt16), "fefffe"},
+ {int64(math.MaxInt32), "fcfffffffe"},
+ {int64(math.MaxInt64), "f8fffffffffffffffe"},
+
+ {int64(-1), "01"},
+ {int64(-2), "03"},
+ {int64(-64), "7f"},
+ {int64(-65), "ff81"},
+ {int64(-66), "ff83"},
+ {int64(-128), "ffff"},
+ {int64(-129), "fe0101"},
+ {int64(-130), "fe0103"},
+ {int64(math.MinInt16), "feffff"},
+ {int64(math.MinInt32), "fcffffffff"},
+ {int64(math.MinInt64), "f8ffffffffffffffff"},
+
+ {float64(0), "00"},
+ {float64(1), "fef03f"},
+ {float64(17), "fe3140"},
+ {float64(18), "fe3240"},
+
+ {"", "00"},
+ {"abc", "03616263"},
+ {"defghi", "06646566676869"},
+ }
+ for _, test := range tests {
+ // Test encode
+ encbuf := newEncbuf()
+ var buf []byte
+ switch val := test.v.(type) {
+ case byte:
+ binaryEncodeControl(encbuf, val)
+ case bool:
+ binaryEncodeBool(encbuf, val)
+ case uint64:
+ binaryEncodeUint(encbuf, val)
+ buf = make([]byte, maxEncodedUintBytes)
+ buf = buf[binaryEncodeUintEnd(buf, val):]
+ case int64:
+ binaryEncodeInt(encbuf, val)
+ buf = make([]byte, maxEncodedUintBytes)
+ buf = buf[binaryEncodeIntEnd(buf, val):]
+ case float64:
+ binaryEncodeFloat(encbuf, val)
+ case string:
+ binaryEncodeString(encbuf, val)
+ }
+ if got, want := fmt.Sprintf("%x", encbuf.Bytes()), test.hex; got != want {
+ t.Errorf("binary encode %T(%v): GOT 0x%v WANT 0x%v", test.v, test.v, got, want)
+ }
+ if buf != nil {
+ if got, want := fmt.Sprintf("%x", buf), test.hex; got != want {
+ t.Errorf("binary encode end %T(%v): GOT 0x%v WANT 0x%v", test.v, test.v, got, want)
+ }
+ }
+ // Test decode
+ var bin string
+ if _, err := fmt.Sscanf(test.hex, "%x", &bin); err != nil {
+ t.Errorf("couldn't scan 0x%v as hex: %v", test.hex, err)
+ continue
+ }
+ decbuf := newDecbuf(strings.NewReader(bin))
+ decbuf2 := newDecbuf(strings.NewReader(bin))
+ decbuf3 := newDecbuf(strings.NewReader(bin))
+ var v, v2 interface{}
+ var err, err2, err3 error
+ switch test.v.(type) {
+ case byte:
+ v, err = binaryPeekControl(decbuf)
+ decbuf.Skip(1)
+ _, v2, err2 = binaryDecodeUintWithControl(decbuf2)
+ err3 = binaryIgnoreUint(decbuf3)
+ case bool:
+ v, err = binaryDecodeBool(decbuf)
+ err2 = binaryIgnoreUint(decbuf2)
+ case uint64:
+ v, err = binaryDecodeUint(decbuf)
+ v2, _, err2 = binaryDecodeUintWithControl(decbuf2)
+ err3 = binaryIgnoreUint(decbuf3)
+ case int64:
+ v, err = binaryDecodeInt(decbuf)
+ err2 = binaryIgnoreUint(decbuf2)
+ case float64:
+ v, err = binaryDecodeFloat(decbuf)
+ err2 = binaryIgnoreUint(decbuf2)
+ case string:
+ v, err = binaryDecodeString(decbuf)
+ err2 = binaryIgnoreString(decbuf2)
+ }
+ if v2 != nil && v != v2 {
+ t.Errorf("binary decode %T(0x%v) differently: %v %v", test.v, test.hex, v, v2)
+ continue
+ }
+ if err != nil || err2 != nil || err3 != nil {
+ t.Errorf("binary decode %T(0x%v): %v %v %v", test.v, test.hex, err, err2, err3)
+ continue
+ }
+ if b, err := decbuf.ReadByte(); err != io.EOF {
+ t.Errorf("binary decode %T(0x%v) leftover byte r=%x", test.v, test.hex, b)
+ continue
+ }
+ if b, err := decbuf2.ReadByte(); err != io.EOF {
+ t.Errorf("binary decode %T(0x%v) leftover byte r2=%x", test.v, test.hex, b)
+ continue
+ }
+ if !reflect.DeepEqual(v, test.v) {
+ t.Errorf("binary decode %T(0x%v): GOT %v WANT %v", test.v, test.hex, v, test.v)
+ }
+ }
+}
diff --git a/lib/vom/buf.go b/lib/vom/buf.go
new file mode 100644
index 0000000..49e6c7d
--- /dev/null
+++ b/lib/vom/buf.go
@@ -0,0 +1,299 @@
+package vom
+
+import "io"
+
+const minBufFree = 1024 // buffers always have at least 1K free after growth
+
+// encbuf manages the write buffer for encoders. The approach is similar to
+// bytes.Buffer, but the implementation is simplified to only deal with many
+// writes followed by a read of the whole buffer.
+type encbuf struct {
+ buf []byte // INVARIANT: len(buf) == cap(buf)
+ end int // [0, end) is data that's already written
+
+ // It's faster to hold end than to use both the len and cap properties of buf,
+ // since end is cheaper to update than buf.
+}
+
+func newEncbuf() *encbuf {
+ return &encbuf{
+ buf: make([]byte, minBufFree),
+ }
+}
+
+// Bytes returns a slice of the bytes written so far.
+func (b *encbuf) Bytes() []byte { return b.buf[:b.end] }
+
+// Len returns the number of bytes written so far.
+func (b *encbuf) Len() int { return b.end }
+
+// Reset the length to 0 to start a new round of writes.
+func (b *encbuf) Reset() { b.end = 0 }
+
+// Truncate the length to n.
+//
+// REQUIRES: n in the range [0, Len]
+func (b *encbuf) Truncate(n int) {
+ b.end = n
+}
+
+// reserve at least min free bytes in the buffer.
+func (b *encbuf) reserve(min int) {
+ if len(b.buf)-b.end < min {
+ newlen := len(b.buf) * 2
+ if newlen-b.end < min {
+ newlen = b.end + min + minBufFree
+ }
+ newbuf := make([]byte, newlen)
+ copy(newbuf, b.buf[:b.end])
+ b.buf = newbuf
+ }
+}
+
+// Grow the buffer by n bytes, and returns those bytes.
+//
+// Different from bytes.Buffer.Grow, which doesn't return the bytes. Although
+// this makes encbuf slightly easier to misuse, it helps to improve performance
+// by avoiding unnecessary copying.
+func (b *encbuf) Grow(n int) []byte {
+ b.reserve(n)
+ oldend := b.end
+ b.end += n
+ return b.buf[oldend:b.end]
+}
+
+// WriteByte writes byte c into the buffer.
+func (b *encbuf) WriteByte(c byte) {
+ b.reserve(1)
+ b.buf[b.end] = c
+ b.end++
+}
+
+// Write writes slice p into the buffer.
+func (b *encbuf) Write(p []byte) {
+ b.reserve(len(p))
+ b.end += copy(b.buf[b.end:], p)
+}
+
+// WriteString writes string s into the buffer.
+func (b *encbuf) WriteString(s string) {
+ b.reserve(len(s))
+ b.end += copy(b.buf[b.end:], s)
+}
+
+// decbuf manages the read buffer for decoders. The approach is similar to
+// bufio.Reader, but the API is better suited for fast decoding.
+type decbuf struct {
+ buf []byte // INVARIANT: len(buf) == cap(buf)
+ beg, end int // [beg, end) is data read from reader but unread by the user
+ lim int // number of bytes left in limit, or -1 for no limit
+ reader io.Reader
+
+ // It's faster to hold end than to use the len and cap properties of buf,
+ // since end is cheaper to update than buf.
+}
+
+func newDecbuf(r io.Reader) *decbuf {
+ return &decbuf{
+ buf: make([]byte, minBufFree),
+ lim: -1,
+ reader: r,
+ }
+}
+
+// Reset resets the buffer so it has no data.
+func (b *decbuf) Reset() {
+ b.beg = 0
+ b.end = 0
+ b.lim = -1
+}
+
+// SetLimit sets a limit to the bytes that are returned by decbuf; after a limit
+// is set, subsequent reads cannot read past the limit, even if more bytes are
+// available. Attempts to read past the limit return io.EOF. Call RemoveLimit
+// to remove the limit.
+//
+// REQUIRES: limit >=0,
+func (b *decbuf) SetLimit(limit int) {
+ b.lim = limit
+}
+
+// RemoveLimit removes the limit, and returns the number of leftover bytes.
+// Returns -1 if no limit was set.
+func (b *decbuf) RemoveLimit() int {
+ leftover := b.lim
+ b.lim = -1
+ return leftover
+}
+
+// fill the buffer with at least min bytes of data. Returns an error if fewer
+// than min bytes could be filled. Doesn't advance the read position.
+func (b *decbuf) fill(min int) error {
+ switch avail := b.end - b.beg; {
+ case avail >= min:
+ // Fastpath - enough bytes are available.
+ return nil
+ case len(b.buf) < min:
+ // The buffer isn't big enough. Make a new buffer that's big enough and
+ // copy existing data to the front.
+ newlen := len(b.buf) * 2
+ if newlen < min+minBufFree {
+ newlen = min + minBufFree
+ }
+ newbuf := make([]byte, newlen)
+ b.end = copy(newbuf, b.buf[b.beg:b.end])
+ b.beg = 0
+ b.buf = newbuf
+ default:
+ // The buffer is big enough. Move existing data to the front.
+ b.moveDataToFront()
+ }
+ // INVARIANT: len(b.buf)-b.beg >= min
+ //
+ // Fill [b.end:] until min bytes are available. We must loop since Read may
+ // return success with fewer bytes than requested.
+ for b.end-b.beg < min {
+ switch nread, err := b.reader.Read(b.buf[b.end:]); {
+ case nread > 0:
+ b.end += nread
+ case err != nil:
+ return err
+ }
+ }
+ return nil
+}
+
+// moveDataToFront moves existing data in buf to the front, so that b.beg is 0.
+func (b *decbuf) moveDataToFront() {
+ b.end = copy(b.buf, b.buf[b.beg:b.end])
+ b.beg = 0
+}
+
+// ReadBuf returns a buffer with the next n bytes, and increments the read
+// position past those bytes. Returns an error if fewer than n bytes are
+// available.
+//
+// The returned slice points directly at our internal buffer, and is only valid
+// until the next decbuf call.
+//
+// REQUIRES: n >= 0
+func (b *decbuf) ReadBuf(n int) ([]byte, error) {
+ if b.lim > -1 {
+ if b.lim < n {
+ b.lim = 0
+ return nil, io.EOF
+ }
+ b.lim -= n
+ }
+ if err := b.fill(n); err != nil {
+ return nil, err
+ }
+ buf := b.buf[b.beg : b.beg+n]
+ b.beg += n
+ return buf, nil
+}
+
+// PeekAtLeast returns a buffer with at least the next n bytes, but possibly
+// more. The read position isn't incremented. Returns an error if fewer than
+// min bytes are available.
+//
+// The returned slice points directly at our internal buffer, and is only valid
+// until the next decbuf call.
+//
+// REQUIRES: min >= 0
+func (b *decbuf) PeekAtLeast(min int) ([]byte, error) {
+ if b.lim > -1 && b.lim < min {
+ return nil, io.EOF
+ }
+ if err := b.fill(min); err != nil {
+ return nil, err
+ }
+ return b.buf[b.beg:b.end], nil
+}
+
+// Skip increments the read position past the next n bytes. Returns an error if
+// fewer than n bytes are available.
+//
+// REQUIRES: n >= 0
+func (b *decbuf) Skip(n int) error {
+ if b.lim > -1 {
+ if b.lim < n {
+ b.lim = 0
+ return io.EOF
+ }
+ b.lim -= n
+ }
+ // If enough bytes are available, just update indices.
+ avail := b.end - b.beg
+ if avail >= n {
+ b.beg += n
+ return nil
+ }
+ n -= avail
+ // Keep reading into buf until we've read enough bytes.
+ for {
+ switch nread, err := b.reader.Read(b.buf); {
+ case nread > 0:
+ if nread >= n {
+ b.beg = n
+ b.end = nread
+ return nil
+ }
+ n -= nread
+ case err != nil:
+ return err
+ }
+ }
+}
+
+// ReadByte returns the next byte, and increments the read position.
+func (b *decbuf) ReadByte() (byte, error) {
+ if b.lim > -1 {
+ if b.lim == 0 {
+ return 0, io.EOF
+ }
+ b.lim--
+ }
+ if err := b.fill(1); err != nil {
+ return 0, err
+ }
+ ret := b.buf[b.beg]
+ b.beg++
+ return ret, nil
+}
+
+// PeekByte returns the next byte, without changing the read position.
+func (b *decbuf) PeekByte() (byte, error) {
+ if b.lim == 0 {
+ return 0, io.EOF
+ }
+ if err := b.fill(1); err != nil {
+ return 0, err
+ }
+ return b.buf[b.beg], nil
+}
+
+// ReadFull reads the next len(p) bytes into p, and increments the read position
+// past those bytes. Returns an error if fewer than len(p) bytes are available.
+func (b *decbuf) ReadFull(p []byte) error {
+ if b.lim > -1 {
+ if b.lim < len(p) {
+ return io.EOF
+ }
+ b.lim -= len(p)
+ }
+ // Copy bytes from the buffer.
+ ncopy := copy(p, b.buf[b.beg:b.end])
+ b.beg += ncopy
+ p = p[ncopy:]
+ // Keep reading into p until we've read enough bytes.
+ for len(p) > 0 {
+ switch nread, err := b.reader.Read(p); {
+ case nread > 0:
+ p = p[nread:]
+ case err != nil:
+ return err
+ }
+ }
+ return nil
+}
diff --git a/lib/vom/buf_test.go b/lib/vom/buf_test.go
new file mode 100644
index 0000000..5b9179f
--- /dev/null
+++ b/lib/vom/buf_test.go
@@ -0,0 +1,361 @@
+package vom
+
+// TODO(toddw): Add more exhaustive tests of decbuf SetLimit and fill.
+
+import (
+ "io"
+ "strings"
+ "testing"
+)
+
+func expectEncbufBytes(t *testing.T, b *encbuf, expect string) {
+ if got, want := b.Len(), len(expect); got != want {
+ t.Errorf("len got %d, want %d", got, want)
+ }
+ if got, want := string(b.Bytes()), expect; got != want {
+ t.Errorf("bytes got %q, want %q", b.Bytes(), expect)
+ }
+}
+
+func TestEncbuf(t *testing.T) {
+ b := newEncbuf()
+ expectEncbufBytes(t, b, "")
+ copy(b.Grow(5), "abcde*****")
+ expectEncbufBytes(t, b, "abcde")
+ b.Truncate(3)
+ expectEncbufBytes(t, b, "abc")
+ b.WriteByte('1')
+ expectEncbufBytes(t, b, "abc1")
+ b.Write([]byte("def"))
+ expectEncbufBytes(t, b, "abc1def")
+ b.Truncate(1)
+ expectEncbufBytes(t, b, "a")
+ b.WriteString("XYZ")
+ expectEncbufBytes(t, b, "aXYZ")
+ b.Reset()
+ expectEncbufBytes(t, b, "")
+ b.WriteString("123")
+ expectEncbufBytes(t, b, "123")
+}
+
+func testEncbufReserve(t *testing.T, base int) {
+ for _, size := range []int{base - 1, base, base + 1} {
+ str := strings.Repeat("x", size)
+ // Test starting empty and writing size.
+ b := newEncbuf()
+ b.WriteString(str)
+ expectEncbufBytes(t, b, str)
+ b.WriteString(str)
+ expectEncbufBytes(t, b, str+str)
+ // Test starting with one byte and writing size.
+ b = newEncbuf()
+ b.WriteByte('A')
+ expectEncbufBytes(t, b, "A")
+ b.WriteString(str)
+ expectEncbufBytes(t, b, "A"+str)
+ b.WriteString(str)
+ expectEncbufBytes(t, b, "A"+str+str)
+ }
+}
+
+func TestEncbufReserve(t *testing.T) {
+ testEncbufReserve(t, minBufFree)
+ testEncbufReserve(t, minBufFree*2)
+ testEncbufReserve(t, minBufFree*3)
+ testEncbufReserve(t, minBufFree*4)
+}
+
+func expectRemoveLimit(t *testing.T, mode readMode, b *decbuf, expect int) {
+ if got, want := b.RemoveLimit(), expect; got != want {
+ t.Errorf("%s RemoveLimit got %v, want %v", mode, got, want)
+ }
+}
+
+func expectReadBuf(t *testing.T, mode readMode, b *decbuf, n int, expect string, expectErr error) {
+ buf, err := b.ReadBuf(n)
+ if got, want := err, expectErr; got != want {
+ t.Errorf("%s ReadBuf err got %v, want %v", mode, got, want)
+ }
+ if got, want := string(buf), expect; got != want {
+ t.Errorf("%s ReadBuf buf got %q, want %q", mode, got, want)
+ }
+}
+
+func expectSkip(t *testing.T, mode readMode, b *decbuf, n int, expectErr error) {
+ if got, want := b.Skip(n), expectErr; got != want {
+ t.Errorf("%s Skip err got %v, want %v", mode, got, want)
+ }
+}
+
+func expectPeekAtLeast(t *testing.T, mode readMode, b *decbuf, n int, expect string, expectErr error) {
+ buf, err := b.PeekAtLeast(n)
+ if got, want := err, expectErr; got != want {
+ t.Errorf("%s PeekAtLeast err got %v, want %v", mode, got, want)
+ }
+ if got, want := string(buf), expect; got != want {
+ t.Errorf("%s PeekAtLeast buf got %q, want %q", mode, got, want)
+ }
+}
+
+func expectReadByte(t *testing.T, mode readMode, b *decbuf, expect byte, expectErr error) {
+ actual, err := b.ReadByte()
+ if got, want := err, expectErr; got != want {
+ t.Errorf("%s ReadByte err got %v, want %v", mode, got, want)
+ }
+ if got, want := actual, expect; got != want {
+ t.Errorf("%s ReadByte buf got %q, want %q", mode, got, want)
+ }
+}
+
+func expectPeekByte(t *testing.T, mode readMode, b *decbuf, expect byte, expectErr error) {
+ actual, err := b.PeekByte()
+ if got, want := err, expectErr; got != want {
+ t.Errorf("%s PeekByte err got %v, want %v", mode, got, want)
+ }
+ if got, want := actual, expect; got != want {
+ t.Errorf("%s PeekByte buf got %q, want %q", mode, got, want)
+ }
+}
+
+func expectReadFull(t *testing.T, mode readMode, b *decbuf, n int, expect string, expectErr error) {
+ buf := make([]byte, n)
+ err := b.ReadFull(buf)
+ if got, want := err, expectErr; got != want {
+ t.Errorf("%s ReadFull err got %v, want %v", mode, got, want)
+ }
+ if err == nil {
+ if got, want := string(buf), expect; got != want {
+ t.Errorf("%s ReadFull buf got %q, want %q", mode, got, want)
+ }
+ }
+}
+
+func TestDecbufReadBuf(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(10)))
+ expectReadBuf(t, mode, b, 1, "a", nil)
+ expectReadBuf(t, mode, b, 2, "bc", nil)
+ expectReadBuf(t, mode, b, 3, "def", nil)
+ expectReadBuf(t, mode, b, 4, "ghij", nil)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ }
+}
+
+func TestDecbufReadBufLimit(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(10)))
+ // Read exactly up to limit.
+ b.SetLimit(3)
+ expectReadBuf(t, mode, b, 1, "a", nil)
+ expectReadBuf(t, mode, b, 2, "bc", nil)
+ expectRemoveLimit(t, mode, b, 0)
+ // Read less than the limit.
+ b.SetLimit(3)
+ expectReadBuf(t, mode, b, 2, "de", nil)
+ expectRemoveLimit(t, mode, b, 1)
+ // Read more than the limit.
+ b.SetLimit(3)
+ expectReadBuf(t, mode, b, 4, "", io.EOF)
+ expectRemoveLimit(t, mode, b, 0)
+
+ expectReadBuf(t, mode, b, 1, "f", nil)
+ }
+}
+
+func TestDecbufSkip(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(10)))
+ expectSkip(t, mode, b, 1, nil)
+ expectReadBuf(t, mode, b, 2, "bc", nil)
+ expectSkip(t, mode, b, 3, nil)
+ expectReadBuf(t, mode, b, 2, "gh", nil)
+ expectSkip(t, mode, b, 2, nil)
+ expectSkip(t, mode, b, 1, io.EOF)
+ expectSkip(t, mode, b, 1, io.EOF)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ }
+}
+
+func TestDecbufSkipLimit(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(10)))
+ // Skip exactly up to limit.
+ b.SetLimit(3)
+ expectSkip(t, mode, b, 1, nil)
+ expectSkip(t, mode, b, 2, nil)
+ expectRemoveLimit(t, mode, b, 0)
+ // Skip less than the limit.
+ b.SetLimit(3)
+ expectSkip(t, mode, b, 2, nil)
+ expectRemoveLimit(t, mode, b, 1)
+ // Skip more than the limit.
+ b.SetLimit(3)
+ expectSkip(t, mode, b, 4, io.EOF)
+ expectRemoveLimit(t, mode, b, 0)
+
+ expectReadBuf(t, mode, b, 1, "f", nil)
+ }
+}
+
+func TestDecbufPeekAtLeast(t *testing.T) {
+ for _, mode := range []readMode{readAll, readHalf, readAllEOF, readHalfEOF} {
+ // Start peeking at beginning.
+ b := newDecbuf(mode.testReader(abcReader(3)))
+ expectPeekAtLeast(t, mode, b, 1, "abc", nil)
+ expectPeekAtLeast(t, mode, b, 2, "abc", nil)
+ expectPeekAtLeast(t, mode, b, 3, "abc", nil)
+ expectPeekAtLeast(t, mode, b, 4, "", io.EOF)
+ expectReadBuf(t, mode, b, 3, "abc", nil)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ expectPeekAtLeast(t, mode, b, 1, "", io.EOF)
+ // Start peeking after reading 1 byte, which fills the buffer
+ b = newDecbuf(mode.testReader(abcReader(4)))
+ expectReadBuf(t, mode, b, 1, "a", nil)
+ expectPeekAtLeast(t, mode, b, 1, "bcd", nil)
+ expectPeekAtLeast(t, mode, b, 2, "bcd", nil)
+ expectPeekAtLeast(t, mode, b, 3, "bcd", nil)
+ expectPeekAtLeast(t, mode, b, 4, "", io.EOF)
+ expectReadBuf(t, mode, b, 3, "bcd", nil)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ expectPeekAtLeast(t, mode, b, 1, "", io.EOF)
+ }
+ for _, mode := range []readMode{readOneByte, readOneByteEOF} {
+ // Start peeking at beginning.
+ b := newDecbuf(mode.testReader(abcReader(3)))
+ expectPeekAtLeast(t, mode, b, 1, "a", nil)
+ expectPeekAtLeast(t, mode, b, 2, "ab", nil)
+ expectPeekAtLeast(t, mode, b, 3, "abc", nil)
+ expectPeekAtLeast(t, mode, b, 2, "abc", nil)
+ expectPeekAtLeast(t, mode, b, 1, "abc", nil)
+ expectPeekAtLeast(t, mode, b, 4, "", io.EOF)
+ expectReadBuf(t, mode, b, 3, "abc", nil)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ expectPeekAtLeast(t, mode, b, 1, "", io.EOF)
+ // Start peeking after reading 1 byte, which fills the buffer
+ b = newDecbuf(mode.testReader(abcReader(4)))
+ expectReadBuf(t, mode, b, 1, "a", nil)
+ expectPeekAtLeast(t, mode, b, 1, "b", nil)
+ expectPeekAtLeast(t, mode, b, 2, "bc", nil)
+ expectPeekAtLeast(t, mode, b, 3, "bcd", nil)
+ expectPeekAtLeast(t, mode, b, 2, "bcd", nil)
+ expectPeekAtLeast(t, mode, b, 1, "bcd", nil)
+ expectPeekAtLeast(t, mode, b, 4, "", io.EOF)
+ expectReadBuf(t, mode, b, 3, "bcd", nil)
+ expectReadBuf(t, mode, b, 1, "", io.EOF)
+ expectPeekAtLeast(t, mode, b, 1, "", io.EOF)
+ }
+}
+
+func TestDecbufReadByte(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(3)))
+ expectReadByte(t, mode, b, 'a', nil)
+ expectReadByte(t, mode, b, 'b', nil)
+ expectReadByte(t, mode, b, 'c', nil)
+ expectReadByte(t, mode, b, 0, io.EOF)
+ expectReadByte(t, mode, b, 0, io.EOF)
+ }
+}
+
+func TestDecbufReadByteLimit(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(10)))
+ // Read exactly up to limit.
+ b.SetLimit(2)
+ expectReadByte(t, mode, b, 'a', nil)
+ expectReadByte(t, mode, b, 'b', nil)
+ expectRemoveLimit(t, mode, b, 0)
+ // Read less than the limit.
+ b.SetLimit(2)
+ expectReadByte(t, mode, b, 'c', nil)
+ expectRemoveLimit(t, mode, b, 1)
+ // Read more than the limit.
+ b.SetLimit(2)
+ expectReadByte(t, mode, b, 'd', nil)
+ expectReadByte(t, mode, b, 'e', nil)
+ expectReadByte(t, mode, b, 0, io.EOF)
+ expectReadByte(t, mode, b, 0, io.EOF)
+ expectRemoveLimit(t, mode, b, 0)
+
+ expectReadByte(t, mode, b, 'f', nil)
+ }
+}
+
+func TestDecbufPeekByte(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(3)))
+ expectPeekByte(t, mode, b, 'a', nil)
+ expectPeekByte(t, mode, b, 'a', nil)
+ expectReadByte(t, mode, b, 'a', nil)
+
+ expectPeekByte(t, mode, b, 'b', nil)
+ expectPeekByte(t, mode, b, 'b', nil)
+ expectReadByte(t, mode, b, 'b', nil)
+
+ expectPeekByte(t, mode, b, 'c', nil)
+ expectPeekByte(t, mode, b, 'c', nil)
+ expectReadByte(t, mode, b, 'c', nil)
+
+ expectPeekByte(t, mode, b, 0, io.EOF)
+ expectPeekByte(t, mode, b, 0, io.EOF)
+ expectReadByte(t, mode, b, 0, io.EOF)
+ }
+}
+
+func TestDecbufPeekByteLimit(t *testing.T) {
+ for _, mode := range allReadModes {
+ b := newDecbuf(mode.testReader(abcReader(10)))
+ // Read exactly up to limit.
+ b.SetLimit(2)
+ expectPeekByte(t, mode, b, 'a', nil)
+ expectPeekByte(t, mode, b, 'a', nil)
+ expectReadByte(t, mode, b, 'a', nil)
+
+ expectPeekByte(t, mode, b, 'b', nil)
+ expectPeekByte(t, mode, b, 'b', nil)
+ expectReadByte(t, mode, b, 'b', nil)
+ expectRemoveLimit(t, mode, b, 0)
+ // Read less than the limit.
+ b.SetLimit(2)
+ expectPeekByte(t, mode, b, 'c', nil)
+ expectPeekByte(t, mode, b, 'c', nil)
+ expectReadByte(t, mode, b, 'c', nil)
+ expectRemoveLimit(t, mode, b, 1)
+ // Read more than the limit.
+ b.SetLimit(2)
+ expectPeekByte(t, mode, b, 'd', nil)
+ expectPeekByte(t, mode, b, 'd', nil)
+ expectReadByte(t, mode, b, 'd', nil)
+
+ expectPeekByte(t, mode, b, 'e', nil)
+ expectPeekByte(t, mode, b, 'e', nil)
+ expectReadByte(t, mode, b, 'e', nil)
+
+ expectPeekByte(t, mode, b, 0, io.EOF)
+ expectPeekByte(t, mode, b, 0, io.EOF)
+ expectReadByte(t, mode, b, 0, io.EOF)
+ expectRemoveLimit(t, mode, b, 0)
+
+ expectPeekByte(t, mode, b, 'f', nil)
+ }
+}
+
+func TestDecbufReadFull(t *testing.T) {
+ for _, mode := range allReadModes {
+ // Start ReadFull from beginning.
+ b := newDecbuf(mode.testReader(abcReader(6)))
+ expectReadFull(t, mode, b, 3, "abc", nil)
+ expectReadFull(t, mode, b, 3, "def", nil)
+ expectReadFull(t, mode, b, 1, "", io.EOF)
+ expectReadFull(t, mode, b, 1, "", io.EOF)
+ // Start ReadFull after reading 1 byte, which fills the buffer.
+ b = newDecbuf(mode.testReader(abcReader(6)))
+ expectReadBuf(t, mode, b, 1, "a", nil)
+ expectReadFull(t, mode, b, 2, "bc", nil)
+ expectReadFull(t, mode, b, 3, "def", nil)
+ expectReadFull(t, mode, b, 1, "", io.EOF)
+ expectReadFull(t, mode, b, 1, "", io.EOF)
+ }
+}
diff --git a/lib/vom/decoder.go b/lib/vom/decoder.go
new file mode 100644
index 0000000..db90b98
--- /dev/null
+++ b/lib/vom/decoder.go
@@ -0,0 +1,87 @@
+package vom
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "reflect"
+
+ "v.io/v23/vdl"
+)
+
+var (
+ errDecodeNil = errors.New("invalid decode into nil interface{}")
+ errDecodeNilRawValue = errors.New("invalid decode into nil *RawValue")
+)
+
+// Decoder manages the receipt and unmarshaling of typed values from the other
+// side of a connection.
+type Decoder struct {
+ dec decoder
+}
+
+type decoder interface {
+ Decode(target vdl.Target) error
+ DecodeRaw(raw *RawValue) error
+ Ignore() error
+}
+
+// This is only used for debugging; add this as the first line of NewDecoder to
+// dump formatted vom bytes to stdout:
+// r = teeDump(r)
+func teeDump(r io.Reader) io.Reader {
+ return io.TeeReader(r, NewDumper(NewDumpWriter(os.Stdout)))
+}
+
+// NewDecoder returns a new Decoder that reads from the given reader. The
+// Decoder understands all formats generated by the Encoder.
+func NewDecoder(r io.Reader) (*Decoder, error) {
+ buf, types := newDecbuf(r), newDecoderTypes()
+ magic, err := buf.PeekByte()
+ if err != nil {
+ return nil, fmt.Errorf("error reading magic byte %v", err)
+ }
+ if magic != binaryMagicByte {
+ return nil, fmt.Errorf("bad magic byte, got %x, want %x", magic, binaryMagicByte)
+ }
+ buf.Skip(1)
+ return &Decoder{newBinaryDecoder(buf, types)}, nil
+}
+
+// Decode reads the next value from the reader and stores it in value v.
+// The type of v need not exactly match the type of the originally encoded
+// value; decoding succeeds as long as the values are compatible.
+//
+// Types that are special-cased, only for v:
+// *RawValue - Store raw (uninterpreted) bytes in v.
+//
+// Types that are special-cased, recursively throughout v:
+// *vdl.Value - Decode into v.
+// reflect.Value - Decode into v, which must be settable.
+//
+// Decoding into a RawValue captures the value in a raw form, which may be
+// subsequently passed to an Encoder for transcoding.
+//
+// Decode(nil) always returns an error. Use Ignore() to ignore the next value.
+func (d *Decoder) Decode(v interface{}) error {
+ switch tv := v.(type) {
+ case nil:
+ return errDecodeNil
+ case *RawValue:
+ if tv == nil {
+ return errDecodeNilRawValue
+ }
+ return d.dec.DecodeRaw(tv)
+ }
+ target, err := vdl.ReflectTarget(reflect.ValueOf(v))
+ if err != nil {
+ return err
+ }
+ return d.dec.Decode(target)
+}
+
+// Ignore ignores the next value from the reader.
+func (d *Decoder) Ignore() error {
+ return d.dec.Ignore()
+}
diff --git a/lib/vom/decoder_test.go b/lib/vom/decoder_test.go
new file mode 100644
index 0000000..820ed0b
--- /dev/null
+++ b/lib/vom/decoder_test.go
@@ -0,0 +1,144 @@
+package vom
+
+import (
+ "bytes"
+ "fmt"
+ "reflect"
+ "strings"
+ "testing"
+
+ "v.io/v23/vdl"
+ "v.io/v23/vom/testdata"
+)
+
+func TestBinaryDecoder(t *testing.T) {
+ for _, test := range testdata.Tests {
+ // Decode hex pattern into binary data.
+ data, err := binFromHexPat(test.Hex)
+ if err != nil {
+ t.Errorf("%s: couldn't convert to binary from hexpat: %v", test.Name, test.Hex)
+ continue
+ }
+
+ name := test.Name + " [vdl.Value]"
+ testDecodeVDL(t, name, data, test.Value)
+
+ name = test.Name + " [vdl.Any]"
+ testDecodeVDL(t, name, data, vdl.AnyValue(test.Value))
+
+ // Convert into Go value for the rest of our tests.
+ goValue, err := toGoValue(test.Value)
+ if err != nil {
+ t.Errorf("%s: %v", name, err)
+ continue
+ }
+
+ name = test.Name + " [go value]"
+ testDecodeGo(t, name, data, reflect.TypeOf(goValue), goValue)
+
+ name = test.Name + " [go interface]"
+ testDecodeGo(t, name, data, reflect.TypeOf((*interface{})(nil)).Elem(), goValue)
+ }
+}
+
+func testDecodeVDL(t *testing.T, name, data string, value *vdl.Value) {
+ for _, mode := range allReadModes {
+ head := fmt.Sprintf("%s (%s)", name, mode)
+ decoder, err := NewDecoder(mode.testReader(strings.NewReader(data)))
+ if err != nil {
+ t.Errorf("%s: NewDecoder failed: %v", head, err)
+ return
+ }
+ got := vdl.ZeroValue(value.Type())
+ if err := decoder.Decode(got); err != nil {
+ t.Errorf("%s: Decode failed: %v", head, err)
+ return
+ }
+ if want := value; !vdl.EqualValue(got, want) {
+ t.Errorf("%s: Decode mismatch\nGOT %v\nWANT %v", head, got, want)
+ return
+ }
+ }
+}
+
+func testDecodeGo(t *testing.T, name, data string, rt reflect.Type, want interface{}) {
+ for _, mode := range allReadModes {
+ head := fmt.Sprintf("%s (%s)", name, mode)
+ decoder, err := NewDecoder(mode.testReader(strings.NewReader(data)))
+ if err != nil {
+ t.Errorf("%s: NewDecoder failed: %v", head, err)
+ return
+ }
+ rvGot := reflect.New(rt)
+ if err := decoder.Decode(rvGot.Interface()); err != nil {
+ t.Errorf("%s: Decode failed: %v", head, err)
+ return
+ }
+ if got := rvGot.Elem().Interface(); !reflect.DeepEqual(got, want) {
+ t.Errorf("%s: Decode mismatch\nGOT %T %#v\nWANT %T %#v", head, got, got, want, want)
+ return
+ }
+ }
+}
+
+// TestRoundtrip tests encoding Input and then decoding results in Want.
+func TestRoundtrip(t *testing.T) {
+ tests := []struct {
+ In, Want interface{}
+ }{
+ // Test that encoding nil/empty composites leads to nil.
+ {[]byte(nil), []byte(nil)},
+ {[]byte{}, []byte(nil)},
+ {[]int64(nil), []int64(nil)},
+ {[]int64{}, []int64(nil)},
+ {map[string]int64(nil), map[string]int64(nil)},
+ {map[string]int64{}, map[string]int64(nil)},
+ {struct{}{}, struct{}{}},
+ {struct{ A []byte }{nil}, struct{ A []byte }{}},
+ {struct{ A []byte }{[]byte{}}, struct{ A []byte }{}},
+ {struct{ A []int64 }{nil}, struct{ A []int64 }{}},
+ {struct{ A []int64 }{[]int64{}}, struct{ A []int64 }{}},
+ // Test that encoding nil typeobject leads to AnyType.
+ {(*vdl.Type)(nil), vdl.AnyType},
+ // Test that both encoding and decoding ignore unexported fields.
+ {struct{ a, X, b string }{"a", "XYZ", "b"}, struct{ d, X, e string }{X: "XYZ"}},
+ {
+ struct {
+ a bool
+ X string
+ b int64
+ }{true, "XYZ", 123},
+ struct {
+ a complex64
+ X string
+ b []byte
+ }{X: "XYZ"},
+ },
+ // Test for array encoding/decoding.
+ {[3]byte{1, 2, 3}, [3]byte{1, 2, 3}},
+ {[3]int64{1, 2, 3}, [3]int64{1, 2, 3}},
+ // Test for zero value struct/union field encoding/decoding.
+ {struct{ A int64 }{0}, struct{ A int64 }{}},
+ {struct{ T *vdl.Type }{nil}, struct{ T *vdl.Type }{vdl.AnyType}},
+ {struct{ M map[uint64]struct{} }{make(map[uint64]struct{})}, struct{ M map[uint64]struct{} }{}},
+ {struct{ M map[uint64]string }{make(map[uint64]string)}, struct{ M map[uint64]string }{}},
+ {struct{ N struct{ A int64 } }{struct{ A int64 }{0}}, struct{ N struct{ A int64 } }{}},
+ {struct{ N *testdata.NStruct }{&testdata.NStruct{false, "", 0}}, struct{ N *testdata.NStruct }{&testdata.NStruct{}}},
+ {struct{ N *testdata.NStruct }{nil}, struct{ N *testdata.NStruct }{}},
+ {testdata.NUnion(testdata.NUnionA{false}), testdata.NUnion(testdata.NUnionA{})},
+ }
+ for _, test := range tests {
+ name := fmt.Sprintf("(%#v,%#v)", test.In, test.Want)
+ var buf bytes.Buffer
+ encoder, err := NewEncoder(&buf)
+ if err != nil {
+ t.Errorf("%s: NewEncoder failed: %v", name, err)
+ continue
+ }
+ if err := encoder.Encode(test.In); err != nil {
+ t.Errorf("%s: binary Encode(%#v) failed: %v", name, test.In, err)
+ continue
+ }
+ testDecodeGo(t, name, buf.String(), reflect.TypeOf(test.Want), test.Want)
+ }
+}
diff --git a/lib/vom/doc.go b/lib/vom/doc.go
new file mode 100644
index 0000000..af40399
--- /dev/null
+++ b/lib/vom/doc.go
@@ -0,0 +1,222 @@
+/*
+Package vom implements Veyron Object Marshaling, a serialization protocol
+similar to the encoding/gob package. Vom is used in Veyron to enable
+interchange of user-defined data structures across networks, languages and
+storage systems.
+
+The vom core API is almost identical to encoding/gob. To marshal objects create
+an Encoder and present it with a series of values. To unmarshal objects create
+a Decoder and retrieve values. The implementation creates a possibly stateful
+stream of messages between the Encoder and Decoder.
+
+Vom supports a limited subset of values; not all Go values are faithfully
+represented. The following features are not supported:
+ Pointers
+ Sized numerics (e.g. int32, float64)
+ Arrays
+ Channels
+ Functions
+
+The types of the encoded and decoded values need not be identical, they only
+need to be compatible. Here are some compatibility rules:
+
++ Numeric values (ints, uints and floats) are compatible if the encoded value
+can be represented without loss; e.g. an encoded float(1.0) may be decoded into
+a value of type uint, but float(-1.0) and float(1.1) may not.
+
++ String values may always be decoded into bytes values. Bytes value may be
+decoded into string values, iff the bytes only contain valid UTF-8.
+
++ Enum values may always be decoded into string or bytes values. String or
+bytes values may be decoded into enum values, iff the value represents a valid
+enum label.
+
++ Values of the same composite types are compatible if their contained values
+are compatible, as specified by the other rules. E.g. map[float]string is
+compatible with map[uint]bytes as long as the encoded float keys are unsigned
+integers.
+
++ Struct values are compatible based on their fields, identified by name. If a
+field with the same name exists in both, their values must be compatible.
+Fields with names that exist in one struct but not the other are silently
+ignored.
+
++ Struct values are compatible with maps with string keys, by assuming the map
+represents a struct and applying the regular struct compatibility rules. Struct
+values may always be decoded into map[string]any; map[string]any may be decoded
+into a struct iff the fields with the same name/key are compatible. The
+restricted form map[string]T is only compatible with structs with fields of type
+T.
+
+Vom supports two interchange formats: a binary format that is compact and fast,
+and a JSON format that is simpler but slower. The binary format is
+self-describing; all type information describing the encoded values is present
+in the encoded stream. The JSON format prefers idiomatic JSON at the expense of
+losing some of the type information.
+*/
+package vom
+
+/*
+TODO: Describe user-defined coders (VomEncode?)
+TODO: Describe wire format, something like this:
+
+Wire protocol. // IMPLEMENTED PROTOCOL
+
+The protocol consists of a stream of messages, where each message describes
+either a type or a value. All values are typed. Here's the protocol grammar:
+ VOM:
+ (TypeMsg | ValueMsg)*
+ TypeMsg:
+ -typeID len(WireType) WireType
+ ValueMsg:
+ +typeID primitive
+ | +typeID len(ValueMsg) CompositeV
+ Value:
+ primitive | CompositeV
+ CompositeV:
+ ArrayV | ListV | SetV | MapV | StructV | UnionV | OptionalV | AnyV
+ ArrayV:
+ len Value*len
+ // len is always 0 for array since we know the exact size of the array. This
+ // prefix is to ensure the decoder can distinguish NIL from the array value.
+ ListV:
+ len Value*len
+ SetV:
+ len Value*len
+ MapV:
+ len (Value Value)*len
+ StructV:
+ (index Value)* EOF // index is the 0-based field index and
+ // zero value fields can be skipped.
+ UnionV:
+ index Value // index is the 0-based field index.
+ OptionalV:
+ NIL
+ | Value
+ AnyV:
+ NIL
+ | +typeID Value
+
+
+
+Wire protocol. // NEW PROTOCOL, NOT IMPLEMENTED YET
+
+The protocol consists of a stream of messages, where each message describes
+either a type or a value. All values are typed. Here's the protocol grammar:
+ VOM:
+ Message*
+ Message:
+ (TypeMsg | ValueMsg)
+ TypeMsg:
+ TypeID WireType
+ ValueMsg:
+ TypeID primitive
+ | TypeID CompositeV
+ Value:
+ primitive | CompositeV
+ CompositeV:
+ ArrayV | ListV | SetV | MapV | StructV | UnionV | AnyV
+ ArrayV:
+ len Value*len
+ ListV:
+ len Value*len
+ SetV:
+ len Value*len
+ MapV:
+ len (Value Value)*len
+ StructV:
+ (index Value)* END // index is the 0-based field index.
+ UnionV:
+ index Value // index is the 0-based field index.
+ AnyV:
+ typeID Value
+
+TODO(toddw): We need the message lengths for fast binary->binary transcoding.
+
+The basis for the encoding is a variable-length unsigned integer (var128), with
+a max size of 128 bits (16 bytes). This is a byte-based encoding. The first
+byte encodes values 0x00...0x7F verbatim. Otherwise it encodes the length of
+the value, and the value is encoded in the subsequent bytes in big-endian order.
+In addition we have space for 112 control entries.
+
+The var128 encoding tries to strike a balance between the coding size and
+performance; we try to not be overtly wasteful of space, but still keep the
+format simple to encode and decode.
+
+ First byte of var128:
+ |7|6|5|4|3|2|1|0|
+ |---------------|
+ |0| Single value| 0x00...0x7F Single-byte value (0...127)
+ -----------------
+ |1|0|x|x|x|x|x|x| 0x80...0xBF Control1 (64 entries)
+ |1|1|0|x|x|x|x|x| 0xC0...0xDF Control2 (32 entries)
+ |1|1|1|0|x|x|x|x| 0xE0...0xEF Control3 (16 entries)
+ |1|1|1|1| Len | 0xF0...0xFF Multi-byte length (FF=1 byte, FE=2 bytes, ...)
+ ----------------- (i.e. the length is -Len)
+
+The encoding of the value and control entries are all disjoint from each other;
+each var128 can hold either a single 128 bit value, or 4 to 6 control bits. The
+encoding favors small values; values less than 0x7F and control entries are all
+encoded in one byte.
+
+The primitives are all encoded using var128:
+ o Unsigned: Verbatim.
+ o Signed : Low bit 0 for positive and 1 for negative, and indicates whether
+ to complement the other bits to recover the signed value.
+ o Float: Byte-reversed ieee754 64-bit float.
+ o Complex: Two floats, real and imaginary.
+ o String: Byte count followed by uninterpreted bytes.
+
+Controls are used to represent special properties and values:
+ 0xE0 // NIL - represents any(nil), a non-existent value.
+ 0xEF // EOF - end of fields, e.g. used for structs
+ ...
+TODO(toddw): Add a flag indicating there is a local TypeID table for Any types.
+
+The first byte of each message takes advantage of the var128 flags and reserved
+entries, to make common encodings smaller, but still easy to decode. The
+assumption is that values will be encoded more frequently than types; we expect
+values of the same type to be encoded repeatedly. Conceptually the first byte
+needs to distinguish TypeMsg from ValueMsg, and also tell us the TypeID.
+
+First byte of each message:
+ |7|6|5|4|3|2|1|0|
+ |---------------|
+ |0|0|0|0|0|0|0|0| Reserved (1 entry 0x00)
+ |0|1|x|x|x|0|0|0| Reserved (8 entries 0x40, 48, 50, 58, 60, 68, 70, 78)
+ |0|0|1|x|x|0|0|0| Reserved (4 entries 0x20, 28, 30, 38)
+ |0|0|0|1|0|0|0|0| TypeMsg (0x10, TypeID encoded next, then WireType)
+ |0|0|0|0|1|0|0|0| ValueMsg bool false (0x08)
+ |0|0|0|1|1|0|0|0| ValueMsg bool true (0x18)
+ |0| StrLen|0|1|0| ValueMsg small string len (0...15)
+ |0| Uint |1|0|0| ValueMsg small uint (0...15)
+ |0| Int |1|1|0| ValueMsg small int (-8...7)
+ |0| TypeID |1| ValueMsg (6-bit built-in TypeID)
+ -----------------
+ |1|0| TypeID | ValueMsg (6-bit user TypeID)
+ |1|1|0| Resv | Reserved (32 entries 0xC0...0xDF)
+ |1|1|1|0| Flag | Flag (16 entries 0xE0...0xEF)
+ |1|1|1|1| Len | Multi-byte length (FF=1 byte, FE=2 bytes, ..., F8=8 bytes)
+ ----------------- (i.e. the length is -Len)
+
+If the first byte is 0x10, this is a TypeMsg, and we encode the TypeID next,
+followed by the WireType. The WireType is simply encoded as a regular value,
+using the protocol described in the grammar above.
+
+Otherwise this is a ValueMsg. We encode small bool, uint and int values that
+fit into 4 bits directly into the first byte, along with their TypeID. For
+small strings with len <= 15, we encode the length into the first byte, followed
+by the bytes of the string value; empty strings are a single byte 0x02.
+
+The first byte of the ValueMsg also contains TypeIDs [0...127], where the
+built-in TypeIDs occupy [0...63], and user-defined TypeIDs start at 64.
+User-defined TypeIDs larger than 127 are encoded as regular multi-byte var128.
+
+TODO(toddw): For small value encoding to be useful, we'll want to use it for all
+values that can fit, but we'll be dropping the sizes of int and uint, and the
+type names. Now that Union is labeled, the only issue is Any. And now that we
+have Signature with type information, maybe we can drop the type names
+regularly, and only send them when the Signature says "Any". This also impacts
+where we perform value conversions - does it happen on the server or the client?
+
+*/
diff --git a/lib/vom/dump.go b/lib/vom/dump.go
new file mode 100644
index 0000000..90b507b
--- /dev/null
+++ b/lib/vom/dump.go
@@ -0,0 +1,761 @@
+package vom
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "io"
+ "reflect"
+
+ "v.io/v23/vdl"
+)
+
+// Dump returns a human-readable dump of the given vom data, in the default
+// string format.
+func Dump(data []byte) string {
+ var buf bytes.Buffer
+ d := NewDumper(NewDumpWriter(&buf))
+ d.Write(data)
+ d.Close()
+ return string(buf.Bytes())
+}
+
+// DumpWriter is the interface that describes how to write out dumps produced by
+// the Dumper. Implement this interface to customize dump output behavior.
+type DumpWriter interface {
+ // WriteAtom is called by the Dumper for each atom it decodes.
+ WriteAtom(atom DumpAtom)
+ // WriteStatus is called by the Dumper to indicate the status of the dumper.
+ WriteStatus(status DumpStatus)
+}
+
+// NewDumpWriter returns a DumpWriter that outputs dumps to w, writing each atom
+// and status on its own line, in their default string format.
+func NewDumpWriter(w io.Writer) DumpWriter {
+ return dumpWriter{w}
+}
+
+type dumpWriter struct {
+ w io.Writer
+}
+
+func (w dumpWriter) WriteAtom(atom DumpAtom) {
+ fmt.Fprintln(w.w, atom)
+}
+
+func (w dumpWriter) WriteStatus(status DumpStatus) {
+ fmt.Fprintln(w.w, status)
+}
+
+// Dumper produces dumps of vom data. It implements the io.WriteCloser
+// interface; Data is fed to the dumper via Write, and Close must be called at
+// the end of usage to release resources.
+//
+// Dumps of vom data consist of a single stream of DumpAtom and DumpStatus.
+// Each atom describes a single piece of the vom encoding; the vom encoding is
+// composed of a stream of atoms. The status describes the state of the dumper
+// at that point in the stream.
+type Dumper struct {
+ // The Dumper only contains channels to communicate with the dumpWorker, which
+ // does all the actual work.
+ cmdChan chan<- dumpCmd
+ closeChan <-chan struct{}
+}
+
+var _ io.WriteCloser = (*Dumper)(nil)
+
+// NewDumper returns a new Dumper, which writes dumps of vom data to w.
+//
+// Close must be called on the returned Dumper to release resources.
+func NewDumper(w DumpWriter) *Dumper {
+ cmd, close := make(chan dumpCmd), make(chan struct{})
+ startDumpWorker(cmd, close, w)
+ return &Dumper{cmd, close}
+}
+
+// Close flushes buffered data and releases resources. Close must be called
+// exactly once, when the dumper is no longer needed.
+func (d *Dumper) Close() error {
+ d.Flush()
+ close(d.cmdChan)
+ <-d.closeChan
+ return nil
+}
+
+// Flush flushes buffered data, and causes the dumper to restart decoding at the
+// start of a new message. This is useful if the previous data in the stream
+// was corrupt, and subsequent data will be for new vom messages. Previously
+// buffered type information remains intact.
+func (d *Dumper) Flush() error {
+ done := make(chan struct{})
+ d.cmdChan <- dumpCmd{nil, done}
+ <-done
+ return nil
+}
+
+// Status triggers an explicit dump of the current status of the dumper to the
+// DumpWriter. Status is normally generated at the end of each each decoded
+// message; call Status to get extra information for partial dumps and errors.
+func (d *Dumper) Status() {
+ done := make(chan struct{})
+ d.cmdChan <- dumpCmd{[]byte{}, done}
+ <-done
+}
+
+// Write implements the io.Writer interface method. This is the mechanism by
+// which data is fed into the dumper.
+func (d *Dumper) Write(data []byte) (int, error) {
+ if len(data) == 0 {
+ // Nil data means Flush, and non-nil empty data means Status, so we must
+ // ensure that normal writes never send 0-length data.
+ return 0, nil
+ }
+ done := make(chan struct{})
+ d.cmdChan <- dumpCmd{data, done}
+ <-done
+ return len(data), nil
+}
+
+type dumpCmd struct {
+ // data holds Write data, except nil means Flush, and empty means Status.
+ data []byte
+ // done is closed when the worker has finished the command.
+ done chan struct{}
+}
+
+// dumpWorker does all the actual work, in its own goroutine. Commands are sent
+// from the Dumper to the worker via the cmdChan, and the closeChan is closed
+// when the worker has exited its goroutine.
+//
+// We run the worker in a separate goroutine to keep the dumping logic simple
+// and synchronous; the worker essentially runs the regular vom decoder logic,
+// annotated with extra dump information. In theory we could implement the
+// dumper without any extra goroutines, but that would require implementing a
+// vom decoder that explicitly maintained the decoding stack (rather than simple
+// recursive calls), which doesn't seem worth it.
+//
+// The reason we re-implement the vom decoding logic in the work rather than
+// just adding the appropriate annotations to the regular vom decoder is for
+// performance; we don't want to bloat the regular decoder with lots of dump
+// annotations.
+type dumpWorker struct {
+ cmdChan <-chan dumpCmd
+ closeChan chan<- struct{}
+
+ // We hold regular decoding state, and output dump information to w.
+ w DumpWriter
+ buf *decbuf
+ recvTypes *decoderTypes
+ status DumpStatus
+
+ // Each Write call on the Dumper is passed to us on the cmdChan. When we get
+ // around to processing the Write data, we buffer any extra data, and hold on
+ // to the done channel so that we can close it when all the data is processed.
+ data bytes.Buffer
+ lastWrite chan<- struct{}
+
+ // Hold on to the done channel for Flush commands, so that we can close it
+ // when the worker actually finishes decoding the current message.
+ lastFlush chan<- struct{}
+}
+
+func startDumpWorker(cmd <-chan dumpCmd, close chan<- struct{}, w DumpWriter) {
+ worker := &dumpWorker{
+ cmdChan: cmd,
+ closeChan: close,
+ w: w,
+ recvTypes: newDecoderTypes(),
+ }
+ worker.buf = newDecbuf(worker)
+ go worker.decodeLoop()
+}
+
+// Read implements the io.Reader method, and is our synchronization strategy.
+// The worker decodeLoop is running in its own goroutine, and keeps trying to
+// decode vom messages. When the decoder runs out of data, it will trigger a
+// Read call.
+//
+// Thus we're guaranteed that when Read is called, the worker decodeLoop is
+// blocked waiting on the results. This gives us a natural place to process all
+// commands, and consume more data from Write calls.
+func (d *dumpWorker) Read(data []byte) (int, error) {
+ // If we have any data buffered up, just return it.
+ if n, _ := d.data.Read(data); n > 0 || len(data) == 0 {
+ return n, nil
+ }
+ // Otherwise we're done with all the buffered data. Signal the last Write
+ // call that all data has been processed.
+ d.lastWriteDone()
+ // Wait for commands on the the cmd channel.
+ for {
+ select {
+ case cmd, ok := <-d.cmdChan:
+ if !ok {
+ // Close called, return our special closed error.
+ return 0, dumperClosed
+ }
+ switch {
+ case cmd.data == nil:
+ // Flush called, return our special flushed error. The Flush is done
+ // when the decoderLoop starts with a new message.
+ d.lastFlush = cmd.done
+ return 0, dumperFlushed
+ case len(cmd.data) == 0:
+ // Status called.
+ d.writeStatus(nil, false)
+ close(cmd.done)
+ default:
+ // Write called. Copy as much as we can into data, writing leftover
+ // into our buffer. Hold on to the cmd.done channel, so we can close it
+ // when the data has all been read.
+ n := copy(data, cmd.data)
+ if n < len(cmd.data) {
+ d.data.Write(cmd.data[n:])
+ }
+ d.lastWrite = cmd.done
+ return n, nil
+ }
+ }
+ }
+}
+
+var (
+ dumperClosed = errors.New("vom: Dumper closed")
+ dumperFlushed = errors.New("vom: Dumper flushed")
+)
+
+// decodeLoop runs a loop synchronously decoding messages. Calls to read from
+// d.buf will eventually result in a call to d.Read, which allows us to handle
+// special commands like Close, Flush and Status synchronously.
+func (d *dumpWorker) decodeLoop() {
+ for {
+ err := d.decodeNextValue()
+ d.writeStatus(err, true)
+ switch {
+ case err == dumperClosed:
+ d.lastWriteDone()
+ d.lastFlushDone()
+ close(d.closeChan)
+ return
+ case err != nil:
+ // Any error causes us to flush our buffers; otherwise we run the risk of
+ // an infinite loop.
+ d.buf.Reset()
+ d.data.Reset()
+ d.lastWriteDone()
+ d.lastFlushDone()
+ }
+ }
+}
+
+func (d *dumpWorker) lastWriteDone() {
+ if d.lastWrite != nil {
+ close(d.lastWrite)
+ d.lastWrite = nil
+ }
+}
+
+func (d *dumpWorker) lastFlushDone() {
+ if d.lastFlush != nil {
+ close(d.lastFlush)
+ d.lastFlush = nil
+ }
+}
+
+// DumpStatus represents the state of the dumper. It is written to the
+// DumpWriter at the end of decoding each value, and may also be triggered
+// explicitly via Dumper.Status calls to get information for partial dumps.
+type DumpStatus struct {
+ MsgID int64
+ MsgLen int
+ MsgN int
+ Buf []byte
+ Debug string
+ Value *vdl.Value
+ Err error
+}
+
+func (s DumpStatus) String() string {
+ ret := fmt.Sprintf("DumpStatus{MsgID: %d", s.MsgID)
+ if s.MsgLen != 0 {
+ ret += fmt.Sprintf(", MsgLen: %d", s.MsgLen)
+ }
+ if s.MsgN != 0 {
+ ret += fmt.Sprintf(", MsgN: %d", s.MsgN)
+ }
+ if len := len(s.Buf); len > 0 {
+ ret += fmt.Sprintf(`, Buf(%d): "%x"`, len, s.Buf)
+ }
+ if s.Debug != "" {
+ ret += fmt.Sprintf(", Debug: %q", s.Debug)
+ }
+ if s.Value.IsValid() {
+ ret += fmt.Sprintf(", Value: %v", s.Value)
+ }
+ if s.Err != nil {
+ ret += fmt.Sprintf(", Err: %v", s.Err)
+ }
+ return ret + "}"
+}
+
+func (a DumpAtom) String() string {
+ dataFmt := "%20v"
+ if _, isString := a.Data.Interface().(string); isString {
+ dataFmt = "%20q"
+ }
+ ret := fmt.Sprintf("%-20x %-15v "+dataFmt, a.Bytes, a.Kind, a.Data.Interface())
+ if a.Debug != "" {
+ ret += fmt.Sprintf(" [%s]", a.Debug)
+ }
+ return ret
+}
+
+func (d *dumpWorker) writeStatus(err error, doneDecoding bool) {
+ if doneDecoding {
+ d.status.Err = err
+ if (err == dumperFlushed || err == dumperClosed) && d.status.MsgLen == 0 && d.status.MsgN == 0 {
+ // Don't write status for flushed and closed when we've finished decoding
+ // and are waiting for the next message.
+ return
+ }
+ if err == nil {
+ // Successful decoding, don't include the last "waiting..." debug message.
+ d.status.Debug = ""
+ }
+ }
+ // If we're stuck in the middle of a Read, the data we have so far is in the
+ // decbuf. Grab the data here for debugging.
+ if buflen := d.buf.end - d.buf.beg; buflen > 0 {
+ d.status.Buf = make([]byte, buflen)
+ copy(d.status.Buf, d.buf.buf[d.buf.beg:d.buf.end])
+ } else {
+ d.status.Buf = nil
+ }
+ d.w.WriteStatus(d.status)
+}
+
+// prepareAtom sets the status.Debug message, and prepares the decbuf so that
+// subsequent writeAtom calls can easily capture all data that's been read.
+func (d *dumpWorker) prepareAtom(format string, v ...interface{}) {
+ d.status.Debug = fmt.Sprintf(format, v...)
+ d.buf.moveDataToFront()
+}
+
+// writeAtom writes an atom describing the chunk of data we just decoded. In
+// order to capture the data that was read, we rely on prepareAtom being called
+// before the writeAtom call.
+//
+// The mechanism to capture the data is subtle. In prepareAtom we moved all
+// decbuf data to the front, setting decbuf.beg to 0. Here we assume that all
+// data in the decbuf up to the new value of decbuf.beg is what was read.
+//
+// This is tricky, and somewhat error-prone. We're using this strategy so that
+// we can share the raw decoding logic with the real decoder, while still
+// keeping the raw decoding logic reasonably compact and fast.
+func (d *dumpWorker) writeAtom(kind DumpKind, data Primitive, format string, v ...interface{}) {
+ var bytes []byte
+ if len := d.buf.beg; len > 0 {
+ bytes = make([]byte, len)
+ copy(bytes, d.buf.buf[:len])
+ }
+ d.w.WriteAtom(DumpAtom{
+ Kind: kind,
+ Bytes: bytes,
+ Data: data,
+ Debug: fmt.Sprintf(format, v...),
+ })
+ d.status.MsgN += len(bytes)
+ d.buf.moveDataToFront()
+}
+
+func (d *dumpWorker) decodeNextValue() error {
+ // Decode type messages until we get to the type of the next value.
+ valType, err := d.decodeValueType()
+ if err != nil {
+ return err
+ }
+ // Decode value message.
+ d.status.Value = vdl.ZeroValue(valType)
+ target, err := vdl.ValueTarget(d.status.Value)
+ if err != nil {
+ return err
+ }
+ return d.decodeValueMsg(valType, target)
+}
+
+func (d *dumpWorker) decodeValueType() (*vdl.Type, error) {
+ for {
+ d.status = DumpStatus{}
+ // Decode the magic byte. To make the dumper easier to use on partial data,
+ // the magic byte is optional. Note that this relies on 0x80 not being a
+ // valid first byte of regular data.
+ d.prepareAtom("waiting for magic byte or first byte of message")
+ switch magic, err := d.buf.PeekByte(); {
+ case err != nil:
+ return nil, err
+ case magic == binaryMagicByte:
+ d.buf.Skip(1)
+ d.writeAtom(DumpKindMagic, PrimitivePByte{magic}, "vom version 0")
+ }
+ d.prepareAtom("waiting for message ID")
+ id, err := binaryDecodeInt(d.buf)
+ if err != nil {
+ return nil, err
+ }
+ d.writeAtom(DumpKindMsgID, PrimitivePInt{id}, "")
+ d.status.MsgID = id
+ switch {
+ case id == 0:
+ return nil, errDecodeZeroTypeID
+ case id > 0:
+ // This is a value message, the typeID is +id.
+ tid := typeID(+id)
+ tt, err := d.recvTypes.LookupOrBuildType(tid)
+ if err != nil {
+ d.writeAtom(DumpKindValueMsg, PrimitivePUint{uint64(tid)}, "%v", err)
+ return nil, err
+ }
+ d.writeAtom(DumpKindValueMsg, PrimitivePUint{uint64(tid)}, "%v", tt)
+ return tt, nil
+ }
+ // This is a type message, the typeID is -id.
+ tid := typeID(-id)
+ d.writeAtom(DumpKindTypeMsg, PrimitivePUint{uint64(tid)}, "")
+ // Decode the wireType like a regular value, and store it in recvTypes. The
+ // type will actually be built when a value message arrives using this tid.
+ var wt wireType
+ target, err := vdl.ReflectTarget(reflect.ValueOf(&wt))
+ if err != nil {
+ return nil, err
+ }
+ if err := d.decodeValueMsg(wireTypeType, target); err != nil {
+ return nil, err
+ }
+ if err := d.recvTypes.AddWireType(tid, wt); err != nil {
+ return nil, err
+ }
+ }
+}
+
+// decodeValueMsg decodes the rest of the message assuming type t, handling the
+// optional message length.
+func (d *dumpWorker) decodeValueMsg(tt *vdl.Type, target vdl.Target) error {
+ if hasBinaryMsgLen(tt) {
+ d.prepareAtom("waiting for message len")
+ msgLen, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindMsgLen, PrimitivePUint{uint64(msgLen)}, "")
+ d.status.MsgLen = msgLen
+ d.status.MsgN = 0 // Make MsgN match up with MsgLen when successful.
+ d.buf.SetLimit(msgLen)
+ }
+ err := d.decodeValue(tt, target)
+ leftover := d.buf.RemoveLimit()
+ switch {
+ case err != nil:
+ return err
+ case leftover > 0:
+ return fmt.Errorf("vom: %d leftover bytes", leftover)
+ }
+ return nil
+}
+
+// decodeValue decodes the rest of the message assuming type tt.
+func (d *dumpWorker) decodeValue(tt *vdl.Type, target vdl.Target) error {
+ ttFrom := tt
+ if tt.Kind() == vdl.Optional {
+ d.prepareAtom("waiting for optional control byte")
+ // If the type is optional, we expect to see either WireCtrlNil or the actual
+ // value, but not both. And thus, we can just peek for the WireCtrlNil here.
+ switch ctrl, err := binaryPeekControl(d.buf); {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlNil:
+ d.buf.Skip(1)
+ d.writeAtom(DumpKindControl, PrimitivePControl{ControlKindNIL}, "%v is nil", ttFrom)
+ return target.FromNil(ttFrom)
+ }
+ tt = tt.Elem()
+ }
+ if tt.IsBytes() {
+ d.prepareAtom("waiting for bytes len")
+ len, err := binaryDecodeLenOrArrayLen(d.buf, ttFrom)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindByteLen, PrimitivePUint{uint64(len)}, "bytes len")
+ d.prepareAtom("waiting for bytes data")
+ bytes, err := d.buf.ReadBuf(len)
+ if err != nil {
+ return err
+ }
+ str := string(bytes) // copy bytes before writeAtom overwrites the buffer.
+ d.writeAtom(DumpKindPrimValue, PrimitivePString{str}, "bytes")
+ return target.FromBytes([]byte(str), ttFrom)
+ }
+ switch kind := tt.Kind(); kind {
+ case vdl.Bool:
+ d.prepareAtom("waiting for bool value")
+ v, err := binaryDecodeBool(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindPrimValue, PrimitivePBool{v}, "bool")
+ return target.FromBool(v, ttFrom)
+ case vdl.Byte:
+ d.prepareAtom("waiting for byte value")
+ v, err := d.buf.ReadByte()
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindPrimValue, PrimitivePByte{v}, "byte")
+ return target.FromUint(uint64(v), ttFrom)
+ case vdl.Uint16, vdl.Uint32, vdl.Uint64:
+ d.prepareAtom("waiting for uint value")
+ v, err := binaryDecodeUint(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindPrimValue, PrimitivePUint{v}, "uint")
+ return target.FromUint(v, ttFrom)
+ case vdl.Int16, vdl.Int32, vdl.Int64:
+ d.prepareAtom("waiting for int value")
+ v, err := binaryDecodeInt(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindPrimValue, PrimitivePInt{v}, "int")
+ return target.FromInt(v, ttFrom)
+ case vdl.Float32, vdl.Float64:
+ d.prepareAtom("waiting for float value")
+ v, err := binaryDecodeFloat(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindPrimValue, PrimitivePFloat{v}, "float")
+ return target.FromFloat(v, ttFrom)
+ case vdl.Complex64, vdl.Complex128:
+ d.prepareAtom("waiting for complex real value")
+ re, err := binaryDecodeFloat(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindPrimValue, PrimitivePFloat{re}, "complex real")
+ d.prepareAtom("waiting for complex imag value")
+ im, err := binaryDecodeFloat(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindPrimValue, PrimitivePFloat{re}, "complex imag")
+ return target.FromComplex(complex(re, im), ttFrom)
+ case vdl.String:
+ d.prepareAtom("waiting for string len")
+ len, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindByteLen, PrimitivePUint{uint64(len)}, "string len")
+ d.prepareAtom("waiting for string data")
+ bytes, err := d.buf.ReadBuf(len)
+ if err != nil {
+ return err
+ }
+ str := string(bytes) // copy bytes before writeAtom overwrites the buffer.
+ d.writeAtom(DumpKindPrimValue, PrimitivePString{str}, "string")
+ return target.FromString(str, ttFrom)
+ case vdl.Enum:
+ d.prepareAtom("waiting for enum index")
+ index, err := binaryDecodeUint(d.buf)
+ if err != nil {
+ return err
+ }
+ if index >= uint64(tt.NumEnumLabel()) {
+ d.writeAtom(DumpKindIndex, PrimitivePUint{index}, "out of range for %v", tt)
+ return errIndexOutOfRange
+ }
+ label := tt.EnumLabel(int(index))
+ d.writeAtom(DumpKindIndex, PrimitivePUint{index}, "%v.%v", tt.Name(), label)
+ return target.FromEnumLabel(label, ttFrom)
+ case vdl.TypeObject:
+ d.prepareAtom("waiting for typeobject ID")
+ id, err := binaryDecodeUint(d.buf)
+ if err != nil {
+ return err
+ }
+ typeobj, err := d.recvTypes.LookupOrBuildType(typeID(id))
+ if err != nil {
+ d.writeAtom(DumpKindTypeID, PrimitivePUint{id}, "%v", err)
+ return err
+ }
+ d.writeAtom(DumpKindTypeID, PrimitivePUint{id}, "%v", typeobj)
+ return target.FromTypeObject(typeobj)
+ case vdl.Array, vdl.List:
+ d.prepareAtom("waiting for list len")
+ len, err := binaryDecodeLenOrArrayLen(d.buf, tt)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindValueLen, PrimitivePUint{uint64(len)}, "list len")
+ listTarget, err := target.StartList(ttFrom, len)
+ if err != nil {
+ return err
+ }
+ for ix := 0; ix < len; ix++ {
+ elem, err := listTarget.StartElem(ix)
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(tt.Elem(), elem); err != nil {
+ return err
+ }
+ if err := listTarget.FinishElem(elem); err != nil {
+ return err
+ }
+ }
+ return target.FinishList(listTarget)
+ case vdl.Set:
+ d.prepareAtom("waiting for set len")
+ len, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindValueLen, PrimitivePUint{uint64(len)}, "set len")
+ setTarget, err := target.StartSet(ttFrom, len)
+ if err != nil {
+ return err
+ }
+ for ix := 0; ix < len; ix++ {
+ key, err := setTarget.StartKey()
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(tt.Key(), key); err != nil {
+ return err
+ }
+ if err := setTarget.FinishKey(key); err != nil {
+ return err
+ }
+ }
+ return target.FinishSet(setTarget)
+ case vdl.Map:
+ d.prepareAtom("waiting for map len")
+ len, err := binaryDecodeLen(d.buf)
+ if err != nil {
+ return err
+ }
+ d.writeAtom(DumpKindValueLen, PrimitivePUint{uint64(len)}, "map len")
+ mapTarget, err := target.StartMap(ttFrom, len)
+ if err != nil {
+ return err
+ }
+ for ix := 0; ix < len; ix++ {
+ key, err := mapTarget.StartKey()
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(tt.Key(), key); err != nil {
+ return err
+ }
+ field, err := mapTarget.FinishKeyStartField(key)
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(tt.Elem(), field); err != nil {
+ return err
+ }
+ if err := mapTarget.FinishField(key, field); err != nil {
+ return err
+ }
+ }
+ return target.FinishMap(mapTarget)
+ case vdl.Struct:
+ fieldsTarget, err := target.StartFields(ttFrom)
+ if err != nil {
+ return err
+ }
+ // Loop through decoding the 0-based field index and corresponding field.
+ for {
+ d.prepareAtom("waiting for struct field index")
+ index, ctrl, err := binaryDecodeUintWithControl(d.buf)
+ switch {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlEOF:
+ d.writeAtom(DumpKindControl, PrimitivePControl{ControlKindEOF}, "%v END", tt.Name())
+ return target.FinishFields(fieldsTarget)
+ case ctrl != 0:
+ return fmt.Errorf("vom: unexpected control byte 0x%x", ctrl)
+ case index >= uint64(tt.NumField()):
+ d.writeAtom(DumpKindIndex, PrimitivePUint{index}, "out of range for %v", tt)
+ return errIndexOutOfRange
+ }
+ ttfield := tt.Field(int(index))
+ d.writeAtom(DumpKindIndex, PrimitivePUint{index}, "%v.%v", tt.Name(), ttfield.Name)
+ key, field, err := fieldsTarget.StartField(ttfield.Name)
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(ttfield.Type, field); err != nil {
+ return err
+ }
+ if err := fieldsTarget.FinishField(key, field); err != nil {
+ return err
+ }
+ }
+ case vdl.Union:
+ fieldsTarget, err := target.StartFields(ttFrom)
+ if err != nil {
+ return err
+ }
+ d.prepareAtom("waiting for union field index")
+ index, err := binaryDecodeUint(d.buf)
+ switch {
+ case err != nil:
+ return err
+ case index >= uint64(tt.NumField()):
+ d.writeAtom(DumpKindIndex, PrimitivePUint{index}, "out of range for %v", tt)
+ return errIndexOutOfRange
+ }
+ ttfield := tt.Field(int(index))
+ if tt == wireTypeType {
+ // Pretty-print for wire type definition messages.
+ d.writeAtom(DumpKindWireTypeIndex, PrimitivePUint{index}, "%v", ttfield.Type.Name())
+ } else {
+ d.writeAtom(DumpKindIndex, PrimitivePUint{index}, "%v.%v", tt.Name(), ttfield.Name)
+ }
+ key, field, err := fieldsTarget.StartField(ttfield.Name)
+ if err != nil {
+ return err
+ }
+ if err := d.decodeValue(ttfield.Type, field); err != nil {
+ return err
+ }
+ if err := fieldsTarget.FinishField(key, field); err != nil {
+ return err
+ }
+ return target.FinishFields(fieldsTarget)
+ case vdl.Any:
+ d.prepareAtom("waiting for any typeID")
+ switch id, ctrl, err := binaryDecodeUintWithControl(d.buf); {
+ case err != nil:
+ return err
+ case ctrl == WireCtrlNil:
+ d.writeAtom(DumpKindControl, PrimitivePControl{ControlKindNIL}, "any(nil)")
+ return target.FromNil(vdl.AnyType)
+ case ctrl != 0:
+ return fmt.Errorf("vom: unexpected control byte 0x%x", ctrl)
+ default:
+ elemType, err := d.recvTypes.LookupOrBuildType(typeID(id))
+ if err != nil {
+ d.writeAtom(DumpKindTypeID, PrimitivePUint{id}, "%v", err)
+ return err
+ }
+ d.writeAtom(DumpKindTypeID, PrimitivePUint{id}, "%v", elemType)
+ return d.decodeValue(elemType, target)
+ }
+ default:
+ panic(fmt.Errorf("vom: decodeValue unhandled type %v", tt))
+ }
+}
diff --git a/lib/vom/dump.vdl b/lib/vom/dump.vdl
new file mode 100644
index 0000000..2c409bc
--- /dev/null
+++ b/lib/vom/dump.vdl
@@ -0,0 +1,44 @@
+package vom
+
+// Primitive represents one of the primitive vom values. All vom values are
+// composed of combinations of these primitives.
+type Primitive union {
+ PBool bool
+ PByte byte
+ PUint uint64
+ PInt int64
+ PFloat float64
+ PString string
+ PControl ControlKind
+}
+
+// DumpAtom describes a single indivisible piece of the vom encoding. The vom
+// encoding is composed of a stream of these atoms.
+type DumpAtom struct {
+ Kind DumpKind // The kind of this atom.
+ Bytes []byte // Raw bytes in the vom encoding representing this atom.
+ Data Primitive // Primitive data corresponding to the raw bytes.
+ Debug string // Free-form debug string with more information.
+}
+
+// DumpKind enumerates the different kinds of dump atoms.
+type DumpKind enum {
+ Magic // [byte] Magic number, the first byte of a vom stream.
+ Control // [byte] Control byte.
+ MsgID // [int] Message ID, distinguishing type and value messages.
+ TypeMsg // [uint] Type message, describes the type identified by -MsgID.
+ ValueMsg // [uint] Value message, describes a value of type +MsgID.
+ MsgLen // [uint] Message length in bytes.
+ TypeID // [uint] Type ID.
+ PrimValue // [*] Primitive value.
+ ByteLen // [uint] Length in bytes.
+ ValueLen // [uint] Number of values in a composite type.
+ Index // [uint] Index in a dense array.
+ WireTypeIndex // [uint] WireType index.
+}
+
+// ControlKind enumerates the different kinds of control bytes.
+type ControlKind enum {
+ NIL // [byte] Nil.
+ EOF // [byte] End of field.
+}
diff --git a/lib/vom/dump.vdl.go b/lib/vom/dump.vdl.go
new file mode 100644
index 0000000..058458d
--- /dev/null
+++ b/lib/vom/dump.vdl.go
@@ -0,0 +1,267 @@
+// This file was auto-generated by the veyron vdl tool.
+// Source: dump.vdl
+
+package vom
+
+import (
+ // VDL system imports
+ "fmt"
+ "v.io/v23/vdl"
+)
+
+type (
+ // Primitive represents any single field of the Primitive union type.
+ //
+ // Primitive represents one of the primitive vom values. All vom values are
+ // composed of combinations of these primitives.
+ Primitive interface {
+ // Index returns the field index.
+ Index() int
+ // Interface returns the field value as an interface.
+ Interface() interface{}
+ // Name returns the field name.
+ Name() string
+ // __VDLReflect describes the Primitive union type.
+ __VDLReflect(__PrimitiveReflect)
+ }
+ // PrimitivePBool represents field PBool of the Primitive union type.
+ PrimitivePBool struct{ Value bool }
+ // PrimitivePByte represents field PByte of the Primitive union type.
+ PrimitivePByte struct{ Value byte }
+ // PrimitivePUint represents field PUint of the Primitive union type.
+ PrimitivePUint struct{ Value uint64 }
+ // PrimitivePInt represents field PInt of the Primitive union type.
+ PrimitivePInt struct{ Value int64 }
+ // PrimitivePFloat represents field PFloat of the Primitive union type.
+ PrimitivePFloat struct{ Value float64 }
+ // PrimitivePString represents field PString of the Primitive union type.
+ PrimitivePString struct{ Value string }
+ // PrimitivePControl represents field PControl of the Primitive union type.
+ PrimitivePControl struct{ Value ControlKind }
+ // __PrimitiveReflect describes the Primitive union type.
+ __PrimitiveReflect struct {
+ Name string "v.io/v23/vom.Primitive"
+ Type Primitive
+ Union struct {
+ PBool PrimitivePBool
+ PByte PrimitivePByte
+ PUint PrimitivePUint
+ PInt PrimitivePInt
+ PFloat PrimitivePFloat
+ PString PrimitivePString
+ PControl PrimitivePControl
+ }
+ }
+)
+
+func (x PrimitivePBool) Index() int { return 0 }
+func (x PrimitivePBool) Interface() interface{} { return x.Value }
+func (x PrimitivePBool) Name() string { return "PBool" }
+func (x PrimitivePBool) __VDLReflect(__PrimitiveReflect) {}
+
+func (x PrimitivePByte) Index() int { return 1 }
+func (x PrimitivePByte) Interface() interface{} { return x.Value }
+func (x PrimitivePByte) Name() string { return "PByte" }
+func (x PrimitivePByte) __VDLReflect(__PrimitiveReflect) {}
+
+func (x PrimitivePUint) Index() int { return 2 }
+func (x PrimitivePUint) Interface() interface{} { return x.Value }
+func (x PrimitivePUint) Name() string { return "PUint" }
+func (x PrimitivePUint) __VDLReflect(__PrimitiveReflect) {}
+
+func (x PrimitivePInt) Index() int { return 3 }
+func (x PrimitivePInt) Interface() interface{} { return x.Value }
+func (x PrimitivePInt) Name() string { return "PInt" }
+func (x PrimitivePInt) __VDLReflect(__PrimitiveReflect) {}
+
+func (x PrimitivePFloat) Index() int { return 4 }
+func (x PrimitivePFloat) Interface() interface{} { return x.Value }
+func (x PrimitivePFloat) Name() string { return "PFloat" }
+func (x PrimitivePFloat) __VDLReflect(__PrimitiveReflect) {}
+
+func (x PrimitivePString) Index() int { return 5 }
+func (x PrimitivePString) Interface() interface{} { return x.Value }
+func (x PrimitivePString) Name() string { return "PString" }
+func (x PrimitivePString) __VDLReflect(__PrimitiveReflect) {}
+
+func (x PrimitivePControl) Index() int { return 6 }
+func (x PrimitivePControl) Interface() interface{} { return x.Value }
+func (x PrimitivePControl) Name() string { return "PControl" }
+func (x PrimitivePControl) __VDLReflect(__PrimitiveReflect) {}
+
+// DumpAtom describes a single indivisible piece of the vom encoding. The vom
+// encoding is composed of a stream of these atoms.
+type DumpAtom struct {
+ Kind DumpKind // The kind of this atom.
+ Bytes []byte // Raw bytes in the vom encoding representing this atom.
+ Data Primitive // Primitive data corresponding to the raw bytes.
+ Debug string // Free-form debug string with more information.
+}
+
+func (DumpAtom) __VDLReflect(struct {
+ Name string "v.io/v23/vom.DumpAtom"
+}) {
+}
+
+// DumpKind enumerates the different kinds of dump atoms.
+type DumpKind int
+
+const (
+ DumpKindMagic DumpKind = iota
+ DumpKindControl
+ DumpKindMsgID
+ DumpKindTypeMsg
+ DumpKindValueMsg
+ DumpKindMsgLen
+ DumpKindTypeID
+ DumpKindPrimValue
+ DumpKindByteLen
+ DumpKindValueLen
+ DumpKindIndex
+ DumpKindWireTypeIndex
+)
+
+// DumpKindAll holds all labels for DumpKind.
+var DumpKindAll = []DumpKind{DumpKindMagic, DumpKindControl, DumpKindMsgID, DumpKindTypeMsg, DumpKindValueMsg, DumpKindMsgLen, DumpKindTypeID, DumpKindPrimValue, DumpKindByteLen, DumpKindValueLen, DumpKindIndex, DumpKindWireTypeIndex}
+
+// DumpKindFromString creates a DumpKind from a string label.
+func DumpKindFromString(label string) (x DumpKind, err error) {
+ err = x.Set(label)
+ return
+}
+
+// Set assigns label to x.
+func (x *DumpKind) Set(label string) error {
+ switch label {
+ case "Magic", "magic":
+ *x = DumpKindMagic
+ return nil
+ case "Control", "control":
+ *x = DumpKindControl
+ return nil
+ case "MsgID", "msgid":
+ *x = DumpKindMsgID
+ return nil
+ case "TypeMsg", "typemsg":
+ *x = DumpKindTypeMsg
+ return nil
+ case "ValueMsg", "valuemsg":
+ *x = DumpKindValueMsg
+ return nil
+ case "MsgLen", "msglen":
+ *x = DumpKindMsgLen
+ return nil
+ case "TypeID", "typeid":
+ *x = DumpKindTypeID
+ return nil
+ case "PrimValue", "primvalue":
+ *x = DumpKindPrimValue
+ return nil
+ case "ByteLen", "bytelen":
+ *x = DumpKindByteLen
+ return nil
+ case "ValueLen", "valuelen":
+ *x = DumpKindValueLen
+ return nil
+ case "Index", "index":
+ *x = DumpKindIndex
+ return nil
+ case "WireTypeIndex", "wiretypeindex":
+ *x = DumpKindWireTypeIndex
+ return nil
+ }
+ *x = -1
+ return fmt.Errorf("unknown label %q in vom.DumpKind", label)
+}
+
+// String returns the string label of x.
+func (x DumpKind) String() string {
+ switch x {
+ case DumpKindMagic:
+ return "Magic"
+ case DumpKindControl:
+ return "Control"
+ case DumpKindMsgID:
+ return "MsgID"
+ case DumpKindTypeMsg:
+ return "TypeMsg"
+ case DumpKindValueMsg:
+ return "ValueMsg"
+ case DumpKindMsgLen:
+ return "MsgLen"
+ case DumpKindTypeID:
+ return "TypeID"
+ case DumpKindPrimValue:
+ return "PrimValue"
+ case DumpKindByteLen:
+ return "ByteLen"
+ case DumpKindValueLen:
+ return "ValueLen"
+ case DumpKindIndex:
+ return "Index"
+ case DumpKindWireTypeIndex:
+ return "WireTypeIndex"
+ }
+ return ""
+}
+
+func (DumpKind) __VDLReflect(struct {
+ Name string "v.io/v23/vom.DumpKind"
+ Enum struct{ Magic, Control, MsgID, TypeMsg, ValueMsg, MsgLen, TypeID, PrimValue, ByteLen, ValueLen, Index, WireTypeIndex string }
+}) {
+}
+
+// ControlKind enumerates the different kinds of control bytes.
+type ControlKind int
+
+const (
+ ControlKindNIL ControlKind = iota
+ ControlKindEOF
+)
+
+// ControlKindAll holds all labels for ControlKind.
+var ControlKindAll = []ControlKind{ControlKindNIL, ControlKindEOF}
+
+// ControlKindFromString creates a ControlKind from a string label.
+func ControlKindFromString(label string) (x ControlKind, err error) {
+ err = x.Set(label)
+ return
+}
+
+// Set assigns label to x.
+func (x *ControlKind) Set(label string) error {
+ switch label {
+ case "NIL", "nil":
+ *x = ControlKindNIL
+ return nil
+ case "EOF", "eof":
+ *x = ControlKindEOF
+ return nil
+ }
+ *x = -1
+ return fmt.Errorf("unknown label %q in vom.ControlKind", label)
+}
+
+// String returns the string label of x.
+func (x ControlKind) String() string {
+ switch x {
+ case ControlKindNIL:
+ return "NIL"
+ case ControlKindEOF:
+ return "EOF"
+ }
+ return ""
+}
+
+func (ControlKind) __VDLReflect(struct {
+ Name string "v.io/v23/vom.ControlKind"
+ Enum struct{ NIL, EOF string }
+}) {
+}
+
+func init() {
+ vdl.Register((*Primitive)(nil))
+ vdl.Register((*DumpAtom)(nil))
+ vdl.Register((*DumpKind)(nil))
+ vdl.Register((*ControlKind)(nil))
+}
diff --git a/lib/vom/encoder.go b/lib/vom/encoder.go
new file mode 100644
index 0000000..8cf562c
--- /dev/null
+++ b/lib/vom/encoder.go
@@ -0,0 +1,59 @@
+package vom
+
+import (
+ "io"
+ "reflect"
+
+ "v.io/v23/vdl"
+)
+
+// Encoder manages the transmission and marshaling of typed values to the other
+// side of a connection.
+type Encoder struct {
+ enc encoder
+}
+
+type encoder interface {
+ vdl.Target
+ StartEncode() error
+ FinishEncode() error
+}
+
+// NewEncoder returns a new Encoder that writes to the given writer in the
+// binary format. The binary format is compact and fast.
+func NewEncoder(w io.Writer) (*Encoder, error) {
+ // The binary format always starts with a magic byte.
+ _, err := w.Write([]byte{binaryMagicByte})
+ if err != nil {
+ return nil, err
+ }
+ return &Encoder{newBinaryEncoder(w, newEncoderTypes())}, nil
+}
+
+// Encode transmits the value v. Values of type T are encodable as long as the
+// type of T is representable as val.Type, or T is special-cased below;
+// otherwise an error is returned.
+//
+// Types that are special-cased, only for v:
+// *RawValue - Transcode v into the appropriate output format.
+//
+// Types that are special-cased, recursively throughout v:
+// *vdl.Value - Encode the semantic value represented by v.
+// reflect.Value - Encode the semantic value represented by v.
+//
+// Encode(nil) is a special case that encodes the zero value of the any type.
+// See the discussion of zero values in the Value documentation.
+func (e *Encoder) Encode(v interface{}) error {
+ if raw, ok := v.(*RawValue); ok && raw != nil {
+ // TODO(toddw): Decode from RawValue, encoding into e.enc.
+ _ = raw
+ panic("Encode(RawValue) NOT IMPLEMENTED")
+ }
+ if err := e.enc.StartEncode(); err != nil {
+ return err
+ }
+ if err := vdl.FromReflect(e.enc, reflect.ValueOf(v)); err != nil {
+ return err
+ }
+ return e.enc.FinishEncode()
+}
diff --git a/lib/vom/encoder_test.go b/lib/vom/encoder_test.go
new file mode 100644
index 0000000..2edf702
--- /dev/null
+++ b/lib/vom/encoder_test.go
@@ -0,0 +1,47 @@
+package vom
+
+import (
+ "bytes"
+ "fmt"
+ "testing"
+
+ "v.io/v23/vom/testdata"
+)
+
+func TestBinaryEncoder(t *testing.T) {
+ for _, test := range testdata.Tests {
+ name := test.Name + " [vdl.Value]"
+ testEncode(t, name, test.Value, test.Hex)
+
+ // Convert into Go value for the rest of our tests.
+ goValue, err := toGoValue(test.Value)
+ if err != nil {
+ t.Errorf("%s: %v", name, err)
+ continue
+ }
+
+ name = test.Name + " [go value]"
+ testEncode(t, name, goValue, test.Hex)
+ }
+}
+
+func testEncode(t *testing.T, name string, value interface{}, hex string) {
+ var buf bytes.Buffer
+ encoder, err := NewEncoder(&buf)
+ if err != nil {
+ t.Errorf("%s: NewEncoder failed: %v", name, err)
+ return
+ }
+ if err := encoder.Encode(value); err != nil {
+ t.Errorf("%s: binary Encode(%#v) failed: %v", name, value, err)
+ return
+ }
+ got, want := fmt.Sprintf("%x", buf.String()), hex
+ match, err := matchHexPat(got, want)
+ if err != nil {
+ t.Error(err)
+ }
+ if !match {
+ t.Errorf("%s: binary Encode(%#v)\nGOT %s\nWANT %s", name, value, got, want)
+ }
+}
diff --git a/lib/vom/init.go b/lib/vom/init.go
new file mode 100644
index 0000000..1c6092b
--- /dev/null
+++ b/lib/vom/init.go
@@ -0,0 +1,7 @@
+package vom
+
+import (
+ // Ensure all standard vdl types are registered.
+ _ "v.io/v23/vdlroot"
+ _ "v.io/v23/verror"
+)
diff --git a/lib/vom/raw_value.go b/lib/vom/raw_value.go
new file mode 100644
index 0000000..b6d59e8
--- /dev/null
+++ b/lib/vom/raw_value.go
@@ -0,0 +1,13 @@
+package vom
+
+import (
+ "v.io/v23/vdl"
+)
+
+// TODO(toddw): Flesh out the RawValue strategy.
+
+type RawValue struct {
+ recvTypes *decoderTypes
+ valType *vdl.Type
+ data []byte
+}
diff --git a/lib/vom/testdata/vomdata.vdl b/lib/vom/testdata/vomdata.vdl
new file mode 100644
index 0000000..f4b2225
--- /dev/null
+++ b/lib/vom/testdata/vomdata.vdl
@@ -0,0 +1,4752 @@
+// This file was auto-generated via "vomtest generate".
+// DO NOT UPDATE MANUALLY; read the comments in vomdata.vdl.config.
+
+package testdata
+
+// TestCase represents an individual testcase for vom encoding and decoding.
+type TestCase struct {
+ Name string // Name of the testcase
+ Value any // Value to test
+ Hex string // Hex pattern representing vom encoding of Value
+ TypeString string // The string representation of the Type
+}
+
+// Tests contains the testcases to use to test vom encoding and decoding.
+const Tests = []TestCase {
+ // 80 Magic 128 [vom version 0]
+ // 02 MsgID 1
+ // ValueMsg 1 [bool]
+ // 01 PrimValue true [bool]
+ // DumpStatus{MsgID: 1, MsgN: 3, Value: true}
+ {
+ `true`,
+ true,
+ "800201",
+ "bool",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 02 MsgID 1
+ // ValueMsg 1 [bool]
+ // 00 PrimValue false [bool]
+ // DumpStatus{MsgID: 1, MsgN: 3, Value: false}
+ {
+ `false`,
+ false,
+ "800200",
+ "bool",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 06 MsgID 3
+ // ValueMsg 3 [string]
+ // 00 ByteLen 0 [string len]
+ // PrimValue "" [string]
+ // DumpStatus{MsgID: 3, MsgN: 3, Value: ""}
+ {
+ `""`,
+ "",
+ "800600",
+ "string",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 06 MsgID 3
+ // ValueMsg 3 [string]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // DumpStatus{MsgID: 3, MsgN: 6, Value: "abc"}
+ {
+ `"abc"`,
+ "abc",
+ "800603616263",
+ "string",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 4e MsgID 39
+ // ValueMsg 39 [[]byte]
+ // 00 ByteLen 0 [bytes len]
+ // PrimValue "" [bytes]
+ // DumpStatus{MsgID: 39, MsgN: 3, Value: []byte("")}
+ {
+ `[]byte("")`,
+ []byte(""),
+ "804e00",
+ "[]byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 4e MsgID 39
+ // ValueMsg 39 [[]byte]
+ // 03 ByteLen 3 [bytes len]
+ // 010203 PrimValue "\x01\x02\x03" [bytes]
+ // DumpStatus{MsgID: 39, MsgN: 6, Value: []byte("\x01\x02\x03")}
+ {
+ `[]byte("\x01\x02\x03")`,
+ []byte("\x01\x02\x03"),
+ "804e03010203",
+ "[]byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 4e MsgID 39
+ // ValueMsg 39 [[]byte]
+ // 04 ByteLen 4 [bytes len]
+ // 61646566 PrimValue "adef" [bytes]
+ // DumpStatus{MsgID: 39, MsgN: 7, Value: []byte("adef")}
+ {
+ `[]byte("adef")`,
+ []byte("adef"),
+ "804e0461646566",
+ "[]byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 04 MsgID 2
+ // ValueMsg 2 [byte]
+ // 00 PrimValue 0 [byte]
+ // DumpStatus{MsgID: 2, MsgN: 3, Value: byte(0)}
+ {
+ `byte(0)`,
+ byte(0),
+ "800400",
+ "byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 04 MsgID 2
+ // ValueMsg 2 [byte]
+ // 7f PrimValue 127 [byte]
+ // DumpStatus{MsgID: 2, MsgN: 3, Value: byte(127)}
+ {
+ `byte(127)`,
+ byte(127),
+ "80047f",
+ "byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 04 MsgID 2
+ // ValueMsg 2 [byte]
+ // ff PrimValue 255 [byte]
+ // DumpStatus{MsgID: 2, MsgN: 3, Value: byte(255)}
+ {
+ `byte(255)`,
+ byte(255),
+ "8004ff",
+ "byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // 00 PrimValue 0 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 3, Value: uint16(0)}
+ {
+ `uint16(0)`,
+ uint16(0),
+ "800800",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // 01 PrimValue 1 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 3, Value: uint16(1)}
+ {
+ `uint16(1)`,
+ uint16(1),
+ "800801",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // 02 PrimValue 2 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 3, Value: uint16(2)}
+ {
+ `uint16(2)`,
+ uint16(2),
+ "800802",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // 3f PrimValue 63 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 3, Value: uint16(63)}
+ {
+ `uint16(63)`,
+ uint16(63),
+ "80083f",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // 40 PrimValue 64 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 3, Value: uint16(64)}
+ {
+ `uint16(64)`,
+ uint16(64),
+ "800840",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // 7f PrimValue 127 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 3, Value: uint16(127)}
+ {
+ `uint16(127)`,
+ uint16(127),
+ "80087f",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // ff80 PrimValue 128 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 4, Value: uint16(128)}
+ {
+ `uint16(128)`,
+ uint16(128),
+ "8008ff80",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // ffff PrimValue 255 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 4, Value: uint16(255)}
+ {
+ `uint16(255)`,
+ uint16(255),
+ "8008ffff",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // fe0100 PrimValue 256 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 5, Value: uint16(256)}
+ {
+ `uint16(256)`,
+ uint16(256),
+ "8008fe0100",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // fe7ffe PrimValue 32766 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 5, Value: uint16(32766)}
+ {
+ `uint16(32766)`,
+ uint16(32766),
+ "8008fe7ffe",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // fe7fff PrimValue 32767 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 5, Value: uint16(32767)}
+ {
+ `uint16(32767)`,
+ uint16(32767),
+ "8008fe7fff",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // fefffe PrimValue 65534 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 5, Value: uint16(65534)}
+ {
+ `uint16(65534)`,
+ uint16(65534),
+ "8008fefffe",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 08 MsgID 4
+ // ValueMsg 4 [uint16]
+ // feffff PrimValue 65535 [uint]
+ // DumpStatus{MsgID: 4, MsgN: 5, Value: uint16(65535)}
+ {
+ `uint16(65535)`,
+ uint16(65535),
+ "8008feffff",
+ "uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // 00 PrimValue 0 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 3, Value: uint32(0)}
+ {
+ `uint32(0)`,
+ uint32(0),
+ "800a00",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fd7ffffe PrimValue 8388606 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 6, Value: uint32(8388606)}
+ {
+ `uint32(8388606)`,
+ uint32(8388606),
+ "800afd7ffffe",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fd7fffff PrimValue 8388607 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 6, Value: uint32(8388607)}
+ {
+ `uint32(8388607)`,
+ uint32(8388607),
+ "800afd7fffff",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fdfffffe PrimValue 16777214 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 6, Value: uint32(16777214)}
+ {
+ `uint32(16777214)`,
+ uint32(16777214),
+ "800afdfffffe",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fdffffff PrimValue 16777215 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 6, Value: uint32(16777215)}
+ {
+ `uint32(16777215)`,
+ uint32(16777215),
+ "800afdffffff",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fc7ffffffe PrimValue 2147483646 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 7, Value: uint32(2147483646)}
+ {
+ `uint32(2147483646)`,
+ uint32(2147483646),
+ "800afc7ffffffe",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fc7fffffff PrimValue 2147483647 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 7, Value: uint32(2147483647)}
+ {
+ `uint32(2147483647)`,
+ uint32(2147483647),
+ "800afc7fffffff",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fcfffffffe PrimValue 4294967294 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 7, Value: uint32(4294967294)}
+ {
+ `uint32(4294967294)`,
+ uint32(4294967294),
+ "800afcfffffffe",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0a MsgID 5
+ // ValueMsg 5 [uint32]
+ // fcffffffff PrimValue 4294967295 [uint]
+ // DumpStatus{MsgID: 5, MsgN: 7, Value: uint32(4294967295)}
+ {
+ `uint32(4294967295)`,
+ uint32(4294967295),
+ "800afcffffffff",
+ "uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // 00 PrimValue 0 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 3, Value: uint64(0)}
+ {
+ `uint64(0)`,
+ uint64(0),
+ "800c00",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // fb7ffffffffe PrimValue 549755813886 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 8, Value: uint64(549755813886)}
+ {
+ `uint64(549755813886)`,
+ uint64(549755813886),
+ "800cfb7ffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // fb7fffffffff PrimValue 549755813887 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 8, Value: uint64(549755813887)}
+ {
+ `uint64(549755813887)`,
+ uint64(549755813887),
+ "800cfb7fffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // fbfffffffffe PrimValue 1099511627774 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 8, Value: uint64(1099511627774)}
+ {
+ `uint64(1099511627774)`,
+ uint64(1099511627774),
+ "800cfbfffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // fbffffffffff PrimValue 1099511627775 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 8, Value: uint64(1099511627775)}
+ {
+ `uint64(1099511627775)`,
+ uint64(1099511627775),
+ "800cfbffffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // fa7ffffffffffe PrimValue 140737488355326 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 9, Value: uint64(140737488355326)}
+ {
+ `uint64(140737488355326)`,
+ uint64(140737488355326),
+ "800cfa7ffffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // fa7fffffffffff PrimValue 140737488355327 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 9, Value: uint64(140737488355327)}
+ {
+ `uint64(140737488355327)`,
+ uint64(140737488355327),
+ "800cfa7fffffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // fafffffffffffe PrimValue 281474976710654 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 9, Value: uint64(281474976710654)}
+ {
+ `uint64(281474976710654)`,
+ uint64(281474976710654),
+ "800cfafffffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // faffffffffffff PrimValue 281474976710655 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 9, Value: uint64(281474976710655)}
+ {
+ `uint64(281474976710655)`,
+ uint64(281474976710655),
+ "800cfaffffffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f97ffffffffffffe PrimValue 36028797018963966 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 10, Value: uint64(36028797018963966)}
+ {
+ `uint64(36028797018963966)`,
+ uint64(36028797018963966),
+ "800cf97ffffffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f97fffffffffffff PrimValue 36028797018963967 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 10, Value: uint64(36028797018963967)}
+ {
+ `uint64(36028797018963967)`,
+ uint64(36028797018963967),
+ "800cf97fffffffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f9fffffffffffffe PrimValue 72057594037927934 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 10, Value: uint64(72057594037927934)}
+ {
+ `uint64(72057594037927934)`,
+ uint64(72057594037927934),
+ "800cf9fffffffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f9ffffffffffffff PrimValue 72057594037927935 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 10, Value: uint64(72057594037927935)}
+ {
+ `uint64(72057594037927935)`,
+ uint64(72057594037927935),
+ "800cf9ffffffffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f87ffffffffffffffe PrimValue 9223372036854775806 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 11, Value: uint64(9223372036854775806)}
+ {
+ `uint64(9223372036854775806)`,
+ uint64(9223372036854775806),
+ "800cf87ffffffffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f87fffffffffffffff PrimValue 9223372036854775807 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 11, Value: uint64(9223372036854775807)}
+ {
+ `uint64(9223372036854775807)`,
+ uint64(9223372036854775807),
+ "800cf87fffffffffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f8fffffffffffffffe PrimValue 18446744073709551614 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 11, Value: uint64(18446744073709551614)}
+ {
+ `uint64(18446744073709551614)`,
+ uint64(18446744073709551614),
+ "800cf8fffffffffffffffe",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0c MsgID 6
+ // ValueMsg 6 [uint64]
+ // f8ffffffffffffffff PrimValue 18446744073709551615 [uint]
+ // DumpStatus{MsgID: 6, MsgN: 11, Value: uint64(18446744073709551615)}
+ {
+ `uint64(18446744073709551615)`,
+ uint64(18446744073709551615),
+ "800cf8ffffffffffffffff",
+ "uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // 00 PrimValue 0 [int]
+ // DumpStatus{MsgID: 7, MsgN: 3, Value: int16(0)}
+ {
+ `int16(0)`,
+ int16(0),
+ "800e00",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // 02 PrimValue 1 [int]
+ // DumpStatus{MsgID: 7, MsgN: 3, Value: int16(1)}
+ {
+ `int16(1)`,
+ int16(1),
+ "800e02",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // 04 PrimValue 2 [int]
+ // DumpStatus{MsgID: 7, MsgN: 3, Value: int16(2)}
+ {
+ `int16(2)`,
+ int16(2),
+ "800e04",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // 7e PrimValue 63 [int]
+ // DumpStatus{MsgID: 7, MsgN: 3, Value: int16(63)}
+ {
+ `int16(63)`,
+ int16(63),
+ "800e7e",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // ff80 PrimValue 64 [int]
+ // DumpStatus{MsgID: 7, MsgN: 4, Value: int16(64)}
+ {
+ `int16(64)`,
+ int16(64),
+ "800eff80",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fffe PrimValue 127 [int]
+ // DumpStatus{MsgID: 7, MsgN: 4, Value: int16(127)}
+ {
+ `int16(127)`,
+ int16(127),
+ "800efffe",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fe0100 PrimValue 128 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(128)}
+ {
+ `int16(128)`,
+ int16(128),
+ "800efe0100",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fe01fe PrimValue 255 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(255)}
+ {
+ `int16(255)`,
+ int16(255),
+ "800efe01fe",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fe0200 PrimValue 256 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(256)}
+ {
+ `int16(256)`,
+ int16(256),
+ "800efe0200",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fefffc PrimValue 32766 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(32766)}
+ {
+ `int16(32766)`,
+ int16(32766),
+ "800efefffc",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fefffe PrimValue 32767 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(32767)}
+ {
+ `int16(32767)`,
+ int16(32767),
+ "800efefffe",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // 00 PrimValue 0 [int]
+ // DumpStatus{MsgID: 8, MsgN: 3, Value: int32(0)}
+ {
+ `int32(0)`,
+ int32(0),
+ "801000",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fdfffffc PrimValue 8388606 [int]
+ // DumpStatus{MsgID: 8, MsgN: 6, Value: int32(8388606)}
+ {
+ `int32(8388606)`,
+ int32(8388606),
+ "8010fdfffffc",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fdfffffe PrimValue 8388607 [int]
+ // DumpStatus{MsgID: 8, MsgN: 6, Value: int32(8388607)}
+ {
+ `int32(8388607)`,
+ int32(8388607),
+ "8010fdfffffe",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fc01fffffc PrimValue 16777214 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(16777214)}
+ {
+ `int32(16777214)`,
+ int32(16777214),
+ "8010fc01fffffc",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fc01fffffe PrimValue 16777215 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(16777215)}
+ {
+ `int32(16777215)`,
+ int32(16777215),
+ "8010fc01fffffe",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fcfffffffc PrimValue 2147483646 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(2147483646)}
+ {
+ `int32(2147483646)`,
+ int32(2147483646),
+ "8010fcfffffffc",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fcfffffffe PrimValue 2147483647 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(2147483647)}
+ {
+ `int32(2147483647)`,
+ int32(2147483647),
+ "8010fcfffffffe",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // 00 PrimValue 0 [int]
+ // DumpStatus{MsgID: 9, MsgN: 3, Value: int64(0)}
+ {
+ `int64(0)`,
+ int64(0),
+ "801200",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // 02 PrimValue 1 [int]
+ // DumpStatus{MsgID: 9, MsgN: 3, Value: int64(1)}
+ {
+ `int64(1)`,
+ int64(1),
+ "801202",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // 04 PrimValue 2 [int]
+ // DumpStatus{MsgID: 9, MsgN: 3, Value: int64(2)}
+ {
+ `int64(2)`,
+ int64(2),
+ "801204",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fbfffffffffc PrimValue 549755813886 [int]
+ // DumpStatus{MsgID: 9, MsgN: 8, Value: int64(549755813886)}
+ {
+ `int64(549755813886)`,
+ int64(549755813886),
+ "8012fbfffffffffc",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fbfffffffffe PrimValue 549755813887 [int]
+ // DumpStatus{MsgID: 9, MsgN: 8, Value: int64(549755813887)}
+ {
+ `int64(549755813887)`,
+ int64(549755813887),
+ "8012fbfffffffffe",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fa01fffffffffc PrimValue 1099511627774 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(1099511627774)}
+ {
+ `int64(1099511627774)`,
+ int64(1099511627774),
+ "8012fa01fffffffffc",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fa01fffffffffe PrimValue 1099511627775 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(1099511627775)}
+ {
+ `int64(1099511627775)`,
+ int64(1099511627775),
+ "8012fa01fffffffffe",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fafffffffffffc PrimValue 140737488355326 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(140737488355326)}
+ {
+ `int64(140737488355326)`,
+ int64(140737488355326),
+ "8012fafffffffffffc",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fafffffffffffe PrimValue 140737488355327 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(140737488355327)}
+ {
+ `int64(140737488355327)`,
+ int64(140737488355327),
+ "8012fafffffffffffe",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f901fffffffffffc PrimValue 281474976710654 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(281474976710654)}
+ {
+ `int64(281474976710654)`,
+ int64(281474976710654),
+ "8012f901fffffffffffc",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f901fffffffffffe PrimValue 281474976710655 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(281474976710655)}
+ {
+ `int64(281474976710655)`,
+ int64(281474976710655),
+ "8012f901fffffffffffe",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f9fffffffffffffc PrimValue 36028797018963966 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(36028797018963966)}
+ {
+ `int64(36028797018963966)`,
+ int64(36028797018963966),
+ "8012f9fffffffffffffc",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f9fffffffffffffe PrimValue 36028797018963967 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(36028797018963967)}
+ {
+ `int64(36028797018963967)`,
+ int64(36028797018963967),
+ "8012f9fffffffffffffe",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f801fffffffffffffc PrimValue 72057594037927934 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(72057594037927934)}
+ {
+ `int64(72057594037927934)`,
+ int64(72057594037927934),
+ "8012f801fffffffffffffc",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f801fffffffffffffe PrimValue 72057594037927935 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(72057594037927935)}
+ {
+ `int64(72057594037927935)`,
+ int64(72057594037927935),
+ "8012f801fffffffffffffe",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f8fffffffffffffffc PrimValue 9223372036854775806 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(9223372036854775806)}
+ {
+ `int64(9223372036854775806)`,
+ int64(9223372036854775806),
+ "8012f8fffffffffffffffc",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f8fffffffffffffffe PrimValue 9223372036854775807 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(9223372036854775807)}
+ {
+ `int64(9223372036854775807)`,
+ int64(9223372036854775807),
+ "8012f8fffffffffffffffe",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // 01 PrimValue -1 [int]
+ // DumpStatus{MsgID: 7, MsgN: 3, Value: int16(-1)}
+ {
+ `int16(-1)`,
+ int16(-1),
+ "800e01",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // 03 PrimValue -2 [int]
+ // DumpStatus{MsgID: 7, MsgN: 3, Value: int16(-2)}
+ {
+ `int16(-2)`,
+ int16(-2),
+ "800e03",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // 7f PrimValue -64 [int]
+ // DumpStatus{MsgID: 7, MsgN: 3, Value: int16(-64)}
+ {
+ `int16(-64)`,
+ int16(-64),
+ "800e7f",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // ff81 PrimValue -65 [int]
+ // DumpStatus{MsgID: 7, MsgN: 4, Value: int16(-65)}
+ {
+ `int16(-65)`,
+ int16(-65),
+ "800eff81",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // ffff PrimValue -128 [int]
+ // DumpStatus{MsgID: 7, MsgN: 4, Value: int16(-128)}
+ {
+ `int16(-128)`,
+ int16(-128),
+ "800effff",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fe0101 PrimValue -129 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(-129)}
+ {
+ `int16(-129)`,
+ int16(-129),
+ "800efe0101",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fe01ff PrimValue -256 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(-256)}
+ {
+ `int16(-256)`,
+ int16(-256),
+ "800efe01ff",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fe0201 PrimValue -257 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(-257)}
+ {
+ `int16(-257)`,
+ int16(-257),
+ "800efe0201",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // fefffd PrimValue -32767 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(-32767)}
+ {
+ `int16(-32767)`,
+ int16(-32767),
+ "800efefffd",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 0e MsgID 7
+ // ValueMsg 7 [int16]
+ // feffff PrimValue -32768 [int]
+ // DumpStatus{MsgID: 7, MsgN: 5, Value: int16(-32768)}
+ {
+ `int16(-32768)`,
+ int16(-32768),
+ "800efeffff",
+ "int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fdfffffd PrimValue -8388607 [int]
+ // DumpStatus{MsgID: 8, MsgN: 6, Value: int32(-8388607)}
+ {
+ `int32(-8388607)`,
+ int32(-8388607),
+ "8010fdfffffd",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fdffffff PrimValue -8388608 [int]
+ // DumpStatus{MsgID: 8, MsgN: 6, Value: int32(-8388608)}
+ {
+ `int32(-8388608)`,
+ int32(-8388608),
+ "8010fdffffff",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fc01fffffd PrimValue -16777215 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(-16777215)}
+ {
+ `int32(-16777215)`,
+ int32(-16777215),
+ "8010fc01fffffd",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fc01ffffff PrimValue -16777216 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(-16777216)}
+ {
+ `int32(-16777216)`,
+ int32(-16777216),
+ "8010fc01ffffff",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fcfffffffd PrimValue -2147483647 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(-2147483647)}
+ {
+ `int32(-2147483647)`,
+ int32(-2147483647),
+ "8010fcfffffffd",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 10 MsgID 8
+ // ValueMsg 8 [int32]
+ // fcffffffff PrimValue -2147483648 [int]
+ // DumpStatus{MsgID: 8, MsgN: 7, Value: int32(-2147483648)}
+ {
+ `int32(-2147483648)`,
+ int32(-2147483648),
+ "8010fcffffffff",
+ "int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // 01 PrimValue -1 [int]
+ // DumpStatus{MsgID: 9, MsgN: 3, Value: int64(-1)}
+ {
+ `int64(-1)`,
+ int64(-1),
+ "801201",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // 03 PrimValue -2 [int]
+ // DumpStatus{MsgID: 9, MsgN: 3, Value: int64(-2)}
+ {
+ `int64(-2)`,
+ int64(-2),
+ "801203",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fbfffffffffd PrimValue -549755813887 [int]
+ // DumpStatus{MsgID: 9, MsgN: 8, Value: int64(-549755813887)}
+ {
+ `int64(-549755813887)`,
+ int64(-549755813887),
+ "8012fbfffffffffd",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fbffffffffff PrimValue -549755813888 [int]
+ // DumpStatus{MsgID: 9, MsgN: 8, Value: int64(-549755813888)}
+ {
+ `int64(-549755813888)`,
+ int64(-549755813888),
+ "8012fbffffffffff",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fa01fffffffffd PrimValue -1099511627775 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(-1099511627775)}
+ {
+ `int64(-1099511627775)`,
+ int64(-1099511627775),
+ "8012fa01fffffffffd",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fa01ffffffffff PrimValue -1099511627776 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(-1099511627776)}
+ {
+ `int64(-1099511627776)`,
+ int64(-1099511627776),
+ "8012fa01ffffffffff",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // fafffffffffffd PrimValue -140737488355327 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(-140737488355327)}
+ {
+ `int64(-140737488355327)`,
+ int64(-140737488355327),
+ "8012fafffffffffffd",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // faffffffffffff PrimValue -140737488355328 [int]
+ // DumpStatus{MsgID: 9, MsgN: 9, Value: int64(-140737488355328)}
+ {
+ `int64(-140737488355328)`,
+ int64(-140737488355328),
+ "8012faffffffffffff",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f901fffffffffffd PrimValue -281474976710655 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(-281474976710655)}
+ {
+ `int64(-281474976710655)`,
+ int64(-281474976710655),
+ "8012f901fffffffffffd",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f901ffffffffffff PrimValue -281474976710656 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(-281474976710656)}
+ {
+ `int64(-281474976710656)`,
+ int64(-281474976710656),
+ "8012f901ffffffffffff",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f9fffffffffffffd PrimValue -36028797018963967 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(-36028797018963967)}
+ {
+ `int64(-36028797018963967)`,
+ int64(-36028797018963967),
+ "8012f9fffffffffffffd",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f9ffffffffffffff PrimValue -36028797018963968 [int]
+ // DumpStatus{MsgID: 9, MsgN: 10, Value: int64(-36028797018963968)}
+ {
+ `int64(-36028797018963968)`,
+ int64(-36028797018963968),
+ "8012f9ffffffffffffff",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f801fffffffffffffd PrimValue -72057594037927935 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(-72057594037927935)}
+ {
+ `int64(-72057594037927935)`,
+ int64(-72057594037927935),
+ "8012f801fffffffffffffd",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f801ffffffffffffff PrimValue -72057594037927936 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(-72057594037927936)}
+ {
+ `int64(-72057594037927936)`,
+ int64(-72057594037927936),
+ "8012f801ffffffffffffff",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f8fffffffffffffffd PrimValue -9223372036854775807 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(-9223372036854775807)}
+ {
+ `int64(-9223372036854775807)`,
+ int64(-9223372036854775807),
+ "8012f8fffffffffffffffd",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 12 MsgID 9
+ // ValueMsg 9 [int64]
+ // f8ffffffffffffffff PrimValue -9223372036854775808 [int]
+ // DumpStatus{MsgID: 9, MsgN: 11, Value: int64(-9223372036854775808)}
+ {
+ `int64(-9223372036854775808)`,
+ int64(-9223372036854775808),
+ "8012f8ffffffffffffffff",
+ "int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 14 MsgID 10
+ // ValueMsg 10 [float32]
+ // 00 PrimValue 0 [float]
+ // DumpStatus{MsgID: 10, MsgN: 3, Value: float32(0)}
+ {
+ `float32(0)`,
+ float32(0),
+ "801400",
+ "float32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 14 MsgID 10
+ // ValueMsg 10 [float32]
+ // fd404040 PrimValue 32.5 [float]
+ // DumpStatus{MsgID: 10, MsgN: 6, Value: float32(32.5)}
+ {
+ `float32(32.5)`,
+ float32(32.5),
+ "8014fd404040",
+ "float32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 14 MsgID 10
+ // ValueMsg 10 [float32]
+ // fd4040c0 PrimValue -32.5 [float]
+ // DumpStatus{MsgID: 10, MsgN: 6, Value: float32(-32.5)}
+ {
+ `float32(-32.5)`,
+ float32(-32.5),
+ "8014fd4040c0",
+ "float32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 16 MsgID 11
+ // ValueMsg 11 [float64]
+ // 00 PrimValue 0 [float]
+ // DumpStatus{MsgID: 11, MsgN: 3, Value: float64(0)}
+ {
+ `float64(0)`,
+ float64(0),
+ "801600",
+ "float64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 16 MsgID 11
+ // ValueMsg 11 [float64]
+ // fd205040 PrimValue 64.5 [float]
+ // DumpStatus{MsgID: 11, MsgN: 6, Value: float64(64.5)}
+ {
+ `float64(64.5)`,
+ float64(64.5),
+ "8016fd205040",
+ "float64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 16 MsgID 11
+ // ValueMsg 11 [float64]
+ // fd2050c0 PrimValue -64.5 [float]
+ // DumpStatus{MsgID: 11, MsgN: 6, Value: float64(-64.5)}
+ {
+ `float64(-64.5)`,
+ float64(-64.5),
+ "8016fd2050c0",
+ "float64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 18 MsgID 12
+ // ValueMsg 12 [complex64]
+ // 02 MsgLen 2
+ // 00 PrimValue 0 [complex real]
+ // 00 PrimValue 0 [complex imag]
+ // DumpStatus{MsgID: 12, MsgLen: 2, MsgN: 2, Value: complex64(0+0i)}
+ {
+ `complex64(0)`,
+ complex64(0),
+ "8018020000",
+ "complex64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 18 MsgID 12
+ // ValueMsg 12 [complex64]
+ // 08 MsgLen 8
+ // fd205040 PrimValue 64.5 [complex real]
+ // fd205040 PrimValue 64.5 [complex imag]
+ // DumpStatus{MsgID: 12, MsgLen: 8, MsgN: 8, Value: complex64(64.5+64.5i)}
+ {
+ `complex64(64.5+64.5i)`,
+ complex64(64.5+64.5i),
+ "801808fd205040fd205040",
+ "complex64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 18 MsgID 12
+ // ValueMsg 12 [complex64]
+ // 08 MsgLen 8
+ // fd205040 PrimValue 64.5 [complex real]
+ // fd2050c0 PrimValue 64.5 [complex imag]
+ // DumpStatus{MsgID: 12, MsgLen: 8, MsgN: 8, Value: complex64(64.5+-64.5i)}
+ {
+ `complex64(64.5-64.5i)`,
+ complex64(64.5-64.5i),
+ "801808fd205040fd2050c0",
+ "complex64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1a MsgID 13
+ // ValueMsg 13 [complex128]
+ // 02 MsgLen 2
+ // 00 PrimValue 0 [complex real]
+ // 00 PrimValue 0 [complex imag]
+ // DumpStatus{MsgID: 13, MsgLen: 2, MsgN: 2, Value: complex128(0+0i)}
+ {
+ `complex128(0)`,
+ complex128(0),
+ "801a020000",
+ "complex128",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1a MsgID 13
+ // ValueMsg 13 [complex128]
+ // 08 MsgLen 8
+ // fd106040 PrimValue 128.5 [complex real]
+ // fd106040 PrimValue 128.5 [complex imag]
+ // DumpStatus{MsgID: 13, MsgLen: 8, MsgN: 8, Value: complex128(128.5+128.5i)}
+ {
+ `complex128(128.5+128.5i)`,
+ complex128(128.5+128.5i),
+ "801a08fd106040fd106040",
+ "complex128",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1a MsgID 13
+ // ValueMsg 13 [complex128]
+ // 08 MsgLen 8
+ // fd106040 PrimValue 128.5 [complex real]
+ // fd1060c0 PrimValue 128.5 [complex imag]
+ // DumpStatus{MsgID: 13, MsgLen: 8, MsgN: 8, Value: complex128(128.5+-128.5i)}
+ {
+ `complex128(128.5-128.5i)`,
+ complex128(128.5-128.5i),
+ "801a08fd106040fd1060c0",
+ "complex128",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NBool bool]
+ // 01 PrimValue true [bool]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NBool bool(true)}
+ {
+ `NBool(true)`,
+ NBool(true),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e15201",
+ "v.io/v23/vom/testdata.NBool bool",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NBool bool]
+ // 00 PrimValue false [bool]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NBool bool(false)}
+ {
+ `NBool(false)`,
+ NBool(false),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e15200",
+ "v.io/v23/vom/testdata.NBool bool",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472696e67 PrimValue "v.io/v23/vom/testdata.NString" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NString string]
+ // 00 ByteLen 0 [string len]
+ // PrimValue "" [string]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NString string("")}
+ {
+ `NString("")`,
+ NString(""),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e537472696e670103e15200",
+ "v.io/v23/vom/testdata.NString string",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472696e67 PrimValue "v.io/v23/vom/testdata.NString" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NString string]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // DumpStatus{MsgID: 41, MsgN: 5, Value: v.io/v23/vom/testdata.NString string("abc")}
+ {
+ `NString("abc")`,
+ NString("abc"),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e537472696e670103e15203616263",
+ "v.io/v23/vom/testdata.NString string",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c696365 PrimValue "v.io/v23/vom/testdata.NByteSlice" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByteSlice []byte]
+ // 00 ByteLen 0 [bytes len]
+ // PrimValue "" [bytes]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NByteSlice []byte("")}
+ {
+ `NByteSlice("")`,
+ NByteSlice(""),
+ "805126030020762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c6963650102e15200",
+ "v.io/v23/vom/testdata.NByteSlice []byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c696365 PrimValue "v.io/v23/vom/testdata.NByteSlice" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByteSlice []byte]
+ // 03 ByteLen 3 [bytes len]
+ // 010203 PrimValue "\x01\x02\x03" [bytes]
+ // DumpStatus{MsgID: 41, MsgN: 5, Value: v.io/v23/vom/testdata.NByteSlice []byte("\x01\x02\x03")}
+ {
+ `NByteSlice("\x01\x02\x03")`,
+ NByteSlice("\x01\x02\x03"),
+ "805126030020762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c6963650102e15203010203",
+ "v.io/v23/vom/testdata.NByteSlice []byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c696365 PrimValue "v.io/v23/vom/testdata.NByteSlice" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByteSlice []byte]
+ // 03 ByteLen 3 [bytes len]
+ // 616263 PrimValue "abc" [bytes]
+ // DumpStatus{MsgID: 41, MsgN: 5, Value: v.io/v23/vom/testdata.NByteSlice []byte("abc")}
+ {
+ `NByteSlice("abc")`,
+ NByteSlice("abc"),
+ "805126030020762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c6963650102e15203616263",
+ "v.io/v23/vom/testdata.NByteSlice []byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 28 MsgLen 40
+ // 02 WireTypeIndex 2 [v.io/v23/vom.wireArray]
+ // 00 Index 0 [v.io/v23/vom.wireArray.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e427974654172726179 PrimValue "v.io/v23/vom/testdata.NByteArray" [string]
+ // 01 Index 1 [v.io/v23/vom.wireArray.Elem]
+ // 02 PrimValue 2 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireArray.Len]
+ // 04 PrimValue 4 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireArray END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByteArray [4]byte]
+ // 00 ByteLen 4 [bytes len]
+ // 00000000 PrimValue "\x00\x00\x00\x00" [bytes]
+ // DumpStatus{MsgID: 41, MsgN: 6, Value: v.io/v23/vom/testdata.NByteArray [4]byte("\x00\x00\x00\x00")}
+ {
+ `NByteArray("\x00\x00\x00\x00")`,
+ NByteArray("\x00\x00\x00\x00"),
+ "805128020020762e696f2f7632332f766f6d2f74657374646174612e4e42797465417272617901020204e1520000000000",
+ "v.io/v23/vom/testdata.NByteArray [4]byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 28 MsgLen 40
+ // 02 WireTypeIndex 2 [v.io/v23/vom.wireArray]
+ // 00 Index 0 [v.io/v23/vom.wireArray.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e427974654172726179 PrimValue "v.io/v23/vom/testdata.NByteArray" [string]
+ // 01 Index 1 [v.io/v23/vom.wireArray.Elem]
+ // 02 PrimValue 2 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireArray.Len]
+ // 04 PrimValue 4 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireArray END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByteArray [4]byte]
+ // 00 ByteLen 4 [bytes len]
+ // 01020300 PrimValue "\x01\x02\x03\x00" [bytes]
+ // DumpStatus{MsgID: 41, MsgN: 6, Value: v.io/v23/vom/testdata.NByteArray [4]byte("\x01\x02\x03\x00")}
+ {
+ `NByteArray("\x01\x02\x03\x00")`,
+ NByteArray("\x01\x02\x03\x00"),
+ "805128020020762e696f2f7632332f766f6d2f74657374646174612e4e42797465417272617901020204e1520001020300",
+ "v.io/v23/vom/testdata.NByteArray [4]byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 28 MsgLen 40
+ // 02 WireTypeIndex 2 [v.io/v23/vom.wireArray]
+ // 00 Index 0 [v.io/v23/vom.wireArray.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e427974654172726179 PrimValue "v.io/v23/vom/testdata.NByteArray" [string]
+ // 01 Index 1 [v.io/v23/vom.wireArray.Elem]
+ // 02 PrimValue 2 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireArray.Len]
+ // 04 PrimValue 4 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireArray END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByteArray [4]byte]
+ // 00 ByteLen 4 [bytes len]
+ // 61626364 PrimValue "abcd" [bytes]
+ // DumpStatus{MsgID: 41, MsgN: 6, Value: v.io/v23/vom/testdata.NByteArray [4]byte("abcd")}
+ {
+ `NByteArray("abcd")`,
+ NByteArray("abcd"),
+ "805128020020762e696f2f7632332f766f6d2f74657374646174612e4e42797465417272617901020204e1520061626364",
+ "v.io/v23/vom/testdata.NByteArray [4]byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e42797465 PrimValue "v.io/v23/vom/testdata.NByte" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByte byte]
+ // 00 PrimValue 0 [byte]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NByte byte(0)}
+ {
+ `NByte(0)`,
+ NByte(0),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e427974650102e15200",
+ "v.io/v23/vom/testdata.NByte byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e42797465 PrimValue "v.io/v23/vom/testdata.NByte" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByte byte]
+ // 7f PrimValue 127 [byte]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NByte byte(127)}
+ {
+ `NByte(127)`,
+ NByte(127),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e427974650102e1527f",
+ "v.io/v23/vom/testdata.NByte byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e42797465 PrimValue "v.io/v23/vom/testdata.NByte" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NByte byte]
+ // ff PrimValue 255 [byte]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NByte byte(255)}
+ {
+ `NByte(255)`,
+ NByte(255),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e427974650102e152ff",
+ "v.io/v23/vom/testdata.NByte byte",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743136 PrimValue "v.io/v23/vom/testdata.NUint16" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 04 PrimValue 4 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUint16 uint16]
+ // 00 PrimValue 0 [uint]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NUint16 uint16(0)}
+ {
+ `NUint16(0)`,
+ NUint16(0),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7431360104e15200",
+ "v.io/v23/vom/testdata.NUint16 uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743136 PrimValue "v.io/v23/vom/testdata.NUint16" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 04 PrimValue 4 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUint16 uint16]
+ // feffff PrimValue 65535 [uint]
+ // DumpStatus{MsgID: 41, MsgN: 4, Value: v.io/v23/vom/testdata.NUint16 uint16(65535)}
+ {
+ `NUint16(65535)`,
+ NUint16(65535),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7431360104e152feffff",
+ "v.io/v23/vom/testdata.NUint16 uint16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743332 PrimValue "v.io/v23/vom/testdata.NUint32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 05 PrimValue 5 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUint32 uint32]
+ // 00 PrimValue 0 [uint]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NUint32 uint32(0)}
+ {
+ `NUint32(0)`,
+ NUint32(0),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7433320105e15200",
+ "v.io/v23/vom/testdata.NUint32 uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743332 PrimValue "v.io/v23/vom/testdata.NUint32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 05 PrimValue 5 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUint32 uint32]
+ // fcffffffff PrimValue 4294967295 [uint]
+ // DumpStatus{MsgID: 41, MsgN: 6, Value: v.io/v23/vom/testdata.NUint32 uint32(4294967295)}
+ {
+ `NUint32(4294967295)`,
+ NUint32(4294967295),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7433320105e152fcffffffff",
+ "v.io/v23/vom/testdata.NUint32 uint32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743634 PrimValue "v.io/v23/vom/testdata.NUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUint64 uint64]
+ // 00 PrimValue 0 [uint]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NUint64 uint64(0)}
+ {
+ `NUint64(0)`,
+ NUint64(0),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7436340106e15200",
+ "v.io/v23/vom/testdata.NUint64 uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743634 PrimValue "v.io/v23/vom/testdata.NUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUint64 uint64]
+ // f8ffffffffffffffff PrimValue 18446744073709551615 [uint]
+ // DumpStatus{MsgID: 41, MsgN: 10, Value: v.io/v23/vom/testdata.NUint64 uint64(18446744073709551615)}
+ {
+ `NUint64(18446744073709551615)`,
+ NUint64(18446744073709551615),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7436340106e152f8ffffffffffffffff",
+ "v.io/v23/vom/testdata.NUint64 uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743136 PrimValue "v.io/v23/vom/testdata.NInt16" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 07 PrimValue 7 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt16 int16]
+ // 00 PrimValue 0 [int]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NInt16 int16(0)}
+ {
+ `NInt16(0)`,
+ NInt16(0),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e15200",
+ "v.io/v23/vom/testdata.NInt16 int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743136 PrimValue "v.io/v23/vom/testdata.NInt16" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 07 PrimValue 7 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt16 int16]
+ // fefffe PrimValue 32767 [int]
+ // DumpStatus{MsgID: 41, MsgN: 4, Value: v.io/v23/vom/testdata.NInt16 int16(32767)}
+ {
+ `NInt16(32767)`,
+ NInt16(32767),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e152fefffe",
+ "v.io/v23/vom/testdata.NInt16 int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743136 PrimValue "v.io/v23/vom/testdata.NInt16" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 07 PrimValue 7 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt16 int16]
+ // feffff PrimValue -32768 [int]
+ // DumpStatus{MsgID: 41, MsgN: 4, Value: v.io/v23/vom/testdata.NInt16 int16(-32768)}
+ {
+ `NInt16(-32768)`,
+ NInt16(-32768),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e152feffff",
+ "v.io/v23/vom/testdata.NInt16 int16",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743332 PrimValue "v.io/v23/vom/testdata.NInt32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 08 PrimValue 8 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt32 int32]
+ // 00 PrimValue 0 [int]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NInt32 int32(0)}
+ {
+ `NInt32(0)`,
+ NInt32(0),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e15200",
+ "v.io/v23/vom/testdata.NInt32 int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743332 PrimValue "v.io/v23/vom/testdata.NInt32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 08 PrimValue 8 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt32 int32]
+ // fcfffffffe PrimValue 2147483647 [int]
+ // DumpStatus{MsgID: 41, MsgN: 6, Value: v.io/v23/vom/testdata.NInt32 int32(2147483647)}
+ {
+ `NInt32(2147483647)`,
+ NInt32(2147483647),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e152fcfffffffe",
+ "v.io/v23/vom/testdata.NInt32 int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743332 PrimValue "v.io/v23/vom/testdata.NInt32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 08 PrimValue 8 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt32 int32]
+ // fcffffffff PrimValue -2147483648 [int]
+ // DumpStatus{MsgID: 41, MsgN: 6, Value: v.io/v23/vom/testdata.NInt32 int32(-2147483648)}
+ {
+ `NInt32(-2147483648)`,
+ NInt32(-2147483648),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e152fcffffffff",
+ "v.io/v23/vom/testdata.NInt32 int32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743634 PrimValue "v.io/v23/vom/testdata.NInt64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt64 int64]
+ // 00 PrimValue 0 [int]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NInt64 int64(0)}
+ {
+ `NInt64(0)`,
+ NInt64(0),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e15200",
+ "v.io/v23/vom/testdata.NInt64 int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743634 PrimValue "v.io/v23/vom/testdata.NInt64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt64 int64]
+ // f8fffffffffffffffe PrimValue 9223372036854775807 [int]
+ // DumpStatus{MsgID: 41, MsgN: 10, Value: v.io/v23/vom/testdata.NInt64 int64(9223372036854775807)}
+ {
+ `NInt64(9223372036854775807)`,
+ NInt64(9223372036854775807),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e152f8fffffffffffffffe",
+ "v.io/v23/vom/testdata.NInt64 int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743634 PrimValue "v.io/v23/vom/testdata.NInt64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NInt64 int64]
+ // f8ffffffffffffffff PrimValue -9223372036854775808 [int]
+ // DumpStatus{MsgID: 41, MsgN: 10, Value: v.io/v23/vom/testdata.NInt64 int64(-9223372036854775808)}
+ {
+ `NInt64(-9223372036854775808)`,
+ NInt64(-9223372036854775808),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e152f8ffffffffffffffff",
+ "v.io/v23/vom/testdata.NInt64 int64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332 PrimValue "v.io/v23/vom/testdata.NFloat32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0a PrimValue 10 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NFloat32 float32]
+ // 00 PrimValue 0 [float]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NFloat32 float32(0)}
+ {
+ `NFloat32(0)`,
+ NFloat32(0),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae15200",
+ "v.io/v23/vom/testdata.NFloat32 float32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332 PrimValue "v.io/v23/vom/testdata.NFloat32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0a PrimValue 10 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NFloat32 float32]
+ // fd404040 PrimValue 32.5 [float]
+ // DumpStatus{MsgID: 41, MsgN: 5, Value: v.io/v23/vom/testdata.NFloat32 float32(32.5)}
+ {
+ `NFloat32(32.5)`,
+ NFloat32(32.5),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae152fd404040",
+ "v.io/v23/vom/testdata.NFloat32 float32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332 PrimValue "v.io/v23/vom/testdata.NFloat32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0a PrimValue 10 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NFloat32 float32]
+ // fd4040c0 PrimValue -32.5 [float]
+ // DumpStatus{MsgID: 41, MsgN: 5, Value: v.io/v23/vom/testdata.NFloat32 float32(-32.5)}
+ {
+ `NFloat32(-32.5)`,
+ NFloat32(-32.5),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae152fd4040c0",
+ "v.io/v23/vom/testdata.NFloat32 float32",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634 PrimValue "v.io/v23/vom/testdata.NFloat64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0b PrimValue 11 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NFloat64 float64]
+ // 00 PrimValue 0 [float]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NFloat64 float64(0)}
+ {
+ `NFloat64(0)`,
+ NFloat64(0),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be15200",
+ "v.io/v23/vom/testdata.NFloat64 float64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634 PrimValue "v.io/v23/vom/testdata.NFloat64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0b PrimValue 11 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NFloat64 float64]
+ // fd205040 PrimValue 64.5 [float]
+ // DumpStatus{MsgID: 41, MsgN: 5, Value: v.io/v23/vom/testdata.NFloat64 float64(64.5)}
+ {
+ `NFloat64(64.5)`,
+ NFloat64(64.5),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be152fd205040",
+ "v.io/v23/vom/testdata.NFloat64 float64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634 PrimValue "v.io/v23/vom/testdata.NFloat64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0b PrimValue 11 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NFloat64 float64]
+ // fd2050c0 PrimValue -64.5 [float]
+ // DumpStatus{MsgID: 41, MsgN: 5, Value: v.io/v23/vom/testdata.NFloat64 float64(-64.5)}
+ {
+ `NFloat64(-64.5)`,
+ NFloat64(-64.5),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be152fd2050c0",
+ "v.io/v23/vom/testdata.NFloat64 float64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634 PrimValue "v.io/v23/vom/testdata.NComplex64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0c PrimValue 12 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NComplex64 complex64]
+ // 02 MsgLen 2
+ // 00 PrimValue 0 [complex real]
+ // 00 PrimValue 0 [complex imag]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: v.io/v23/vom/testdata.NComplex64 complex64(0+0i)}
+ {
+ `NComplex64(0)`,
+ NComplex64(0),
+ "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce152020000",
+ "v.io/v23/vom/testdata.NComplex64 complex64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634 PrimValue "v.io/v23/vom/testdata.NComplex64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0c PrimValue 12 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NComplex64 complex64]
+ // 08 MsgLen 8
+ // fd205040 PrimValue 64.5 [complex real]
+ // fd205040 PrimValue 64.5 [complex imag]
+ // DumpStatus{MsgID: 41, MsgLen: 8, MsgN: 8, Value: v.io/v23/vom/testdata.NComplex64 complex64(64.5+64.5i)}
+ {
+ `NComplex64(64.5+64.5i)`,
+ NComplex64(64.5+64.5i),
+ "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce15208fd205040fd205040",
+ "v.io/v23/vom/testdata.NComplex64 complex64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634 PrimValue "v.io/v23/vom/testdata.NComplex64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0c PrimValue 12 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NComplex64 complex64]
+ // 08 MsgLen 8
+ // fd205040 PrimValue 64.5 [complex real]
+ // fd2050c0 PrimValue 64.5 [complex imag]
+ // DumpStatus{MsgID: 41, MsgLen: 8, MsgN: 8, Value: v.io/v23/vom/testdata.NComplex64 complex64(64.5+-64.5i)}
+ {
+ `NComplex64(64.5-64.5i)`,
+ NComplex64(64.5-64.5i),
+ "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce15208fd205040fd2050c0",
+ "v.io/v23/vom/testdata.NComplex64 complex64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238 PrimValue "v.io/v23/vom/testdata.NComplex128" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0d PrimValue 13 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NComplex128 complex128]
+ // 02 MsgLen 2
+ // 00 PrimValue 0 [complex real]
+ // 00 PrimValue 0 [complex imag]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: v.io/v23/vom/testdata.NComplex128 complex128(0+0i)}
+ {
+ `NComplex128(0)`,
+ NComplex128(0),
+ "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de152020000",
+ "v.io/v23/vom/testdata.NComplex128 complex128",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238 PrimValue "v.io/v23/vom/testdata.NComplex128" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0d PrimValue 13 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NComplex128 complex128]
+ // 08 MsgLen 8
+ // fd106040 PrimValue 128.5 [complex real]
+ // fd106040 PrimValue 128.5 [complex imag]
+ // DumpStatus{MsgID: 41, MsgLen: 8, MsgN: 8, Value: v.io/v23/vom/testdata.NComplex128 complex128(128.5+128.5i)}
+ {
+ `NComplex128(128.5+128.5i)`,
+ NComplex128(128.5+128.5i),
+ "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de15208fd106040fd106040",
+ "v.io/v23/vom/testdata.NComplex128 complex128",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238 PrimValue "v.io/v23/vom/testdata.NComplex128" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0d PrimValue 13 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NComplex128 complex128]
+ // 08 MsgLen 8
+ // fd106040 PrimValue 128.5 [complex real]
+ // fd1060c0 PrimValue 128.5 [complex imag]
+ // DumpStatus{MsgID: 41, MsgLen: 8, MsgN: 8, Value: v.io/v23/vom/testdata.NComplex128 complex128(128.5+-128.5i)}
+ {
+ `NComplex128(128.5-128.5i)`,
+ NComplex128(128.5-128.5i),
+ "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de15208fd106040fd1060c0",
+ "v.io/v23/vom/testdata.NComplex128 complex128",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 2b MsgLen 43
+ // 02 WireTypeIndex 2 [v.io/v23/vom.wireArray]
+ // 00 Index 0 [v.io/v23/vom.wireArray.Name]
+ // 23 ByteLen 35 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e41727261793255696e743634 PrimValue "v.io/v23/vom/testdata.NArray2Uint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireArray.Elem]
+ // 06 PrimValue 6 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireArray.Len]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireArray END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NArray2Uint64 [2]uint64]
+ // 03 MsgLen 3
+ // 00 ValueLen 2 [list len]
+ // 01 PrimValue 1 [uint]
+ // 02 PrimValue 2 [uint]
+ // DumpStatus{MsgID: 41, MsgLen: 3, MsgN: 3, Value: v.io/v23/vom/testdata.NArray2Uint64 [2]uint64{1, 2}}
+ {
+ `NArray2Uint64{1, 2}`,
+ NArray2Uint64{1, 2},
+ "80512b020023762e696f2f7632332f766f6d2f74657374646174612e4e41727261793255696e74363401060202e15203000102",
+ "v.io/v23/vom/testdata.NArray2Uint64 [2]uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 04 MsgLen 4
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [[]uint64]
+ // 03 MsgLen 3
+ // 02 ValueLen 2 [list len]
+ // 01 PrimValue 1 [uint]
+ // 02 PrimValue 2 [uint]
+ // DumpStatus{MsgID: 41, MsgLen: 3, MsgN: 3, Value: []uint64{1, 2}}
+ {
+ `[]uint64{1, 2}`,
+ []uint64{1, 2},
+ "805104030106e15203020102",
+ "[]uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e743634 PrimValue "v.io/v23/vom/testdata.NListUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NListUint64 []uint64]
+ // 03 MsgLen 3
+ // 02 ValueLen 2 [list len]
+ // 01 PrimValue 1 [uint]
+ // 02 PrimValue 2 [uint]
+ // DumpStatus{MsgID: 41, MsgLen: 3, MsgN: 3, Value: v.io/v23/vom/testdata.NListUint64 []uint64{1, 2}}
+ {
+ `NListUint64{1, 2}`,
+ NListUint64{1, 2},
+ "805127030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e15203020102",
+ "v.io/v23/vom/testdata.NListUint64 []uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 04 MsgLen 4
+ // 04 WireTypeIndex 4 [v.io/v23/vom.wireSet]
+ // 01 Index 1 [v.io/v23/vom.wireSet.Key]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireSet END]
+ // 52 MsgID 41
+ // ValueMsg 41 [set[uint64]]
+ // 02 MsgLen 2
+ // 01 ValueLen 1 [set len]
+ // 01 PrimValue 1 [uint]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: set[uint64]{1}}
+ {
+ `set[uint64]{1}`,
+ set[uint64]{1},
+ "805104040106e152020101",
+ "set[uint64]",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 04 WireTypeIndex 4 [v.io/v23/vom.wireSet]
+ // 00 Index 0 [v.io/v23/vom.wireSet.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e53657455696e743634 PrimValue "v.io/v23/vom/testdata.NSetUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireSet.Key]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireSet END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NSetUint64 set[uint64]]
+ // 02 MsgLen 2
+ // 01 ValueLen 1 [set len]
+ // 01 PrimValue 1 [uint]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: v.io/v23/vom/testdata.NSetUint64 set[uint64]{1}}
+ {
+ `NSetUint64{1}`,
+ NSetUint64{1},
+ "805126040020762e696f2f7632332f766f6d2f74657374646174612e4e53657455696e7436340106e152020101",
+ "v.io/v23/vom/testdata.NSetUint64 set[uint64]",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 06 MsgLen 6
+ // 05 WireTypeIndex 5 [v.io/v23/vom.wireMap]
+ // 01 Index 1 [v.io/v23/vom.wireMap.Key]
+ // 06 PrimValue 6 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireMap.Elem]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireMap END]
+ // 52 MsgID 41
+ // ValueMsg 41 [map[uint64]string]
+ // 06 MsgLen 6
+ // 01 ValueLen 1 [map len]
+ // 01 PrimValue 1 [uint]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // DumpStatus{MsgID: 41, MsgLen: 6, MsgN: 6, Value: map[uint64]string{1: "abc"}}
+ {
+ `map[uint64]string{1: "abc"}`,
+ map[uint64]string{1: "abc"},
+ "8051060501060203e15206010103616263",
+ "map[uint64]string",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 2e MsgLen 46
+ // 05 WireTypeIndex 5 [v.io/v23/vom.wireMap]
+ // 00 Index 0 [v.io/v23/vom.wireMap.Name]
+ // 26 ByteLen 38 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e4d617055696e743634537472696e67 PrimValue "v.io/v23/vom/testdata.NMapUint64String" [string]
+ // 01 Index 1 [v.io/v23/vom.wireMap.Key]
+ // 06 PrimValue 6 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireMap.Elem]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireMap END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NMapUint64String map[uint64]string]
+ // 06 MsgLen 6
+ // 01 ValueLen 1 [map len]
+ // 01 PrimValue 1 [uint]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // DumpStatus{MsgID: 41, MsgLen: 6, MsgN: 6, Value: v.io/v23/vom/testdata.NMapUint64String map[uint64]string{1: "abc"}}
+ {
+ `NMapUint64String{1: "abc"}`,
+ NMapUint64String{1: "abc"},
+ "80512e050026762e696f2f7632332f766f6d2f74657374646174612e4e4d617055696e743634537472696e6701060203e15206010103616263",
+ "v.io/v23/vom/testdata.NMapUint64String map[uint64]string",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}]
+ // 0b MsgLen 11
+ // 00 Index 0 [v.io/v23/vom/testdata.NStruct.A]
+ // 01 PrimValue true [bool]
+ // 01 Index 1 [v.io/v23/vom/testdata.NStruct.B]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // 02 Index 2 [v.io/v23/vom/testdata.NStruct.C]
+ // fff6 PrimValue 123 [int]
+ // e1 Control EOF [v.io/v23/vom/testdata.NStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 11, MsgN: 11, Value: v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}{A: true, B: "abc", C: 123}}
+ {
+ `NStruct{A: true, B: "abc", C: 123}`,
+ NStruct{A: true, B: "abc", C: 123},
+ "80513506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1520b0001010361626302fff6e1",
+ "v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 52 MsgID 41
+ // ValueMsg 41 [?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}]
+ // 01 MsgLen 1
+ // e0 Control NIL [?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64} is nil]
+ // DumpStatus{MsgID: 41, MsgLen: 1, MsgN: 1, Value: ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}(nil)}
+ {
+ `?NStruct(nil)`,
+ ?NStruct(nil),
+ "80533506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1510408012ae15201e0",
+ "?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 52 MsgID 41
+ // ValueMsg 41 [?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}]
+ // 01 MsgLen 1
+ // e1 Control EOF [v.io/v23/vom/testdata.NStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 1, MsgN: 1, Value: ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}({A: false, B: "", C: 0})}
+ {
+ `?NStruct{}`,
+ ?NStruct{},
+ "80533506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1510408012ae15201e1",
+ "?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 52 MsgID 41
+ // ValueMsg 41 [?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}]
+ // 0b MsgLen 11
+ // 00 Index 0 [v.io/v23/vom/testdata.NStruct.A]
+ // 01 PrimValue true [bool]
+ // 01 Index 1 [v.io/v23/vom/testdata.NStruct.B]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // 02 Index 2 [v.io/v23/vom/testdata.NStruct.C]
+ // fff6 PrimValue 123 [int]
+ // e1 Control EOF [v.io/v23/vom/testdata.NStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 11, MsgN: 11, Value: ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}({A: true, B: "abc", C: 123})}
+ {
+ `?NStruct{A: true, B: "abc", C: 123}`,
+ ?NStruct{A: true, B: "abc", C: 123},
+ "80533506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1510408012ae1520b0001010361626302fff6e1",
+ "?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 01 WireTypeIndex 1 [v.io/v23/vom.wireEnum]
+ // 00 Index 0 [v.io/v23/vom.wireEnum.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e456e756d PrimValue "v.io/v23/vom/testdata.NEnum" [string]
+ // 01 Index 1 [v.io/v23/vom.wireEnum.Labels]
+ // 03 ValueLen 3 [list len]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // e1 Control EOF [v.io/v23/vom.wireEnum END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NEnum enum{A;B;C}]
+ // 00 Index 0 [v.io/v23/vom/testdata.NEnum.A]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NEnum enum{A;B;C}(A)}
+ {
+ `NEnum.A`,
+ NEnum.A,
+ "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e15200",
+ "v.io/v23/vom/testdata.NEnum enum{A;B;C}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 01 WireTypeIndex 1 [v.io/v23/vom.wireEnum]
+ // 00 Index 0 [v.io/v23/vom.wireEnum.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e456e756d PrimValue "v.io/v23/vom/testdata.NEnum" [string]
+ // 01 Index 1 [v.io/v23/vom.wireEnum.Labels]
+ // 03 ValueLen 3 [list len]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // e1 Control EOF [v.io/v23/vom.wireEnum END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NEnum enum{A;B;C}]
+ // 01 Index 1 [v.io/v23/vom/testdata.NEnum.B]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NEnum enum{A;B;C}(B)}
+ {
+ `NEnum.B`,
+ NEnum.B,
+ "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e15201",
+ "v.io/v23/vom/testdata.NEnum enum{A;B;C}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 01 WireTypeIndex 1 [v.io/v23/vom.wireEnum]
+ // 00 Index 0 [v.io/v23/vom.wireEnum.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e456e756d PrimValue "v.io/v23/vom/testdata.NEnum" [string]
+ // 01 Index 1 [v.io/v23/vom.wireEnum.Labels]
+ // 03 ValueLen 3 [list len]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // e1 Control EOF [v.io/v23/vom.wireEnum END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NEnum enum{A;B;C}]
+ // 02 Index 2 [v.io/v23/vom/testdata.NEnum.C]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.NEnum enum{A;B;C}(C)}
+ {
+ `NEnum.C`,
+ NEnum.C,
+ "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e15202",
+ "v.io/v23/vom/testdata.NEnum enum{A;B;C}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // 02 MsgLen 2
+ // 00 Index 0 [v.io/v23/vom/testdata.NUnion.A]
+ // 01 PrimValue true [bool]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}{A: true}}
+ {
+ `NUnion{A: true}`,
+ NUnion{A: true},
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020001",
+ "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // 02 MsgLen 2
+ // 00 Index 0 [v.io/v23/vom/testdata.NUnion.A]
+ // 00 PrimValue false [bool]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}{A: false}}
+ {
+ `NUnion{A: false}`,
+ NUnion{A: false},
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020000",
+ "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // 02 MsgLen 2
+ // 01 Index 1 [v.io/v23/vom/testdata.NUnion.B]
+ // 00 ByteLen 0 [string len]
+ // PrimValue "" [string]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}{B: ""}}
+ {
+ `NUnion{B: ""}`,
+ NUnion{B: ""},
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020100",
+ "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // 05 MsgLen 5
+ // 01 Index 1 [v.io/v23/vom/testdata.NUnion.B]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // DumpStatus{MsgID: 41, MsgLen: 5, MsgN: 5, Value: v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}{B: "abc"}}
+ {
+ `NUnion{B: "abc"}`,
+ NUnion{B: "abc"},
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152050103616263",
+ "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // 02 MsgLen 2
+ // 02 Index 2 [v.io/v23/vom/testdata.NUnion.C]
+ // 00 PrimValue 0 [int]
+ // DumpStatus{MsgID: 41, MsgLen: 2, MsgN: 2, Value: v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}{C: 0}}
+ {
+ `NUnion{C: 0}`,
+ NUnion{C: 0},
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020200",
+ "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // 03 MsgLen 3
+ // 02 Index 2 [v.io/v23/vom/testdata.NUnion.C]
+ // fff6 PrimValue 123 [int]
+ // DumpStatus{MsgID: 41, MsgLen: 3, MsgN: 3, Value: v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}{C: 123}}
+ {
+ `NUnion{C: 123}`,
+ NUnion{C: 123},
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e1520302fff6",
+ "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // 03 MsgLen 3
+ // 02 Index 2 [v.io/v23/vom/testdata.NUnion.C]
+ // fff5 PrimValue -123 [int]
+ // DumpStatus{MsgID: 41, MsgLen: 3, MsgN: 3, Value: v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}{C: -123}}
+ {
+ `NUnion{C: -123}`,
+ NUnion{C: -123},
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e1520302fff5",
+ "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MBool bool]
+ // 01 PrimValue true [bool]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.MBool bool(true)}
+ {
+ `MBool(true)`,
+ MBool(true),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e15201",
+ "v.io/v23/vom/testdata.MBool bool",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MBool bool]
+ // 00 PrimValue false [bool]
+ // DumpStatus{MsgID: 41, MsgN: 2, Value: v.io/v23/vom/testdata.MBool bool(false)}
+ {
+ `MBool(false)`,
+ MBool(false),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e15200",
+ "v.io/v23/vom/testdata.MBool bool",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 59 MsgID -45
+ // TypeMsg 45
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 57 MsgID -44
+ // TypeMsg 44
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2d PrimValue 45 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 47 MsgLen 71
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d537472756374 PrimValue "v.io/v23/vom/testdata.MStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 06 ValueLen 6 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 44 PrimValue "D" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2c PrimValue 44 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 45 PrimValue "E" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0e PrimValue 14 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 46 PrimValue "F" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0f PrimValue 15 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}]
+ // 07 MsgLen 7
+ // 00 Index 0 [v.io/v23/vom/testdata.MStruct.A]
+ // 01 PrimValue true [bool]
+ // 01 Index 1 [v.io/v23/vom/testdata.MStruct.B]
+ // 01 PrimValue true [bool]
+ // 02 Index 2 [v.io/v23/vom/testdata.MStruct.C]
+ // 01 PrimValue true [bool]
+ // e1 Control EOF [v.io/v23/vom/testdata.MStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 7, MsgN: 7, Value: v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}{A: true, B: true, C: true, D: nil, E: any, F: nil}}
+ {
+ `MStruct{A: true, B: true, C: true}`,
+ MStruct{A: true, B: true, C: true},
+ "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15207000101010201e1",
+ "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 59 MsgID -45
+ // TypeMsg 45
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 57 MsgID -44
+ // TypeMsg 44
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2d PrimValue 45 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 47 MsgLen 71
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d537472756374 PrimValue "v.io/v23/vom/testdata.MStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 06 ValueLen 6 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 44 PrimValue "D" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2c PrimValue 44 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 45 PrimValue "E" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0e PrimValue 14 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 46 PrimValue "F" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0f PrimValue 15 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}]
+ // 01 MsgLen 1
+ // e1 Control EOF [v.io/v23/vom/testdata.MStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 1, MsgN: 1, Value: v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}{A: false, B: false, C: false, D: nil, E: any, F: nil}}
+ {
+ `MStruct{}`,
+ MStruct{},
+ "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15201e1",
+ "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 59 MsgID -45
+ // TypeMsg 45
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 57 MsgID -44
+ // TypeMsg 44
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2d PrimValue 45 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 47 MsgLen 71
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d537472756374 PrimValue "v.io/v23/vom/testdata.MStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 06 ValueLen 6 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 44 PrimValue "D" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2c PrimValue 44 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 45 PrimValue "E" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0e PrimValue 14 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 46 PrimValue "F" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0f PrimValue 15 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}]
+ // 03 MsgLen 3
+ // 03 Index 3 [v.io/v23/vom/testdata.MStruct.D]
+ // e1 Control EOF [v.io/v23/vom/testdata.NStruct END]
+ // e1 Control EOF [v.io/v23/vom/testdata.MStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 3, MsgN: 3, Value: v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}{A: false, B: false, C: false, D: {A: false, B: "", C: 0}, E: any, F: nil}}
+ {
+ `MStruct{D: {}}`,
+ MStruct{D: {}},
+ "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e1520303e1e1",
+ "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 59 MsgID -45
+ // TypeMsg 45
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 57 MsgID -44
+ // TypeMsg 44
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2d PrimValue 45 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 47 MsgLen 71
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d537472756374 PrimValue "v.io/v23/vom/testdata.MStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 06 ValueLen 6 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 44 PrimValue "D" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2c PrimValue 44 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 45 PrimValue "E" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0e PrimValue 14 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 46 PrimValue "F" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0f PrimValue 15 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}]
+ // 0d MsgLen 13
+ // 03 Index 3 [v.io/v23/vom/testdata.MStruct.D]
+ // 00 Index 0 [v.io/v23/vom/testdata.NStruct.A]
+ // 01 PrimValue true [bool]
+ // 01 Index 1 [v.io/v23/vom/testdata.NStruct.B]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // 02 Index 2 [v.io/v23/vom/testdata.NStruct.C]
+ // fff6 PrimValue 123 [int]
+ // e1 Control EOF [v.io/v23/vom/testdata.NStruct END]
+ // e1 Control EOF [v.io/v23/vom/testdata.MStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 13, MsgN: 13, Value: v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}{A: false, B: false, C: false, D: {A: true, B: "abc", C: 123}, E: any, F: nil}}
+ {
+ `MStruct{D: {A: true, B: "abc", C: 123}}`,
+ MStruct{D: {A: true, B: "abc", C: 123}},
+ "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e1520d030001010361626302fff6e1e1",
+ "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 59 MsgID -45
+ // TypeMsg 45
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 57 MsgID -44
+ // TypeMsg 44
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2d PrimValue 45 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 47 MsgLen 71
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d537472756374 PrimValue "v.io/v23/vom/testdata.MStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 06 ValueLen 6 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 44 PrimValue "D" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2c PrimValue 44 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 45 PrimValue "E" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0e PrimValue 14 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 46 PrimValue "F" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0f PrimValue 15 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}]
+ // 07 MsgLen 7
+ // 05 Index 5 [v.io/v23/vom/testdata.MStruct.F]
+ // 03 TypeID 3 [string]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // e1 Control EOF [v.io/v23/vom/testdata.MStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 7, MsgN: 7, Value: v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}{A: false, B: false, C: false, D: nil, E: any, F: "abc"}}
+ {
+ `MStruct{F: "abc"}`,
+ MStruct{F: "abc"},
+ "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15207050303616263e1",
+ "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 59 MsgID -45
+ // TypeMsg 45
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 57 MsgID -44
+ // TypeMsg 44
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2d PrimValue 45 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 47 MsgLen 71
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d537472756374 PrimValue "v.io/v23/vom/testdata.MStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 06 ValueLen 6 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 44 PrimValue "D" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2c PrimValue 44 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 45 PrimValue "E" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0e PrimValue 14 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 46 PrimValue "F" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0f PrimValue 15 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}]
+ // 04 MsgLen 4
+ // 05 Index 5 [v.io/v23/vom/testdata.MStruct.F]
+ // 2b TypeID 43 [v.io/v23/vom/testdata.MBool bool]
+ // 01 PrimValue true [bool]
+ // e1 Control EOF [v.io/v23/vom/testdata.MStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 4, MsgN: 4, Value: v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}{A: false, B: false, C: false, D: nil, E: any, F: v.io/v23/vom/testdata.MBool bool(true)}}
+ {
+ `MStruct{F: MBool(true)}`,
+ MStruct{F: MBool(true)},
+ "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15204052b01e1",
+ "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c PrimValue "v.io/v23/vom/testdata.MBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 59 MsgID -45
+ // TypeMsg 45
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 57 MsgID -44
+ // TypeMsg 44
+ // 04 MsgLen 4
+ // 08 WireTypeIndex 8 [v.io/v23/vom.wireOptional]
+ // 01 Index 1 [v.io/v23/vom.wireOptional.Elem]
+ // 2d PrimValue 45 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireOptional END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 47 MsgLen 71
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d537472756374 PrimValue "v.io/v23/vom/testdata.MStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 06 ValueLen 6 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 44 PrimValue "D" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 2c PrimValue 44 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 45 PrimValue "E" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0e PrimValue 14 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 46 PrimValue "F" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 0f PrimValue 15 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}]
+ // 09 MsgLen 9
+ // 05 Index 5 [v.io/v23/vom/testdata.MStruct.F]
+ // 2c TypeID 44 [?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}]
+ // 01 Index 1 [v.io/v23/vom/testdata.NStruct.B]
+ // 03 ByteLen 3 [string len]
+ // 616263 PrimValue "abc" [string]
+ // e1 Control EOF [v.io/v23/vom/testdata.NStruct END]
+ // e1 Control EOF [v.io/v23/vom/testdata.MStruct END]
+ // DumpStatus{MsgID: 41, MsgLen: 9, MsgN: 9, Value: v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}{A: false, B: false, C: false, D: nil, E: any, F: ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}({A: false, B: "abc", C: 0})}}
+ {
+ `MStruct{F: ?NStruct{B: "abc"}}`,
+ MStruct{F: ?NStruct{B: "abc"}},
+ "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15209052c0103616263e1e1",
+ "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 27 MsgLen 39
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e743634 PrimValue "v.io/v23/vom/testdata.NListUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d4c697374 PrimValue "v.io/v23/vom/testdata.MList" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MList []v.io/v23/vom/testdata.NListUint64 []uint64]
+ // 07 MsgLen 7
+ // 03 ValueLen 3 [list len]
+ // 02 ValueLen 2 [list len]
+ // 04 PrimValue 4 [uint]
+ // 02 PrimValue 2 [uint]
+ // 00 ValueLen 0 [list len]
+ // 01 ValueLen 1 [list len]
+ // 63 PrimValue 99 [uint]
+ // DumpStatus{MsgID: 41, MsgLen: 7, MsgN: 7, Value: v.io/v23/vom/testdata.MList []v.io/v23/vom/testdata.NListUint64 []uint64{{4, 2}, {}, {99}}}
+ {
+ `MList{{4, 2}, {}, {99}}`,
+ MList{{4, 2}, {}, {99}},
+ "805327030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e1512103001b762e696f2f7632332f766f6d2f74657374646174612e4d4c697374012ae1520703020402000163",
+ "v.io/v23/vom/testdata.MList []v.io/v23/vom/testdata.NListUint64 []uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332 PrimValue "v.io/v23/vom/testdata.NFloat32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0a PrimValue 10 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 55 MsgID -43
+ // TypeMsg 43
+ // 27 MsgLen 39
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e743634 PrimValue "v.io/v23/vom/testdata.NListUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 05 WireTypeIndex 5 [v.io/v23/vom.wireMap]
+ // 00 Index 0 [v.io/v23/vom.wireMap.Name]
+ // 1a ByteLen 26 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4d4d6170 PrimValue "v.io/v23/vom/testdata.MMap" [string]
+ // 01 Index 1 [v.io/v23/vom.wireMap.Key]
+ // 2a PrimValue 42 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireMap.Elem]
+ // 2b PrimValue 43 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireMap END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.MMap map[v.io/v23/vom/testdata.NFloat32 float32]v.io/v23/vom/testdata.NListUint64 []uint64]
+ // 07 MsgLen 7
+ // 01 ValueLen 1 [map len]
+ // fe1240 PrimValue 4.5 [float]
+ // 02 ValueLen 2 [list len]
+ // 02 PrimValue 2 [uint]
+ // 03 PrimValue 3 [uint]
+ // DumpStatus{MsgID: 41, MsgLen: 7, MsgN: 7, Value: v.io/v23/vom/testdata.MMap map[v.io/v23/vom/testdata.NFloat32 float32]v.io/v23/vom/testdata.NListUint64 []uint64{4.5: {2, 3}}}
+ {
+ `MMap{4.5: {2, 3}}`,
+ MMap{4.5: {2, 3}},
+ "80532400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae15527030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e1512205001a762e696f2f7632332f766f6d2f74657374646174612e4d4d6170012a022be1520701fe1240020203",
+ "v.io/v23/vom/testdata.MMap map[v.io/v23/vom/testdata.NFloat32 float32]v.io/v23/vom/testdata.NListUint64 []uint64",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 20 MsgLen 32
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 1a ByteLen 26 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e52656341 PrimValue "v.io/v23/vom/testdata.RecA" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 29 PrimValue 41 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.RecA []v.io/v23/vom/testdata.RecA]
+ // 04 MsgLen 4
+ // 02 ValueLen 2 [list len]
+ // 00 ValueLen 0 [list len]
+ // 01 ValueLen 1 [list len]
+ // 00 ValueLen 0 [list len]
+ // DumpStatus{MsgID: 41, MsgLen: 4, MsgN: 4, Value: v.io/v23/vom/testdata.RecA []v.io/v23/vom/testdata.RecA{{}, {{}}}}
+ {
+ `RecA{{}, {{}}}`,
+ RecA{{}, {{}}},
+ "80512003001a762e696f2f7632332f766f6d2f74657374646174612e526563410129e1520402000100",
+ "v.io/v23/vom/testdata.RecA []v.io/v23/vom/testdata.RecA",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 53 MsgID -42
+ // TypeMsg 42
+ // 20 MsgLen 32
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 1a ByteLen 26 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e52656359 PrimValue "v.io/v23/vom/testdata.RecY" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 29 PrimValue 41 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 20 MsgLen 32
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 1a ByteLen 26 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e52656358 PrimValue "v.io/v23/vom/testdata.RecX" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 2a PrimValue 42 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 52 MsgID 41
+ // ValueMsg 41 [v.io/v23/vom/testdata.RecX []v.io/v23/vom/testdata.RecY []v.io/v23/vom/testdata.RecX]
+ // 05 MsgLen 5
+ // 02 ValueLen 2 [list len]
+ // 00 ValueLen 0 [list len]
+ // 02 ValueLen 2 [list len]
+ // 00 ValueLen 0 [list len]
+ // 00 ValueLen 0 [list len]
+ // DumpStatus{MsgID: 41, MsgLen: 5, MsgN: 5, Value: v.io/v23/vom/testdata.RecX []v.io/v23/vom/testdata.RecY []v.io/v23/vom/testdata.RecX{{}, {{}, {}}}}
+ {
+ `RecX{{}, {{}, {}}}`,
+ RecX{{}, {{}, {}}},
+ "80532003001a762e696f2f7632332f766f6d2f74657374646174612e526563590129e1512003001a762e696f2f7632332f766f6d2f74657374646174612e52656358012ae152050200020000",
+ "v.io/v23/vom/testdata.RecX []v.io/v23/vom/testdata.RecY []v.io/v23/vom/testdata.RecX",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 0f TypeID 15 [any]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(any)}
+ {
+ `typeobject(any)`,
+ typeobject(any),
+ "801c0f",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 01 TypeID 1 [bool]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(bool)}
+ {
+ `typeobject(bool)`,
+ typeobject(bool),
+ "801c01",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 04 TypeID 4 [uint16]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(uint16)}
+ {
+ `typeobject(uint16)`,
+ typeobject(uint16),
+ "801c04",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 05 TypeID 5 [uint32]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(uint32)}
+ {
+ `typeobject(uint32)`,
+ typeobject(uint32),
+ "801c05",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 06 TypeID 6 [uint64]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(uint64)}
+ {
+ `typeobject(uint64)`,
+ typeobject(uint64),
+ "801c06",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 07 TypeID 7 [int16]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(int16)}
+ {
+ `typeobject(int16)`,
+ typeobject(int16),
+ "801c07",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 08 TypeID 8 [int32]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(int32)}
+ {
+ `typeobject(int32)`,
+ typeobject(int32),
+ "801c08",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 09 TypeID 9 [int64]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(int64)}
+ {
+ `typeobject(int64)`,
+ typeobject(int64),
+ "801c09",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 07 TypeID 7 [int16]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(int16)}
+ {
+ `typeobject(int16)`,
+ typeobject(int16),
+ "801c07",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 08 TypeID 8 [int32]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(int32)}
+ {
+ `typeobject(int32)`,
+ typeobject(int32),
+ "801c08",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 09 TypeID 9 [int64]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(int64)}
+ {
+ `typeobject(int64)`,
+ typeobject(int64),
+ "801c09",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 0a TypeID 10 [float32]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(float32)}
+ {
+ `typeobject(float32)`,
+ typeobject(float32),
+ "801c0a",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 0b TypeID 11 [float64]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(float64)}
+ {
+ `typeobject(float64)`,
+ typeobject(float64),
+ "801c0b",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 0c TypeID 12 [complex64]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(complex64)}
+ {
+ `typeobject(complex64)`,
+ typeobject(complex64),
+ "801c0c",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 0d TypeID 13 [complex128]
+ // DumpStatus{MsgID: 14, MsgN: 3, Value: typeobject(complex128)}
+ {
+ `typeobject(complex128)`,
+ typeobject(complex128),
+ "801c0d",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 21 MsgLen 33
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c PrimValue "v.io/v23/vom/testdata.NBool" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NBool bool]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NBool bool)}
+ {
+ `typeobject(NBool)`,
+ typeobject(NBool),
+ "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743136 PrimValue "v.io/v23/vom/testdata.NUint16" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 04 PrimValue 4 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NUint16 uint16]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NUint16 uint16)}
+ {
+ `typeobject(NUint16)`,
+ typeobject(NUint16),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7431360104e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743332 PrimValue "v.io/v23/vom/testdata.NUint32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 05 PrimValue 5 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NUint32 uint32]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NUint32 uint32)}
+ {
+ `typeobject(NUint32)`,
+ typeobject(NUint32),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7433320105e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 23 MsgLen 35
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e55696e743634 PrimValue "v.io/v23/vom/testdata.NUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NUint64 uint64]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NUint64 uint64)}
+ {
+ `typeobject(NUint64)`,
+ typeobject(NUint64),
+ "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7436340106e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743136 PrimValue "v.io/v23/vom/testdata.NInt16" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 07 PrimValue 7 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NInt16 int16]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NInt16 int16)}
+ {
+ `typeobject(NInt16)`,
+ typeobject(NInt16),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743332 PrimValue "v.io/v23/vom/testdata.NInt32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 08 PrimValue 8 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NInt32 int32]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NInt32 int32)}
+ {
+ `typeobject(NInt32)`,
+ typeobject(NInt32),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 22 MsgLen 34
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e496e743634 PrimValue "v.io/v23/vom/testdata.NInt64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NInt64 int64]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NInt64 int64)}
+ {
+ `typeobject(NInt64)`,
+ typeobject(NInt64),
+ "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332 PrimValue "v.io/v23/vom/testdata.NFloat32" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0a PrimValue 10 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NFloat32 float32]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NFloat32 float32)}
+ {
+ `typeobject(NFloat32)`,
+ typeobject(NFloat32),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 24 MsgLen 36
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 1e ByteLen 30 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634 PrimValue "v.io/v23/vom/testdata.NFloat64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0b PrimValue 11 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NFloat64 float64]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NFloat64 float64)}
+ {
+ `typeobject(NFloat64)`,
+ typeobject(NFloat64),
+ "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634 PrimValue "v.io/v23/vom/testdata.NComplex64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0c PrimValue 12 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NComplex64 complex64]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NComplex64 complex64)}
+ {
+ `typeobject(NComplex64)`,
+ typeobject(NComplex64),
+ "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 00 WireTypeIndex 0 [v.io/v23/vom.wireNamed]
+ // 00 Index 0 [v.io/v23/vom.wireNamed.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238 PrimValue "v.io/v23/vom/testdata.NComplex128" [string]
+ // 01 Index 1 [v.io/v23/vom.wireNamed.Base]
+ // 0d PrimValue 13 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireNamed END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NComplex128 complex128]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NComplex128 complex128)}
+ {
+ `typeobject(NComplex128)`,
+ typeobject(NComplex128),
+ "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 2b MsgLen 43
+ // 02 WireTypeIndex 2 [v.io/v23/vom.wireArray]
+ // 00 Index 0 [v.io/v23/vom.wireArray.Name]
+ // 23 ByteLen 35 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e41727261793255696e743634 PrimValue "v.io/v23/vom/testdata.NArray2Uint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireArray.Elem]
+ // 06 PrimValue 6 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireArray.Len]
+ // 02 PrimValue 2 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireArray END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NArray2Uint64 [2]uint64]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NArray2Uint64 [2]uint64)}
+ {
+ `typeobject(NArray2Uint64)`,
+ typeobject(NArray2Uint64),
+ "80512b020023762e696f2f7632332f766f6d2f74657374646174612e4e41727261793255696e74363401060202e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 04 MsgLen 4
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [[]uint64]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject([]uint64)}
+ {
+ `typeobject([]uint64)`,
+ typeobject([]uint64),
+ "805104030106e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 03 WireTypeIndex 3 [v.io/v23/vom.wireList]
+ // 00 Index 0 [v.io/v23/vom.wireList.Name]
+ // 21 ByteLen 33 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e743634 PrimValue "v.io/v23/vom/testdata.NListUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireList.Elem]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireList END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NListUint64 []uint64]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NListUint64 []uint64)}
+ {
+ `typeobject(NListUint64)`,
+ typeobject(NListUint64),
+ "805127030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 04 MsgLen 4
+ // 04 WireTypeIndex 4 [v.io/v23/vom.wireSet]
+ // 01 Index 1 [v.io/v23/vom.wireSet.Key]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireSet END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [set[uint64]]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(set[uint64])}
+ {
+ `typeobject(set[uint64])`,
+ typeobject(set[uint64]),
+ "805104040106e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 26 MsgLen 38
+ // 04 WireTypeIndex 4 [v.io/v23/vom.wireSet]
+ // 00 Index 0 [v.io/v23/vom.wireSet.Name]
+ // 20 ByteLen 32 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e53657455696e743634 PrimValue "v.io/v23/vom/testdata.NSetUint64" [string]
+ // 01 Index 1 [v.io/v23/vom.wireSet.Key]
+ // 06 PrimValue 6 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireSet END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NSetUint64 set[uint64]]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NSetUint64 set[uint64])}
+ {
+ `typeobject(NSetUint64)`,
+ typeobject(NSetUint64),
+ "805126040020762e696f2f7632332f766f6d2f74657374646174612e4e53657455696e7436340106e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 06 MsgLen 6
+ // 05 WireTypeIndex 5 [v.io/v23/vom.wireMap]
+ // 01 Index 1 [v.io/v23/vom.wireMap.Key]
+ // 06 PrimValue 6 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireMap.Elem]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireMap END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [map[uint64]string]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(map[uint64]string)}
+ {
+ `typeobject(map[uint64]string)`,
+ typeobject(map[uint64]string),
+ "8051060501060203e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 2e MsgLen 46
+ // 05 WireTypeIndex 5 [v.io/v23/vom.wireMap]
+ // 00 Index 0 [v.io/v23/vom.wireMap.Name]
+ // 26 ByteLen 38 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e4d617055696e743634537472696e67 PrimValue "v.io/v23/vom/testdata.NMapUint64String" [string]
+ // 01 Index 1 [v.io/v23/vom.wireMap.Key]
+ // 06 PrimValue 6 [uint]
+ // 02 Index 2 [v.io/v23/vom.wireMap.Elem]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireMap END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NMapUint64String map[uint64]string]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NMapUint64String map[uint64]string)}
+ {
+ `typeobject(NMapUint64String)`,
+ typeobject(NMapUint64String),
+ "80512e050026762e696f2f7632332f766f6d2f74657374646174612e4e4d617055696e743634537472696e6701060203e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 35 MsgLen 53
+ // 06 WireTypeIndex 6 [v.io/v23/vom.wireStruct]
+ // 00 Index 0 [v.io/v23/vom.wireStruct.Name]
+ // 1d ByteLen 29 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e537472756374 PrimValue "v.io/v23/vom/testdata.NStruct" [string]
+ // 01 Index 1 [v.io/v23/vom.wireStruct.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireStruct END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64})}
+ {
+ `typeobject(NStruct)`,
+ typeobject(NStruct),
+ "80513506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 27 MsgLen 39
+ // 01 WireTypeIndex 1 [v.io/v23/vom.wireEnum]
+ // 00 Index 0 [v.io/v23/vom.wireEnum.Name]
+ // 1b ByteLen 27 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e456e756d PrimValue "v.io/v23/vom/testdata.NEnum" [string]
+ // 01 Index 1 [v.io/v23/vom.wireEnum.Labels]
+ // 03 ValueLen 3 [list len]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // e1 Control EOF [v.io/v23/vom.wireEnum END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NEnum enum{A;B;C}]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NEnum enum{A;B;C})}
+ {
+ `typeobject(NEnum)`,
+ typeobject(NEnum),
+ "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e11c29",
+ "typeobject",
+ },
+ // 80 Magic 128 [vom version 0]
+ // 51 MsgID -41
+ // TypeMsg 41
+ // 34 MsgLen 52
+ // 07 WireTypeIndex 7 [v.io/v23/vom.wireUnion]
+ // 00 Index 0 [v.io/v23/vom.wireUnion.Name]
+ // 1c ByteLen 28 [string len]
+ // 762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e PrimValue "v.io/v23/vom/testdata.NUnion" [string]
+ // 01 Index 1 [v.io/v23/vom.wireUnion.Fields]
+ // 03 ValueLen 3 [list len]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 41 PrimValue "A" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 01 PrimValue 1 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 42 PrimValue "B" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 03 PrimValue 3 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // 00 Index 0 [v.io/v23/vom.wireField.Name]
+ // 01 ByteLen 1 [string len]
+ // 43 PrimValue "C" [string]
+ // 01 Index 1 [v.io/v23/vom.wireField.Type]
+ // 09 PrimValue 9 [uint]
+ // e1 Control EOF [v.io/v23/vom.wireField END]
+ // e1 Control EOF [v.io/v23/vom.wireUnion END]
+ // 1c MsgID 14
+ // ValueMsg 14 [typeobject]
+ // 29 TypeID 41 [v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}]
+ // DumpStatus{MsgID: 14, MsgN: 2, Value: typeobject(v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64})}
+ {
+ `typeobject(NUnion)`,
+ typeobject(NUnion),
+ "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e11c29",
+ "typeobject",
+ },
+}
+
+// CompatTests contains the testcases to use to test vom type compatibility.
+// CompatTests maps TestName (string) to CompatibleTypeSet ([]typeobject)
+// Each CompatibleTypeSet contains types compatible with each other. However,
+// types from different CompatibleTypeSets are incompatible.
+const CompatTests = map[string][]typeobject{
+ "bool": []typeobject{typeobject(bool), typeobject(NBool), typeobject(MBool)},
+ "map[X]bool/set[X]": []typeobject{typeobject(SetOnlyMap), typeobject(MapOnlySet)},
+ "map[string]X/struct": []typeobject{typeobject(MapOnlyStruct), typeobject(StructOnlyMap)},
+ "map[string]bool/set[string]/struct": []typeobject{typeobject(MapSetStruct), typeobject(SetStructMap), typeobject(MapStructSet)},
+ "number list/array": []typeobject{typeobject([]int32), typeobject(NArray2Uint64), typeobject(NListUint64)},
+ "number": []typeobject{typeobject(uint16), typeobject(uint32), typeobject(uint64), typeobject(int16), typeobject(int32), typeobject(int64), typeobject(float32), typeobject(float64), typeobject(complex64), typeobject(complex128), typeobject(NUint16), typeobject(NUint32), typeobject(NUint64), typeobject(NInt16), typeobject(NInt32), typeobject(NInt64), typeobject(NFloat32), typeobject(NFloat64), typeobject(NComplex64), typeobject(NComplex128)},
+ "string list/array": []typeobject{typeobject([]string), typeobject(ListString), typeobject(Array3String)},
+ "string/[]byte/enum": []typeobject{typeobject(string), typeobject(NString), typeobject([]byte), typeobject(NByteSlice), typeobject(NByteArray), typeobject(NEnum)},
+ "struct A": []typeobject{typeobject(NStruct), typeobject(ABCStruct), typeobject(ADEStruct)},
+ "struct Z": []typeobject{typeobject(XYZStruct), typeobject(YZStruct), typeobject(ZStruct)},
+ "typeobject": []typeobject{typeobject(typeobject)},
+ "union B": []typeobject{typeobject(NUnion), typeobject(BDEunion)},
+}
+
+// ConvertTests contains the testcases to check vom value convertibility.
+// ConvertTests maps TestName (string) to ConvertGroups ([]ConvertGroup)
+// Each ConvertGroup is a struct with 'Name', 'PrimaryType', and 'Values'.
+// The values within a ConvertGroup can convert between themselves w/o error.
+// However, values in higher-indexed ConvertGroups will error when converting up
+// to the primary type of the lower-indexed ConvertGroups.
+const ConvertTests = map[string][]ConvertGroup{
+ "number": {
+ {
+ "byte",
+ typeobject(byte),
+ { byte(3), uint16(3), int32(3), float64(3), int64(3), complex128(3), },
+ },
+ {
+ "uint16",
+ typeobject(uint16),
+ { uint16(256), int32(256), float64(256), int64(256), complex128(256), },
+ },
+ {
+ "int32",
+ typeobject(int32),
+ { int32(-5), float64(-5), int64(-5), complex128(-5), },
+ },
+ {
+ "float64",
+ typeobject(float64),
+ { float64(3.3), complex128(3.3), },
+ },
+ {
+ "int64",
+ typeobject(int64),
+ { int64(-9223372036854775808), },
+ },
+ {
+ "complex128",
+ typeobject(complex128),
+ { complex128(1.5-1i), },
+ },
+ },
+}
diff --git a/lib/vom/testdata/vomdata.vdl.config b/lib/vom/testdata/vomdata.vdl.config
new file mode 100644
index 0000000..e2a473a
--- /dev/null
+++ b/lib/vom/testdata/vomdata.vdl.config
@@ -0,0 +1,267 @@
+// This is the input file for VOM test data, in the VDL config file format. The
+// purpose of this file is to make it easy to add VOM test cases for each
+// generated language.
+//
+// In order to add new test cases, simply add new values to the list below.
+// Test types are defined in the vomtype.vdl file in this directory; they can't
+// appear in this file since they're not allowed in VDL config files.
+//
+// To re-generate the tests:
+// 0) If your PATH does not include $VANADIUM_ROOT/release/go/bin, then prefix
+// commands 2 and 3 with PATH=$VANADIUM_ROOT/release/go/bin:$PATH
+// This way, the new binaries are run without overwriting existing dev tools.
+// 1) v23 go install v.io/v23/vdl/vdl v.io/v23/vom/vomtestgen
+// 2) v23 run vomtestgen
+// 3) v23 run vdl generate v.io/v23/vom/...
+//
+// Running "vomtestgen" against this file produces the vomdata.vdl file, and
+// running "vdl generate" against the resulting package produces the VOM test
+// data in each generated language.
+config = x
+
+import (
+ t "v.io/v23/vom/testdata"
+)
+
+const encodeDecodeData = []any{
+ // Values of simple unnamed types.
+ bool(true), bool(false),
+ string(""), string("abc"),
+ []byte(""), []byte{1, 2, 3}, []byte("adef"),
+
+ byte(0), byte(127), byte(255),
+
+ uint16(0), uint16(1), uint16(2), uint16(63), uint16(64),
+ uint16(127), uint16(128), uint16(255), uint16(256),
+ uint16(0x7ffe), uint16(0x7fff), uint16(0xfffe), uint16(0xffff),
+
+ uint32(0),
+ uint32(0x7ffffe), uint32(0x7fffff),
+ uint32(0xfffffe), uint32(0xffffff),
+ uint32(0x7ffffffe), uint32(0x7fffffff),
+ uint32(0xfffffffe), uint32(0xffffffff),
+
+ uint64(0),
+ uint64(0x7ffffffffe), uint64(0x7fffffffff),
+ uint64(0xfffffffffe), uint64(0xffffffffff),
+ uint64(0x7ffffffffffe), uint64(0x7fffffffffff),
+ uint64(0xfffffffffffe), uint64(0xffffffffffff),
+ uint64(0x7ffffffffffffe), uint64(0x7fffffffffffff),
+ uint64(0xfffffffffffffe), uint64(0xffffffffffffff),
+ uint64(0x7ffffffffffffffe), uint64(0x7fffffffffffffff),
+ uint64(0xfffffffffffffffe), uint64(0xffffffffffffffff),
+
+ int16(0), int16(1), int16(2), int16(63), int16(64),
+ int16(127), int16(128), int16(255), int16(256),
+ int16(0x7ffe), int16(0x7fff),
+
+ int32(0),
+ int32(0x7ffffe), int32(0x7fffff),
+ int32(0xfffffe), int32(0xffffff),
+ int32(0x7ffffffe), int32(0x7fffffff),
+
+ int64(0),
+ int64(1), int64(2),
+ int64(0x7ffffffffe), int64(0x7fffffffff),
+ int64(0xfffffffffe), int64(0xffffffffff),
+ int64(0x7ffffffffffe), int64(0x7fffffffffff),
+ int64(0xfffffffffffe), int64(0xffffffffffff),
+ int64(0x7ffffffffffffe), int64(0x7fffffffffffff),
+ int64(0xfffffffffffffe), int64(0xffffffffffffff),
+ int64(0x7ffffffffffffffe), int64(0x7fffffffffffffff),
+
+ int16(-1), int16(-2), int16(-64), int16(-65),
+ int16(-128), int16(-129), int16(-256), int16(-257),
+ int16(-0x7fff), int16(-0x8000),
+
+ int32(-0x7fffff), int32(-0x800000),
+ int32(-0xffffff), int32(-0x1000000),
+ int32(-0x7fffffff), int32(-0x80000000),
+
+ int64(-1), int64(-2),
+ int64(-0x7fffffffff), int64(-0x8000000000),
+ int64(-0xffffffffff), int64(-0x10000000000),
+ int64(-0x7fffffffffff), int64(-0x800000000000),
+ int64(-0xffffffffffff), int64(-0x1000000000000),
+ int64(-0x7fffffffffffff), int64(-0x80000000000000),
+ int64(-0xffffffffffffff), int64(-0x100000000000000),
+ int64(-0x7fffffffffffffff), int64(-0x8000000000000000),
+
+ float32(0), float32(32.5), float32(-32.5),
+ float64(0), float64(64.5), float64(-64.5),
+ complex64(0), complex64(64.5+64.5i), complex64(64.5-64.5i),
+ complex128(0), complex128(128.5+128.5i), complex128(128.5-128.5i),
+
+ // Values of simple named types.
+ t.NBool(true), t.NBool(false),
+ t.NString(""), t.NString("abc"),
+ t.NByteSlice{}, t.NByteSlice{1, 2, 3}, t.NByteSlice("abc"),
+ t.NByteArray{}, t.NByteArray{1, 2, 3}, t.NByteArray("abcd"),
+ t.NByte(0), t.NByte(127), t.NByte(255),
+ t.NUint16(0), t.NUint16(0xffff),
+ t.NUint32(0), t.NUint32(0xffffffff),
+ t.NUint64(0), t.NUint64(0xffffffffffffffff),
+ t.NInt16(0), t.NInt16(0x7fff), t.NInt16(-0x8000),
+ t.NInt32(0), t.NInt32(0x7fffffff), t.NInt32(-0x80000000),
+ t.NInt64(0), t.NInt64(0x7fffffffffffffff), t.NInt64(-0x8000000000000000),
+ t.NFloat32(0), t.NFloat32(32.5), t.NFloat32(-32.5),
+ t.NFloat64(0), t.NFloat64(64.5), t.NFloat64(-64.5),
+ t.NComplex64(0), t.NComplex64(64.5+64.5i), t.NComplex64(64.5-64.5i),
+ t.NComplex128(0), t.NComplex128(128.5+128.5i), t.NComplex128(128.5-128.5i),
+
+ // Values of composite types.
+ //
+ // TODO(toddw): Add more than 1 entry to the set and map values, after
+ // accounting for possible ordering differences.
+ t.NArray2Uint64{1, 2},
+ []uint64{1, 2}, t.NListUint64{1, 2},
+ set[uint64]{1}, t.NSetUint64{1},
+ map[uint64]string{1:"abc"}, t.NMapUint64String{1:"abc"},
+ t.NStruct{A: true, B: "abc", C: 123 },
+ ?t.NStruct(nil), ?t.NStruct{}, ?t.NStruct{A: true, B: "abc", C: 123},
+
+ // Values of special types.
+ // TODO(toddw): Add tests for embedded Any, etc.
+ t.NEnum.A, t.NEnum.B, t.NEnum.C,
+ t.NUnion{A: true}, t.NUnion{A: false},
+ t.NUnion{B: ""}, t.NUnion{B: "abc"},
+ t.NUnion{C: 0}, t.NUnion{C: 123}, t.NUnion{C: -123},
+
+ // Values of nested custom types.
+ t.MBool(true), t.MBool(false),
+ t.MStruct{A: true, B: t.NBool(true), C: t.MBool(true)},
+ t.MStruct{D: nil}, t.MStruct{D: {}}, t.MStruct{D: {true, "abc", 123}},
+ t.MStruct{F: "abc"}, t.MStruct{F: t.MBool(true)}, t.MStruct{F: ?t.NStruct{B: "abc"}},
+ t.MList{t.NListUint64{4, 2}, t.NListUint64{}, t.NListUint64{99}},
+ // TODO(bprosnitz) Add more than one entry to the map, after we have
+ // support for testing reordered bytes.
+ t.MMap{t.NFloat32(4.5): t.NListUint64{2,3}},
+
+ // Values of recursive types.
+ t.RecA{t.RecA{},t.RecA{t.RecA{}}},
+ t.RecX{t.RecY{},t.RecY{t.RecX{}, t.RecX{}}},
+
+ // Values of typeobject types.
+ typeobject(any),
+ typeobject(bool),
+ typeobject(uint16),typeobject(uint32),typeobject(uint64),
+ typeobject(int16),typeobject(int32),typeobject(int64),
+ typeobject(int16),typeobject(int32),typeobject(int64),
+ typeobject(float32),typeobject(float64),
+ typeobject(complex64),typeobject(complex128),
+ typeobject(t.NBool),
+ typeobject(t.NUint16),typeobject(t.NUint32),typeobject(t.NUint64),
+ typeobject(t.NInt16),typeobject(t.NInt32),typeobject(t.NInt64),
+ typeobject(t.NFloat32),typeobject(t.NFloat64),
+ typeobject(t.NComplex64),typeobject(t.NComplex128),
+ typeobject(t.NArray2Uint64),
+ typeobject([]uint64), typeobject(t.NListUint64),
+ typeobject(set[uint64]), typeobject(t.NSetUint64),
+ typeobject(map[uint64]string), typeobject(t.NMapUint64String),
+ typeobject(t.NStruct),
+ typeobject(t.NEnum), typeobject(t.NUnion),
+}
+
+const compatData = map[string][]typeobject{
+ "bool": {
+ typeobject(bool), typeobject(t.NBool), typeobject(t.MBool),
+ },
+ "number": {
+ typeobject(uint16),typeobject(uint32),typeobject(uint64),
+ typeobject(int16),typeobject(int32),typeobject(int64),
+ typeobject(float32),typeobject(float64),
+ typeobject(complex64),typeobject(complex128),
+ typeobject(t.NUint16),typeobject(t.NUint32),typeobject(t.NUint64),
+ typeobject(t.NInt16),typeobject(t.NInt32),typeobject(t.NInt64),
+ typeobject(t.NFloat32),typeobject(t.NFloat64),
+ typeobject(t.NComplex64),typeobject(t.NComplex128),
+ },
+ "string/[]byte/enum": {
+ typeobject(string),typeobject(t.NString),
+ typeobject([]byte),typeobject(t.NByteSlice),typeobject(t.NByteArray),
+ typeobject(t.NEnum),
+ },
+ "number list/array": { // number lists
+ typeobject([]int32),typeobject(t.NArray2Uint64),typeobject(t.NListUint64),
+ },
+ "string list/array": { // string lists
+ typeobject([]string),typeobject(t.ListString),typeobject(t.Array3String),
+ },
+ "struct A": { // structs with themselves (1 common field)
+ typeobject(t.NStruct),typeobject(t.ABCStruct),typeobject(t.ADEStruct),
+ },
+ "struct Z": { // structs with themselves (a different common field)
+ typeobject(t.XYZStruct),typeobject(t.YZStruct),typeobject(t.ZStruct),
+ },
+ "map[string]X/struct": { // maps and structs (all fields have compatible types)
+ typeobject(t.MapOnlyStruct),typeobject(t.StructOnlyMap),
+ },
+ "map[string]bool/set[string]/struct": { // maps, sets, and structs (elem/field are bool)
+ typeobject(t.MapSetStruct),typeobject(t.SetStructMap),typeobject(t.MapStructSet),
+ },
+ "map[X]bool/set[X]": { // maps and sets (non-string keys)
+ typeobject(t.SetOnlyMap),typeobject(t.MapOnlySet),
+ },
+ "union B": {
+ typeobject(t.NUnion),typeobject(t.BDEunion),
+ },
+ "typeobject": {
+ typeobject(typeobject),
+ },
+}
+
+const convertData = map[string][]t.ConvertGroup{
+ "number": {
+ {
+ "byte",
+ typeobject(byte),
+ {
+ byte(3),uint16(3),int32(3),float64(3),int64(3),complex128(3),
+ },
+ },
+ {
+ "uint16",
+ typeobject(uint16),
+ {
+ uint16(256),int32(256),float64(256),int64(256),complex128(256),
+ },
+ },
+ {
+ "int32",
+ typeobject(int32),
+ {
+ int32(-5),float64(-5),int64(-5),complex128(-5),
+ },
+ },
+ {
+ "float64",
+ typeobject(float64),
+ {
+ float64(3.3),complex128(3.3),
+ },
+ },
+ {
+ "int64",
+ typeobject(int64),
+ {
+ int64(-0x8000000000000000),
+ },
+ },
+ {
+ "complex128",
+ typeobject(complex128),
+ {
+ complex128(1.5-1i),
+ },
+ },
+ },
+ // TODO(alexfandrianto): Add more tests and start using them in js vom.
+ // The 'number' testcase above is meant to illustrate how this data is
+ // structured and to elicit feedback before it's finalized.
+}
+
+const x = t.VomdataStruct{
+ EncodeDecodeData: encodeDecodeData,
+ CompatData: compatData,
+ ConvertData: convertData,
+}
diff --git a/lib/vom/testdata/vomdata.vdl.go b/lib/vom/testdata/vomdata.vdl.go
new file mode 100644
index 0000000..0698fbf
--- /dev/null
+++ b/lib/vom/testdata/vomdata.vdl.go
@@ -0,0 +1,1696 @@
+// This file was auto-generated by the veyron vdl tool.
+// Source: vomdata.vdl
+
+package testdata
+
+import (
+ // VDL system imports
+ "v.io/v23/vdl"
+)
+
+// TestCase represents an individual testcase for vom encoding and decoding.
+type TestCase struct {
+ Name string // Name of the testcase
+ Value *vdl.Value // Value to test
+ Hex string // Hex pattern representing vom encoding of Value
+ TypeString string // The string representation of the Type
+}
+
+func (TestCase) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.TestCase"
+}) {
+}
+
+func init() {
+ vdl.Register((*TestCase)(nil))
+}
+
+// Tests contains the testcases to use to test vom encoding and decoding.
+var Tests = []TestCase{
+ {
+ Name: "true",
+ Value: vdl.ValueOf(true),
+ Hex: "800201",
+ TypeString: "bool",
+ },
+ {
+ Name: "false",
+ Value: vdl.ValueOf(false),
+ Hex: "800200",
+ TypeString: "bool",
+ },
+ {
+ Name: "\"\"",
+ Value: vdl.ValueOf(""),
+ Hex: "800600",
+ TypeString: "string",
+ },
+ {
+ Name: "\"abc\"",
+ Value: vdl.ValueOf("abc"),
+ Hex: "800603616263",
+ TypeString: "string",
+ },
+ {
+ Name: "[]byte(\"\")",
+ Value: vdl.ValueOf([]byte(nil)),
+ Hex: "804e00",
+ TypeString: "[]byte",
+ },
+ {
+ Name: "[]byte(\"\\x01\\x02\\x03\")",
+ Value: vdl.ValueOf([]byte("\x01\x02\x03")),
+ Hex: "804e03010203",
+ TypeString: "[]byte",
+ },
+ {
+ Name: "[]byte(\"adef\")",
+ Value: vdl.ValueOf([]byte("adef")),
+ Hex: "804e0461646566",
+ TypeString: "[]byte",
+ },
+ {
+ Name: "byte(0)",
+ Value: vdl.ValueOf(byte(0)),
+ Hex: "800400",
+ TypeString: "byte",
+ },
+ {
+ Name: "byte(127)",
+ Value: vdl.ValueOf(byte(127)),
+ Hex: "80047f",
+ TypeString: "byte",
+ },
+ {
+ Name: "byte(255)",
+ Value: vdl.ValueOf(byte(255)),
+ Hex: "8004ff",
+ TypeString: "byte",
+ },
+ {
+ Name: "uint16(0)",
+ Value: vdl.ValueOf(uint16(0)),
+ Hex: "800800",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(1)",
+ Value: vdl.ValueOf(uint16(1)),
+ Hex: "800801",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(2)",
+ Value: vdl.ValueOf(uint16(2)),
+ Hex: "800802",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(63)",
+ Value: vdl.ValueOf(uint16(63)),
+ Hex: "80083f",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(64)",
+ Value: vdl.ValueOf(uint16(64)),
+ Hex: "800840",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(127)",
+ Value: vdl.ValueOf(uint16(127)),
+ Hex: "80087f",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(128)",
+ Value: vdl.ValueOf(uint16(128)),
+ Hex: "8008ff80",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(255)",
+ Value: vdl.ValueOf(uint16(255)),
+ Hex: "8008ffff",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(256)",
+ Value: vdl.ValueOf(uint16(256)),
+ Hex: "8008fe0100",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(32766)",
+ Value: vdl.ValueOf(uint16(32766)),
+ Hex: "8008fe7ffe",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(32767)",
+ Value: vdl.ValueOf(uint16(32767)),
+ Hex: "8008fe7fff",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(65534)",
+ Value: vdl.ValueOf(uint16(65534)),
+ Hex: "8008fefffe",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint16(65535)",
+ Value: vdl.ValueOf(uint16(65535)),
+ Hex: "8008feffff",
+ TypeString: "uint16",
+ },
+ {
+ Name: "uint32(0)",
+ Value: vdl.ValueOf(uint32(0)),
+ Hex: "800a00",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(8388606)",
+ Value: vdl.ValueOf(uint32(8388606)),
+ Hex: "800afd7ffffe",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(8388607)",
+ Value: vdl.ValueOf(uint32(8388607)),
+ Hex: "800afd7fffff",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(16777214)",
+ Value: vdl.ValueOf(uint32(16777214)),
+ Hex: "800afdfffffe",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(16777215)",
+ Value: vdl.ValueOf(uint32(16777215)),
+ Hex: "800afdffffff",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(2147483646)",
+ Value: vdl.ValueOf(uint32(2147483646)),
+ Hex: "800afc7ffffffe",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(2147483647)",
+ Value: vdl.ValueOf(uint32(2147483647)),
+ Hex: "800afc7fffffff",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(4294967294)",
+ Value: vdl.ValueOf(uint32(4294967294)),
+ Hex: "800afcfffffffe",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint32(4294967295)",
+ Value: vdl.ValueOf(uint32(4294967295)),
+ Hex: "800afcffffffff",
+ TypeString: "uint32",
+ },
+ {
+ Name: "uint64(0)",
+ Value: vdl.ValueOf(uint64(0)),
+ Hex: "800c00",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(549755813886)",
+ Value: vdl.ValueOf(uint64(549755813886)),
+ Hex: "800cfb7ffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(549755813887)",
+ Value: vdl.ValueOf(uint64(549755813887)),
+ Hex: "800cfb7fffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(1099511627774)",
+ Value: vdl.ValueOf(uint64(1099511627774)),
+ Hex: "800cfbfffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(1099511627775)",
+ Value: vdl.ValueOf(uint64(1099511627775)),
+ Hex: "800cfbffffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(140737488355326)",
+ Value: vdl.ValueOf(uint64(140737488355326)),
+ Hex: "800cfa7ffffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(140737488355327)",
+ Value: vdl.ValueOf(uint64(140737488355327)),
+ Hex: "800cfa7fffffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(281474976710654)",
+ Value: vdl.ValueOf(uint64(281474976710654)),
+ Hex: "800cfafffffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(281474976710655)",
+ Value: vdl.ValueOf(uint64(281474976710655)),
+ Hex: "800cfaffffffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(36028797018963966)",
+ Value: vdl.ValueOf(uint64(36028797018963966)),
+ Hex: "800cf97ffffffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(36028797018963967)",
+ Value: vdl.ValueOf(uint64(36028797018963967)),
+ Hex: "800cf97fffffffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(72057594037927934)",
+ Value: vdl.ValueOf(uint64(72057594037927934)),
+ Hex: "800cf9fffffffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(72057594037927935)",
+ Value: vdl.ValueOf(uint64(72057594037927935)),
+ Hex: "800cf9ffffffffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(9223372036854775806)",
+ Value: vdl.ValueOf(uint64(9223372036854775806)),
+ Hex: "800cf87ffffffffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(9223372036854775807)",
+ Value: vdl.ValueOf(uint64(9223372036854775807)),
+ Hex: "800cf87fffffffffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(18446744073709551614)",
+ Value: vdl.ValueOf(uint64(18446744073709551614)),
+ Hex: "800cf8fffffffffffffffe",
+ TypeString: "uint64",
+ },
+ {
+ Name: "uint64(18446744073709551615)",
+ Value: vdl.ValueOf(uint64(18446744073709551615)),
+ Hex: "800cf8ffffffffffffffff",
+ TypeString: "uint64",
+ },
+ {
+ Name: "int16(0)",
+ Value: vdl.ValueOf(int16(0)),
+ Hex: "800e00",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(1)",
+ Value: vdl.ValueOf(int16(1)),
+ Hex: "800e02",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(2)",
+ Value: vdl.ValueOf(int16(2)),
+ Hex: "800e04",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(63)",
+ Value: vdl.ValueOf(int16(63)),
+ Hex: "800e7e",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(64)",
+ Value: vdl.ValueOf(int16(64)),
+ Hex: "800eff80",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(127)",
+ Value: vdl.ValueOf(int16(127)),
+ Hex: "800efffe",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(128)",
+ Value: vdl.ValueOf(int16(128)),
+ Hex: "800efe0100",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(255)",
+ Value: vdl.ValueOf(int16(255)),
+ Hex: "800efe01fe",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(256)",
+ Value: vdl.ValueOf(int16(256)),
+ Hex: "800efe0200",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(32766)",
+ Value: vdl.ValueOf(int16(32766)),
+ Hex: "800efefffc",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(32767)",
+ Value: vdl.ValueOf(int16(32767)),
+ Hex: "800efefffe",
+ TypeString: "int16",
+ },
+ {
+ Name: "int32(0)",
+ Value: vdl.ValueOf(int32(0)),
+ Hex: "801000",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(8388606)",
+ Value: vdl.ValueOf(int32(8388606)),
+ Hex: "8010fdfffffc",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(8388607)",
+ Value: vdl.ValueOf(int32(8388607)),
+ Hex: "8010fdfffffe",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(16777214)",
+ Value: vdl.ValueOf(int32(16777214)),
+ Hex: "8010fc01fffffc",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(16777215)",
+ Value: vdl.ValueOf(int32(16777215)),
+ Hex: "8010fc01fffffe",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(2147483646)",
+ Value: vdl.ValueOf(int32(2147483646)),
+ Hex: "8010fcfffffffc",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(2147483647)",
+ Value: vdl.ValueOf(int32(2147483647)),
+ Hex: "8010fcfffffffe",
+ TypeString: "int32",
+ },
+ {
+ Name: "int64(0)",
+ Value: vdl.ValueOf(int64(0)),
+ Hex: "801200",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(1)",
+ Value: vdl.ValueOf(int64(1)),
+ Hex: "801202",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(2)",
+ Value: vdl.ValueOf(int64(2)),
+ Hex: "801204",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(549755813886)",
+ Value: vdl.ValueOf(int64(549755813886)),
+ Hex: "8012fbfffffffffc",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(549755813887)",
+ Value: vdl.ValueOf(int64(549755813887)),
+ Hex: "8012fbfffffffffe",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(1099511627774)",
+ Value: vdl.ValueOf(int64(1099511627774)),
+ Hex: "8012fa01fffffffffc",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(1099511627775)",
+ Value: vdl.ValueOf(int64(1099511627775)),
+ Hex: "8012fa01fffffffffe",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(140737488355326)",
+ Value: vdl.ValueOf(int64(140737488355326)),
+ Hex: "8012fafffffffffffc",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(140737488355327)",
+ Value: vdl.ValueOf(int64(140737488355327)),
+ Hex: "8012fafffffffffffe",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(281474976710654)",
+ Value: vdl.ValueOf(int64(281474976710654)),
+ Hex: "8012f901fffffffffffc",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(281474976710655)",
+ Value: vdl.ValueOf(int64(281474976710655)),
+ Hex: "8012f901fffffffffffe",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(36028797018963966)",
+ Value: vdl.ValueOf(int64(36028797018963966)),
+ Hex: "8012f9fffffffffffffc",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(36028797018963967)",
+ Value: vdl.ValueOf(int64(36028797018963967)),
+ Hex: "8012f9fffffffffffffe",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(72057594037927934)",
+ Value: vdl.ValueOf(int64(72057594037927934)),
+ Hex: "8012f801fffffffffffffc",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(72057594037927935)",
+ Value: vdl.ValueOf(int64(72057594037927935)),
+ Hex: "8012f801fffffffffffffe",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(9223372036854775806)",
+ Value: vdl.ValueOf(int64(9223372036854775806)),
+ Hex: "8012f8fffffffffffffffc",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(9223372036854775807)",
+ Value: vdl.ValueOf(int64(9223372036854775807)),
+ Hex: "8012f8fffffffffffffffe",
+ TypeString: "int64",
+ },
+ {
+ Name: "int16(-1)",
+ Value: vdl.ValueOf(int16(-1)),
+ Hex: "800e01",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-2)",
+ Value: vdl.ValueOf(int16(-2)),
+ Hex: "800e03",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-64)",
+ Value: vdl.ValueOf(int16(-64)),
+ Hex: "800e7f",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-65)",
+ Value: vdl.ValueOf(int16(-65)),
+ Hex: "800eff81",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-128)",
+ Value: vdl.ValueOf(int16(-128)),
+ Hex: "800effff",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-129)",
+ Value: vdl.ValueOf(int16(-129)),
+ Hex: "800efe0101",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-256)",
+ Value: vdl.ValueOf(int16(-256)),
+ Hex: "800efe01ff",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-257)",
+ Value: vdl.ValueOf(int16(-257)),
+ Hex: "800efe0201",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-32767)",
+ Value: vdl.ValueOf(int16(-32767)),
+ Hex: "800efefffd",
+ TypeString: "int16",
+ },
+ {
+ Name: "int16(-32768)",
+ Value: vdl.ValueOf(int16(-32768)),
+ Hex: "800efeffff",
+ TypeString: "int16",
+ },
+ {
+ Name: "int32(-8388607)",
+ Value: vdl.ValueOf(int32(-8388607)),
+ Hex: "8010fdfffffd",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(-8388608)",
+ Value: vdl.ValueOf(int32(-8388608)),
+ Hex: "8010fdffffff",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(-16777215)",
+ Value: vdl.ValueOf(int32(-16777215)),
+ Hex: "8010fc01fffffd",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(-16777216)",
+ Value: vdl.ValueOf(int32(-16777216)),
+ Hex: "8010fc01ffffff",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(-2147483647)",
+ Value: vdl.ValueOf(int32(-2147483647)),
+ Hex: "8010fcfffffffd",
+ TypeString: "int32",
+ },
+ {
+ Name: "int32(-2147483648)",
+ Value: vdl.ValueOf(int32(-2147483648)),
+ Hex: "8010fcffffffff",
+ TypeString: "int32",
+ },
+ {
+ Name: "int64(-1)",
+ Value: vdl.ValueOf(int64(-1)),
+ Hex: "801201",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-2)",
+ Value: vdl.ValueOf(int64(-2)),
+ Hex: "801203",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-549755813887)",
+ Value: vdl.ValueOf(int64(-549755813887)),
+ Hex: "8012fbfffffffffd",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-549755813888)",
+ Value: vdl.ValueOf(int64(-549755813888)),
+ Hex: "8012fbffffffffff",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-1099511627775)",
+ Value: vdl.ValueOf(int64(-1099511627775)),
+ Hex: "8012fa01fffffffffd",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-1099511627776)",
+ Value: vdl.ValueOf(int64(-1099511627776)),
+ Hex: "8012fa01ffffffffff",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-140737488355327)",
+ Value: vdl.ValueOf(int64(-140737488355327)),
+ Hex: "8012fafffffffffffd",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-140737488355328)",
+ Value: vdl.ValueOf(int64(-140737488355328)),
+ Hex: "8012faffffffffffff",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-281474976710655)",
+ Value: vdl.ValueOf(int64(-281474976710655)),
+ Hex: "8012f901fffffffffffd",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-281474976710656)",
+ Value: vdl.ValueOf(int64(-281474976710656)),
+ Hex: "8012f901ffffffffffff",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-36028797018963967)",
+ Value: vdl.ValueOf(int64(-36028797018963967)),
+ Hex: "8012f9fffffffffffffd",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-36028797018963968)",
+ Value: vdl.ValueOf(int64(-36028797018963968)),
+ Hex: "8012f9ffffffffffffff",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-72057594037927935)",
+ Value: vdl.ValueOf(int64(-72057594037927935)),
+ Hex: "8012f801fffffffffffffd",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-72057594037927936)",
+ Value: vdl.ValueOf(int64(-72057594037927936)),
+ Hex: "8012f801ffffffffffffff",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-9223372036854775807)",
+ Value: vdl.ValueOf(int64(-9223372036854775807)),
+ Hex: "8012f8fffffffffffffffd",
+ TypeString: "int64",
+ },
+ {
+ Name: "int64(-9223372036854775808)",
+ Value: vdl.ValueOf(int64(-9223372036854775808)),
+ Hex: "8012f8ffffffffffffffff",
+ TypeString: "int64",
+ },
+ {
+ Name: "float32(0)",
+ Value: vdl.ValueOf(float32(0)),
+ Hex: "801400",
+ TypeString: "float32",
+ },
+ {
+ Name: "float32(32.5)",
+ Value: vdl.ValueOf(float32(32.5)),
+ Hex: "8014fd404040",
+ TypeString: "float32",
+ },
+ {
+ Name: "float32(-32.5)",
+ Value: vdl.ValueOf(float32(-32.5)),
+ Hex: "8014fd4040c0",
+ TypeString: "float32",
+ },
+ {
+ Name: "float64(0)",
+ Value: vdl.ValueOf(float64(0)),
+ Hex: "801600",
+ TypeString: "float64",
+ },
+ {
+ Name: "float64(64.5)",
+ Value: vdl.ValueOf(float64(64.5)),
+ Hex: "8016fd205040",
+ TypeString: "float64",
+ },
+ {
+ Name: "float64(-64.5)",
+ Value: vdl.ValueOf(float64(-64.5)),
+ Hex: "8016fd2050c0",
+ TypeString: "float64",
+ },
+ {
+ Name: "complex64(0)",
+ Value: vdl.ValueOf(complex64(0)),
+ Hex: "8018020000",
+ TypeString: "complex64",
+ },
+ {
+ Name: "complex64(64.5+64.5i)",
+ Value: vdl.ValueOf(complex64(64.5 + 64.5i)),
+ Hex: "801808fd205040fd205040",
+ TypeString: "complex64",
+ },
+ {
+ Name: "complex64(64.5-64.5i)",
+ Value: vdl.ValueOf(complex64(64.5 - 64.5i)),
+ Hex: "801808fd205040fd2050c0",
+ TypeString: "complex64",
+ },
+ {
+ Name: "complex128(0)",
+ Value: vdl.ValueOf(complex128(0)),
+ Hex: "801a020000",
+ TypeString: "complex128",
+ },
+ {
+ Name: "complex128(128.5+128.5i)",
+ Value: vdl.ValueOf(complex128(128.5 + 128.5i)),
+ Hex: "801a08fd106040fd106040",
+ TypeString: "complex128",
+ },
+ {
+ Name: "complex128(128.5-128.5i)",
+ Value: vdl.ValueOf(complex128(128.5 - 128.5i)),
+ Hex: "801a08fd106040fd1060c0",
+ TypeString: "complex128",
+ },
+ {
+ Name: "NBool(true)",
+ Value: vdl.ValueOf(NBool(true)),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e15201",
+ TypeString: "v.io/v23/vom/testdata.NBool bool",
+ },
+ {
+ Name: "NBool(false)",
+ Value: vdl.ValueOf(NBool(false)),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e15200",
+ TypeString: "v.io/v23/vom/testdata.NBool bool",
+ },
+ {
+ Name: "NString(\"\")",
+ Value: vdl.ValueOf(NString("")),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e537472696e670103e15200",
+ TypeString: "v.io/v23/vom/testdata.NString string",
+ },
+ {
+ Name: "NString(\"abc\")",
+ Value: vdl.ValueOf(NString("abc")),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e537472696e670103e15203616263",
+ TypeString: "v.io/v23/vom/testdata.NString string",
+ },
+ {
+ Name: "NByteSlice(\"\")",
+ Value: vdl.ValueOf(NByteSlice(nil)),
+ Hex: "805126030020762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c6963650102e15200",
+ TypeString: "v.io/v23/vom/testdata.NByteSlice []byte",
+ },
+ {
+ Name: "NByteSlice(\"\\x01\\x02\\x03\")",
+ Value: vdl.ValueOf(NByteSlice("\x01\x02\x03")),
+ Hex: "805126030020762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c6963650102e15203010203",
+ TypeString: "v.io/v23/vom/testdata.NByteSlice []byte",
+ },
+ {
+ Name: "NByteSlice(\"abc\")",
+ Value: vdl.ValueOf(NByteSlice("abc")),
+ Hex: "805126030020762e696f2f7632332f766f6d2f74657374646174612e4e42797465536c6963650102e15203616263",
+ TypeString: "v.io/v23/vom/testdata.NByteSlice []byte",
+ },
+ {
+ Name: "NByteArray(\"\\x00\\x00\\x00\\x00\")",
+ Value: vdl.ValueOf(NByteArray{}),
+ Hex: "805128020020762e696f2f7632332f766f6d2f74657374646174612e4e42797465417272617901020204e1520000000000",
+ TypeString: "v.io/v23/vom/testdata.NByteArray [4]byte",
+ },
+ {
+ Name: "NByteArray(\"\\x01\\x02\\x03\\x00\")",
+ Value: vdl.ValueOf(NByteArray{
+ 1,
+ 2,
+ 3,
+ 0,
+ }),
+ Hex: "805128020020762e696f2f7632332f766f6d2f74657374646174612e4e42797465417272617901020204e1520001020300",
+ TypeString: "v.io/v23/vom/testdata.NByteArray [4]byte",
+ },
+ {
+ Name: "NByteArray(\"abcd\")",
+ Value: vdl.ValueOf(NByteArray{
+ 97,
+ 98,
+ 99,
+ 100,
+ }),
+ Hex: "805128020020762e696f2f7632332f766f6d2f74657374646174612e4e42797465417272617901020204e1520061626364",
+ TypeString: "v.io/v23/vom/testdata.NByteArray [4]byte",
+ },
+ {
+ Name: "NByte(0)",
+ Value: vdl.ValueOf(NByte(0)),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e427974650102e15200",
+ TypeString: "v.io/v23/vom/testdata.NByte byte",
+ },
+ {
+ Name: "NByte(127)",
+ Value: vdl.ValueOf(NByte(127)),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e427974650102e1527f",
+ TypeString: "v.io/v23/vom/testdata.NByte byte",
+ },
+ {
+ Name: "NByte(255)",
+ Value: vdl.ValueOf(NByte(255)),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e427974650102e152ff",
+ TypeString: "v.io/v23/vom/testdata.NByte byte",
+ },
+ {
+ Name: "NUint16(0)",
+ Value: vdl.ValueOf(NUint16(0)),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7431360104e15200",
+ TypeString: "v.io/v23/vom/testdata.NUint16 uint16",
+ },
+ {
+ Name: "NUint16(65535)",
+ Value: vdl.ValueOf(NUint16(65535)),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7431360104e152feffff",
+ TypeString: "v.io/v23/vom/testdata.NUint16 uint16",
+ },
+ {
+ Name: "NUint32(0)",
+ Value: vdl.ValueOf(NUint32(0)),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7433320105e15200",
+ TypeString: "v.io/v23/vom/testdata.NUint32 uint32",
+ },
+ {
+ Name: "NUint32(4294967295)",
+ Value: vdl.ValueOf(NUint32(4294967295)),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7433320105e152fcffffffff",
+ TypeString: "v.io/v23/vom/testdata.NUint32 uint32",
+ },
+ {
+ Name: "NUint64(0)",
+ Value: vdl.ValueOf(NUint64(0)),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7436340106e15200",
+ TypeString: "v.io/v23/vom/testdata.NUint64 uint64",
+ },
+ {
+ Name: "NUint64(18446744073709551615)",
+ Value: vdl.ValueOf(NUint64(18446744073709551615)),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7436340106e152f8ffffffffffffffff",
+ TypeString: "v.io/v23/vom/testdata.NUint64 uint64",
+ },
+ {
+ Name: "NInt16(0)",
+ Value: vdl.ValueOf(NInt16(0)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e15200",
+ TypeString: "v.io/v23/vom/testdata.NInt16 int16",
+ },
+ {
+ Name: "NInt16(32767)",
+ Value: vdl.ValueOf(NInt16(32767)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e152fefffe",
+ TypeString: "v.io/v23/vom/testdata.NInt16 int16",
+ },
+ {
+ Name: "NInt16(-32768)",
+ Value: vdl.ValueOf(NInt16(-32768)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e152feffff",
+ TypeString: "v.io/v23/vom/testdata.NInt16 int16",
+ },
+ {
+ Name: "NInt32(0)",
+ Value: vdl.ValueOf(NInt32(0)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e15200",
+ TypeString: "v.io/v23/vom/testdata.NInt32 int32",
+ },
+ {
+ Name: "NInt32(2147483647)",
+ Value: vdl.ValueOf(NInt32(2147483647)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e152fcfffffffe",
+ TypeString: "v.io/v23/vom/testdata.NInt32 int32",
+ },
+ {
+ Name: "NInt32(-2147483648)",
+ Value: vdl.ValueOf(NInt32(-2147483648)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e152fcffffffff",
+ TypeString: "v.io/v23/vom/testdata.NInt32 int32",
+ },
+ {
+ Name: "NInt64(0)",
+ Value: vdl.ValueOf(NInt64(0)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e15200",
+ TypeString: "v.io/v23/vom/testdata.NInt64 int64",
+ },
+ {
+ Name: "NInt64(9223372036854775807)",
+ Value: vdl.ValueOf(NInt64(9223372036854775807)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e152f8fffffffffffffffe",
+ TypeString: "v.io/v23/vom/testdata.NInt64 int64",
+ },
+ {
+ Name: "NInt64(-9223372036854775808)",
+ Value: vdl.ValueOf(NInt64(-9223372036854775808)),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e152f8ffffffffffffffff",
+ TypeString: "v.io/v23/vom/testdata.NInt64 int64",
+ },
+ {
+ Name: "NFloat32(0)",
+ Value: vdl.ValueOf(NFloat32(0)),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae15200",
+ TypeString: "v.io/v23/vom/testdata.NFloat32 float32",
+ },
+ {
+ Name: "NFloat32(32.5)",
+ Value: vdl.ValueOf(NFloat32(32.5)),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae152fd404040",
+ TypeString: "v.io/v23/vom/testdata.NFloat32 float32",
+ },
+ {
+ Name: "NFloat32(-32.5)",
+ Value: vdl.ValueOf(NFloat32(-32.5)),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae152fd4040c0",
+ TypeString: "v.io/v23/vom/testdata.NFloat32 float32",
+ },
+ {
+ Name: "NFloat64(0)",
+ Value: vdl.ValueOf(NFloat64(0)),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be15200",
+ TypeString: "v.io/v23/vom/testdata.NFloat64 float64",
+ },
+ {
+ Name: "NFloat64(64.5)",
+ Value: vdl.ValueOf(NFloat64(64.5)),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be152fd205040",
+ TypeString: "v.io/v23/vom/testdata.NFloat64 float64",
+ },
+ {
+ Name: "NFloat64(-64.5)",
+ Value: vdl.ValueOf(NFloat64(-64.5)),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be152fd2050c0",
+ TypeString: "v.io/v23/vom/testdata.NFloat64 float64",
+ },
+ {
+ Name: "NComplex64(0)",
+ Value: vdl.ValueOf(NComplex64(0)),
+ Hex: "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce152020000",
+ TypeString: "v.io/v23/vom/testdata.NComplex64 complex64",
+ },
+ {
+ Name: "NComplex64(64.5+64.5i)",
+ Value: vdl.ValueOf(NComplex64(64.5 + 64.5i)),
+ Hex: "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce15208fd205040fd205040",
+ TypeString: "v.io/v23/vom/testdata.NComplex64 complex64",
+ },
+ {
+ Name: "NComplex64(64.5-64.5i)",
+ Value: vdl.ValueOf(NComplex64(64.5 - 64.5i)),
+ Hex: "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce15208fd205040fd2050c0",
+ TypeString: "v.io/v23/vom/testdata.NComplex64 complex64",
+ },
+ {
+ Name: "NComplex128(0)",
+ Value: vdl.ValueOf(NComplex128(0)),
+ Hex: "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de152020000",
+ TypeString: "v.io/v23/vom/testdata.NComplex128 complex128",
+ },
+ {
+ Name: "NComplex128(128.5+128.5i)",
+ Value: vdl.ValueOf(NComplex128(128.5 + 128.5i)),
+ Hex: "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de15208fd106040fd106040",
+ TypeString: "v.io/v23/vom/testdata.NComplex128 complex128",
+ },
+ {
+ Name: "NComplex128(128.5-128.5i)",
+ Value: vdl.ValueOf(NComplex128(128.5 - 128.5i)),
+ Hex: "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de15208fd106040fd1060c0",
+ TypeString: "v.io/v23/vom/testdata.NComplex128 complex128",
+ },
+ {
+ Name: "NArray2Uint64{1, 2}",
+ Value: vdl.ValueOf(NArray2Uint64{
+ 1,
+ 2,
+ }),
+ Hex: "80512b020023762e696f2f7632332f766f6d2f74657374646174612e4e41727261793255696e74363401060202e15203000102",
+ TypeString: "v.io/v23/vom/testdata.NArray2Uint64 [2]uint64",
+ },
+ {
+ Name: "[]uint64{1, 2}",
+ Value: vdl.ValueOf([]uint64{
+ 1,
+ 2,
+ }),
+ Hex: "805104030106e15203020102",
+ TypeString: "[]uint64",
+ },
+ {
+ Name: "NListUint64{1, 2}",
+ Value: vdl.ValueOf(NListUint64{
+ 1,
+ 2,
+ }),
+ Hex: "805127030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e15203020102",
+ TypeString: "v.io/v23/vom/testdata.NListUint64 []uint64",
+ },
+ {
+ Name: "set[uint64]{1}",
+ Value: vdl.ValueOf(map[uint64]struct{}{
+ 1: struct{}{},
+ }),
+ Hex: "805104040106e152020101",
+ TypeString: "set[uint64]",
+ },
+ {
+ Name: "NSetUint64{1}",
+ Value: vdl.ValueOf(NSetUint64{
+ 1: struct{}{},
+ }),
+ Hex: "805126040020762e696f2f7632332f766f6d2f74657374646174612e4e53657455696e7436340106e152020101",
+ TypeString: "v.io/v23/vom/testdata.NSetUint64 set[uint64]",
+ },
+ {
+ Name: "map[uint64]string{1: \"abc\"}",
+ Value: vdl.ValueOf(map[uint64]string{
+ 1: "abc",
+ }),
+ Hex: "8051060501060203e15206010103616263",
+ TypeString: "map[uint64]string",
+ },
+ {
+ Name: "NMapUint64String{1: \"abc\"}",
+ Value: vdl.ValueOf(NMapUint64String{
+ 1: "abc",
+ }),
+ Hex: "80512e050026762e696f2f7632332f766f6d2f74657374646174612e4e4d617055696e743634537472696e6701060203e15206010103616263",
+ TypeString: "v.io/v23/vom/testdata.NMapUint64String map[uint64]string",
+ },
+ {
+ Name: "NStruct{A: true, B: \"abc\", C: 123}",
+ Value: vdl.ValueOf(NStruct{
+ A: true,
+ B: "abc",
+ C: 123,
+ }),
+ Hex: "80513506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1520b0001010361626302fff6e1",
+ TypeString: "v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ {
+ Name: "?NStruct(nil)",
+ Value: vdl.ValueOf((*NStruct)(nil)),
+ Hex: "80533506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1510408012ae15201e0",
+ TypeString: "?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ {
+ Name: "?NStruct{}",
+ Value: vdl.ValueOf(&NStruct{}),
+ Hex: "80533506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1510408012ae15201e1",
+ TypeString: "?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ {
+ Name: "?NStruct{A: true, B: \"abc\", C: 123}",
+ Value: vdl.ValueOf(&NStruct{
+ A: true,
+ B: "abc",
+ C: 123,
+ }),
+ Hex: "80533506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1510408012ae1520b0001010361626302fff6e1",
+ TypeString: "?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64}",
+ },
+ {
+ Name: "NEnum.A",
+ Value: vdl.ValueOf(NEnumA),
+ Hex: "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e15200",
+ TypeString: "v.io/v23/vom/testdata.NEnum enum{A;B;C}",
+ },
+ {
+ Name: "NEnum.B",
+ Value: vdl.ValueOf(NEnumB),
+ Hex: "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e15201",
+ TypeString: "v.io/v23/vom/testdata.NEnum enum{A;B;C}",
+ },
+ {
+ Name: "NEnum.C",
+ Value: vdl.ValueOf(NEnumC),
+ Hex: "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e15202",
+ TypeString: "v.io/v23/vom/testdata.NEnum enum{A;B;C}",
+ },
+ {
+ Name: "NUnion{A: true}",
+ Value: vdl.ValueOf(NUnion(NUnionA{true})),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020001",
+ TypeString: "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ {
+ Name: "NUnion{A: false}",
+ Value: vdl.ValueOf(NUnion(NUnionA{false})),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020000",
+ TypeString: "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ {
+ Name: "NUnion{B: \"\"}",
+ Value: vdl.ValueOf(NUnion(NUnionB{""})),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020100",
+ TypeString: "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ {
+ Name: "NUnion{B: \"abc\"}",
+ Value: vdl.ValueOf(NUnion(NUnionB{"abc"})),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152050103616263",
+ TypeString: "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ {
+ Name: "NUnion{C: 0}",
+ Value: vdl.ValueOf(NUnion(NUnionC{int64(0)})),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e152020200",
+ TypeString: "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ {
+ Name: "NUnion{C: 123}",
+ Value: vdl.ValueOf(NUnion(NUnionC{int64(123)})),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e1520302fff6",
+ TypeString: "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ {
+ Name: "NUnion{C: -123}",
+ Value: vdl.ValueOf(NUnion(NUnionC{int64(-123)})),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e1520302fff5",
+ TypeString: "v.io/v23/vom/testdata.NUnion union{A bool;B string;C int64}",
+ },
+ {
+ Name: "MBool(true)",
+ Value: vdl.ValueOf(MBool(true)),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e15201",
+ TypeString: "v.io/v23/vom/testdata.MBool bool",
+ },
+ {
+ Name: "MBool(false)",
+ Value: vdl.ValueOf(MBool(false)),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e15200",
+ TypeString: "v.io/v23/vom/testdata.MBool bool",
+ },
+ {
+ Name: "MStruct{A: true, B: true, C: true}",
+ Value: vdl.ValueOf(MStruct{
+ A: true,
+ B: true,
+ C: true,
+ E: vdl.AnyType,
+ }),
+ Hex: "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15207000101010201e1",
+ TypeString: "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ {
+ Name: "MStruct{}",
+ Value: vdl.ValueOf(MStruct{
+ E: vdl.AnyType,
+ }),
+ Hex: "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15201e1",
+ TypeString: "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ {
+ Name: "MStruct{D: {}}",
+ Value: vdl.ValueOf(MStruct{
+ D: &NStruct{},
+ E: vdl.AnyType,
+ }),
+ Hex: "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e1520303e1e1",
+ TypeString: "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ {
+ Name: "MStruct{D: {A: true, B: \"abc\", C: 123}}",
+ Value: vdl.ValueOf(MStruct{
+ D: &NStruct{
+ A: true,
+ B: "abc",
+ C: 123,
+ },
+ E: vdl.AnyType,
+ }),
+ Hex: "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e1520d030001010361626302fff6e1e1",
+ TypeString: "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ {
+ Name: "MStruct{F: \"abc\"}",
+ Value: vdl.ValueOf(MStruct{
+ E: vdl.AnyType,
+ F: vdl.ValueOf("abc"),
+ }),
+ Hex: "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15207050303616263e1",
+ TypeString: "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ {
+ Name: "MStruct{F: MBool(true)}",
+ Value: vdl.ValueOf(MStruct{
+ E: vdl.AnyType,
+ F: vdl.ValueOf(MBool(true)),
+ }),
+ Hex: "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15204052b01e1",
+ TypeString: "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ {
+ Name: "MStruct{F: ?NStruct{B: \"abc\"}}",
+ Value: vdl.ValueOf(MStruct{
+ E: vdl.AnyType,
+ F: vdl.ValueOf(&NStruct{
+ B: "abc",
+ }),
+ }),
+ Hex: "80532100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e1552100001b762e696f2f7632332f766f6d2f74657374646174612e4d426f6f6c0101e1593506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e1570408012de1514706001d762e696f2f7632332f766f6d2f74657374646174612e4d53747275637401060001410101e1000142012ae1000143012be1000144012ce1000145010ee1000146010fe1e15209052c0103616263e1e1",
+ TypeString: "v.io/v23/vom/testdata.MStruct struct{A bool;B v.io/v23/vom/testdata.NBool bool;C v.io/v23/vom/testdata.MBool bool;D ?v.io/v23/vom/testdata.NStruct struct{A bool;B string;C int64};E typeobject;F any}",
+ },
+ {
+ Name: "MList{{4, 2}, {}, {99}}",
+ Value: vdl.ValueOf(MList{
+ {
+ 4,
+ 2,
+ },
+ nil,
+ {
+ 99,
+ },
+ }),
+ Hex: "805327030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e1512103001b762e696f2f7632332f766f6d2f74657374646174612e4d4c697374012ae1520703020402000163",
+ TypeString: "v.io/v23/vom/testdata.MList []v.io/v23/vom/testdata.NListUint64 []uint64",
+ },
+ {
+ Name: "MMap{4.5: {2, 3}}",
+ Value: vdl.ValueOf(MMap{
+ 4.5: {
+ 2,
+ 3,
+ },
+ }),
+ Hex: "80532400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae15527030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e1512205001a762e696f2f7632332f766f6d2f74657374646174612e4d4d6170012a022be1520701fe1240020203",
+ TypeString: "v.io/v23/vom/testdata.MMap map[v.io/v23/vom/testdata.NFloat32 float32]v.io/v23/vom/testdata.NListUint64 []uint64",
+ },
+ {
+ Name: "RecA{{}, {{}}}",
+ Value: vdl.ValueOf(RecA{
+ nil,
+ {
+ nil,
+ },
+ }),
+ Hex: "80512003001a762e696f2f7632332f766f6d2f74657374646174612e526563410129e1520402000100",
+ TypeString: "v.io/v23/vom/testdata.RecA []v.io/v23/vom/testdata.RecA",
+ },
+ {
+ Name: "RecX{{}, {{}, {}}}",
+ Value: vdl.ValueOf(RecX{
+ nil,
+ {
+ nil,
+ nil,
+ },
+ }),
+ Hex: "80532003001a762e696f2f7632332f766f6d2f74657374646174612e526563590129e1512003001a762e696f2f7632332f766f6d2f74657374646174612e52656358012ae152050200020000",
+ TypeString: "v.io/v23/vom/testdata.RecX []v.io/v23/vom/testdata.RecY []v.io/v23/vom/testdata.RecX",
+ },
+ {
+ Name: "typeobject(any)",
+ Value: vdl.ValueOf(vdl.AnyType),
+ Hex: "801c0f",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(bool)",
+ Value: vdl.ValueOf(vdl.TypeOf(false)),
+ Hex: "801c01",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(uint16)",
+ Value: vdl.ValueOf(vdl.TypeOf(uint16(0))),
+ Hex: "801c04",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(uint32)",
+ Value: vdl.ValueOf(vdl.TypeOf(uint32(0))),
+ Hex: "801c05",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(uint64)",
+ Value: vdl.ValueOf(vdl.TypeOf(uint64(0))),
+ Hex: "801c06",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(int16)",
+ Value: vdl.ValueOf(vdl.TypeOf(int16(0))),
+ Hex: "801c07",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(int32)",
+ Value: vdl.ValueOf(vdl.TypeOf(int32(0))),
+ Hex: "801c08",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(int64)",
+ Value: vdl.ValueOf(vdl.TypeOf(int64(0))),
+ Hex: "801c09",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(int16)",
+ Value: vdl.ValueOf(vdl.TypeOf(int16(0))),
+ Hex: "801c07",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(int32)",
+ Value: vdl.ValueOf(vdl.TypeOf(int32(0))),
+ Hex: "801c08",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(int64)",
+ Value: vdl.ValueOf(vdl.TypeOf(int64(0))),
+ Hex: "801c09",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(float32)",
+ Value: vdl.ValueOf(vdl.TypeOf(float32(0))),
+ Hex: "801c0a",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(float64)",
+ Value: vdl.ValueOf(vdl.TypeOf(float64(0))),
+ Hex: "801c0b",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(complex64)",
+ Value: vdl.ValueOf(vdl.TypeOf(complex64(0))),
+ Hex: "801c0c",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(complex128)",
+ Value: vdl.ValueOf(vdl.TypeOf(complex128(0))),
+ Hex: "801c0d",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NBool)",
+ Value: vdl.ValueOf(vdl.TypeOf(NBool(false))),
+ Hex: "80512100001b762e696f2f7632332f766f6d2f74657374646174612e4e426f6f6c0101e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NUint16)",
+ Value: vdl.ValueOf(vdl.TypeOf(NUint16(0))),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7431360104e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NUint32)",
+ Value: vdl.ValueOf(vdl.TypeOf(NUint32(0))),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7433320105e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NUint64)",
+ Value: vdl.ValueOf(vdl.TypeOf(NUint64(0))),
+ Hex: "80512300001d762e696f2f7632332f766f6d2f74657374646174612e4e55696e7436340106e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NInt16)",
+ Value: vdl.ValueOf(vdl.TypeOf(NInt16(0))),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7431360107e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NInt32)",
+ Value: vdl.ValueOf(vdl.TypeOf(NInt32(0))),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7433320108e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NInt64)",
+ Value: vdl.ValueOf(vdl.TypeOf(NInt64(0))),
+ Hex: "80512200001c762e696f2f7632332f766f6d2f74657374646174612e4e496e7436340109e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NFloat32)",
+ Value: vdl.ValueOf(vdl.TypeOf(NFloat32(0))),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743332010ae11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NFloat64)",
+ Value: vdl.ValueOf(vdl.TypeOf(NFloat64(0))),
+ Hex: "80512400001e762e696f2f7632332f766f6d2f74657374646174612e4e466c6f61743634010be11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NComplex64)",
+ Value: vdl.ValueOf(vdl.TypeOf(NComplex64(0))),
+ Hex: "805126000020762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c65783634010ce11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NComplex128)",
+ Value: vdl.ValueOf(vdl.TypeOf(NComplex128(0))),
+ Hex: "805127000021762e696f2f7632332f766f6d2f74657374646174612e4e436f6d706c6578313238010de11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NArray2Uint64)",
+ Value: vdl.ValueOf(vdl.TypeOf(NArray2Uint64{})),
+ Hex: "80512b020023762e696f2f7632332f766f6d2f74657374646174612e4e41727261793255696e74363401060202e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject([]uint64)",
+ Value: vdl.ValueOf(vdl.TypeOf([]uint64(nil))),
+ Hex: "805104030106e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NListUint64)",
+ Value: vdl.ValueOf(vdl.TypeOf(NListUint64(nil))),
+ Hex: "805127030021762e696f2f7632332f766f6d2f74657374646174612e4e4c69737455696e7436340106e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(set[uint64])",
+ Value: vdl.ValueOf(vdl.TypeOf(map[uint64]struct{}(nil))),
+ Hex: "805104040106e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NSetUint64)",
+ Value: vdl.ValueOf(vdl.TypeOf(NSetUint64(nil))),
+ Hex: "805126040020762e696f2f7632332f766f6d2f74657374646174612e4e53657455696e7436340106e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(map[uint64]string)",
+ Value: vdl.ValueOf(vdl.TypeOf(map[uint64]string(nil))),
+ Hex: "8051060501060203e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NMapUint64String)",
+ Value: vdl.ValueOf(vdl.TypeOf(NMapUint64String(nil))),
+ Hex: "80512e050026762e696f2f7632332f766f6d2f74657374646174612e4e4d617055696e743634537472696e6701060203e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NStruct)",
+ Value: vdl.ValueOf(vdl.TypeOf(NStruct{})),
+ Hex: "80513506001d762e696f2f7632332f766f6d2f74657374646174612e4e53747275637401030001410101e10001420103e10001430109e1e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NEnum)",
+ Value: vdl.ValueOf(vdl.TypeOf(NEnumA)),
+ Hex: "80512701001b762e696f2f7632332f766f6d2f74657374646174612e4e456e756d0103014101420143e11c29",
+ TypeString: "typeobject",
+ },
+ {
+ Name: "typeobject(NUnion)",
+ Value: vdl.ValueOf(vdl.TypeOf(NUnion(NUnionA{false}))),
+ Hex: "80513407001c762e696f2f7632332f766f6d2f74657374646174612e4e556e696f6e01030001410101e10001420103e10001430109e1e11c29",
+ TypeString: "typeobject",
+ },
+}
+
+// CompatTests contains the testcases to use to test vom type compatibility.
+// CompatTests maps TestName (string) to CompatibleTypeSet ([]typeobject)
+// Each CompatibleTypeSet contains types compatible with each other. However,
+// types from different CompatibleTypeSets are incompatible.
+var CompatTests = map[string][]*vdl.Type{
+ "bool": {
+ vdl.TypeOf(false),
+ vdl.TypeOf(NBool(false)),
+ vdl.TypeOf(MBool(false)),
+ },
+ "map[X]bool/set[X]": {
+ vdl.TypeOf(SetOnlyMap(nil)),
+ vdl.TypeOf(MapOnlySet(nil)),
+ },
+ "map[string]X/struct": {
+ vdl.TypeOf(MapOnlyStruct{}),
+ vdl.TypeOf(StructOnlyMap(nil)),
+ },
+ "map[string]bool/set[string]/struct": {
+ vdl.TypeOf(MapSetStruct{}),
+ vdl.TypeOf(SetStructMap(nil)),
+ vdl.TypeOf(MapStructSet(nil)),
+ },
+ "number list/array": {
+ vdl.TypeOf([]int32(nil)),
+ vdl.TypeOf(NArray2Uint64{}),
+ vdl.TypeOf(NListUint64(nil)),
+ },
+ "number": {
+ vdl.TypeOf(uint16(0)),
+ vdl.TypeOf(uint32(0)),
+ vdl.TypeOf(uint64(0)),
+ vdl.TypeOf(int16(0)),
+ vdl.TypeOf(int32(0)),
+ vdl.TypeOf(int64(0)),
+ vdl.TypeOf(float32(0)),
+ vdl.TypeOf(float64(0)),
+ vdl.TypeOf(complex64(0)),
+ vdl.TypeOf(complex128(0)),
+ vdl.TypeOf(NUint16(0)),
+ vdl.TypeOf(NUint32(0)),
+ vdl.TypeOf(NUint64(0)),
+ vdl.TypeOf(NInt16(0)),
+ vdl.TypeOf(NInt32(0)),
+ vdl.TypeOf(NInt64(0)),
+ vdl.TypeOf(NFloat32(0)),
+ vdl.TypeOf(NFloat64(0)),
+ vdl.TypeOf(NComplex64(0)),
+ vdl.TypeOf(NComplex128(0)),
+ },
+ "string list/array": {
+ vdl.TypeOf([]string(nil)),
+ vdl.TypeOf(ListString(nil)),
+ vdl.TypeOf(Array3String{}),
+ },
+ "string/[]byte/enum": {
+ vdl.TypeOf(""),
+ vdl.TypeOf(NString("")),
+ vdl.TypeOf([]byte(nil)),
+ vdl.TypeOf(NByteSlice(nil)),
+ vdl.TypeOf(NByteArray{}),
+ vdl.TypeOf(NEnumA),
+ },
+ "struct A": {
+ vdl.TypeOf(NStruct{}),
+ vdl.TypeOf(ABCStruct{}),
+ vdl.TypeOf(ADEStruct{
+ E: vdl.AnyType,
+ }),
+ },
+ "struct Z": {
+ vdl.TypeOf(XYZStruct{}),
+ vdl.TypeOf(YZStruct{}),
+ vdl.TypeOf(ZStruct{}),
+ },
+ "typeobject": {
+ vdl.TypeObjectType,
+ },
+ "union B": {
+ vdl.TypeOf(NUnion(NUnionA{false})),
+ vdl.TypeOf(BDEunion(BDEunionB{""})),
+ },
+}
+
+// ConvertTests contains the testcases to check vom value convertibility.
+// ConvertTests maps TestName (string) to ConvertGroups ([]ConvertGroup)
+// Each ConvertGroup is a struct with 'Name', 'PrimaryType', and 'Values'.
+// The values within a ConvertGroup can convert between themselves w/o error.
+// However, values in higher-indexed ConvertGroups will error when converting up
+// to the primary type of the lower-indexed ConvertGroups.
+var ConvertTests = map[string][]ConvertGroup{
+ "number": {
+ {
+ Name: "byte",
+ PrimaryType: vdl.TypeOf(byte(0)),
+ Values: []*vdl.Value{
+ vdl.ValueOf(byte(3)),
+ vdl.ValueOf(uint16(3)),
+ vdl.ValueOf(int32(3)),
+ vdl.ValueOf(float64(3)),
+ vdl.ValueOf(int64(3)),
+ vdl.ValueOf(complex128(3)),
+ },
+ },
+ {
+ Name: "uint16",
+ PrimaryType: vdl.TypeOf(uint16(0)),
+ Values: []*vdl.Value{
+ vdl.ValueOf(uint16(256)),
+ vdl.ValueOf(int32(256)),
+ vdl.ValueOf(float64(256)),
+ vdl.ValueOf(int64(256)),
+ vdl.ValueOf(complex128(256)),
+ },
+ },
+ {
+ Name: "int32",
+ PrimaryType: vdl.TypeOf(int32(0)),
+ Values: []*vdl.Value{
+ vdl.ValueOf(int32(-5)),
+ vdl.ValueOf(float64(-5)),
+ vdl.ValueOf(int64(-5)),
+ vdl.ValueOf(complex128(-5)),
+ },
+ },
+ {
+ Name: "float64",
+ PrimaryType: vdl.TypeOf(float64(0)),
+ Values: []*vdl.Value{
+ vdl.ValueOf(float64(3.3)),
+ vdl.ValueOf(complex128(3.3)),
+ },
+ },
+ {
+ Name: "int64",
+ PrimaryType: vdl.TypeOf(int64(0)),
+ Values: []*vdl.Value{
+ vdl.ValueOf(int64(-9223372036854775808)),
+ },
+ },
+ {
+ Name: "complex128",
+ PrimaryType: vdl.TypeOf(complex128(0)),
+ Values: []*vdl.Value{
+ vdl.ValueOf(complex128(1.5 - 1i)),
+ },
+ },
+ },
+}
diff --git a/lib/vom/testdata/vomtype.vdl b/lib/vom/testdata/vomtype.vdl
new file mode 100644
index 0000000..e615e02
--- /dev/null
+++ b/lib/vom/testdata/vomtype.vdl
@@ -0,0 +1,106 @@
+package testdata
+
+type (
+ // vomdata config types
+ ConvertGroup struct{ Name string; PrimaryType typeobject; Values []any }
+ VomdataStruct struct{
+ EncodeDecodeData []any
+ CompatData map[string][]typeobject
+ ConvertData map[string][]ConvertGroup
+ }
+
+ // Named Types
+ NBool bool
+ NString string
+ NByteSlice []byte
+ NByteArray [4]byte
+ NByte byte
+ NUint16 uint16
+ NUint32 uint32
+ NUint64 uint64
+ NInt16 int16
+ NInt32 int32
+ NInt64 int64
+ NFloat32 float32
+ NFloat64 float64
+ NComplex64 complex64
+ NComplex128 complex128
+
+ NArray2Uint64 [2]uint64
+ NListUint64 []uint64
+ NSetUint64 set[uint64]
+ NMapUint64String map[uint64]string
+
+ NStruct struct {
+ A bool
+ B string
+ C int64
+ }
+
+ NEnum enum{ A; B; C }
+ NUnion union{ A bool; B string; C int64 }
+
+ // Nested Custom Types
+ MBool NBool
+ MStruct struct {
+ A bool
+ B NBool
+ C MBool
+ D ?NStruct
+ E typeobject
+ F any
+ }
+ MList []NListUint64
+ MMap map[NFloat32]NListUint64
+
+ // Recursive Type Definitions
+ RecA []RecA
+ RecX []RecY
+ RecY []RecX
+
+ // Additional types for compatibility and conversion checks
+ ListString []string
+ Array3String [3]string
+
+ ABCStruct struct {
+ A bool
+ B string
+ C int64
+ }
+ ADEStruct struct {
+ A bool
+ D any
+ E typeobject
+ }
+
+ XYZStruct struct {
+ X bool
+ Y any
+ Z string
+ }
+ YZStruct struct {
+ Y NBool
+ Z NString
+ }
+ ZStruct struct {
+ Z string
+ }
+
+ MapOnlyStruct struct {
+ Key1 int64
+ Key2 uint32
+ Key3 complex128
+ }
+ StructOnlyMap map[string]uint64
+
+ MapSetStruct struct {
+ Key bool
+ }
+ SetStructMap map[string]bool
+ MapStructSet set[string]
+
+ SetOnlyMap map[int64]bool
+ MapOnlySet set[uint16]
+
+ BDEunion union{ B string; D any; E typeobject }
+)
diff --git a/lib/vom/testdata/vomtype.vdl.go b/lib/vom/testdata/vomtype.vdl.go
new file mode 100644
index 0000000..976a9a4
--- /dev/null
+++ b/lib/vom/testdata/vomtype.vdl.go
@@ -0,0 +1,550 @@
+// This file was auto-generated by the veyron vdl tool.
+// Source: vomtype.vdl
+
+package testdata
+
+import (
+ // VDL system imports
+ "fmt"
+ "v.io/v23/vdl"
+)
+
+// vomdata config types
+type ConvertGroup struct {
+ Name string
+ PrimaryType *vdl.Type
+ Values []*vdl.Value
+}
+
+func (ConvertGroup) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.ConvertGroup"
+}) {
+}
+
+type VomdataStruct struct {
+ EncodeDecodeData []*vdl.Value
+ CompatData map[string][]*vdl.Type
+ ConvertData map[string][]ConvertGroup
+}
+
+func (VomdataStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.VomdataStruct"
+}) {
+}
+
+// Named Types
+type NBool bool
+
+func (NBool) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NBool"
+}) {
+}
+
+type NString string
+
+func (NString) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NString"
+}) {
+}
+
+type NByteSlice []byte
+
+func (NByteSlice) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NByteSlice"
+}) {
+}
+
+type NByteArray [4]byte
+
+func (NByteArray) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NByteArray"
+}) {
+}
+
+type NByte byte
+
+func (NByte) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NByte"
+}) {
+}
+
+type NUint16 uint16
+
+func (NUint16) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NUint16"
+}) {
+}
+
+type NUint32 uint32
+
+func (NUint32) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NUint32"
+}) {
+}
+
+type NUint64 uint64
+
+func (NUint64) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NUint64"
+}) {
+}
+
+type NInt16 int16
+
+func (NInt16) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NInt16"
+}) {
+}
+
+type NInt32 int32
+
+func (NInt32) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NInt32"
+}) {
+}
+
+type NInt64 int64
+
+func (NInt64) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NInt64"
+}) {
+}
+
+type NFloat32 float32
+
+func (NFloat32) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NFloat32"
+}) {
+}
+
+type NFloat64 float64
+
+func (NFloat64) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NFloat64"
+}) {
+}
+
+type NComplex64 complex64
+
+func (NComplex64) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NComplex64"
+}) {
+}
+
+type NComplex128 complex128
+
+func (NComplex128) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NComplex128"
+}) {
+}
+
+type NArray2Uint64 [2]uint64
+
+func (NArray2Uint64) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NArray2Uint64"
+}) {
+}
+
+type NListUint64 []uint64
+
+func (NListUint64) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NListUint64"
+}) {
+}
+
+type NSetUint64 map[uint64]struct{}
+
+func (NSetUint64) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NSetUint64"
+}) {
+}
+
+type NMapUint64String map[uint64]string
+
+func (NMapUint64String) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NMapUint64String"
+}) {
+}
+
+type NStruct struct {
+ A bool
+ B string
+ C int64
+}
+
+func (NStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NStruct"
+}) {
+}
+
+type NEnum int
+
+const (
+ NEnumA NEnum = iota
+ NEnumB
+ NEnumC
+)
+
+// NEnumAll holds all labels for NEnum.
+var NEnumAll = []NEnum{NEnumA, NEnumB, NEnumC}
+
+// NEnumFromString creates a NEnum from a string label.
+func NEnumFromString(label string) (x NEnum, err error) {
+ err = x.Set(label)
+ return
+}
+
+// Set assigns label to x.
+func (x *NEnum) Set(label string) error {
+ switch label {
+ case "A", "a":
+ *x = NEnumA
+ return nil
+ case "B", "b":
+ *x = NEnumB
+ return nil
+ case "C", "c":
+ *x = NEnumC
+ return nil
+ }
+ *x = -1
+ return fmt.Errorf("unknown label %q in testdata.NEnum", label)
+}
+
+// String returns the string label of x.
+func (x NEnum) String() string {
+ switch x {
+ case NEnumA:
+ return "A"
+ case NEnumB:
+ return "B"
+ case NEnumC:
+ return "C"
+ }
+ return ""
+}
+
+func (NEnum) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.NEnum"
+ Enum struct{ A, B, C string }
+}) {
+}
+
+type (
+ // NUnion represents any single field of the NUnion union type.
+ NUnion interface {
+ // Index returns the field index.
+ Index() int
+ // Interface returns the field value as an interface.
+ Interface() interface{}
+ // Name returns the field name.
+ Name() string
+ // __VDLReflect describes the NUnion union type.
+ __VDLReflect(__NUnionReflect)
+ }
+ // NUnionA represents field A of the NUnion union type.
+ NUnionA struct{ Value bool }
+ // NUnionB represents field B of the NUnion union type.
+ NUnionB struct{ Value string }
+ // NUnionC represents field C of the NUnion union type.
+ NUnionC struct{ Value int64 }
+ // __NUnionReflect describes the NUnion union type.
+ __NUnionReflect struct {
+ Name string "v.io/v23/vom/testdata.NUnion"
+ Type NUnion
+ Union struct {
+ A NUnionA
+ B NUnionB
+ C NUnionC
+ }
+ }
+)
+
+func (x NUnionA) Index() int { return 0 }
+func (x NUnionA) Interface() interface{} { return x.Value }
+func (x NUnionA) Name() string { return "A" }
+func (x NUnionA) __VDLReflect(__NUnionReflect) {}
+
+func (x NUnionB) Index() int { return 1 }
+func (x NUnionB) Interface() interface{} { return x.Value }
+func (x NUnionB) Name() string { return "B" }
+func (x NUnionB) __VDLReflect(__NUnionReflect) {}
+
+func (x NUnionC) Index() int { return 2 }
+func (x NUnionC) Interface() interface{} { return x.Value }
+func (x NUnionC) Name() string { return "C" }
+func (x NUnionC) __VDLReflect(__NUnionReflect) {}
+
+// Nested Custom Types
+type MBool NBool
+
+func (MBool) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MBool"
+}) {
+}
+
+type MStruct struct {
+ A bool
+ B NBool
+ C MBool
+ D *NStruct
+ E *vdl.Type
+ F *vdl.Value
+}
+
+func (MStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MStruct"
+}) {
+}
+
+type MList []NListUint64
+
+func (MList) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MList"
+}) {
+}
+
+type MMap map[NFloat32]NListUint64
+
+func (MMap) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MMap"
+}) {
+}
+
+// Recursive Type Definitions
+type RecA []RecA
+
+func (RecA) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.RecA"
+}) {
+}
+
+type RecX []RecY
+
+func (RecX) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.RecX"
+}) {
+}
+
+type RecY []RecX
+
+func (RecY) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.RecY"
+}) {
+}
+
+// Additional types for compatibility and conversion checks
+type ListString []string
+
+func (ListString) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.ListString"
+}) {
+}
+
+type Array3String [3]string
+
+func (Array3String) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.Array3String"
+}) {
+}
+
+type ABCStruct struct {
+ A bool
+ B string
+ C int64
+}
+
+func (ABCStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.ABCStruct"
+}) {
+}
+
+type ADEStruct struct {
+ A bool
+ D *vdl.Value
+ E *vdl.Type
+}
+
+func (ADEStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.ADEStruct"
+}) {
+}
+
+type XYZStruct struct {
+ X bool
+ Y *vdl.Value
+ Z string
+}
+
+func (XYZStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.XYZStruct"
+}) {
+}
+
+type YZStruct struct {
+ Y NBool
+ Z NString
+}
+
+func (YZStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.YZStruct"
+}) {
+}
+
+type ZStruct struct {
+ Z string
+}
+
+func (ZStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.ZStruct"
+}) {
+}
+
+type MapOnlyStruct struct {
+ Key1 int64
+ Key2 uint32
+ Key3 complex128
+}
+
+func (MapOnlyStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MapOnlyStruct"
+}) {
+}
+
+type StructOnlyMap map[string]uint64
+
+func (StructOnlyMap) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.StructOnlyMap"
+}) {
+}
+
+type MapSetStruct struct {
+ Key bool
+}
+
+func (MapSetStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MapSetStruct"
+}) {
+}
+
+type SetStructMap map[string]bool
+
+func (SetStructMap) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.SetStructMap"
+}) {
+}
+
+type MapStructSet map[string]struct{}
+
+func (MapStructSet) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MapStructSet"
+}) {
+}
+
+type SetOnlyMap map[int64]bool
+
+func (SetOnlyMap) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.SetOnlyMap"
+}) {
+}
+
+type MapOnlySet map[uint16]struct{}
+
+func (MapOnlySet) __VDLReflect(struct {
+ Name string "v.io/v23/vom/testdata.MapOnlySet"
+}) {
+}
+
+type (
+ // BDEunion represents any single field of the BDEunion union type.
+ BDEunion interface {
+ // Index returns the field index.
+ Index() int
+ // Interface returns the field value as an interface.
+ Interface() interface{}
+ // Name returns the field name.
+ Name() string
+ // __VDLReflect describes the BDEunion union type.
+ __VDLReflect(__BDEunionReflect)
+ }
+ // BDEunionB represents field B of the BDEunion union type.
+ BDEunionB struct{ Value string }
+ // BDEunionD represents field D of the BDEunion union type.
+ BDEunionD struct{ Value *vdl.Value }
+ // BDEunionE represents field E of the BDEunion union type.
+ BDEunionE struct{ Value *vdl.Type }
+ // __BDEunionReflect describes the BDEunion union type.
+ __BDEunionReflect struct {
+ Name string "v.io/v23/vom/testdata.BDEunion"
+ Type BDEunion
+ Union struct {
+ B BDEunionB
+ D BDEunionD
+ E BDEunionE
+ }
+ }
+)
+
+func (x BDEunionB) Index() int { return 0 }
+func (x BDEunionB) Interface() interface{} { return x.Value }
+func (x BDEunionB) Name() string { return "B" }
+func (x BDEunionB) __VDLReflect(__BDEunionReflect) {}
+
+func (x BDEunionD) Index() int { return 1 }
+func (x BDEunionD) Interface() interface{} { return x.Value }
+func (x BDEunionD) Name() string { return "D" }
+func (x BDEunionD) __VDLReflect(__BDEunionReflect) {}
+
+func (x BDEunionE) Index() int { return 2 }
+func (x BDEunionE) Interface() interface{} { return x.Value }
+func (x BDEunionE) Name() string { return "E" }
+func (x BDEunionE) __VDLReflect(__BDEunionReflect) {}
+
+func init() {
+ vdl.Register((*ConvertGroup)(nil))
+ vdl.Register((*VomdataStruct)(nil))
+ vdl.Register((*NBool)(nil))
+ vdl.Register((*NString)(nil))
+ vdl.Register((*NByteSlice)(nil))
+ vdl.Register((*NByteArray)(nil))
+ vdl.Register((*NByte)(nil))
+ vdl.Register((*NUint16)(nil))
+ vdl.Register((*NUint32)(nil))
+ vdl.Register((*NUint64)(nil))
+ vdl.Register((*NInt16)(nil))
+ vdl.Register((*NInt32)(nil))
+ vdl.Register((*NInt64)(nil))
+ vdl.Register((*NFloat32)(nil))
+ vdl.Register((*NFloat64)(nil))
+ vdl.Register((*NComplex64)(nil))
+ vdl.Register((*NComplex128)(nil))
+ vdl.Register((*NArray2Uint64)(nil))
+ vdl.Register((*NListUint64)(nil))
+ vdl.Register((*NSetUint64)(nil))
+ vdl.Register((*NMapUint64String)(nil))
+ vdl.Register((*NStruct)(nil))
+ vdl.Register((*NEnum)(nil))
+ vdl.Register((*NUnion)(nil))
+ vdl.Register((*MBool)(nil))
+ vdl.Register((*MStruct)(nil))
+ vdl.Register((*MList)(nil))
+ vdl.Register((*MMap)(nil))
+ vdl.Register((*RecA)(nil))
+ vdl.Register((*RecX)(nil))
+ vdl.Register((*RecY)(nil))
+ vdl.Register((*ListString)(nil))
+ vdl.Register((*Array3String)(nil))
+ vdl.Register((*ABCStruct)(nil))
+ vdl.Register((*ADEStruct)(nil))
+ vdl.Register((*XYZStruct)(nil))
+ vdl.Register((*YZStruct)(nil))
+ vdl.Register((*ZStruct)(nil))
+ vdl.Register((*MapOnlyStruct)(nil))
+ vdl.Register((*StructOnlyMap)(nil))
+ vdl.Register((*MapSetStruct)(nil))
+ vdl.Register((*SetStructMap)(nil))
+ vdl.Register((*MapStructSet)(nil))
+ vdl.Register((*SetOnlyMap)(nil))
+ vdl.Register((*MapOnlySet)(nil))
+ vdl.Register((*BDEunion)(nil))
+}
diff --git a/lib/vom/testutil_test.go b/lib/vom/testutil_test.go
new file mode 100644
index 0000000..1ab3bb0
--- /dev/null
+++ b/lib/vom/testutil_test.go
@@ -0,0 +1,252 @@
+package vom
+
+import (
+ "fmt"
+ "io"
+ "reflect"
+ "strings"
+ "testing"
+ "testing/iotest"
+
+ "v.io/v23/vdl"
+)
+
+// readMode ensures the decoder handles short reads and different EOF semantics.
+type readMode int
+
+const (
+ readAll readMode = iota // Read fills all data, EOF after final data
+ readHalf // Read fills half data, EOF after final data
+ readOneByte // Read fills one byte, EOF after final data
+ readAllEOF // Read fills all data, EOF with final data
+ readHalfEOF // Read fills half data, EOF with final data
+ readOneByteEOF // Read fills one byte, EOF with final data
+)
+
+var allReadModes = [...]readMode{readAll, readHalf, readOneByte, readAllEOF, readHalfEOF, readOneByteEOF}
+
+func (m readMode) String() string {
+ switch m {
+ case readAll:
+ return "readAll"
+ case readHalf:
+ return "readHalf"
+ case readOneByte:
+ return "readOneByte"
+ case readAllEOF:
+ return "readAllEOF"
+ case readHalfEOF:
+ return "readHalfEOF"
+ case readOneByteEOF:
+ return "readOneByteEOF"
+ default:
+ panic(fmt.Errorf("unknown readMode %d", m))
+ }
+}
+
+func (m readMode) testReader(r io.Reader) io.Reader {
+ switch m {
+ case readAll:
+ return r
+ case readHalf:
+ return iotest.HalfReader(r)
+ case readOneByte:
+ return iotest.OneByteReader(r)
+ case readAllEOF:
+ return iotest.DataErrReader(r)
+ case readHalfEOF:
+ return iotest.DataErrReader(iotest.HalfReader(r))
+ case readOneByteEOF:
+ return iotest.DataErrReader(iotest.OneByteReader(r))
+ default:
+ panic(fmt.Errorf("unknown readMode %d", m))
+ }
+}
+
+// abcReader returns data looping from a-z, up to lim bytes.
+func abcReader(lim int) io.Reader {
+ return &abcRead{lim: lim}
+}
+
+type abcRead struct {
+ n, lim int
+}
+
+func (abc *abcRead) Read(p []byte) (int, error) {
+ if abc.n >= abc.lim {
+ return 0, io.EOF
+ }
+ startlen := len(p)
+ for ; len(p) > 0 && abc.n < abc.lim; abc.n++ {
+ p[0] = byte('a' + (abc.n % 26))
+ p = p[1:]
+ }
+ return startlen - len(p), nil
+}
+
+// matchHexPat compares the given target and pat hex codes, and returns true if
+// they match. We allow special syntax in the pat code; in addition to regular
+// string matching, we allow sequences that may appear in any order.
+// E.g. "1122[33,44]55" means that 33 and 44 are a sequence that may appear in
+// any order, so either "1122334455" or "1122443355" are accepted.
+//
+// We allow this special syntax since parts of the encoding aren't
+// deterministic; e.g. Go maps are unordered.
+func matchHexPat(target, pat string) (bool, error) {
+ orig := pat
+ for pat != "" {
+ start := strings.IndexRune(pat, '[')
+ // If there isn't a start token, just compare the full strings.
+ if start == -1 {
+ return target == pat, nil
+ }
+ // Compare everything up to the start token.
+ if !strings.HasPrefix(target, pat[:start]) {
+ return false, nil
+ }
+ // Now compare all permutations of the sequence until we find a match.
+ pat = pat[start+1:] // remove '[' too
+ target = target[start:]
+ end := strings.IndexRune(pat, ']')
+ if end == -1 {
+ return false, fmt.Errorf("Malformed hex pattern, no closing ] in %q", orig)
+ }
+ seqs := strings.Split(pat[:end], ",")
+ if !matchPrefixSeq(target, seqs) {
+ return false, nil
+ }
+ // Found a match, move past this sequence. An example of our state:
+ // pat="11,22]3344" target="22113344" end_seq=5
+ // We need to remove everything up to and including "]" from pat, and
+ // remove the matched sequence length from target, so that we get:
+ // pat="3344" target="3344"
+ pat = pat[end+1:]
+ target = target[end-len(seqs)+1:]
+ }
+ return target == "", nil
+}
+
+// matchPrefixSeq is a recursive function that returns true iff a prefix of the
+// target string matches any permutation of the seqs strings.
+func matchPrefixSeq(target string, seqs []string) bool {
+ if len(seqs) == 0 {
+ return true
+ }
+ for ix, seq := range seqs {
+ if strings.HasPrefix(target, seq) {
+ if matchPrefixSeq(target[len(seq):], append(seqs[:ix], seqs[ix+1:]...)) {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+// binFromHexPat returns a binary string based on the given hex pattern.
+// Allowed hex patterns are the same as for matchHexPat.
+func binFromHexPat(pat string) (string, error) {
+ // TODO(toddw): We could also choose to randomly re-order the sequences.
+ hex := strings.NewReplacer("[", "", "]", "", ",", "").Replace(pat)
+ var bin []byte
+ _, err := fmt.Sscanf(hex, "%x", &bin)
+ return string(bin), err
+}
+
+func TestMatchPrefixSeq(t *testing.T) {
+ tests := []struct {
+ target string
+ seqs []string
+ expect bool
+ }{
+ {"112233", []string{"11"}, true},
+ {"112233", []string{"1122"}, true},
+ {"112233", []string{"11", "22"}, true},
+ {"112233", []string{"22", "11"}, true},
+ {"112233", []string{"112233"}, true},
+ {"112233", []string{"11", "2233"}, true},
+ {"112233", []string{"2233", "11"}, true},
+ {"112233", []string{"112", "233"}, true},
+ {"112233", []string{"233", "112"}, true},
+ {"112233", []string{"1122", "33"}, true},
+ {"112233", []string{"33", "1122"}, true},
+ {"112233", []string{"1", "1223", "3"}, true},
+ {"112233", []string{"3", "1223", "1"}, true},
+ {"112233", []string{"11", "22", "33"}, true},
+ {"112233", []string{"11", "33", "22"}, true},
+ {"112233", []string{"22", "11", "33"}, true},
+ {"112233", []string{"22", "33", "11"}, true},
+ {"112233", []string{"33", "11", "22"}, true},
+ {"112233", []string{"33", "22", "11"}, true},
+ {"112233", []string{"1", "1", "2", "2", "3", "3"}, true},
+ {"112233", []string{"1", "2", "3", "1", "2", "3"}, true},
+ {"112233", []string{"332211"}, false},
+ {"112233", []string{"1122333"}, false},
+ {"112233", []string{"11", "22333"}, false},
+ {"112233", []string{"11", "22", "333"}, false},
+ {"112233", []string{"11", "11", "11"}, false},
+ }
+ for _, test := range tests {
+ if matchPrefixSeq(test.target, test.seqs) != test.expect {
+ t.Errorf("matchPrefixSeq(%q, %v) != %v", test.target, test.seqs, test.expect)
+ }
+ }
+}
+
+func TestMatchHexPat(t *testing.T) {
+ tests := []struct {
+ target, pat string
+ expect bool
+ }{
+ {"112233", "112233", true},
+ {"112233", "[112233]", true},
+ {"112233", "11[2233]", true},
+ {"112233", "1122[33]", true},
+ {"112233", "11[22]33", true},
+ {"112233", "[11,22]33", true},
+ {"112233", "[22,11]33", true},
+ {"112233", "11[22,33]", true},
+ {"112233", "11[33,22]", true},
+ {"112233", "1[12,23]3", true},
+ {"112233", "1[23,12]3", true},
+ {"112233", "[11,22,33]", true},
+ {"112233", "[11,33,22]", true},
+ {"112233", "[22,11,33]", true},
+ {"112233", "[22,33,11]", true},
+ {"112233", "[33,11,22]", true},
+ {"112233", "[33,22,11]", true},
+
+ {"112233", "11223", false},
+ {"112233", "1122333", false},
+ {"112233", "[11223]", false},
+ {"112233", "[1122333]", false},
+ {"112233", "11[223]", false},
+ {"112233", "11[22333]", false},
+ {"112233", "11[22,3]", false},
+ {"112233", "11[223,33]", false},
+ {"112233", "[11,2]33", false},
+ {"112233", "[22,1]33", false},
+ {"112233", "11[2,3]33", false},
+ {"112233", "[11,2,33]", false},
+ }
+ for _, test := range tests {
+ actual, err := matchHexPat(test.target, test.pat)
+ if err != nil {
+ t.Error(err)
+ }
+ if actual != test.expect {
+ t.Errorf("matchHexPat(%q, %q) != %v", test.target, test.pat, test.expect)
+ }
+ }
+}
+
+func toGoValue(value *vdl.Value) (interface{}, error) {
+ rt := vdl.TypeToReflect(value.Type())
+ if rt == nil {
+ return reflect.Value{}, fmt.Errorf("TypeToReflect(%v) failed", value.Type())
+ }
+ rv := reflect.New(rt)
+ if err := vdl.Convert(rv.Interface(), value); err != nil {
+ return reflect.Value{}, fmt.Errorf("vdl.Convert(%T, %v) failed: %v", rt, value, err)
+ }
+ return rv.Elem().Interface(), nil
+}
diff --git a/lib/vom/type.go b/lib/vom/type.go
new file mode 100644
index 0000000..b3cb7f7
--- /dev/null
+++ b/lib/vom/type.go
@@ -0,0 +1,366 @@
+package vom
+
+// TODO(toddw): Add tests.
+
+import (
+ "fmt"
+
+ "v.io/v23/vdl"
+)
+
+// encoderTypes maintains the mapping from type to type id, used by the encoder.
+type encoderTypes struct {
+ typeToID map[*vdl.Type]typeID
+ nextID typeID
+}
+
+func newEncoderTypes() *encoderTypes {
+ return &encoderTypes{make(map[*vdl.Type]typeID), WireIDFirstUserType}
+}
+
+func (et *encoderTypes) LookupID(tt *vdl.Type) typeID {
+ if id := bootstrapTypeToID[tt]; id != 0 {
+ return id
+ }
+ return et.typeToID[tt]
+}
+
+func (et *encoderTypes) LookupOrAssignID(tt *vdl.Type) (typeID, bool) {
+ if id := et.LookupID(tt); id != 0 {
+ return id, false
+ }
+ // Assign a new id.
+ newID := et.nextID
+ et.nextID++
+ et.typeToID[tt] = newID
+ return newID, true
+}
+
+// decoderTypes maintains the mapping from type id to type, used by the decoder.
+type decoderTypes struct {
+ idToWire map[typeID]wireType
+ idToType map[typeID]*vdl.Type
+}
+
+func newDecoderTypes() *decoderTypes {
+ return &decoderTypes{make(map[typeID]wireType), make(map[typeID]*vdl.Type)}
+}
+
+func (dt *decoderTypes) LookupOrBuildType(id typeID) (*vdl.Type, error) {
+ if tt := dt.lookupType(id); tt != nil {
+ return tt, nil
+ }
+ builder := new(vdl.TypeBuilder)
+ pending := make(map[typeID]vdl.PendingType)
+ result, err := dt.makeType(id, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ if !builder.Build() {
+ // TODO(toddw): Change TypeBuilder.Build() to directly return the error.
+ _, err := result.Built()
+ return nil, err
+ }
+ for id, pend := range pending {
+ tt, err := pend.Built()
+ if err != nil {
+ return nil, err
+ }
+ dt.idToType[id] = tt
+ }
+ built, err := result.Built()
+ if err != nil {
+ return nil, err
+ }
+ return built, nil
+}
+
+func (dt *decoderTypes) lookupType(id typeID) *vdl.Type {
+ if tt := bootstrapIDToType[id]; tt != nil {
+ return tt
+ }
+ return dt.idToType[id]
+}
+
+func (dt *decoderTypes) makeType(id typeID, builder *vdl.TypeBuilder, pending map[typeID]vdl.PendingType) (vdl.PendingType, error) {
+ wt := dt.idToWire[id]
+ if wt == nil {
+ return nil, fmt.Errorf("vom: unknown type ID %d", id)
+ }
+ // Make the type from its wireType representation. First remove it from
+ // dt.idToWire, and add it to pending, so that subsequent lookups will get the
+ // pending type. Eventually the built type will be added to dt.idToType.
+ delete(dt.idToWire, id)
+ if name := wt.(wireTypeGeneric).TypeName(); name != "" {
+ // Named types may be recursive, so we must create the named type first and
+ // add it to pending, before we make the base type. The base type may refer
+ // back to this named type, and will find it in pending.
+ namedType := builder.Named(name)
+ pending[id] = namedType
+ if wtNamed, ok := wt.(wireTypeNamedT); ok {
+ // This is a NamedType pointing at a base type.
+ baseType, err := dt.lookupOrMakeType(wtNamed.Value.Base, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ namedType.AssignBase(baseType)
+ return namedType, nil
+ }
+ // This isn't NamedType, but has a non-empty name.
+ baseType, err := dt.makeBaseType(wt, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ namedType.AssignBase(baseType)
+ return namedType, nil
+ }
+ // Unnamed types are made directly from their base type. It's fine to update
+ // pending after making the base type, since there's no way to create a
+ // recursive type based solely on unnamed vdl.
+ baseType, err := dt.makeBaseType(wt, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ pending[id] = baseType
+ return baseType, nil
+}
+
+func (dt *decoderTypes) makeBaseType(wt wireType, builder *vdl.TypeBuilder, pending map[typeID]vdl.PendingType) (vdl.PendingType, error) {
+ switch wt := wt.(type) {
+ case wireTypeNamedT:
+ return nil, fmt.Errorf("vom: NamedType has empty name: %v", wt)
+ case wireTypeEnumT:
+ enumType := builder.Enum()
+ for _, label := range wt.Value.Labels {
+ enumType.AppendLabel(label)
+ }
+ return enumType, nil
+ case wireTypeArrayT:
+ elemType, err := dt.lookupOrMakeType(wt.Value.Elem, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ return builder.Array().AssignElem(elemType).AssignLen(int(wt.Value.Len)), nil
+ case wireTypeListT:
+ elemType, err := dt.lookupOrMakeType(wt.Value.Elem, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ return builder.List().AssignElem(elemType), nil
+ case wireTypeSetT:
+ keyType, err := dt.lookupOrMakeType(wt.Value.Key, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ return builder.Set().AssignKey(keyType), nil
+ case wireTypeMapT:
+ keyType, err := dt.lookupOrMakeType(wt.Value.Key, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ elemType, err := dt.lookupOrMakeType(wt.Value.Elem, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ return builder.Map().AssignKey(keyType).AssignElem(elemType), nil
+ case wireTypeStructT:
+ structType := builder.Struct()
+ for _, field := range wt.Value.Fields {
+ fieldType, err := dt.lookupOrMakeType(field.Type, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ structType.AppendField(field.Name, fieldType)
+ }
+ return structType, nil
+ case wireTypeUnionT:
+ unionType := builder.Union()
+ for _, field := range wt.Value.Fields {
+ fieldType, err := dt.lookupOrMakeType(field.Type, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ unionType.AppendField(field.Name, fieldType)
+ }
+ return unionType, nil
+ case wireTypeOptionalT:
+ elemType, err := dt.lookupOrMakeType(wt.Value.Elem, builder, pending)
+ if err != nil {
+ return nil, err
+ }
+ return builder.Optional().AssignElem(elemType), nil
+ default:
+ return nil, fmt.Errorf("vom: unknown wire type definition %v", wt)
+ }
+}
+
+func (dt *decoderTypes) lookupOrMakeType(id typeID, builder *vdl.TypeBuilder, pending map[typeID]vdl.PendingType) (vdl.TypeOrPending, error) {
+ if tt := dt.lookupType(id); tt != nil {
+ return tt, nil
+ }
+ if p, ok := pending[id]; ok {
+ return p, nil
+ }
+ return dt.makeType(id, builder, pending)
+}
+
+func (dt *decoderTypes) AddWireType(id typeID, wt wireType) error {
+ if id < WireIDFirstUserType {
+ return fmt.Errorf("vom: type %q id %d invalid, the min user id is %d", wt, id, WireIDFirstUserType)
+ }
+ // TODO(toddw): Allow duplicates according to some heuristic (e.g. only
+ // identical, or only if the later one is a "superset", etc).
+ if _, dup := dt.idToWire[id]; dup {
+ return fmt.Errorf("vom: type %q id %d already defined as %q", wt, id, dup)
+ }
+ if _, dup := dt.idToType[id]; dup {
+ return fmt.Errorf("vom: type %q id %d already defined as %q", wt, id, dup)
+ }
+ dt.idToWire[id] = wt
+ return nil
+}
+
+func isWireTypeType(tt *vdl.Type) bool {
+ _, exist := bootstrapWireTypes[tt]
+ return exist
+}
+
+// TODO(toddw): Provide type management routines
+
+// Bootstrap mappings between type, id and kind.
+var (
+ bootstrapWireTypes map[*vdl.Type]struct{}
+ bootstrapIDToType map[typeID]*vdl.Type
+ bootstrapTypeToID map[*vdl.Type]typeID
+ bootstrapKindToID map[vdl.Kind]typeID
+
+ typeIDType = vdl.TypeOf(typeID(0))
+ wireTypeType = vdl.TypeOf((*wireType)(nil))
+ wireNamedType = vdl.TypeOf(wireNamed{})
+ wireEnumType = vdl.TypeOf(wireEnum{})
+ wireArrayType = vdl.TypeOf(wireArray{})
+ wireListType = vdl.TypeOf(wireList{})
+ wireSetType = vdl.TypeOf(wireSet{})
+ wireMapType = vdl.TypeOf(wireMap{})
+ wireFieldType = vdl.TypeOf(wireField{})
+ wireFieldListType = vdl.TypeOf([]wireField{})
+ wireStructType = vdl.TypeOf(wireStruct{})
+ wireUnionType = vdl.TypeOf(wireUnion{})
+ wireOptionalType = vdl.TypeOf(wireOptional{})
+
+ wireByteListType = vdl.TypeOf([]byte{})
+ wireStringListType = vdl.TypeOf([]string{})
+)
+
+func init() {
+ bootstrapWireTypes = make(map[*vdl.Type]struct{})
+
+ // The basic wire types for type definition.
+ for _, tt := range []*vdl.Type{
+ typeIDType,
+ wireTypeType,
+ wireFieldType,
+ wireFieldListType,
+ } {
+ bootstrapWireTypes[tt] = struct{}{}
+ }
+
+ // The extra wire types for each kind of type definition. The field indices
+ // in wireType should not be changed.
+ wtTypes := []*vdl.Type{
+ wireNamedType,
+ wireEnumType,
+ wireArrayType,
+ wireListType,
+ wireSetType,
+ wireMapType,
+ wireStructType,
+ wireUnionType,
+ wireOptionalType,
+ }
+ if len(wtTypes) != wireTypeType.NumField() {
+ panic("vom: wireType definition changed")
+ }
+ for ix, tt := range wtTypes {
+ if tt != wireTypeType.Field(ix).Type {
+ panic("vom: wireType definition changed")
+ }
+ bootstrapWireTypes[tt] = struct{}{}
+ }
+
+ bootstrapIDToType = make(map[typeID]*vdl.Type)
+ bootstrapTypeToID = make(map[*vdl.Type]typeID)
+ bootstrapKindToID = make(map[vdl.Kind]typeID)
+
+ // The basic bootstrap types can be converted between type, id and kind.
+ for id, tt := range map[typeID]*vdl.Type{
+ WireIDBool: vdl.BoolType,
+ WireIDByte: vdl.ByteType,
+ WireIDString: vdl.StringType,
+ WireIDUint16: vdl.Uint16Type,
+ WireIDUint32: vdl.Uint32Type,
+ WireIDUint64: vdl.Uint64Type,
+ WireIDInt16: vdl.Int16Type,
+ WireIDInt32: vdl.Int32Type,
+ WireIDInt64: vdl.Int64Type,
+ WireIDFloat32: vdl.Float32Type,
+ WireIDFloat64: vdl.Float64Type,
+ WireIDComplex64: vdl.Complex64Type,
+ WireIDComplex128: vdl.Complex128Type,
+ WireIDTypeObject: vdl.TypeObjectType,
+ WireIDAny: vdl.AnyType,
+ } {
+ bootstrapIDToType[id] = tt
+ bootstrapTypeToID[tt] = id
+ bootstrapKindToID[tt.Kind()] = id
+ }
+ // The extra bootstrap types can be converted between type and id.
+ for id, tt := range map[typeID]*vdl.Type{
+ WireIDByteList: wireByteListType,
+ WireIDStringList: wireStringListType,
+ } {
+ bootstrapIDToType[id] = tt
+ bootstrapTypeToID[tt] = id
+ }
+}
+
+// A generic interface for all wireType types.
+type wireTypeGeneric interface {
+ TypeName() string
+}
+
+func (wt wireTypeNamedT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeEnumT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeArrayT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeListT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeSetT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeMapT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeStructT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeUnionT) TypeName() string {
+ return wt.Value.Name
+}
+
+func (wt wireTypeOptionalT) TypeName() string {
+ return wt.Value.Name
+}
diff --git a/lib/vom/util.go b/lib/vom/util.go
new file mode 100644
index 0000000..9996294
--- /dev/null
+++ b/lib/vom/util.go
@@ -0,0 +1,26 @@
+package vom
+
+import "bytes"
+
+// Encode encodes the provided value using a new instance of a VOM encoder.
+func Encode(value interface{}) ([]byte, error) {
+ var buf bytes.Buffer
+ encoder, err := NewEncoder(&buf)
+ if err != nil {
+ return nil, err
+ }
+ if err := encoder.Encode(value); err != nil {
+ return nil, err
+ }
+ return buf.Bytes(), nil
+}
+
+// Decode VOM-decodes the given data into the provided value using a new
+// instance of a VOM decoder.
+func Decode(data []byte, valptr interface{}) error {
+ decoder, err := NewDecoder(bytes.NewReader(data))
+ if err != nil {
+ return err
+ }
+ return decoder.Decode(valptr)
+}
diff --git a/lib/vom/vom/doc.go b/lib/vom/vom/doc.go
new file mode 100644
index 0000000..ed87934
--- /dev/null
+++ b/lib/vom/vom/doc.go
@@ -0,0 +1,87 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+
+/*
+The vom tool helps debug the Veyron Object Marshaling (vom) protocol.
+
+Usage:
+ vom <command>
+
+The vom commands are:
+ decode Decode data encoded in the vom format
+ dump Dump data encoded in the vom format into formatted output
+ help Display help for commands or topics
+Run "vom help [command]" for command usage.
+
+Vom Decode
+
+Decode decodes data encoded in the vom format. If no arguments are provided,
+decode reads the data from stdin, otherwise the argument is the data.
+
+By default the data is assumed to be represented in hex, with all whitespace
+anywhere in the data ignored. Use the -data flag to specify other data
+representations.
+
+Usage:
+ vom decode [flags] [data]
+
+[data] is the data to decode; if not specified, reads from stdin
+
+The vom decode flags are:
+ -data=Hex
+ Data representation, one of [Hex Binary]
+
+Vom Dump
+
+Dump dumps data encoded in the vom format, generating formatted output
+describing each portion of the encoding. If no arguments are provided, dump
+reads the data from stdin, otherwise the argument is the data.
+
+By default the data is assumed to be represented in hex, with all whitespace
+anywhere in the data ignored. Use the -data flag to specify other data
+representations.
+
+Calling "vom dump" with no flags and no arguments combines the default stdin
+mode with the default hex mode. This default mode is special; certain non-hex
+characters may be input to represent commands:
+ . (period) Calls Dumper.Status to get the current decoding status.
+ ; (semicolon) Calls Dumper.Flush to flush output and start a new message.
+
+This lets you cut-and-paste hex strings into your terminal, and use the commands
+to trigger status or flush calls; i.e. a rudimentary debugging UI.
+
+See v.io/v23/vom.Dumper for details on the dump output.
+
+Usage:
+ vom dump [flags] [data]
+
+[data] is the data to dump; if not specified, reads from stdin
+
+The vom dump flags are:
+ -data=Hex
+ Data representation, one of [Hex Binary]
+
+Vom Help
+
+Help with no args displays the usage of the parent command.
+
+Help with args displays the usage of the specified sub-command or help topic.
+
+"help ..." recursively displays help for all commands and topics.
+
+The output is formatted to a target width in runes. The target width is
+determined by checking the environment variable CMDLINE_WIDTH, falling back on
+the terminal width from the OS, falling back on 80 chars. By setting
+CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
+if x == 0 or is unset one of the fallbacks is used.
+
+Usage:
+ vom help [flags] [command/topic ...]
+
+[command/topic ...] optionally identifies a specific sub-command or help topic.
+
+The vom help flags are:
+ -style=text
+ The formatting style for help output, either "text" or "godoc".
+*/
+package main
diff --git a/lib/vom/vom/types.vdl b/lib/vom/vom/types.vdl
new file mode 100644
index 0000000..6387f15
--- /dev/null
+++ b/lib/vom/vom/types.vdl
@@ -0,0 +1,6 @@
+package main
+
+type dataRep enum {
+ Hex
+ Binary
+}
diff --git a/lib/vom/vom/types.vdl.go b/lib/vom/vom/types.vdl.go
new file mode 100644
index 0000000..6494df8
--- /dev/null
+++ b/lib/vom/vom/types.vdl.go
@@ -0,0 +1,61 @@
+// This file was auto-generated by the veyron vdl tool.
+// Source: types.vdl
+
+package main
+
+import (
+ // VDL system imports
+ "fmt"
+ "v.io/v23/vdl"
+)
+
+type dataRep int
+
+const (
+ dataRepHex dataRep = iota
+ dataRepBinary
+)
+
+// dataRepAll holds all labels for dataRep.
+var dataRepAll = []dataRep{dataRepHex, dataRepBinary}
+
+// dataRepFromString creates a dataRep from a string label.
+func dataRepFromString(label string) (x dataRep, err error) {
+ err = x.Set(label)
+ return
+}
+
+// Set assigns label to x.
+func (x *dataRep) Set(label string) error {
+ switch label {
+ case "Hex", "hex":
+ *x = dataRepHex
+ return nil
+ case "Binary", "binary":
+ *x = dataRepBinary
+ return nil
+ }
+ *x = -1
+ return fmt.Errorf("unknown label %q in main.dataRep", label)
+}
+
+// String returns the string label of x.
+func (x dataRep) String() string {
+ switch x {
+ case dataRepHex:
+ return "Hex"
+ case dataRepBinary:
+ return "Binary"
+ }
+ return ""
+}
+
+func (dataRep) __VDLReflect(struct {
+ Name string "v.io/v23/vom/vom.dataRep"
+ Enum struct{ Hex, Binary string }
+}) {
+}
+
+func init() {
+ vdl.Register((*dataRep)(nil))
+}
diff --git a/lib/vom/vom/vom.go b/lib/vom/vom/vom.go
new file mode 100644
index 0000000..03027d7
--- /dev/null
+++ b/lib/vom/vom/vom.go
@@ -0,0 +1,265 @@
+// The following enables go generate to generate the doc.go file.
+//go:generate go run $VANADIUM_ROOT/release/go/src/v.io/lib/cmdline/testdata/gendoc.go .
+
+package main
+
+import (
+ "bytes"
+ "encoding/hex"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "strings"
+ "unicode"
+
+ "v.io/lib/cmdline"
+ "v.io/v23/vdl"
+ "v.io/v23/vom"
+)
+
+func main() {
+ os.Exit(cmdVom.Main())
+}
+
+var cmdVom = &cmdline.Command{
+ Name: "vom",
+ Short: "Veyron Object Marshaling debugging tool",
+ Long: `
+The vom tool helps debug the Veyron Object Marshaling (vom) protocol.
+`,
+ Children: []*cmdline.Command{cmdDecode, cmdDump},
+}
+
+var cmdDecode = &cmdline.Command{
+ Run: runDecode,
+ Name: "decode",
+ Short: "Decode data encoded in the vom format",
+ Long: `
+Decode decodes data encoded in the vom format. If no arguments are provided,
+decode reads the data from stdin, otherwise the argument is the data.
+
+By default the data is assumed to be represented in hex, with all whitespace
+anywhere in the data ignored. Use the -data flag to specify other data
+representations.
+
+`,
+ ArgsName: "[data]",
+ ArgsLong: "[data] is the data to decode; if not specified, reads from stdin",
+}
+
+var cmdDump = &cmdline.Command{
+ Run: runDump,
+ Name: "dump",
+ Short: "Dump data encoded in the vom format into formatted output",
+ Long: `
+Dump dumps data encoded in the vom format, generating formatted output
+describing each portion of the encoding. If no arguments are provided, dump
+reads the data from stdin, otherwise the argument is the data.
+
+By default the data is assumed to be represented in hex, with all whitespace
+anywhere in the data ignored. Use the -data flag to specify other data
+representations.
+
+Calling "vom dump" with no flags and no arguments combines the default stdin
+mode with the default hex mode. This default mode is special; certain non-hex
+characters may be input to represent commands:
+ . (period) Calls Dumper.Status to get the current decoding status.
+ ; (semicolon) Calls Dumper.Flush to flush output and start a new message.
+
+This lets you cut-and-paste hex strings into your terminal, and use the commands
+to trigger status or flush calls; i.e. a rudimentary debugging UI.
+
+See v.io/v23/vom.Dumper for details on the dump output.
+`,
+ ArgsName: "[data]",
+ ArgsLong: "[data] is the data to dump; if not specified, reads from stdin",
+}
+
+var (
+ flagDataRep = dataRepHex
+)
+
+func init() {
+ cmdDecode.Flags.Var(&flagDataRep, "data",
+ "Data representation, one of "+fmt.Sprint(dataRepAll))
+ cmdDump.Flags.Var(&flagDataRep, "data",
+ "Data representation, one of "+fmt.Sprint(dataRepAll))
+}
+
+func runDecode(cmd *cmdline.Command, args []string) error {
+ // Convert all inputs into a reader over binary bytes.
+ var data string
+ switch {
+ case len(args) > 1:
+ return cmd.UsageErrorf("too many args")
+ case len(args) == 1:
+ data = args[0]
+ default:
+ bytes, err := ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ return err
+ }
+ data = string(bytes)
+ }
+ binbytes, err := dataToBinaryBytes(data)
+ if err != nil {
+ return err
+ }
+ reader := bytes.NewBuffer(binbytes)
+ // Decode the binary bytes.
+ // TODO(toddw): Add a flag to set a specific type to decode into.
+ decoder, err := vom.NewDecoder(reader)
+ if err != nil {
+ return err
+ }
+ var result *vdl.Value
+ if err := decoder.Decode(&result); err != nil {
+ return err
+ }
+ fmt.Fprintln(cmd.Stdout(), result)
+ if reader.Len() != 0 {
+ return fmt.Errorf("%d leftover bytes: % x", reader.Len(), reader.String())
+ }
+ return nil
+}
+
+func runDump(cmd *cmdline.Command, args []string) error {
+ // Handle non-streaming cases.
+ switch {
+ case len(args) > 1:
+ return cmd.UsageErrorf("too many args")
+ case len(args) == 1:
+ binbytes, err := dataToBinaryBytes(args[0])
+ if err != nil {
+ return err
+ }
+ fmt.Fprintln(cmd.Stdout(), vom.Dump(binbytes))
+ return nil
+ }
+ // Handle streaming from stdin.
+ // TODO(toddw): Add a flag to configure stdout/stderr dumping.
+ dumper := vom.NewDumper(dumpWriter{cmd.Stdout(), cmd.Stdout()})
+ defer dumper.Close()
+ // Handle simple non-hex cases.
+ switch flagDataRep {
+ case dataRepBinary:
+ _, err := io.Copy(dumper, os.Stdin)
+ return err
+ }
+ return runDumpHexStream(dumper)
+}
+
+// runDumpHexStream handles the hex stdin-streaming special-case, with commands
+// for status and flush. This is tricky because we need to strip whitespace,
+// handle commands where they appear in the stream, and deal with the fact that
+// it takes two hex characters to encode a single byte.
+//
+// The strategy is to run a ReadLoop that reads into a reasonably-sized buffer.
+// Inside the ReadLoop we take the buffer, strip whitespace, and keep looping to
+// process all data up to each command, and then process the command. If a
+// command appears in the middle of two hex characters representing a byte, we
+// send the command first, before sending the byte.
+//
+// Any leftover non-command single byte is stored in buf and bufStart is set, so
+// that the next iteration of ReadLoop can read after those bytes.
+func runDumpHexStream(dumper *vom.Dumper) error {
+ buf := make([]byte, 1024)
+ bufStart := 0
+ReadLoop:
+ for {
+ n, err := os.Stdin.Read(buf[bufStart:])
+ switch {
+ case n == 0 && err == io.EOF:
+ return nil
+ case n == 0 && err != nil:
+ return err
+ }
+ // We may have hex interspersed with spaces and commands. The strategy is
+ // to strip all whitespace, and process each even-sized chunk of hex bytes
+ // up to a command or the end of the buffer.
+ //
+ // Data that appears before a command is written before the command, and
+ // data after the command is written after. But if a command appears in the
+ // middle of two hex characters representing a byte, we send the command
+ // first, before sending the byte.
+ hexbytes := bytes.Map(dropWhitespace, buf[:bufStart+n])
+ for len(hexbytes) > 0 {
+ end := len(hexbytes)
+ cmdIndex := bytes.IndexAny(hexbytes, ".;")
+ if cmdIndex != -1 {
+ end = cmdIndex
+ } else if end == 1 {
+ // We have a single non-command byte left in hexbytes; copy it into buf
+ // and set bufStart.
+ copy(buf, hexbytes[0:1])
+ bufStart = 1
+ continue ReadLoop
+ }
+ if end%2 == 1 {
+ end -= 1 // Ensure the end is on an even boundary.
+ }
+ // Write this even-sized chunk of hex bytes to the dumper.
+ binbytes, err := hex.DecodeString(string(hexbytes[:end]))
+ if err != nil {
+ return err
+ }
+ if _, err := dumper.Write(binbytes); err != nil {
+ return err
+ }
+ // Handle commands.
+ if cmdIndex != -1 {
+ switch cmd := hexbytes[cmdIndex]; cmd {
+ case '.':
+ dumper.Status()
+ case ';':
+ dumper.Flush()
+ default:
+ return fmt.Errorf("unhandled command %q", cmd)
+ }
+ // Move data after the command forward.
+ copy(hexbytes[cmdIndex:], hexbytes[cmdIndex+1:])
+ hexbytes = hexbytes[:len(hexbytes)-1]
+ }
+ // Move data after the end forward.
+ copy(hexbytes, hexbytes[end:])
+ hexbytes = hexbytes[:len(hexbytes)-end]
+ }
+ bufStart = 0
+ }
+}
+
+func dataToBinaryBytes(data string) ([]byte, error) {
+ // Transform all data representations to binary.
+ switch flagDataRep {
+ case dataRepHex:
+ // Remove all whitespace out of the hex string.
+ binbytes, err := hex.DecodeString(strings.Map(dropWhitespace, data))
+ if err != nil {
+ return nil, err
+ }
+ return binbytes, nil
+ }
+ return []byte(data), nil
+}
+
+func dropWhitespace(r rune) rune {
+ if unicode.IsSpace(r) {
+ return -1
+ }
+ return r
+}
+
+type dumpWriter struct {
+ atom, status io.Writer
+}
+
+var _ vom.DumpWriter = dumpWriter{}
+
+func (w dumpWriter) WriteAtom(atom vom.DumpAtom) {
+ w.atom.Write([]byte(atom.String() + "\n"))
+}
+
+func (w dumpWriter) WriteStatus(status vom.DumpStatus) {
+ w.status.Write([]byte("\n" + status.String() + "\n"))
+}
diff --git a/lib/vom/vomtestgen/doc.go b/lib/vom/vomtestgen/doc.go
new file mode 100644
index 0000000..42d1129
--- /dev/null
+++ b/lib/vom/vomtestgen/doc.go
@@ -0,0 +1,30 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+
+/*
+The vomtestgen tool generates vom test data, using the vomdata file as input,
+and creating a vdl file as output.
+
+Usage:
+ vomtestgen [flags] [vomdata]
+
+[vomdata] is the path to the vomdata input file, specified in the vdl config
+file format. It must be of the form "NAME.vdl.config", and the output vdl file
+will be generated at "NAME.vdl".
+
+The config file should export a const []any that contains all of the values that
+will be tested. Here's an example:
+ config = []any{
+ bool(true), uint64(123), string("abc"),
+ }
+
+If not specified, we'll try to find the file at its canonical location:
+ v.io/v23/vom/testdata/vomdata.vdl.config
+
+The vomtestgen flags are:
+ -exts=.vdl
+ Comma-separated list of valid VDL file name extensions.
+ -max_errors=-1
+ Stop processing after this many errors, or -1 for unlimited.
+*/
+package main
diff --git a/lib/vom/vomtestgen/generate.go b/lib/vom/vomtestgen/generate.go
new file mode 100644
index 0000000..009a02c
--- /dev/null
+++ b/lib/vom/vomtestgen/generate.go
@@ -0,0 +1,328 @@
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "v.io/lib/cmdline"
+ "v.io/v23/vdl"
+ "v.io/v23/vdl/build"
+ "v.io/v23/vdl/codegen"
+ "v.io/v23/vdl/codegen/vdlgen"
+ "v.io/v23/vdl/compile"
+ "v.io/v23/vom"
+)
+
+const (
+ testpkg = "v.io/v23/vom/testdata"
+ vomdataCanonical = testpkg + "/" + vomdataConfig
+ vomdataConfig = "vomdata.vdl.config"
+)
+
+var cmdGenerate = &cmdline.Command{
+ Run: runGenerate,
+ Name: "vomtestgen",
+ Short: "Generate test data for the vom encoder / decoder",
+ Long: `
+The vomtestgen tool generates vom test data, using the vomdata file as input,
+and creating a vdl file as output.
+`,
+ ArgsName: "[vomdata]",
+ ArgsLong: `
+[vomdata] is the path to the vomdata input file, specified in the vdl config
+file format. It must be of the form "NAME.vdl.config", and the output vdl
+file will be generated at "NAME.vdl".
+
+The config file should export a const []any that contains all of the values
+that will be tested. Here's an example:
+ config = []any{
+ bool(true), uint64(123), string("abc"),
+ }
+
+If not specified, we'll try to find the file at its canonical location:
+ ` + vomdataCanonical,
+}
+
+var (
+ optGenMaxErrors int
+ optGenExts string
+)
+
+func init() {
+ cmdGenerate.Flags.IntVar(&optGenMaxErrors, "max_errors", -1, "Stop processing after this many errors, or -1 for unlimited.")
+ cmdGenerate.Flags.StringVar(&optGenExts, "exts", ".vdl", "Comma-separated list of valid VDL file name extensions.")
+}
+
+func runGenerate(cmd *cmdline.Command, args []string) error {
+ debug := new(bytes.Buffer)
+ defer dumpDebug(cmd.Stderr(), debug)
+ env := compile.NewEnv(optGenMaxErrors)
+ // Get the input datafile path.
+ var path string
+ switch len(args) {
+ case 0:
+ srcDirs := build.SrcDirs(env.Errors)
+ if err := env.Errors.ToError(); err != nil {
+ return cmd.UsageErrorf("%v", err)
+ }
+ path = guessDataFilePath(debug, srcDirs)
+ if path == "" {
+ return cmd.UsageErrorf("couldn't find vomdata file in src dirs: %v", srcDirs)
+ }
+ case 1:
+ path = args[0]
+ default:
+ return cmd.UsageErrorf("too many args (expecting exactly 1 vomdata file)")
+ }
+ inName := filepath.Clean(path)
+ if !strings.HasSuffix(inName, ".vdl.config") {
+ return cmd.UsageErrorf(`vomdata file doesn't end in ".vdl.config": %s`, inName)
+ }
+ outName := inName[:len(inName)-len(".config")]
+ // Remove the generated file, so that it doesn't interfere with compiling the
+ // config. Ignore errors since it might not exist yet.
+ if err := os.Remove(outName); err == nil {
+ fmt.Fprintf(debug, "Removed output file %v\n", outName)
+ }
+ config, err := compileConfig(debug, inName, env)
+ if err != nil {
+ return err
+ }
+ data, err := generate(config)
+ if err != nil {
+ return err
+ }
+ if err := writeFile(data, outName); err != nil {
+ return err
+ }
+ debug.Reset() // Don't dump debugging information on success
+ fmt.Fprintf(cmd.Stdout(), "Wrote output file %v\n", outName)
+ return nil
+}
+
+func dumpDebug(stderr io.Writer, debug *bytes.Buffer) {
+ if d := debug.Bytes(); len(d) > 0 {
+ io.Copy(stderr, debug)
+ }
+}
+
+func guessDataFilePath(debug io.Writer, srcDirs []string) string {
+ // Try to guess the data file path by looking for the canonical vomdata input
+ // file in each of our source directories.
+ for _, dir := range srcDirs {
+ guess := filepath.Join(dir, vomdataCanonical)
+ if stat, err := os.Stat(guess); err == nil && !stat.IsDir() {
+ fmt.Fprintf(debug, "Found vomdata file %s\n", guess)
+ return guess
+ }
+ }
+ return ""
+}
+
+func compileConfig(debug io.Writer, inName string, env *compile.Env) (*vdl.Value, error) {
+ basename := filepath.Base(inName)
+ data, err := os.Open(inName)
+ if err != nil {
+ return nil, fmt.Errorf("couldn't open vomdata file %s: %v", inName, err)
+ }
+ defer func() { data.Close() }() // make defer use the latest value of data
+ if stat, err := data.Stat(); err != nil || stat.IsDir() {
+ return nil, fmt.Errorf("vomdata file %s is a directory", inName)
+ }
+ var opts build.Opts
+ opts.Extensions = strings.Split(optGenExts, ",")
+ // Compile package dependencies in transitive order.
+ deps := build.TransitivePackagesForConfig(basename, data, opts, env.Errors)
+ for _, dep := range deps {
+ if pkg := build.BuildPackage(dep, env); pkg != nil {
+ fmt.Fprintf(debug, "Built package %s\n", pkg.Path)
+ }
+ }
+ // Try to seek back to the beginning of the data file, or if that fails try to
+ // open the data file again.
+ if off, err := data.Seek(0, 0); off != 0 || err != nil {
+ if err := data.Close(); err != nil {
+ return nil, fmt.Errorf("couldn't close vomdata file %s: %v", inName, err)
+ }
+ data, err = os.Open(inName)
+ if err != nil {
+ return nil, fmt.Errorf("couldn't re-open vomdata file %s: %v", inName, err)
+ }
+ }
+ // Compile config into our test values.
+ config := build.BuildConfig(basename, data, nil, nil, env)
+ if err := env.Errors.ToError(); err != nil {
+ return nil, err
+ }
+ fmt.Fprintf(debug, "Compiled vomdata file %s\n", inName)
+ return config, err
+}
+
+func generate(config *vdl.Value) ([]byte, error) {
+ // This config needs to have a specific struct format. See @testdata/vomtype.vdl.
+ // TODO(alexfandrianto): Instead of this, we should have separate generator
+ // functions that switch off of the vomdata config filename. That way, we can
+ // have 1 config each for encode/decode, compatibility, and convertibility.
+ buf := new(bytes.Buffer)
+ fmt.Fprintf(buf, `// This file was auto-generated via "vomtest generate".
+// DO NOT UPDATE MANUALLY; read the comments in `+vomdataConfig+`.
+
+package testdata
+`)
+ imports := codegen.ImportsForValue(config, testpkg)
+ if len(imports) > 0 {
+ fmt.Fprintf(buf, "\n%s\n", vdlgen.Imports(imports))
+ }
+ fmt.Fprintf(buf, `
+// TestCase represents an individual testcase for vom encoding and decoding.
+type TestCase struct {
+ Name string // Name of the testcase
+ Value any // Value to test
+ Hex string // Hex pattern representing vom encoding of Value
+ TypeString string // The string representation of the Type
+}
+
+// Tests contains the testcases to use to test vom encoding and decoding.
+const Tests = []TestCase {`)
+ // The vom encode-decode test cases need to be of type []any.
+ encodeDecodeTests := config.StructField(0)
+ if got, want := encodeDecodeTests.Type(), vdl.ListType(vdl.AnyType); got != want {
+ return nil, fmt.Errorf("got encodeDecodeTests type %v, want %v", got, want)
+ }
+
+ for ix := 0; ix < encodeDecodeTests.Len(); ix++ {
+ value := encodeDecodeTests.Index(ix)
+ if !value.IsNil() {
+ // The encodeDecodeTests has type []any, and there's no need for our values to
+ // include the "any" type explicitly, so we descend into the elem value.
+ value = value.Elem()
+ }
+ valstr := vdlgen.TypedConst(value, testpkg, imports)
+ vomhex, vomdump, err := toVomHex(value)
+ if err != nil {
+ return nil, err
+ }
+ fmt.Fprintf(buf, `
+%[3]s
+ {
+ %#[1]q,
+ %[1]s,
+ %[2]q,
+ %[4]q,
+ },`, valstr, vomhex, vomdump, value.Type().String())
+ }
+ fmt.Fprintf(buf, `
+}
+`)
+
+ // The vom compatibility tests need to be of type map[string][]typeobject
+ // Each of the []typeobject are a slice of inter-compatible typeobjects.
+ // However, the typeobjects are not compatible with any other []typeobject.
+ // Note: any and optional should be tested separately.
+ compatTests := config.StructField(1)
+ if got, want := compatTests.Type(), vdl.MapType(vdl.StringType, vdl.ListType(vdl.TypeObjectType)); got != want {
+ return nil, fmt.Errorf("got compatTests type %v, want %v", got, want)
+ }
+ fmt.Fprintf(buf, `
+// CompatTests contains the testcases to use to test vom type compatibility.
+// CompatTests maps TestName (string) to CompatibleTypeSet ([]typeobject)
+// Each CompatibleTypeSet contains types compatible with each other. However,
+// types from different CompatibleTypeSets are incompatible.
+const CompatTests = map[string][]typeobject{`)
+
+ for _, testName := range vdl.SortValuesAsString(compatTests.Keys()) {
+ compatibleTypeSet := compatTests.MapIndex(testName)
+ valstr := vdlgen.TypedConst(compatibleTypeSet, testpkg, imports)
+ fmt.Fprintf(buf, `
+ %[1]q: %[2]s,`, testName.RawString(), valstr)
+ }
+ fmt.Fprintf(buf, `
+}
+`)
+
+ // The vom conversion tests need to be a map[string][]ConvertGroup
+ // See vom/testdata/vomtype.vdl
+ convertTests := config.StructField(2)
+ fmt.Fprintf(buf, `
+// ConvertTests contains the testcases to check vom value convertibility.
+// ConvertTests maps TestName (string) to ConvertGroups ([]ConvertGroup)
+// Each ConvertGroup is a struct with 'Name', 'PrimaryType', and 'Values'.
+// The values within a ConvertGroup can convert between themselves w/o error.
+// However, values in higher-indexed ConvertGroups will error when converting up
+// to the primary type of the lower-indexed ConvertGroups.
+const ConvertTests = map[string][]ConvertGroup{`)
+ for _, testName := range vdl.SortValuesAsString(convertTests.Keys()) {
+ fmt.Fprintf(buf, `
+ %[1]q: {`, testName.RawString())
+
+ convertTest := convertTests.MapIndex(testName)
+ for ix := 0; ix < convertTest.Len(); ix++ {
+ convertGroup := convertTest.Index(ix)
+
+ fmt.Fprintf(buf, `
+ {
+ %[1]q,
+ %[2]s,
+ { `, convertGroup.StructField(0).RawString(), vdlgen.TypedConst(convertGroup.StructField(1), testpkg, imports))
+
+ values := convertGroup.StructField(2)
+ for iy := 0; iy < values.Len(); iy++ {
+ value := values.Index(iy)
+ if !value.IsNil() {
+ // The value is any, and there's no need for our values to include
+ // the "any" type explicitly, so we descend into the elem value.
+ value = value.Elem()
+ }
+ valstr := vdlgen.TypedConst(value, testpkg, imports)
+ fmt.Fprintf(buf, `%[1]s, `, valstr)
+ }
+
+ fmt.Fprintf(buf, `},
+ },`)
+ }
+
+ fmt.Fprintf(buf, `
+ },`)
+ }
+ fmt.Fprintf(buf, `
+}
+`)
+
+ return buf.Bytes(), nil
+}
+
+func toVomHex(value *vdl.Value) (string, string, error) {
+ buf := new(bytes.Buffer)
+ enc, err := vom.NewEncoder(buf)
+ if err != nil {
+ return "", "", fmt.Errorf("vom.NewEncoder failed: %v", err)
+ }
+ if err := enc.Encode(value); err != nil {
+ return "", "", fmt.Errorf("vom.Encode(%v) failed: %v", value, err)
+ }
+ vombytes := buf.String()
+ const pre = "\t// "
+ vomdump := pre + strings.Replace(vom.Dump(buf.Bytes()), "\n", "\n"+pre, -1)
+ if strings.HasSuffix(vomdump, "\n"+pre) {
+ vomdump = vomdump[:len(vomdump)-len("\n"+pre)]
+ }
+ // TODO(toddw): Add hex pattern bracketing for map and set.
+ return fmt.Sprintf("%x", vombytes), vomdump, nil
+}
+
+func writeFile(data []byte, outName string) error {
+ // Create containing directory and write the file.
+ dirName := filepath.Dir(outName)
+ if err := os.MkdirAll(dirName, os.FileMode(0777)); err != nil {
+ return fmt.Errorf("couldn't create directory %s: %v", dirName, err)
+ }
+ if err := ioutil.WriteFile(outName, data, os.FileMode(0666)); err != nil {
+ return fmt.Errorf("couldn't write file %s: %v", outName, err)
+ }
+ return nil
+}
diff --git a/lib/vom/vomtestgen/main.go b/lib/vom/vomtestgen/main.go
new file mode 100644
index 0000000..631d197
--- /dev/null
+++ b/lib/vom/vomtestgen/main.go
@@ -0,0 +1,10 @@
+// The following enables go generate to generate the doc.go file.
+//go:generate go run $VANADIUM_ROOT/release/go/src/v.io/lib/cmdline/testdata/gendoc.go . -help
+
+package main
+
+import "os"
+
+func main() {
+ os.Exit(cmdGenerate.Main())
+}
diff --git a/lib/vom/wiretype.vdl b/lib/vom/wiretype.vdl
new file mode 100644
index 0000000..1e6d5fe
--- /dev/null
+++ b/lib/vom/wiretype.vdl
@@ -0,0 +1,121 @@
+package vom
+
+// Built-in type IDs
+const (
+ // Primitive types.
+ WireIDBool = typeID(1)
+ WireIDByte = typeID(2)
+ WireIDString = typeID(3)
+ WireIDUint16 = typeID(4)
+ WireIDUint32 = typeID(5)
+ WireIDUint64 = typeID(6)
+ WireIDInt16 = typeID(7)
+ WireIDInt32 = typeID(8)
+ WireIDInt64 = typeID(9)
+ WireIDFloat32 = typeID(10)
+ WireIDFloat64 = typeID(11)
+ WireIDComplex64 = typeID(12)
+ WireIDComplex128 = typeID(13)
+ WireIDTypeObject = typeID(14)
+ WireIDAny = typeID(15)
+
+ // Other commonly used composites.
+ WireIDByteList = typeID(39)
+ WireIDStringList = typeID(40)
+
+ // The first user-defined typeID is 41.
+ WireIDFirstUserType = typeID(41)
+)
+
+// typeID uniquely identifies a type definition within a vom stream.
+type typeID uint64
+
+// The wireType union is used to encode the payload part of each type message,
+// using the regular rules for encoding union values. But unlike our regular
+// encoding, the type message for wireType itself (and its fields) are never
+// encoded; we need to bootstrap the system. Thus unlike regular values, the
+// ordering of fields within the wire* types cannot be changed.
+type wireType union {
+ // FIELD INDICES MUST NOT BE CHANGED.
+ NamedT wireNamed // INDEX = 0
+ EnumT wireEnum // INDEX = 1
+ ArrayT wireArray // INDEX = 2
+ ListT wireList // INDEX = 3
+ SetT wireSet // INDEX = 4
+ MapT wireMap // INDEX = 5
+ StructT wireStruct // INDEX = 6
+ UnionT wireUnion // INDEX = 7
+ OptionalT wireOptional // INDEX = 8
+}
+
+// wireNamed represents a type definition for named primitives.
+type wireNamed struct {
+ Name string
+ Base typeID
+}
+
+// wireEnum represents an type definition for enum types.
+type wireEnum struct {
+ Name string
+ Labels []string
+}
+
+// wireArray represents an type definition for array types.
+type wireArray struct {
+ Name string
+ Elem typeID
+ Len uint64
+}
+
+// wireList represents a type definition for list types.
+type wireList struct {
+ Name string
+ Elem typeID
+}
+
+// wireSet represents a type definition for set types.
+type wireSet struct {
+ Name string
+ Key typeID
+}
+
+// wireMap represents a type definition for map types.
+type wireMap struct {
+ Name string
+ Key typeID
+ Elem typeID
+}
+
+// wireField represents a field in a struct or union type.
+type wireField struct {
+ Name string
+ Type typeID
+}
+
+// wireStruct represents a type definition for struct types.
+type wireStruct struct {
+ Name string
+ Fields []wireField
+}
+
+// wireUnion represents a type definition for union types.
+type wireUnion struct {
+ Name string
+ Fields []wireField
+}
+
+// wireOptional represents an type definition for optional types.
+type wireOptional struct {
+ Name string
+ Elem typeID
+}
+
+// Control codes used in VOM wire format
+//
+// region 1: 0x80...0xBF (64 entries)
+// region 2: 0xC0...0xDF (32 entries)
+// region 3: 0xE0...0xEF (16 entries)
+const (
+ WireCtrlNil = byte(0xe0)
+ WireCtrlEOF = byte(0xe1)
+)
diff --git a/lib/vom/wiretype.vdl.go b/lib/vom/wiretype.vdl.go
new file mode 100644
index 0000000..9e3b082
--- /dev/null
+++ b/lib/vom/wiretype.vdl.go
@@ -0,0 +1,288 @@
+// This file was auto-generated by the veyron vdl tool.
+// Source: wiretype.vdl
+
+package vom
+
+import (
+ // VDL system imports
+ "v.io/v23/vdl"
+)
+
+// typeID uniquely identifies a type definition within a vom stream.
+type typeID uint64
+
+func (typeID) __VDLReflect(struct {
+ Name string "v.io/v23/vom.typeID"
+}) {
+}
+
+type (
+ // wireType represents any single field of the wireType union type.
+ //
+ // The wireType union is used to encode the payload part of each type message,
+ // using the regular rules for encoding union values. But unlike our regular
+ // encoding, the type message for wireType itself (and its fields) are never
+ // encoded; we need to bootstrap the system. Thus unlike regular values, the
+ // ordering of fields within the wire* types cannot be changed.
+ wireType interface {
+ // Index returns the field index.
+ Index() int
+ // Interface returns the field value as an interface.
+ Interface() interface{}
+ // Name returns the field name.
+ Name() string
+ // __VDLReflect describes the wireType union type.
+ __VDLReflect(__wireTypeReflect)
+ }
+ // wireTypeNamedT represents field NamedT of the wireType union type.
+ //
+ // FIELD INDICES MUST NOT BE CHANGED.
+ wireTypeNamedT struct{ Value wireNamed } // INDEX = 0
+ // wireTypeEnumT represents field EnumT of the wireType union type.
+ wireTypeEnumT struct{ Value wireEnum } // INDEX = 1
+ // wireTypeArrayT represents field ArrayT of the wireType union type.
+ wireTypeArrayT struct{ Value wireArray } // INDEX = 2
+ // wireTypeListT represents field ListT of the wireType union type.
+ wireTypeListT struct{ Value wireList } // INDEX = 3
+ // wireTypeSetT represents field SetT of the wireType union type.
+ wireTypeSetT struct{ Value wireSet } // INDEX = 4
+ // wireTypeMapT represents field MapT of the wireType union type.
+ wireTypeMapT struct{ Value wireMap } // INDEX = 5
+ // wireTypeStructT represents field StructT of the wireType union type.
+ wireTypeStructT struct{ Value wireStruct } // INDEX = 6
+ // wireTypeUnionT represents field UnionT of the wireType union type.
+ wireTypeUnionT struct{ Value wireUnion } // INDEX = 7
+ // wireTypeOptionalT represents field OptionalT of the wireType union type.
+ wireTypeOptionalT struct{ Value wireOptional } // INDEX = 8
+ // __wireTypeReflect describes the wireType union type.
+ __wireTypeReflect struct {
+ Name string "v.io/v23/vom.wireType"
+ Type wireType
+ Union struct {
+ NamedT wireTypeNamedT
+ EnumT wireTypeEnumT
+ ArrayT wireTypeArrayT
+ ListT wireTypeListT
+ SetT wireTypeSetT
+ MapT wireTypeMapT
+ StructT wireTypeStructT
+ UnionT wireTypeUnionT
+ OptionalT wireTypeOptionalT
+ }
+ }
+)
+
+func (x wireTypeNamedT) Index() int { return 0 }
+func (x wireTypeNamedT) Interface() interface{} { return x.Value }
+func (x wireTypeNamedT) Name() string { return "NamedT" }
+func (x wireTypeNamedT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeEnumT) Index() int { return 1 }
+func (x wireTypeEnumT) Interface() interface{} { return x.Value }
+func (x wireTypeEnumT) Name() string { return "EnumT" }
+func (x wireTypeEnumT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeArrayT) Index() int { return 2 }
+func (x wireTypeArrayT) Interface() interface{} { return x.Value }
+func (x wireTypeArrayT) Name() string { return "ArrayT" }
+func (x wireTypeArrayT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeListT) Index() int { return 3 }
+func (x wireTypeListT) Interface() interface{} { return x.Value }
+func (x wireTypeListT) Name() string { return "ListT" }
+func (x wireTypeListT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeSetT) Index() int { return 4 }
+func (x wireTypeSetT) Interface() interface{} { return x.Value }
+func (x wireTypeSetT) Name() string { return "SetT" }
+func (x wireTypeSetT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeMapT) Index() int { return 5 }
+func (x wireTypeMapT) Interface() interface{} { return x.Value }
+func (x wireTypeMapT) Name() string { return "MapT" }
+func (x wireTypeMapT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeStructT) Index() int { return 6 }
+func (x wireTypeStructT) Interface() interface{} { return x.Value }
+func (x wireTypeStructT) Name() string { return "StructT" }
+func (x wireTypeStructT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeUnionT) Index() int { return 7 }
+func (x wireTypeUnionT) Interface() interface{} { return x.Value }
+func (x wireTypeUnionT) Name() string { return "UnionT" }
+func (x wireTypeUnionT) __VDLReflect(__wireTypeReflect) {}
+
+func (x wireTypeOptionalT) Index() int { return 8 }
+func (x wireTypeOptionalT) Interface() interface{} { return x.Value }
+func (x wireTypeOptionalT) Name() string { return "OptionalT" }
+func (x wireTypeOptionalT) __VDLReflect(__wireTypeReflect) {}
+
+// wireNamed represents a type definition for named primitives.
+type wireNamed struct {
+ Name string
+ Base typeID
+}
+
+func (wireNamed) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireNamed"
+}) {
+}
+
+// wireEnum represents an type definition for enum types.
+type wireEnum struct {
+ Name string
+ Labels []string
+}
+
+func (wireEnum) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireEnum"
+}) {
+}
+
+// wireArray represents an type definition for array types.
+type wireArray struct {
+ Name string
+ Elem typeID
+ Len uint64
+}
+
+func (wireArray) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireArray"
+}) {
+}
+
+// wireList represents a type definition for list types.
+type wireList struct {
+ Name string
+ Elem typeID
+}
+
+func (wireList) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireList"
+}) {
+}
+
+// wireSet represents a type definition for set types.
+type wireSet struct {
+ Name string
+ Key typeID
+}
+
+func (wireSet) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireSet"
+}) {
+}
+
+// wireMap represents a type definition for map types.
+type wireMap struct {
+ Name string
+ Key typeID
+ Elem typeID
+}
+
+func (wireMap) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireMap"
+}) {
+}
+
+// wireField represents a field in a struct or union type.
+type wireField struct {
+ Name string
+ Type typeID
+}
+
+func (wireField) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireField"
+}) {
+}
+
+// wireStruct represents a type definition for struct types.
+type wireStruct struct {
+ Name string
+ Fields []wireField
+}
+
+func (wireStruct) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireStruct"
+}) {
+}
+
+// wireUnion represents a type definition for union types.
+type wireUnion struct {
+ Name string
+ Fields []wireField
+}
+
+func (wireUnion) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireUnion"
+}) {
+}
+
+// wireOptional represents an type definition for optional types.
+type wireOptional struct {
+ Name string
+ Elem typeID
+}
+
+func (wireOptional) __VDLReflect(struct {
+ Name string "v.io/v23/vom.wireOptional"
+}) {
+}
+
+func init() {
+ vdl.Register((*typeID)(nil))
+ vdl.Register((*wireType)(nil))
+ vdl.Register((*wireNamed)(nil))
+ vdl.Register((*wireEnum)(nil))
+ vdl.Register((*wireArray)(nil))
+ vdl.Register((*wireList)(nil))
+ vdl.Register((*wireSet)(nil))
+ vdl.Register((*wireMap)(nil))
+ vdl.Register((*wireField)(nil))
+ vdl.Register((*wireStruct)(nil))
+ vdl.Register((*wireUnion)(nil))
+ vdl.Register((*wireOptional)(nil))
+}
+
+// Primitive types.
+const WireIDBool = typeID(1)
+
+const WireIDByte = typeID(2)
+
+const WireIDString = typeID(3)
+
+const WireIDUint16 = typeID(4)
+
+const WireIDUint32 = typeID(5)
+
+const WireIDUint64 = typeID(6)
+
+const WireIDInt16 = typeID(7)
+
+const WireIDInt32 = typeID(8)
+
+const WireIDInt64 = typeID(9)
+
+const WireIDFloat32 = typeID(10)
+
+const WireIDFloat64 = typeID(11)
+
+const WireIDComplex64 = typeID(12)
+
+const WireIDComplex128 = typeID(13)
+
+const WireIDTypeObject = typeID(14)
+
+const WireIDAny = typeID(15)
+
+// Other commonly used composites.
+const WireIDByteList = typeID(39)
+
+const WireIDStringList = typeID(40)
+
+// The first user-defined typeID is 41.
+const WireIDFirstUserType = typeID(41)
+
+const WireCtrlNil = byte(224)
+
+const WireCtrlEOF = byte(225)