|
@@ -109,6 +109,11 @@ var (
|
|
|
extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()
|
|
extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// raw is the interface satisfied by RawMessage.
|
|
|
|
|
+type raw interface {
|
|
|
|
|
+ Bytes() []byte
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func writeStruct(w *textWriter, sv reflect.Value) {
|
|
func writeStruct(w *textWriter, sv reflect.Value) {
|
|
|
if sv.Type() == messageSetType {
|
|
if sv.Type() == messageSetType {
|
|
|
writeMessageSet(w, sv.Addr().Interface().(*MessageSet))
|
|
writeMessageSet(w, sv.Addr().Interface().(*MessageSet))
|
|
@@ -159,6 +164,10 @@ func writeStruct(w *textWriter, sv reflect.Value) {
|
|
|
if !w.compact {
|
|
if !w.compact {
|
|
|
w.WriteByte(' ')
|
|
w.WriteByte(' ')
|
|
|
}
|
|
}
|
|
|
|
|
+ if b, ok := fv.Interface().(raw); ok {
|
|
|
|
|
+ writeRaw(w, b.Bytes())
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
if props.Enum != "" && tryWriteEnum(w, props.Enum, fv) {
|
|
if props.Enum != "" && tryWriteEnum(w, props.Enum, fv) {
|
|
|
// Enum written.
|
|
// Enum written.
|
|
|
} else {
|
|
} else {
|
|
@@ -174,6 +183,18 @@ func writeStruct(w *textWriter, sv reflect.Value) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// writeRaw writes an uninterpreted raw message.
|
|
|
|
|
+func writeRaw(w *textWriter, b []byte) {
|
|
|
|
|
+ w.WriteByte('<')
|
|
|
|
|
+ if !w.compact {
|
|
|
|
|
+ w.WriteByte('\n')
|
|
|
|
|
+ }
|
|
|
|
|
+ w.indent()
|
|
|
|
|
+ writeUnknownStruct(w, b)
|
|
|
|
|
+ w.unindent()
|
|
|
|
|
+ w.WriteByte('>')
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// tryWriteEnum attempts to write an enum value as a symbolic constant.
|
|
// tryWriteEnum attempts to write an enum value as a symbolic constant.
|
|
|
// If the enum is unregistered, nothing is written and false is returned.
|
|
// If the enum is unregistered, nothing is written and false is returned.
|
|
|
func tryWriteEnum(w *textWriter, enum string, v reflect.Value) bool {
|
|
func tryWriteEnum(w *textWriter, enum string, v reflect.Value) bool {
|