package impl
import (
)
func ( *MessageInfo) ( protoiface.CheckInitializedInput) (protoiface.CheckInitializedOutput, error) {
var pointer
if , := .Message.(*messageState); {
= .pointer()
} else {
= .Message.(*messageReflectWrapper).pointer()
}
return protoiface.CheckInitializedOutput{}, .checkInitializedPointer()
}
func ( *MessageInfo) ( pointer) error {
.init()
if !.needsInitCheck {
return nil
}
if .IsNil() {
for , := range .orderedCoderFields {
if .isRequired {
return errors.RequiredNotSet(string(.Desc.Fields().ByNumber(.num).FullName()))
}
}
return nil
}
if .extensionOffset.IsValid() {
:= .Apply(.extensionOffset).Extensions()
if := .isInitExtensions(); != nil {
return
}
}
for , := range .orderedCoderFields {
if !.isRequired && .funcs.isInit == nil {
continue
}
:= .Apply(.offset)
if .isPointer && .Elem().IsNil() {
if .isRequired {
return errors.RequiredNotSet(string(.Desc.Fields().ByNumber(.num).FullName()))
}
continue
}
if .funcs.isInit == nil {
continue
}
if := .funcs.isInit(, ); != nil {
return
}
}
return nil
}
func ( *MessageInfo) ( *map[int32]ExtensionField) error {
if == nil {
return nil
}
for , := range * {
:= getExtensionFieldInfo(.Type())
if .funcs.isInit == nil {
continue
}
:= .Value()
if !.IsValid() {
continue
}
if := .funcs.isInit(); != nil {
return
}
}
return nil
}
var (
needsInitCheckMu sync.Mutex
needsInitCheckMap sync.Map
)
func ( protoreflect.MessageDescriptor) bool {
if , := needsInitCheckMap.Load(); {
if , := .(bool); {
return
}
}
needsInitCheckMu.Lock()
defer needsInitCheckMu.Unlock()
return needsInitCheckLocked()
}
func ( protoreflect.MessageDescriptor) ( bool) {
if , := needsInitCheckMap.Load(); {
, := .(bool)
return &&
}
needsInitCheckMap.Store(, struct{}{})
defer func() {
needsInitCheckMap.Store(, )
}()
if .RequiredNumbers().Len() > 0 {
return true
}
if .ExtensionRanges().Len() > 0 {
return true
}
for := 0; < .Fields().Len(); ++ {
:= .Fields().Get()
if .IsMap() {
= .MapValue()
}
:= .Message()
if != nil && () {
return true
}
}
return false
}