types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SymbolUser 用戶定義的 型別
	SymbolUser = 0
	// SymbolCore 系統型別
	SymbolCore = 1
)
View Source
const (
	// Write8 byte bool
	Write8 = 1
	// Write16 int16 uint16
	Write16 = 2
	// Write32 float32 int32 uint32
	Write32 = 3
	// Write64 float64 int64 uint64
	Write64 = 4
	// WriteLength bytes strings type repeat
	WriteLength = 5
	// WriteBits bit repeat
	WriteBits = 6
)
View Source
const MaxFieldID = 0x1FFF

MaxFieldID 最大 id

Variables

This section is empty.

Functions

func SetErrorFilename

func SetErrorFilename(e error, filename string) error

SetErrorFilename 設置 錯誤

func ToFieldName

func ToFieldName(typeName string) (name string, e error)

ToFieldName 驗證名稱 並返回 標準名稱

func ToPackageName

func ToPackageName(pkg string) (name string, e error)

ToPackageName 驗證包名 並返回 標準名稱

Types

type Context

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

Context 上下文

func NewContext

func NewContext() *Context

NewContext 創建 上下文

func (*Context) Find

func (c *Context) Find(pkg, name string) (t *Type, e error)

Find 返回 型別

func (*Context) Items

func (c *Context) Items() []*Package

Items 返回 所有 包

func (*Context) Keys

func (c *Context) Keys() map[string]*Package

Keys 返回 所有 包

func (*Context) Register

func (c *Context) Register(pkg, name, filename string, enum bool) (e error)

Register 註冊一個型別

type Enum

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

Enum 定義枚舉

func NewEnum

func NewEnum(pkg, t string) *Enum

NewEnum 創建枚舉

func (*Enum) Items

func (enum *Enum) Items() (items []EnumSymbol)

Items 返回 枚舉

func (*Enum) Register

func (enum *Enum) Register(name string) (e error)

Register 註冊 字段

func (*Enum) RegisterValue

func (enum *Enum) RegisterValue(name string, val int16) (e error)

RegisterValue 註冊 字段

type EnumSymbol

type EnumSymbol struct {
	Name string
	Val  int16
}

EnumSymbol 枚舉 符號信息

func (EnumSymbol) NameString

func (symbol EnumSymbol) NameString() string

NameString 返回名稱 字符串

type Error

type Error struct {
	Filename string
	Message  string
}

Error 錯誤定義

func (Error) Error

func (e Error) Error() string

type Field

type Field struct {
	ID     uint16
	Name   string
	Symbol Symbol
}

Field 屬性

type Fields

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

Fields 屬性

func NewFields

func NewFields(pkg, t string) *Fields

NewFields 創建屬性列表

func (*Fields) Items

func (fields *Fields) Items() (items []*Field)

Items 返回 枚舉

func (*Fields) Register

func (fields *Fields) Register(id uint16, name string, symbol Symbol) (e error)

Register 註冊 字段

type Package

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

Package 註冊包

func NewPackage

func NewPackage(name string) *Package

NewPackage 創建註冊包

func (*Package) FileKeys

func (p *Package) FileKeys() map[string][]*Type

FileKeys 返回 同個檔案中 註冊的型別

func (*Package) Items

func (p *Package) Items() []*Type

Items 返回所有註冊的型別

func (*Package) Keys

func (p *Package) Keys() map[string]*Type

Keys 返回所有註冊的型別

func (*Package) Name

func (p *Package) Name() string

Name 返回 包名

func (*Package) Register

func (p *Package) Register(name, filename string, enum bool) (e error)

Register 註冊一個 型別

type SortType

type SortType []*Type

SortType 實現 排序

func (SortType) Len

func (arrs SortType) Len() int

Len is the number of elements in the collection.

func (SortType) Less

func (arrs SortType) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (SortType) Swap

func (arrs SortType) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type Symbol

type Symbol interface {
	Package() string
	Name() string
	IsRepeat() bool
	Core() int
	IsCore() bool
	IsString() bool
	IsBool() bool
	IsEnum() bool
	IsClass() bool
	SetType(t *Type)
	GetType() *Type
	// 返回 寫入類型
	WriteType() uint8
	WriteString() string
}

Symbol 符號接口

func NewCoreSymbol

func NewCoreSymbol(pkg, name string, repeat bool, writeType uint8) Symbol

NewCoreSymbol 創建 符號

func NewUserSymbol

func NewUserSymbol(pkg, name string, repeat bool, writeType uint8) Symbol

NewUserSymbol 創建 符號

type Type

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

Type .

func NewType

func NewType(pkg *Package, name, filename string, enum bool) *Type

NewType 創建型別

func (*Type) Enum

func (t *Type) Enum() *Enum

Enum 返回 枚舉

func (*Type) Fields

func (t *Type) Fields() *Fields

Fields 返回 屬性

func (*Type) Filename

func (t *Type) Filename() string

Filename 返回 定義檔案

func (*Type) Name

func (t *Type) Name() string

Name 返回 型別 名稱

func (*Type) Package

func (t *Type) Package() *Package

Package 返回 所在包

Jump to

Keyboard shortcuts

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