transformer

package
v0.0.0-...-ae53340 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeMapping = map[string]string{
	"bool":    "bool",
	"int":     "i64",
	"int8":    "byte",
	"int16":   "i16",
	"int32":   "i32",
	"int64":   "i64",
	"uint":    "i64",
	"uint8":   "byte",
	"uint16":  "i16",
	"uint32":  "i32",
	"uint64":  "i64",
	"byte":    "byte",
	"float32": "double",
	"float64": "double",
	"string":  "string",
}

Functions

This section is empty.

Types

type Enum

type Enum struct {
	Name       string
	EnumFields []*EnumField
}

func (*Enum) Generate

func (enum *Enum) Generate() string

type EnumField

type EnumField struct {
	Name  string
	Value string
}

type Function

type Function struct {
	Name     string
	ReqName  string
	ReqType  string
	RespType string
}

type Service

type Service struct {
	Name      string
	Functions []*Function
}

type Struct

type Struct struct {
	Name         string
	StructFields []*StructField
}

func ConvertStruct

func ConvertStruct(name, repoPath, repoImport, curPath string, astSt *ast.StructType, astFile *ast.File) (*Struct, error)

ConvertStruct is used to convert *ast.StructType to *transformer.Struct.

name: struct name.
repoPath: the goMod path where the structure is located.
repoImport: the goMod where the structure is located.
curPath: the directory where the structure is located.

func (*Struct) Generate

func (st *Struct) Generate(structMap, enumMap map[string]struct{}) string

func (*Struct) GenerateSingle

func (st *Struct) GenerateSingle() string

GenerateSingle is used to check if the structural versions of the client and server are consistent.

type StructField

type StructField struct {
	Name            string
	Type            string
	Tag             string
	RelevantStructs []*Struct
	RelevantEnums   []*Enum
}

type ThriftFile

type ThriftFile struct {
	Name      string
	Namespace string
	Structs   []*Struct
	Service   *Service
	// contains filtered or unexported fields
}

func NewThriftFile

func NewThriftFile() *ThriftFile

func (*ThriftFile) Generate

func (tf *ThriftFile) Generate(genPath string) (string, error)

Jump to

Keyboard shortcuts

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