summaryrefslogtreecommitdiffstats
path: root/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go')
-rw-r--r--vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go32
1 files changed, 18 insertions, 14 deletions
diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go
index dd85915b..55aa1492 100644
--- a/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go
+++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go
@@ -8,8 +8,7 @@
// defined in proto source files and value interfaces which provide the
// ability to examine and manipulate the contents of messages.
//
-//
-// Protocol Buffer Descriptors
+// # Protocol Buffer Descriptors
//
// Protobuf descriptors (e.g., EnumDescriptor or MessageDescriptor)
// are immutable objects that represent protobuf type information.
@@ -26,8 +25,7 @@
// The "google.golang.org/protobuf/reflect/protodesc" package converts between
// google.protobuf.DescriptorProto messages and protobuf descriptors.
//
-//
-// Go Type Descriptors
+// # Go Type Descriptors
//
// A type descriptor (e.g., EnumType or MessageType) is a constructor for
// a concrete Go type that represents the associated protobuf descriptor.
@@ -41,8 +39,7 @@
// The "google.golang.org/protobuf/types/dynamicpb" package can be used to
// create Go type descriptors from protobuf descriptors.
//
-//
-// Value Interfaces
+// # Value Interfaces
//
// The Enum and Message interfaces provide a reflective view over an
// enum or message instance. For enums, it provides the ability to retrieve
@@ -55,13 +52,11 @@
// The "github.com/golang/protobuf/proto".MessageReflect function can be used
// to obtain a reflective view on older messages.
//
-//
-// Relationships
+// # Relationships
//
// The following diagrams demonstrate the relationships between
// various types declared in this package.
//
-//
// ┌───────────────────────────────────┐
// V │
// ┌────────────── New(n) ─────────────┐ │
@@ -83,7 +78,6 @@
//
// • An Enum is a concrete enum instance. Generated enums implement Enum.
//
-//
// ┌──────────────── New() ─────────────────┐
// │ │
// │ ┌─── Descriptor() ─────┐ │ ┌── Interface() ───┐
@@ -98,12 +92,22 @@
//
// • A MessageType describes a concrete Go message type.
// It has a MessageDescriptor and can construct a Message instance.
+// Just as how Go's reflect.Type is a reflective description of a Go type,
+// a MessageType is a reflective description of a Go type for a protobuf message.
//
// • A MessageDescriptor describes an abstract protobuf message type.
-//
-// • A Message is a concrete message instance. Generated messages implement
-// ProtoMessage, which can convert to/from a Message.
-//
+// It has no understanding of Go types. In order to construct a MessageType
+// from just a MessageDescriptor, you can consider looking up the message type
+// in the global registry using protoregistry.GlobalTypes.FindMessageByName
+// or constructing a dynamic MessageType using dynamicpb.NewMessageType.
+//
+// • A Message is a reflective view over a concrete message instance.
+// Generated messages implement ProtoMessage, which can convert to a Message.
+// Just as how Go's reflect.Value is a reflective view over a Go value,
+// a Message is a reflective view over a concrete protobuf message instance.
+// Using Go reflection as an analogy, the ProtoReflect method is similar to
+// calling reflect.ValueOf, and the Message.Interface method is similar to
+// calling reflect.Value.Interface.
//
// ┌── TypeDescriptor() ──┐ ┌───── Descriptor() ─────┐
// │ V │ V