blob: 1c563759765dd00ec8ca38386f727bfaedacbaa1 [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}
127
128func (m *messageReflectWrapper) Descriptor() protoreflect.MessageDescriptor {
Damien Neil16163b42019-08-06 15:43:25 -0700129 return m.messageInfo().Desc
Joe Tsai82760ce2019-06-20 03:09:57 -0700130}
Joe Tsaid4211502019-07-02 14:58:02 -0700131func (m *messageReflectWrapper) Type() protoreflect.MessageType {
Damien Neil16163b42019-08-06 15:43:25 -0700132 return m.messageInfo()
Joe Tsaid4211502019-07-02 14:58:02 -0700133}
Joe Tsai82760ce2019-06-20 03:09:57 -0700134func (m *messageReflectWrapper) New() protoreflect.Message {
Damien Neil16163b42019-08-06 15:43:25 -0700135 return m.messageInfo().New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700136}
137func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage {
Joe Tsaifd528ff2019-09-03 16:30:39 -0700138 if m, ok := m.protoUnwrap().(protoreflect.ProtoMessage); ok {
Joe Tsai82760ce2019-06-20 03:09:57 -0700139 return m
140 }
141 return (*messageIfaceWrapper)(m)
142}
Joe Tsaifd528ff2019-09-03 16:30:39 -0700143func (m *messageReflectWrapper) protoUnwrap() interface{} {
Damien Neil16163b42019-08-06 15:43:25 -0700144 return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
Joe Tsai82760ce2019-06-20 03:09:57 -0700145}
Joe Tsai0f81b382019-07-10 23:14:31 -0700146func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {
Joe Tsai2aea6142019-07-31 12:27:30 -0700147 m.messageInfo().init()
148 return &m.messageInfo().methods
Joe Tsai0f81b382019-07-10 23:14:31 -0700149}
Joe Tsai82760ce2019-06-20 03:09:57 -0700150
Joe Tsaif647c822019-07-15 15:56:54 -0700151// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
152// to be able to retrieve a v2 MessageInfo struct.
153//
154// WARNING: This method is exempt from the compatibility promise and
155// may be removed in the future without warning.
156func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo {
Joe Tsai2aea6142019-07-31 12:27:30 -0700157 return m.messageInfo()
Joe Tsaif647c822019-07-15 15:56:54 -0700158}
159
Joe Tsai82760ce2019-06-20 03:09:57 -0700160func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700161 m.messageInfo().init()
Joe Tsai9d637ca2019-09-18 18:08:52 -0700162 for _, ri := range m.messageInfo().rangeInfos {
163 switch ri := ri.(type) {
164 case *fieldInfo:
165 if ri.has(m.pointer()) {
166 if !f(ri.fieldDesc, ri.get(m.pointer())) {
167 return
168 }
169 }
170 case *oneofInfo:
171 if n := ri.which(m.pointer()); n > 0 {
172 fi := m.messageInfo().fields[n]
173 if !f(fi.fieldDesc, fi.get(m.pointer())) {
174 return
175 }
Joe Tsai82760ce2019-06-20 03:09:57 -0700176 }
177 }
178 }
Joe Tsai2aea6142019-07-31 12:27:30 -0700179 m.messageInfo().extensionMap(m.pointer()).Range(f)
Joe Tsai82760ce2019-06-20 03:09:57 -0700180}
181func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool {
Joe Tsai2aea6142019-07-31 12:27:30 -0700182 m.messageInfo().init()
183 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700184 return fi.has(m.pointer())
185 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700186 return m.messageInfo().extensionMap(m.pointer()).Has(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700187 }
188}
189func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700190 m.messageInfo().init()
191 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700192 fi.clear(m.pointer())
193 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700194 m.messageInfo().extensionMap(m.pointer()).Clear(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700195 }
196}
197func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700198 m.messageInfo().init()
199 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700200 return fi.get(m.pointer())
201 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700202 return m.messageInfo().extensionMap(m.pointer()).Get(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700203 }
204}
205func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700206 m.messageInfo().init()
207 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700208 fi.set(m.pointer(), v)
209 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700210 m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
Joe Tsai82760ce2019-06-20 03:09:57 -0700211 }
212}
213func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700214 m.messageInfo().init()
215 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700216 return fi.mutable(m.pointer())
217 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700218 return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700219 }
220}
Damien Neilf5274512019-08-05 10:48:38 -0700221func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700222 m.messageInfo().init()
223 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Damien Neilf5274512019-08-05 10:48:38 -0700224 return fi.newField()
Joe Tsai82760ce2019-06-20 03:09:57 -0700225 } else {
Damien Neilf5274512019-08-05 10:48:38 -0700226 return xt.New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700227 }
228}
229func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
Joe Tsai2aea6142019-07-31 12:27:30 -0700230 m.messageInfo().init()
231 if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
Joe Tsai82760ce2019-06-20 03:09:57 -0700232 return od.Fields().ByNumber(oi.which(m.pointer()))
233 }
234 panic("invalid oneof descriptor")
235}
236func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
Joe Tsai2aea6142019-07-31 12:27:30 -0700237 m.messageInfo().init()
238 return m.messageInfo().getUnknown(m.pointer())
Joe Tsai82760ce2019-06-20 03:09:57 -0700239}
240func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700241 m.messageInfo().init()
242 m.messageInfo().setUnknown(m.pointer(), b)
Joe Tsai82760ce2019-06-20 03:09:57 -0700243}