internal

package
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxNormalTag is the maximum allowed tag number for a field in a normal message.
	MaxNormalTag = 536870911 // 2^29 - 1

	// MaxMessageSetTag is the maximum allowed tag number of a field in a message that
	// uses the message set wire format.
	MaxMessageSetTag = math.MaxInt32 - 1

	// MaxTag is the maximum allowed tag number. (It is the same as MaxMessageSetTag
	// since that is the absolute highest allowed.)
	MaxTag = MaxMessageSetTag

	// SpecialReservedStart is the first tag in a range that is reserved and not
	// allowed for use in message definitions.
	SpecialReservedStart = 19000
	// SpecialReservedEnd is the last tag in a range that is reserved and not
	// allowed for use in message definitions.
	SpecialReservedEnd = 19999

	// File_packageTag is the tag number of the package element in a file
	// descriptor proto.
	File_packageTag = 2
	// File_dependencyTag is the tag number of the dependencies element in a
	// file descriptor proto.
	File_dependencyTag = 3
	// File_messagesTag is the tag number of the messages element in a file
	// descriptor proto.
	File_messagesTag = 4
	// File_enumsTag is the tag number of the enums element in a file descriptor
	// proto.
	File_enumsTag = 5
	// File_servicesTag is the tag number of the services element in a file
	// descriptor proto.
	File_servicesTag = 6
	// File_extensionsTag is the tag number of the extensions element in a file
	// descriptor proto.
	File_extensionsTag = 7
	// File_optionsTag is the tag number of the options element in a file
	// descriptor proto.
	File_optionsTag = 8
	// File_syntaxTag is the tag number of the syntax element in a file
	// descriptor proto.
	File_syntaxTag = 12
	// File_editionTag is the tag number of the edition element in a file
	// descriptor proto.
	File_editionTag = 14
	// Message_nameTag is the tag number of the name element in a message
	// descriptor proto.
	Message_nameTag = 1
	// Message_fieldsTag is the tag number of the fields element in a message
	// descriptor proto.
	Message_fieldsTag = 2
	// Message_nestedMessagesTag is the tag number of the nested messages
	// element in a message descriptor proto.
	Message_nestedMessagesTag = 3
	// Message_enumsTag is the tag number of the enums element in a message
	// descriptor proto.
	Message_enumsTag = 4
	// Message_extensionRangeTag is the tag number of the extension ranges
	// element in a message descriptor proto.
	Message_extensionRangeTag = 5
	// Message_extensionsTag is the tag number of the extensions element in a
	// message descriptor proto.
	Message_extensionsTag = 6
	// Message_optionsTag is the tag number of the options element in a message
	// descriptor proto.
	Message_optionsTag = 7
	// Message_oneOfsTag is the tag number of the one-ofs element in a message
	// descriptor proto.
	Message_oneOfsTag = 8
	// Message_reservedRangeTag is the tag number of the reserved ranges element
	// in a message descriptor proto.
	Message_reservedRangeTag = 9
	// Message_reservedNameTag is the tag number of the reserved names element
	// in a message descriptor proto.
	Message_reservedNameTag = 10
	// ExtensionRange_startTag is the tag number of the start index in an
	// extension range proto.
	ExtensionRange_startTag = 1
	// ExtensionRange_endTag is the tag number of the end index in an
	// extension range proto.
	ExtensionRange_endTag = 2
	// ExtensionRange_optionsTag is the tag number of the options element in an
	// extension range proto.
	ExtensionRange_optionsTag = 3
	// ReservedRange_startTag is the tag number of the start index in a reserved
	// range proto.
	ReservedRange_startTag = 1
	// ReservedRange_endTag is the tag number of the end index in a reserved
	// range proto.
	ReservedRange_endTag = 2
	// Field_nameTag is the tag number of the name element in a field descriptor
	// proto.
	Field_nameTag = 1
	// Field_extendeeTag is the tag number of the extendee element in a field
	// descriptor proto.
	Field_extendeeTag = 2
	// Field_numberTag is the tag number of the number element in a field
	// descriptor proto.
	Field_numberTag = 3
	// Field_labelTag is the tag number of the label element in a field
	// descriptor proto.
	Field_labelTag = 4
	// Field_typeTag is the tag number of the type element in a field descriptor
	// proto.
	Field_typeTag = 5
	// Field_typeNameTag is the tag number of the type name element in a field
	// descriptor proto.
	Field_typeNameTag = 6
	// Field_defaultTag is the tag number of the default value element in a
	// field descriptor proto.
	Field_defaultTag = 7
	// Field_optionsTag is the tag number of the options element in a field
	// descriptor proto.
	Field_optionsTag = 8
	// Field_jsonNameTag is the tag number of the JSON name element in a field
	// descriptor proto.
	Field_jsonNameTag = 10
	// Field_proto3OptionalTag is the tag number of the proto3_optional element
	// in a descriptor proto.
	Field_proto3OptionalTag = 17
	// OneOf_nameTag is the tag number of the name element in a one-of
	// descriptor proto.
	OneOf_nameTag = 1
	// OneOf_optionsTag is the tag number of the options element in a one-of
	// descriptor proto.
	OneOf_optionsTag = 2
	// Enum_nameTag is the tag number of the name element in an enum descriptor
	// proto.
	Enum_nameTag = 1
	// Enum_valuesTag is the tag number of the values element in an enum
	// descriptor proto.
	Enum_valuesTag = 2
	// Enum_optionsTag is the tag number of the options element in an enum
	// descriptor proto.
	Enum_optionsTag = 3
	// Enum_reservedRangeTag is the tag number of the reserved ranges element in
	// an enum descriptor proto.
	Enum_reservedRangeTag = 4
	// Enum_reservedNameTag is the tag number of the reserved names element in
	// an enum descriptor proto.
	Enum_reservedNameTag = 5
	// EnumVal_nameTag is the tag number of the name element in an enum value
	// descriptor proto.
	EnumVal_nameTag = 1
	// EnumVal_numberTag is the tag number of the number element in an enum
	// value descriptor proto.
	EnumVal_numberTag = 2
	// EnumVal_optionsTag is the tag number of the options element in an enum
	// value descriptor proto.
	EnumVal_optionsTag = 3
	// Service_nameTag is the tag number of the name element in a service
	// descriptor proto.
	Service_nameTag = 1
	// Service_methodsTag is the tag number of the methods element in a service
	// descriptor proto.
	Service_methodsTag = 2
	// Service_optionsTag is the tag number of the options element in a service
	// descriptor proto.
	Service_optionsTag = 3
	// Method_nameTag is the tag number of the name element in a method
	// descriptor proto.
	Method_nameTag = 1
	// Method_inputTag is the tag number of the input type element in a method
	// descriptor proto.
	Method_inputTag = 2
	// Method_outputTag is the tag number of the output type element in a method
	// descriptor proto.
	Method_outputTag = 3
	// Method_optionsTag is the tag number of the options element in a method
	// descriptor proto.
	Method_optionsTag = 4
	// Method_inputStreamTag is the tag number of the input stream flag in a
	// method descriptor proto.
	Method_inputStreamTag = 5
	// Method_outputStreamTag is the tag number of the output stream flag in a
	// method descriptor proto.
	Method_outputStreamTag = 6

	// UninterpretedOptionsTag is the tag number of the uninterpreted options
	// element. All *Options messages use the same tag for the field that stores
	// uninterpreted options.
	UninterpretedOptionsTag = 999

	// Uninterpreted_nameTag is the tag number of the name element in an
	// uninterpreted options proto.
	Uninterpreted_nameTag = 2
	// Uninterpreted_identTag is the tag number of the identifier value in an
	// uninterpreted options proto.
	Uninterpreted_identTag = 3
	// Uninterpreted_posIntTag is the tag number of the positive int value in an
	// uninterpreted options proto.
	Uninterpreted_posIntTag = 4
	// Uninterpreted_negIntTag is the tag number of the negative int value in an
	// uninterpreted options proto.
	Uninterpreted_negIntTag = 5
	// Uninterpreted_doubleTag is the tag number of the double value in an
	// uninterpreted options proto.
	Uninterpreted_doubleTag = 6
	// Uninterpreted_stringTag is the tag number of the string value in an
	// uninterpreted options proto.
	Uninterpreted_stringTag = 7
	// Uninterpreted_aggregateTag is the tag number of the aggregate value in an
	// uninterpreted options proto.
	Uninterpreted_aggregateTag = 8
	// UninterpretedName_nameTag is the tag number of the name element in an
	// uninterpreted option name proto.
	UninterpretedName_nameTag = 1
)

