blob: e894659364d0d7d0402d54905da298b65611572d [file] [log] [blame]
Joe Tsai82760ce2019-06-20 03:09:57 -07001// 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
7package impl
8
9import (
10 "google.golang.org/protobuf/reflect/protoreflect"
Joe Tsai0f81b382019-07-10 23:14:31 -070011 "google.golang.org/protobuf/runtime/protoiface"
Joe Tsai82760ce2019-06-20 03:09:57 -070012)
13
14func (m *messageState) Descriptor() protoreflect.MessageDescriptor {
Damien Neil16163b42019-08-06 15:43:25 -070015 return m.messageInfo().Desc
Joe Tsai82760ce2019-06-20 03:09:57 -070016}
Joe Tsaid4211502019-07-02 14:58:02 -070017func (m *messageState) Type() protoreflect.MessageType {
Damien Neil16163b42019-08-06 15:43:25 -070018 return m.messageInfo()
Joe Tsaid4211502019-07-02 14:58:02 -070019}
Joe Tsai82760ce2019-06-20 03:09:57 -070020func (m *messageState) New() protoreflect.Message {
Damien Neil16163b42019-08-06 15:43:25 -070021 return m.messageInfo().New()
Joe Tsai82760ce2019-06-20 03:09:57 -070022}
23func (m *messageState) Interface() protoreflect.ProtoMessage {
Joe Tsaifd528ff2019-09-03 16:30:39 -070024 return m.protoUnwrap().(protoreflect.ProtoMessage)
Joe Tsai82760ce2019-06-20 03:09:57 -070025}
Joe Tsaifd528ff2019-09-03 16:30:39 -070026func (m *messageState) protoUnwrap() interface{} {
Damien Neil16163b42019-08-06 15:43:25 -070027 return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
Joe Tsai82760ce2019-06-20 03:09:57 -070028}
Joe Tsai0f81b382019-07-10 23:14:31 -070029func (m *messageState) ProtoMethods() *protoiface.Methods {
Joe Tsai2aea6142019-07-31 12:27:30 -070030 m.messageInfo().init()
31 return &m.messageInfo().methods
Joe Tsai0f81b382019-07-10 23:14:31 -070032}
Joe Tsai82760ce2019-06-20 03:09:57 -070033
Joe Tsaif647c822019-07-15 15:56:54 -070034// 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.
39func (m *messageState) ProtoMessageInfo() *MessageInfo {
Joe Tsai2aea6142019-07-31 12:27:30 -070040 return m.messageInfo()
Joe Tsaif647c822019-07-15 15:56:54 -070041}
42
Joe Tsai82760ce2019-06-20 03:09:57 -070043func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
Joe Tsai2aea6142019-07-31 12:27:30 -070044 m.messageInfo().init()
Joe Tsai9d637ca2019-09-18 18:08:52 -070045 for _, ri := range m.messageInfo().rangeInfos {
46 switch ri := ri.(type) {
47 case *fieldInfo:
48 if ri.has(m.pointer()) {
49 if !f(ri.fieldDesc, ri.get(m.pointer())) {
50 return
51 }
52 }
53 case *oneofInfo:
54 if n := ri.which(m.pointer()); n > 0 {
55 fi := m.messageInfo().fields[n]
56 if !f(fi.fieldDesc, fi.get(m.pointer())) {
57 return
58 }
Joe Tsai82760ce2019-06-20 03:09:57 -070059 }
60 }
61 }
Joe Tsai2aea6142019-07-31 12:27:30 -070062 m.messageInfo().extensionMap(m.pointer()).Range(f)
Joe Tsai82760ce2019-06-20 03:09:57 -070063}
64func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool {
Joe Tsai2aea6142019-07-31 12:27:30 -070065 m.messageInfo().init()
66 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070067 return fi.has(m.pointer())
68 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070069 return m.messageInfo().extensionMap(m.pointer()).Has(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -070070 }
71}
72func (m *messageState) Clear(fd protoreflect.FieldDescriptor) {
Joe Tsai2aea6142019-07-31 12:27:30 -070073 m.messageInfo().init()
74 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070075 fi.clear(m.pointer())
76 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070077 m.messageInfo().extensionMap(m.pointer()).Clear(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -070078 }
79}
80func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -070081 m.messageInfo().init()
82 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070083 return fi.get(m.pointer())
84 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070085 return m.messageInfo().extensionMap(m.pointer()).Get(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -070086 }
87}
88func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
Joe Tsai2aea6142019-07-31 12:27:30 -070089 m.messageInfo().init()
90 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070091 fi.set(m.pointer(), v)
92 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070093 m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
Joe Tsai82760ce2019-06-20 03:09:57 -070094 }
95}
96func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -070097 m.messageInfo().init()
98 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070099 return fi.mutable(m.pointer())
100 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700101 return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700102 }
103}
Damien Neilf5274512019-08-05 10:48:38 -0700104func (m *messageState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700105 m.messageInfo().init()
106 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Damien Neilf5274512019-08-05 10:48:38 -0700107 return fi.newField()
Joe Tsai82760ce2019-06-20 03:09:57 -0700108 } else {
Damien Neilf5274512019-08-05 10:48:38 -0700109 return xt.New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700110 }
111}
112func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
Joe Tsai2aea6142019-07-31 12:27:30 -0700113 m.messageInfo().init()
114 if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
Joe Tsai82760ce2019-06-20 03:09:57 -0700115 return od.Fields().ByNumber(oi.which(m.pointer()))
116 }
117 panic("invalid oneof descriptor")
118}
119func (m *messageState) GetUnknown() protoreflect.RawFields {
Joe Tsai2aea6142019-07-31 12:27:30 -0700120 m.messageInfo().init()
121 return m.messageInfo().getUnknown(m.pointer())
Joe Tsai82760ce2019-06-20 03:09:57 -0700122}
123func (m *messageState) SetUnknown(b protoreflect.RawFields) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700124 m.messageInfo().init()
125 m.messageInfo().setUnknown(m.pointer(), b)
Joe Tsai82760ce2019-06-20 03:09:57 -0700126}
Damien Neil82886da2019-11-26 13:27:24 -0800127func (m *messageState) IsValid() bool {
128 return m.pointer().IsNil()
129}
Joe Tsai82760ce2019-06-20 03:09:57 -0700130
131func (m *messageReflectWrapper) Descriptor() protoreflect.MessageDescriptor {
Damien Neil16163b42019-08-06 15:43:25 -0700132 return m.messageInfo().Desc
Joe Tsai82760ce2019-06-20 03:09:57 -0700133}
Joe Tsaid4211502019-07-02 14:58:02 -0700134func (m *messageReflectWrapper) Type() protoreflect.MessageType {
Damien Neil16163b42019-08-06 15:43:25 -0700135 return m.messageInfo()
Joe Tsaid4211502019-07-02 14:58:02 -0700136}
Joe Tsai82760ce2019-06-20 03:09:57 -0700137func (m *messageReflectWrapper) New() protoreflect.Message {
Damien Neil16163b42019-08-06 15:43:25 -0700138 return m.messageInfo().New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700139}
140func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage {
Joe Tsaifd528ff2019-09-03 16:30:39 -0700141 if m, ok := m.protoUnwrap().(protoreflect.ProtoMessage); ok {
Joe Tsai82760ce2019-06-20 03:09:57 -0700142 return m
143 }
144 return (*messageIfaceWrapper)(m)
145}
Joe Tsaifd528ff2019-09-03 16:30:39 -0700146func (m *messageReflectWrapper) protoUnwrap() interface{} {
Damien Neil16163b42019-08-06 15:43:25 -0700147 return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
Joe Tsai82760ce2019-06-20 03:09:57 -0700148}
Joe Tsai0f81b382019-07-10 23:14:31 -0700149func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {
Joe Tsai2aea6142019-07-31 12:27:30 -0700150 m.messageInfo().init()
151 return &m.messageInfo().methods
Joe Tsai0f81b382019-07-10 23:14:31 -0700152}
Joe Tsai82760ce2019-06-20 03:09:57 -0700153
Joe Tsaif647c822019-07-15 15:56:54 -0700154// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
155// to be able to retrieve a v2 MessageInfo struct.
156//
157// WARNING: This method is exempt from the compatibility promise and
158// may be removed in the future without warning.
159func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo {
Joe Tsai2aea6142019-07-31 12:27:30 -0700160 return m.messageInfo()
Joe Tsaif647c822019-07-15 15:56:54 -0700161}
162
Joe Tsai82760ce2019-06-20 03:09:57 -0700163func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700164 m.messageInfo().init()
Joe Tsai9d637ca2019-09-18 18:08:52 -0700165 for _, ri := range m.messageInfo().rangeInfos {
166 switch ri := ri.(type) {
167 case *fieldInfo:
168 if ri.has(m.pointer()) {
169 if !f(ri.fieldDesc, ri.get(m.pointer())) {
170 return
171 }
172 }
173 case *oneofInfo:
174 if n := ri.which(m.pointer()); n > 0 {
175 fi := m.messageInfo().fields[n]
176 if !f(fi.fieldDesc, fi.get(m.pointer())) {
177 return
178 }
Joe Tsai82760ce2019-06-20 03:09:57 -0700179 }
180 }
181 }
Joe Tsai2aea6142019-07-31 12:27:30 -0700182 m.messageInfo().extensionMap(m.pointer()).Range(f)
Joe Tsai82760ce2019-06-20 03:09:57 -0700183}
184func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool {
Joe Tsai2aea6142019-07-31 12:27:30 -0700185 m.messageInfo().init()
186 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700187 return fi.has(m.pointer())
188 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700189 return m.messageInfo().extensionMap(m.pointer()).Has(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700190 }
191}
192func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700193 m.messageInfo().init()
194 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700195 fi.clear(m.pointer())
196 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700197 m.messageInfo().extensionMap(m.pointer()).Clear(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700198 }
199}
200func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700201 m.messageInfo().init()
202 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700203 return fi.get(m.pointer())
204 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700205 return m.messageInfo().extensionMap(m.pointer()).Get(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700206 }
207}
208func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700209 m.messageInfo().init()
210 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700211 fi.set(m.pointer(), v)
212 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700213 m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
Joe Tsai82760ce2019-06-20 03:09:57 -0700214 }
215}
216func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700217 m.messageInfo().init()
218 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700219 return fi.mutable(m.pointer())
220 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700221 return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700222 }
223}
Damien Neilf5274512019-08-05 10:48:38 -0700224func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700225 m.messageInfo().init()
226 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Damien Neilf5274512019-08-05 10:48:38 -0700227 return fi.newField()
Joe Tsai82760ce2019-06-20 03:09:57 -0700228 } else {
Damien Neilf5274512019-08-05 10:48:38 -0700229 return xt.New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700230 }
231}
232func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
Joe Tsai2aea6142019-07-31 12:27:30 -0700233 m.messageInfo().init()
234 if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
Joe Tsai82760ce2019-06-20 03:09:57 -0700235 return od.Fields().ByNumber(oi.which(m.pointer()))
236 }
237 panic("invalid oneof descriptor")
238}
239func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
Joe Tsai2aea6142019-07-31 12:27:30 -0700240 m.messageInfo().init()
241 return m.messageInfo().getUnknown(m.pointer())
Joe Tsai82760ce2019-06-20 03:09:57 -0700242}
243func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700244 m.messageInfo().init()
245 m.messageInfo().setUnknown(m.pointer(), b)
Joe Tsai82760ce2019-06-20 03:09:57 -0700246}
Damien Neil82886da2019-11-26 13:27:24 -0800247func (m *messageReflectWrapper) IsValid() bool {
248 return m.pointer().IsNil()
249}