blob: 574fb4fbd783a4f576dd962768409a61b7ca3457 [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()
45 for _, fi := range m.messageInfo().fields {
Joe Tsai82760ce2019-06-20 03:09:57 -070046 if fi.has(m.pointer()) {
47 if !f(fi.fieldDesc, fi.get(m.pointer())) {
48 return
49 }
50 }
51 }
Joe Tsai2aea6142019-07-31 12:27:30 -070052 m.messageInfo().extensionMap(m.pointer()).Range(f)
Joe Tsai82760ce2019-06-20 03:09:57 -070053}
54func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool {
Joe Tsai2aea6142019-07-31 12:27:30 -070055 m.messageInfo().init()
56 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070057 return fi.has(m.pointer())
58 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070059 return m.messageInfo().extensionMap(m.pointer()).Has(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -070060 }
61}
62func (m *messageState) Clear(fd protoreflect.FieldDescriptor) {
Joe Tsai2aea6142019-07-31 12:27:30 -070063 m.messageInfo().init()
64 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070065 fi.clear(m.pointer())
66 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070067 m.messageInfo().extensionMap(m.pointer()).Clear(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -070068 }
69}
70func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -070071 m.messageInfo().init()
72 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070073 return fi.get(m.pointer())
74 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070075 return m.messageInfo().extensionMap(m.pointer()).Get(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -070076 }
77}
78func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
Joe Tsai2aea6142019-07-31 12:27:30 -070079 m.messageInfo().init()
80 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070081 fi.set(m.pointer(), v)
82 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070083 m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
Joe Tsai82760ce2019-06-20 03:09:57 -070084 }
85}
86func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -070087 m.messageInfo().init()
88 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -070089 return fi.mutable(m.pointer())
90 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -070091 return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -070092 }
93}
Damien Neilf5274512019-08-05 10:48:38 -070094func (m *messageState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -070095 m.messageInfo().init()
96 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Damien Neilf5274512019-08-05 10:48:38 -070097 return fi.newField()
Joe Tsai82760ce2019-06-20 03:09:57 -070098 } else {
Damien Neilf5274512019-08-05 10:48:38 -070099 return xt.New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700100 }
101}
102func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
Joe Tsai2aea6142019-07-31 12:27:30 -0700103 m.messageInfo().init()
104 if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
Joe Tsai82760ce2019-06-20 03:09:57 -0700105 return od.Fields().ByNumber(oi.which(m.pointer()))
106 }
107 panic("invalid oneof descriptor")
108}
109func (m *messageState) GetUnknown() protoreflect.RawFields {
Joe Tsai2aea6142019-07-31 12:27:30 -0700110 m.messageInfo().init()
111 return m.messageInfo().getUnknown(m.pointer())
Joe Tsai82760ce2019-06-20 03:09:57 -0700112}
113func (m *messageState) SetUnknown(b protoreflect.RawFields) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700114 m.messageInfo().init()
115 m.messageInfo().setUnknown(m.pointer(), b)
Joe Tsai82760ce2019-06-20 03:09:57 -0700116}
117
118func (m *messageReflectWrapper) Descriptor() protoreflect.MessageDescriptor {
Damien Neil16163b42019-08-06 15:43:25 -0700119 return m.messageInfo().Desc
Joe Tsai82760ce2019-06-20 03:09:57 -0700120}
Joe Tsaid4211502019-07-02 14:58:02 -0700121func (m *messageReflectWrapper) Type() protoreflect.MessageType {
Damien Neil16163b42019-08-06 15:43:25 -0700122 return m.messageInfo()
Joe Tsaid4211502019-07-02 14:58:02 -0700123}
Joe Tsai82760ce2019-06-20 03:09:57 -0700124func (m *messageReflectWrapper) New() protoreflect.Message {
Damien Neil16163b42019-08-06 15:43:25 -0700125 return m.messageInfo().New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700126}
127func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage {
Joe Tsaifd528ff2019-09-03 16:30:39 -0700128 if m, ok := m.protoUnwrap().(protoreflect.ProtoMessage); ok {
Joe Tsai82760ce2019-06-20 03:09:57 -0700129 return m
130 }
131 return (*messageIfaceWrapper)(m)
132}
Joe Tsaifd528ff2019-09-03 16:30:39 -0700133func (m *messageReflectWrapper) protoUnwrap() interface{} {
Damien Neil16163b42019-08-06 15:43:25 -0700134 return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
Joe Tsai82760ce2019-06-20 03:09:57 -0700135}
Joe Tsai0f81b382019-07-10 23:14:31 -0700136func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {
Joe Tsai2aea6142019-07-31 12:27:30 -0700137 m.messageInfo().init()
138 return &m.messageInfo().methods
Joe Tsai0f81b382019-07-10 23:14:31 -0700139}
Joe Tsai82760ce2019-06-20 03:09:57 -0700140
Joe Tsaif647c822019-07-15 15:56:54 -0700141// 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.
146func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo {
Joe Tsai2aea6142019-07-31 12:27:30 -0700147 return m.messageInfo()
Joe Tsaif647c822019-07-15 15:56:54 -0700148}
149
Joe Tsai82760ce2019-06-20 03:09:57 -0700150func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700151 m.messageInfo().init()
152 for _, fi := range m.messageInfo().fields {
Joe Tsai82760ce2019-06-20 03:09:57 -0700153 if fi.has(m.pointer()) {
154 if !f(fi.fieldDesc, fi.get(m.pointer())) {
155 return
156 }
157 }
158 }
Joe Tsai2aea6142019-07-31 12:27:30 -0700159 m.messageInfo().extensionMap(m.pointer()).Range(f)
Joe Tsai82760ce2019-06-20 03:09:57 -0700160}
161func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool {
Joe Tsai2aea6142019-07-31 12:27:30 -0700162 m.messageInfo().init()
163 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700164 return fi.has(m.pointer())
165 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700166 return m.messageInfo().extensionMap(m.pointer()).Has(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700167 }
168}
169func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700170 m.messageInfo().init()
171 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700172 fi.clear(m.pointer())
173 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700174 m.messageInfo().extensionMap(m.pointer()).Clear(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700175 }
176}
177func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700178 m.messageInfo().init()
179 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700180 return fi.get(m.pointer())
181 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700182 return m.messageInfo().extensionMap(m.pointer()).Get(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700183 }
184}
185func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700186 m.messageInfo().init()
187 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700188 fi.set(m.pointer(), v)
189 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700190 m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
Joe Tsai82760ce2019-06-20 03:09:57 -0700191 }
192}
193func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700194 m.messageInfo().init()
195 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Joe Tsai82760ce2019-06-20 03:09:57 -0700196 return fi.mutable(m.pointer())
197 } else {
Joe Tsai2aea6142019-07-31 12:27:30 -0700198 return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
Joe Tsai82760ce2019-06-20 03:09:57 -0700199 }
200}
Damien Neilf5274512019-08-05 10:48:38 -0700201func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
Joe Tsai2aea6142019-07-31 12:27:30 -0700202 m.messageInfo().init()
203 if fi, xt := m.messageInfo().checkField(fd); fi != nil {
Damien Neilf5274512019-08-05 10:48:38 -0700204 return fi.newField()
Joe Tsai82760ce2019-06-20 03:09:57 -0700205 } else {
Damien Neilf5274512019-08-05 10:48:38 -0700206 return xt.New()
Joe Tsai82760ce2019-06-20 03:09:57 -0700207 }
208}
209func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
Joe Tsai2aea6142019-07-31 12:27:30 -0700210 m.messageInfo().init()
211 if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
Joe Tsai82760ce2019-06-20 03:09:57 -0700212 return od.Fields().ByNumber(oi.which(m.pointer()))
213 }
214 panic("invalid oneof descriptor")
215}
216func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
Joe Tsai2aea6142019-07-31 12:27:30 -0700217 m.messageInfo().init()
218 return m.messageInfo().getUnknown(m.pointer())
Joe Tsai82760ce2019-06-20 03:09:57 -0700219}
220func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
Joe Tsai2aea6142019-07-31 12:27:30 -0700221 m.messageInfo().init()
222 m.messageInfo().setUnknown(m.pointer(), b)
Joe Tsai82760ce2019-06-20 03:09:57 -0700223}