Documentation ¶
Index ¶
- func CamelCase(s string) string
- func CamelCaseSlice(elem []string) string
- type Descriptor
- type EnumDescriptor
- type FileDescriptor
- type Generator
- func (g *Generator) BuildTypeNameMap()
- func (g *Generator) Fail(msgs ...string)
- func (g *Generator) FileOf(fd *descriptor.FileDescriptorProto) *FileDescriptor
- func (g *Generator) GenerateAllFiles()
- func (g *Generator) In()
- func (g *Generator) ObjectNamed(typeName string) Object
- func (g *Generator) Out()
- func (g *Generator) P(str ...interface{})
- func (g *Generator) SetPackageNames()
- func (g *Generator) WrapTypes()
- type Object
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCaseSlice ¶
CamelCaseSlice is like CamelCase, but the argument is a slice of strings to be joined with "_".
Types ¶
type Descriptor ¶
type Descriptor struct { *descriptor.DescriptorProto // contains filtered or unexported fields }
Descriptor represents a protocol buffer message.
func (*Descriptor) PackageName ¶
func (c *Descriptor) PackageName() string
PackageName is name in the package clause in the generated file.
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) PackageName ¶
func (c *EnumDescriptor) PackageName() string
PackageName is name in the package clause in the generated file.
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 FileDescriptor ¶
type FileDescriptor struct { *descriptor.FileDescriptorProto // 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 (*FileDescriptor) PackageName ¶
func (d *FileDescriptor) PackageName() string
PackageName is the package name we'll use in the generated code to refer to this file.
type Generator ¶
type Generator struct { *bytes.Buffer Request *plugin.CodeGeneratorRequest Response *plugin.CodeGeneratorResponse // contains filtered or unexported fields }
Generator is the type whose methods generate the output, stored in the associated response structure.
func New ¶
func New() *Generator
New creates a new generator and allocates the request and response protobufs.
func (*Generator) BuildTypeNameMap ¶
func (g *Generator) BuildTypeNameMap()
BuildTypeNameMap populates g.typeNameToObject.
func (*Generator) FileOf ¶
func (g *Generator) FileOf(fd *descriptor.FileDescriptorProto) *FileDescriptor
FileOf return the FileDescriptor for this FileDescriptorProto.
func (*Generator) GenerateAllFiles ¶
func (g *Generator) GenerateAllFiles()
GenerateAllFiles generates the output for all the files we're outputting.
func (*Generator) ObjectNamed ¶
ObjectNamed returns an object found in g.typeNameToObject.
func (*Generator) P ¶
func (g *Generator) P(str ...interface{})
P prints the arguments to the generated output. It handles strings and int32s, plus handling indirections because they may be *string, etc.
func (*Generator) SetPackageNames ¶
func (g *Generator) SetPackageNames()
SetPackageNames sets the package name for this run. The package name must agree across all files being generated.
func (*Generator) WrapTypes ¶
func (g *Generator) WrapTypes()
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.