Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 1 | // Copyright 2018 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style. |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Code generated by generate-types. DO NOT EDIT. |
| 6 | |
| 7 | package impl |
| 8 | |
| 9 | import ( |
| 10 | "google.golang.org/protobuf/reflect/protoreflect" |
Joe Tsai | 0f81b38 | 2019-07-10 23:14:31 -0700 | [diff] [blame] | 11 | "google.golang.org/protobuf/runtime/protoiface" |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 12 | ) |
| 13 | |
| 14 | func (m *messageState) Descriptor() protoreflect.MessageDescriptor { |
| 15 | return m.mi.PBType.Descriptor() |
| 16 | } |
Joe Tsai | d421150 | 2019-07-02 14:58:02 -0700 | [diff] [blame] | 17 | func (m *messageState) Type() protoreflect.MessageType { |
| 18 | return m.mi.PBType |
| 19 | } |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 20 | func (m *messageState) New() protoreflect.Message { |
| 21 | return m.mi.PBType.New() |
| 22 | } |
| 23 | func (m *messageState) Interface() protoreflect.ProtoMessage { |
| 24 | return m.ProtoUnwrap().(protoreflect.ProtoMessage) |
| 25 | } |
| 26 | func (m *messageState) ProtoUnwrap() interface{} { |
| 27 | return m.pointer().AsIfaceOf(m.mi.GoType.Elem()) |
| 28 | } |
Joe Tsai | 0f81b38 | 2019-07-10 23:14:31 -0700 | [diff] [blame] | 29 | func (m *messageState) ProtoMethods() *protoiface.Methods { |
| 30 | m.mi.init() |
| 31 | return &m.mi.methods |
| 32 | } |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 33 | |
Joe Tsai | f647c82 | 2019-07-15 15:56:54 -0700 | [diff] [blame^] | 34 | // ProtoMessageInfo is a pseudo-internal API for allowing the v1 code |
| 35 | // to be able to retrieve a v2 MessageInfo struct. |
| 36 | // |
| 37 | // WARNING: This method is exempt from the compatibility promise and |
| 38 | // may be removed in the future without warning. |
| 39 | func (m *messageState) ProtoMessageInfo() *MessageInfo { |
| 40 | return m.mi |
| 41 | } |
| 42 | |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 43 | func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { |
| 44 | m.mi.init() |
| 45 | for _, fi := range m.mi.fields { |
| 46 | if fi.has(m.pointer()) { |
| 47 | if !f(fi.fieldDesc, fi.get(m.pointer())) { |
| 48 | return |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | m.mi.extensionMap(m.pointer()).Range(f) |
| 53 | } |
| 54 | func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool { |
| 55 | m.mi.init() |
| 56 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 57 | return fi.has(m.pointer()) |
| 58 | } else { |
| 59 | return m.mi.extensionMap(m.pointer()).Has(xt) |
| 60 | } |
| 61 | } |
| 62 | func (m *messageState) Clear(fd protoreflect.FieldDescriptor) { |
| 63 | m.mi.init() |
| 64 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 65 | fi.clear(m.pointer()) |
| 66 | } else { |
| 67 | m.mi.extensionMap(m.pointer()).Clear(xt) |
| 68 | } |
| 69 | } |
| 70 | func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value { |
| 71 | m.mi.init() |
| 72 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 73 | return fi.get(m.pointer()) |
| 74 | } else { |
| 75 | return m.mi.extensionMap(m.pointer()).Get(xt) |
| 76 | } |
| 77 | } |
| 78 | func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) { |
| 79 | m.mi.init() |
| 80 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 81 | fi.set(m.pointer(), v) |
| 82 | } else { |
| 83 | m.mi.extensionMap(m.pointer()).Set(xt, v) |
| 84 | } |
| 85 | } |
| 86 | func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { |
| 87 | m.mi.init() |
| 88 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 89 | return fi.mutable(m.pointer()) |
| 90 | } else { |
| 91 | return m.mi.extensionMap(m.pointer()).Mutable(xt) |
| 92 | } |
| 93 | } |
| 94 | func (m *messageState) NewMessage(fd protoreflect.FieldDescriptor) protoreflect.Message { |
| 95 | m.mi.init() |
| 96 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 97 | return fi.newMessage() |
| 98 | } else { |
| 99 | return xt.New().Message() |
| 100 | } |
| 101 | } |
| 102 | func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { |
| 103 | m.mi.init() |
| 104 | if oi := m.mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { |
| 105 | return od.Fields().ByNumber(oi.which(m.pointer())) |
| 106 | } |
| 107 | panic("invalid oneof descriptor") |
| 108 | } |
| 109 | func (m *messageState) GetUnknown() protoreflect.RawFields { |
| 110 | m.mi.init() |
| 111 | return m.mi.getUnknown(m.pointer()) |
| 112 | } |
| 113 | func (m *messageState) SetUnknown(b protoreflect.RawFields) { |
| 114 | m.mi.init() |
| 115 | m.mi.setUnknown(m.pointer(), b) |
| 116 | } |
| 117 | |
| 118 | func (m *messageReflectWrapper) Descriptor() protoreflect.MessageDescriptor { |
| 119 | return m.mi.PBType.Descriptor() |
| 120 | } |
Joe Tsai | d421150 | 2019-07-02 14:58:02 -0700 | [diff] [blame] | 121 | func (m *messageReflectWrapper) Type() protoreflect.MessageType { |
| 122 | return m.mi.PBType |
| 123 | } |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 124 | func (m *messageReflectWrapper) New() protoreflect.Message { |
| 125 | return m.mi.PBType.New() |
| 126 | } |
| 127 | func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage { |
| 128 | if m, ok := m.ProtoUnwrap().(protoreflect.ProtoMessage); ok { |
| 129 | return m |
| 130 | } |
| 131 | return (*messageIfaceWrapper)(m) |
| 132 | } |
| 133 | func (m *messageReflectWrapper) ProtoUnwrap() interface{} { |
| 134 | return m.pointer().AsIfaceOf(m.mi.GoType.Elem()) |
| 135 | } |
Joe Tsai | 0f81b38 | 2019-07-10 23:14:31 -0700 | [diff] [blame] | 136 | func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods { |
| 137 | m.mi.init() |
| 138 | return &m.mi.methods |
| 139 | } |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 140 | |
Joe Tsai | f647c82 | 2019-07-15 15:56:54 -0700 | [diff] [blame^] | 141 | // ProtoMessageInfo is a pseudo-internal API for allowing the v1 code |
| 142 | // to be able to retrieve a v2 MessageInfo struct. |
| 143 | // |
| 144 | // WARNING: This method is exempt from the compatibility promise and |
| 145 | // may be removed in the future without warning. |
| 146 | func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo { |
| 147 | return m.mi |
| 148 | } |
| 149 | |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 150 | func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { |
| 151 | m.mi.init() |
| 152 | for _, fi := range m.mi.fields { |
| 153 | if fi.has(m.pointer()) { |
| 154 | if !f(fi.fieldDesc, fi.get(m.pointer())) { |
| 155 | return |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | m.mi.extensionMap(m.pointer()).Range(f) |
| 160 | } |
| 161 | func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool { |
| 162 | m.mi.init() |
| 163 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 164 | return fi.has(m.pointer()) |
| 165 | } else { |
| 166 | return m.mi.extensionMap(m.pointer()).Has(xt) |
| 167 | } |
| 168 | } |
| 169 | func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) { |
| 170 | m.mi.init() |
| 171 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 172 | fi.clear(m.pointer()) |
| 173 | } else { |
| 174 | m.mi.extensionMap(m.pointer()).Clear(xt) |
| 175 | } |
| 176 | } |
| 177 | func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value { |
| 178 | m.mi.init() |
| 179 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 180 | return fi.get(m.pointer()) |
| 181 | } else { |
| 182 | return m.mi.extensionMap(m.pointer()).Get(xt) |
| 183 | } |
| 184 | } |
| 185 | func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) { |
| 186 | m.mi.init() |
| 187 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 188 | fi.set(m.pointer(), v) |
| 189 | } else { |
| 190 | m.mi.extensionMap(m.pointer()).Set(xt, v) |
| 191 | } |
| 192 | } |
| 193 | func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { |
| 194 | m.mi.init() |
| 195 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 196 | return fi.mutable(m.pointer()) |
| 197 | } else { |
| 198 | return m.mi.extensionMap(m.pointer()).Mutable(xt) |
| 199 | } |
| 200 | } |
| 201 | func (m *messageReflectWrapper) NewMessage(fd protoreflect.FieldDescriptor) protoreflect.Message { |
| 202 | m.mi.init() |
| 203 | if fi, xt := m.mi.checkField(fd); fi != nil { |
| 204 | return fi.newMessage() |
| 205 | } else { |
| 206 | return xt.New().Message() |
| 207 | } |
| 208 | } |
| 209 | func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { |
| 210 | m.mi.init() |
| 211 | if oi := m.mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { |
| 212 | return od.Fields().ByNumber(oi.which(m.pointer())) |
| 213 | } |
| 214 | panic("invalid oneof descriptor") |
| 215 | } |
| 216 | func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields { |
| 217 | m.mi.init() |
| 218 | return m.mi.getUnknown(m.pointer()) |
| 219 | } |
| 220 | func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) { |
| 221 | m.mi.init() |
| 222 | m.mi.setUnknown(m.pointer(), b) |
| 223 | } |