package impl
import (
)
func ( *MessageInfo, uint32, protoreflect.FieldDescriptor, reflect.StructField, Converter, offset) func( pointer) protoreflect.Value {
:= .Type
if .Kind() == reflect.Ptr {
= .Elem()
}
if .Kind() == protoreflect.EnumKind {
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().AsValueOf(.Type).Elem()
return .PBValueOf()
}
}
switch .Kind() {
case reflect.Bool:
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Bool()
return protoreflect.ValueOfBool(*)
}
case reflect.Int32:
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Int32()
return protoreflect.ValueOfInt32(*)
}
case reflect.Uint32:
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Uint32()
return protoreflect.ValueOfUint32(*)
}
case reflect.Int64:
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Int64()
return protoreflect.ValueOfInt64(*)
}
case reflect.Uint64:
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Uint64()
return protoreflect.ValueOfUint64(*)
}
case reflect.Float32:
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Float32()
return protoreflect.ValueOfFloat32(*)
}
case reflect.Float64:
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Float64()
return protoreflect.ValueOfFloat64(*)
}
case reflect.String:
if .Kind() == protoreflect.BytesKind {
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().StringPtr()
if * == nil {
return .Zero()
}
if len(**) == 0 {
return protoreflect.ValueOfBytes(nil)
}
return protoreflect.ValueOfBytes([]byte(**))
}
}
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().StringPtr()
if * == nil {
return .Zero()
}
return protoreflect.ValueOfString(**)
}
case reflect.Slice:
if .Kind() == protoreflect.StringKind {
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Bytes()
return protoreflect.ValueOfString(string(*))
}
}
return func( pointer) protoreflect.Value {
if .IsNil() || !.present(, ) {
return .Zero()
}
:= .Apply().Bytes()
return protoreflect.ValueOfBytes(*)
}
}
panic("unexpected protobuf kind: " + .Kind().String())
}