types

package
v0.0.0-...-0dd21e6 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TUINT64 = 3
)

Variables

View Source
var ScalarValueTypes = [...]ScalarValueType{
	{"int32", "int32", "varint"},
	{"uint32", "uint32", "varint"},
	{"int64", "int64", "varint"},
	{"uint64", "uint64", "varint"},
	{"sint32", "int32", "zigzag32"},
	{"sint64", "int64", "zigzag64"},
	{"float32", "float32", "fixed32"},
	{"float64", "float64", "fixed64"},
	{"fixed32", "uint32", "fixed32"},
	{"fixed64", "uint64", "fixed64"},
	{"bool", "bool", "varint"},
	{"bytes", "[]byte", "bytes"},
	{"string", "string", "bytes"},
}

Functions

func Convert

func Convert(x string, src, dst Type) string

func KeySize

func KeySize(fieldNumber int, wire Wire) int

func KeyValue

func KeyValue(fieldNumber int, wire Wire) uint32

func WireString

func WireString(t Type) string

Types

type Class

type Class uint8
const (
	CScalar Class = iota
	CMessage
	CEnum
)

type Enum

type Enum struct {
	Name   string
	Fields []*EnumField
	// contains filtered or unexported fields
}

func (*Enum) GoType

func (e *Enum) GoType() string

func (*Enum) Pos

func (o *Enum) Pos() scanner.Position

func (*Enum) SetPos

func (o *Enum) SetPos(pos scanner.Position)

type EnumField

type EnumField struct {
	Name  string
	Value int
}

func (*EnumField) GoName

func (e *EnumField) GoName() string

type EnumType

type EnumType struct {
	// contains filtered or unexported fields
}

func (*EnumType) GoType

func (e *EnumType) GoType() string

func (*EnumType) Name

func (e *EnumType) Name() string

func (*EnumType) ScopeClass

func (e *EnumType) ScopeClass() Class

type Flag

type Flag uint
const (
	FOptional Flag = 1 << iota
	FRepeated
	FRequired

	// FPtr mark a pointer field.
	FPtr
)

func (Flag) Is

func (f Flag) Is(mask Flag) bool

func (*Flag) Set

func (f *Flag) Set(mask Flag, value bool)

type ImportedType

type ImportedType struct {
	TypeName string
	Gotype   string
}

func (*ImportedType) GoType

func (i *ImportedType) GoType() string

func (*ImportedType) Name

func (i *ImportedType) Name() string

func (*ImportedType) ScopeClass

func (i *ImportedType) ScopeClass() Class

type Message

type Message struct {
	Name   string
	Fields []*MessageField
	// contains filtered or unexported fields
}

func (*Message) GoType

func (m *Message) GoType() string

func (*Message) Pos

func (o *Message) Pos() scanner.Position

func (*Message) SetPos

func (o *Message) SetPos(pos scanner.Position)

type MessageField

type MessageField struct {
	Flag

	Type     Type
	Name     string
	Sequence int
}

func (*MessageField) Conv

func (f *MessageField) Conv(dst Type) string

Conv converts the filed to dst Type.

func (*MessageField) Elem

func (f *MessageField) Elem() *MessageField

func (*MessageField) Ftype

func (f *MessageField) Ftype() (s string)

Ftype is type of the field in struct field definition

func (*MessageField) GoName

func (f *MessageField) GoName() string

func (*MessageField) GoType

func (f *MessageField) GoType() string

func (*MessageField) IsPtr

func (f *MessageField) IsPtr() bool

func (*MessageField) IsRepeated

func (f *MessageField) IsRepeated() bool

func (*MessageField) Null

func (f *MessageField) Null() string

Null returns the null value of the field.

func (*MessageField) Rtype

func (f *MessageField) Rtype() string

Rtype is return type of the field

func (*MessageField) Selector

func (f *MessageField) Selector(deref bool) string

type MessageType

type MessageType struct {
	// contains filtered or unexported fields
}

func (*MessageType) GoType

func (m *MessageType) GoType() string

func (*MessageType) Name

func (m *MessageType) Name() string

func (*MessageType) ScopeClass

func (m *MessageType) ScopeClass() Class

type Object

type Object struct {
	Obj protoObject
}

func (*Object) GoType

func (o *Object) GoType() string

type Package

type Package struct {
	Name      string
	GoPackage string
	GoOutPath string
	Scope     *Scope

	sync.Mutex
}

func LookupPkg

func LookupPkg(name string) *Package

type ScalarValueType

type ScalarValueType struct {
	// contains filtered or unexported fields
}

func (ScalarValueType) GoType

func (b ScalarValueType) GoType() string

func (ScalarValueType) Name

func (b ScalarValueType) Name() string

func (ScalarValueType) ScopeClass

func (b ScalarValueType) ScopeClass() Class

func (ScalarValueType) WireType

func (b ScalarValueType) WireType() Wire

type Scope

type Scope struct {
	Children []*Scope
	Elems    map[string]*Object
	// contains filtered or unexported fields
}

func NewScope

func NewScope(parent *Scope, name string) *Scope

func (*Scope) Copy

func (s *Scope) Copy(parent *Scope) *Scope

func (*Scope) Lookup

func (s *Scope) Lookup(name string) *Object

func (*Scope) LookupEnum

func (s *Scope) LookupEnum(m *proto.Enum) (msg *Enum)

func (*Scope) LookupMessage

func (s *Scope) LookupMessage(m *proto.Message) (msg *Message)

func (*Scope) LookupOK

func (s *Scope) LookupOK(name string) (*Object, bool)

func (*Scope) LookupParent

func (s *Scope) LookupParent(name string) (*Scope, *Object)

func (*Scope) ResolveName

func (s *Scope) ResolveName(name string) string

func (*Scope) Type

func (s *Scope) Type(t string) (Type, error)

type Type

type Type interface {
	GoType() string
	Name() string
	ScopeClass() Class
}

type UnknownTypeError

type UnknownTypeError struct {
	Type string
}

func (*UnknownTypeError) Error

func (e *UnknownTypeError) Error() string

type Wire

type Wire uint8
const (
	WireVarint Wire = iota
	WireFixed64
	WireBytes
	WireStartGroup
	WireEndGroup
	WireFixed32
)

func WireType

func WireType(t Type) Wire

func (Wire) String

func (w Wire) String() string

Jump to

Keyboard shortcuts

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