Variables

This section is empty.

Functions

func CreatePrefixList

func CreatePrefixList(pkg string) []string

CreatePrefixList returns a list of package prefixes to search when resolving a symbol name. If the given package is blank, it returns only the empty string. If the given package contains only one token, e.g. "foo", it returns that token and the empty string, e.g. ["foo", ""]. Otherwise, it returns successively shorter prefixes of the package and then the empty string. For example, for a package named "foo.bar.baz" it will return the following list:

["foo.bar.baz", "foo.bar", "foo", ""]

func GetMaxTag added in v1.6.1

func GetMaxTag(isMessageSet bool) int32

GetMaxTag returns the max tag number allowed, based on whether a message uses message set wire format or not.

func InitCap

func InitCap(name string) string

InitCap returns the given field name, but with the first letter capitalized.

func JsonName

func JsonName(name string) string

JsonName returns the default JSON name for a field with the given name. This mirrors the algorithm in protoc:

https://github.com/protocolbuffers/protobuf/blob/v21.3/src/google/protobuf/descriptor.cc#L95

func PopulateSourceInfoMap added in v1.2.0

func PopulateSourceInfoMap(fd *descriptorpb.FileDescriptorProto, m SourceInfoMap)

PopulateSourceInfoMap populates the given SourceInfoMap with information from the given file descriptor.

