modelgen

package
v0.0.0-...-4280267 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Descriptor

type Descriptor struct {
	*descriptor.DescriptorProto
	// contains filtered or unexported fields
}

Descriptor wraps a DescriptorProto.

func (*Descriptor) File

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

func (*Descriptor) PackageName

func (c *Descriptor) PackageName() string

PackageName returns the Go package name for the file the common object belongs to.

func (*Descriptor) Path

func (d *Descriptor) Path() string

Path returns the path string associated with this Descriptor object.

func (*Descriptor) TypeName

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

TypeName returns a cached typename vector.

type EnumDescriptor

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

EnumDescriptor wraps a EnumDescriptorProto.

func (*EnumDescriptor) File

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

func (*EnumDescriptor) PackageName

func (c *EnumDescriptor) PackageName() string

PackageName returns the Go package name for the file the common object belongs to.

func (*EnumDescriptor) Path

func (e *EnumDescriptor) Path() string

Path returns the path string associated with this EnumDescriptor object.

func (*EnumDescriptor) TypeName

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

TypeName returns a cached typename vector.

type FieldInfo

type FieldInfo struct {
	ProtoName string
	GoName    string
	Number    string // Only for proto fields
	Comment   string

	ProtoType TypeInfo
	GoType    TypeInfo
}

FieldInfo contains the data about the field

type FileDescriptor

type FileDescriptor struct {
	*descriptor.FileDescriptorProto
	// contains filtered or unexported fields
}

FileDescriptor wraps a FileDescriptorProto.

type FileDescriptorSetParser

type FileDescriptorSetParser struct {
	Param             map[string]string // Command-line parameters.
	PackageImportPath string            // Go import path of the package we're generating code for
	ImportMap         map[string]string // Mapping from .proto file name to import path

	Pkg map[string]string // The names under which we import support packages
	// contains filtered or unexported fields
}

FileDescriptorSetParser parses the FileDescriptorSetProto and creates an intermediate object that is used to create Model struct.

func CreateFileDescriptorSetParser

func CreateFileDescriptorSetParser(fds *descriptor.FileDescriptorSet, importMap map[string]string, packageImportPath string) (*FileDescriptorSetParser, error)

CreateFileDescriptorSetParser builds a FileDescriptorSetParser instance.

func (*FileDescriptorSetParser) BuildTypeNameMap

func (g *FileDescriptorSetParser) BuildTypeNameMap()

BuildTypeNameMap creates a map of type name to the wrapper Object associated with it.

func (*FileDescriptorSetParser) DefaultPackageName

func (g *FileDescriptorSetParser) DefaultPackageName(obj Object) string

DefaultPackageName returns a full packagen name for the underlying Object type.

func (*FileDescriptorSetParser) ObjectNamed

func (g *FileDescriptorSetParser) ObjectNamed(typeName string) Object

ObjectNamed returns the descriptor for the message or enum with that name.

func (*FileDescriptorSetParser) TypeName

func (g *FileDescriptorSetParser) TypeName(obj Object) string

TypeName returns a full name for the underlying Object type.

func (*FileDescriptorSetParser) WrapTypes

WrapTypes creates wrapper types for messages, enumse and file inside the FileDescriptorSet.

type MessageInfo

type MessageInfo struct {
	Comment string
	Fields  []FieldInfo
}

MessageInfo contains the data about the type/message

type Model

type Model struct {
	TemplateName string
	VarietyName  string

	InterfaceName     string
	PackageImportPath string

	Comment string

	// Info for go interfaces
	GoPackageName string

	// Info for regenerated template proto
	PackageName     string
	TemplateMessage MessageInfo
	// contains filtered or unexported fields
}

Model represents the object used to code generate mixer artifacts.

func Create

func Create(parser *FileDescriptorSetParser) (*Model, error)

Create creates a Model object.

type Object

type Object interface {
	PackageName() string // The name we use in our output (a_b_c), possibly renamed for uniqueness.
	TypeName() []string
	File() *descriptor.FileDescriptorProto
	Path() string
}

Object is a shared interface implemented by EnumDescriptor and Descriptor

type TypeInfo

type TypeInfo struct {
	Name        string
	IsRepeated  bool
	IsMap       bool
	IsValueType bool
	MapKey      *TypeInfo
	MapValue    *TypeInfo
	Import      string
}

TypeInfo contains the data about the field

Jump to

Keyboard shortcuts

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