gen

package
v7.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "v7.1.1"

Variables

This section is empty.

Functions

func Error

func Error(err error, msgs ...string)

func Fail

func Fail(msgs ...string)

func Main

func Main(g Generator)

Types

type Descriptor

type Descriptor struct {
	*descriptor.DescriptorProto
	Parent *Descriptor // The containing message, if any.
	// contains filtered or unexported fields
}

Descriptor represents a protocol buffer message.

func (*Descriptor) File

func (c *Descriptor) File() *descriptor.FileDescriptorProto

func (*Descriptor) TypeName

func (d *Descriptor) TypeName() []string

TypeName returns the elements of the dotted type name. The package name is not part of this name.

type EnumDescriptor

type EnumDescriptor struct {
	*descriptor.EnumDescriptorProto
	// contains filtered or unexported fields
}

EnumDescriptor describes an enum. If it's at top level, its parent will be nil. Otherwise it will be the descriptor of the message in which it is defined.

func (*EnumDescriptor) File

func (c *EnumDescriptor) File() *descriptor.FileDescriptorProto

func (*EnumDescriptor) TypeName

func (e *EnumDescriptor) TypeName() (s []string)

TypeName returns the elements of the dotted type name. The package name is not part of this name.

type ExtensionDescriptor

type ExtensionDescriptor struct {
	*descriptor.FieldDescriptorProto
	// contains filtered or unexported fields
}

ExtensionDescriptor describes an extension. If it's at top level, its parent will be nil. Otherwise it will be the descriptor of the message in which it is defined.

func (*ExtensionDescriptor) DescName

func (e *ExtensionDescriptor) DescName() string

DescName returns the variable name used for the generated descriptor.

func (*ExtensionDescriptor) File

func (c *ExtensionDescriptor) File() *descriptor.FileDescriptorProto

func (*ExtensionDescriptor) TypeName

func (e *ExtensionDescriptor) TypeName() (s []string)

TypeName returns the elements of the dotted type name. The package name is not part of this name.

type FileDescriptor

type FileDescriptor struct {
	*descriptor.FileDescriptorProto
	Descriptors []*Descriptor          // All the messages defined in this file.
	Enums       []*EnumDescriptor      // All the enums defined in this file.
	Extensions  []*ExtensionDescriptor // All the top-level extensions defined in this file.
	Imported    []*ImportedDescriptor  // All types defined in files publicly imported by this file.
	Services    []*ServiceDescriptor   // All the services defined in this file.

	// Comments, stored as a map of path (comma-separated integers) to the comment.
	Comments map[string]*descriptor.SourceCodeInfo_Location

	Index int // The index of this file in the list of files to generate code for
	// contains filtered or unexported fields
}

FileDescriptor describes an protocol buffer descriptor file (.proto). It includes slices of all the messages and enums defined within it. Those slices are constructed by WrapTypes.

func WrapTypes

func WrapTypes(req *plugin.CodeGeneratorRequest) (genFiles, allFiles []*FileDescriptor, allFilesByName map[string]*FileDescriptor)

WrapTypes walks the incoming data, wrapping DescriptorProtos, EnumDescriptorProtos and FileDescriptorProtos into file-referenced objects within the Generator. It also creates the list of files to generate and so should be called before GenerateAllFiles.

func (*FileDescriptor) BaseFileName

func (d *FileDescriptor) BaseFileName() string

func (*FileDescriptor) PackageComments

func (d *FileDescriptor) PackageComments() string

func (*FileDescriptor) VarName

func (d *FileDescriptor) VarName() string

VarName is the variable name used in generated code to refer to the compressed bytes of this descriptor. It is not exported, so it is only valid inside the generated package.

protoc-gen-go writes its own version of this file, but so does protoc-gen-gogo - with a different name! Twirp aims to be compatible with both; the simplest way forward is to write the file descriptor again as another variable that we control.

type Generator

type Generator interface {
	Generate(in *plugin.CodeGeneratorRequest) *plugin.CodeGeneratorResponse
}

type ImportedDescriptor

type ImportedDescriptor struct {
	Object Object
	// contains filtered or unexported fields
}

ImportedDescriptor describes a type that has been publicly imported from another file.

func (*ImportedDescriptor) File

func (c *ImportedDescriptor) File() *descriptor.FileDescriptorProto

func (*ImportedDescriptor) TypeName

func (id *ImportedDescriptor) TypeName() []string

type MethodDescriptor

type MethodDescriptor struct {
	*descriptor.MethodDescriptorProto

	Path string // The SourceCodeInfo path as comma-separated integers.
	// contains filtered or unexported fields
}

MethodDescriptor represents an RPC method on a protocol buffer service.

func (*MethodDescriptor) File

func (c *MethodDescriptor) File() *descriptor.FileDescriptorProto

func (*MethodDescriptor) TypeName

func (md *MethodDescriptor) TypeName() []string

type Object

type Object interface {
	TypeName() []string
	File() *descriptor.FileDescriptorProto
}

Object is an interface abstracting the abilities shared by enums, messages, extensions and imported objects.

type ServiceDescriptor

type ServiceDescriptor struct {
	*descriptor.ServiceDescriptorProto
	Methods []*MethodDescriptor
	Index   int // index of the ServiceDescriptorProto in its parent FileDescriptorProto

	Path string // The SourceCodeInfo path as comma-separated integers.
	// contains filtered or unexported fields
}

ServiceDescriptor represents a protocol buffer service.

func (*ServiceDescriptor) File

func (c *ServiceDescriptor) File() *descriptor.FileDescriptorProto

func (*ServiceDescriptor) TypeName

func (sd *ServiceDescriptor) TypeName() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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