func ProcessProto3OptionalFields added in v1.7.0

func ProcessProto3OptionalFields(msgd *descriptorpb.DescriptorProto, callback func(*descriptorpb.FieldDescriptorProto, *descriptorpb.OneofDescriptorProto))

ProcessProto3OptionalFields adds synthetic oneofs to the given message descriptor for each proto3 optional field. It also updates the fields to have the correct oneof index reference. The given callback, if not nil, is called for each synthetic oneof created.

func RecomputeSourceInfo added in v1.2.0

func RecomputeSourceInfo(c SourceInfoComputer)

RecomputeSourceInfo is used to initiate recomputation of source info. This is is used by the protoparse package, after it interprets options.

func RegisterExtensionsFromImportedFile added in v1.15.5

func RegisterExtensionsFromImportedFile(reg *protoregistry.Types, fd protoreflect.FileDescriptor)

RegisterExtensionsFromImportedFile registers extensions in the given file as well as those in its public imports. So if another file imports the given fd, this adds all extensions made visible to that importing file.

All extensions in the given file are made visible to the importing file, and so are extensions in any public imports in the given file.

func RegisterExtensionsVisibleToFile added in v1.15.5

func RegisterExtensionsVisibleToFile(reg *protoregistry.Types, fd protoreflect.FileDescriptor)

RegisterExtensionsVisibleToFile registers all extensions visible to the given file. This includes all extensions defined in fd and as well as extensions defined in the files that it imports (and any public imports thereof, etc).

This is effectively the same as registering the extensions in fd and then calling RegisterExtensionsFromImportedFile for each file imported by fd.

func RegisterTypesVisibleToFile added in v1.15.5

func RegisterTypesVisibleToFile(reg *protoregistry.Types, fd protoreflect.FileDescriptor)

RegisterTypesVisibleToFile registers all types visible to the given file. This is the same as RegisterExtensionsVisibleToFile but it also registers message and enum types, not just extensions.

Types

type SourceInfoComputeFunc added in v1.2.0

type SourceInfoComputeFunc func()

SourceInfoComputeFunc is the type that a desc.Descriptor will embed. It will be aliased in the desc package to an unexported name so it is not marked as an exported field in reflection and not present in Go docs.

type SourceInfoComputer added in v1.2.0

type SourceInfoComputer interface {
	// contains filtered or unexported methods
}

SourceInfoComputer is a single method which will be invoked to recompute source info. This is needed for the protoparse package, which needs to link descriptors without source info in order to interpret options, but then needs to re-compute source info after that interpretation so that final linked descriptors expose the right info.

type SourceInfoMap

type SourceInfoMap map[string][]*descriptorpb.SourceCodeInfo_Location

SourceInfoMap is a map of paths in a descriptor to the corresponding source code info.

func CreateSourceInfoMap

func CreateSourceInfoMap(fd *descriptorpb.FileDescriptorProto) SourceInfoMap

CreateSourceInfoMap constructs a new SourceInfoMap and populates it with the source code info in the given file descriptor proto.

func (SourceInfoMap) Add added in v1.5.0

Add stores the given source code info for the given path.

func (SourceInfoMap) Get

Get returns the source code info for the given path. If there are multiple locations for the same path, the first one is returned.

func (SourceInfoMap) GetAll added in v1.5.0

GetAll returns all source code info for the given path.

func (SourceInfoMap) PutIfAbsent

func (m SourceInfoMap) PutIfAbsent(path []int32, loc *descriptorpb.SourceCodeInfo_Location) bool

PutIfAbsent stores the given source code info for the given path only if the given path does not exist in the map. This method returns true when the value is stored, false if the path already exists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL