api

package
v0.0.0-...-aac793c Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAnnotationType = errors.New("not a valid AnnotationType")
View Source
var ErrInvalidOrder = errors.New("not a valid Order")

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Doc     []string
	Name    string
	Params  []*AnnotationParam
	Extends []*AnnotationExtend
	Comment string
}

func (*Annotation) To

func (a *Annotation) To(t any) (err error)

type AnnotationExtend

type AnnotationExtend struct {
	Doc     []string
	Name    string
	Values  []structure.ValueWrapper
	Value   structure.ValueWrapper
	Comment string
}

type AnnotationParam

type AnnotationParam struct {
	Doc     []string
	Key     string
	Value   structure.ValueWrapper
	Comment string
}

type AnnotationType

type AnnotationType int
@Enum {
	global
	type
	func
	funcRecv
	funcField
}
const (
	// AnnotationTypeGlobal is an AnnotationType of type global.
	AnnotationTypeGlobal AnnotationType = iota
	// AnnotationTypeType is an AnnotationType of type type.
	AnnotationTypeType
	// AnnotationTypeFunc is an AnnotationType of type func.
	AnnotationTypeFunc
	// AnnotationTypeFuncRecv is an AnnotationType of type funcRecv.
	AnnotationTypeFuncRecv
	// AnnotationTypeFuncField is an AnnotationType of type funcField.
	AnnotationTypeFuncField
)

func ParseAnnotationType

func ParseAnnotationType(value string) (AnnotationType, error)

ParseAnnotationType converts a string to an AnnotationType.

func (AnnotationType) IsValid

func (x AnnotationType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (AnnotationType) Name

func (x AnnotationType) Name() string

Name is the attribute of AnnotationType.

func (AnnotationType) String

func (x AnnotationType) String() string

String implements the Stringer interface.

func (AnnotationType) Val

func (x AnnotationType) Val() int

Val is the attribute of AnnotationType.

type Annotations

type Annotations struct {
	Annotations []*Annotation
}

func (*Annotations) FindAnnotationByName

func (anns *Annotations) FindAnnotationByName(name string) *Annotation

type BaseGenerator

type BaseGenerator[T any] struct {
	Tmpl     *template.Template
	DataList []*T
}

func (*BaseGenerator[T]) ExecuteTemplate

func (bg *BaseGenerator[T]) ExecuteTemplate(wr io.Writer, name string) error

func (*BaseGenerator[T]) GetImports

func (bg *BaseGenerator[T]) GetImports() []string

func (*BaseGenerator[T]) WriteBody

func (bg *BaseGenerator[T]) WriteBody(wr io.Writer) error

func (*BaseGenerator[T]) WriteConst

func (bg *BaseGenerator[T]) WriteConst(wr io.Writer) error

func (*BaseGenerator[T]) WriteInitFunc

func (bg *BaseGenerator[T]) WriteInitFunc(wr io.Writer) error

type Bool

type Bool struct {
	V Boolean `@("true" | "false") ","? `
}

func (Bool) Value

func (b Bool) Value() any

type Boolean

type Boolean bool

func (*Boolean) Capture

func (b *Boolean) Capture(values []string) error

type FileInfo

type FileInfo struct {
	ModuleName           string
	ModuleAbsLocalPath   string
	FileFullPath         string
	FileFullAbsLocalPath string
}

func GetFileInfo

func GetFileInfo(filename string) (*FileInfo, error)

type Float

type Float struct {
	V float64 `@Float ","? `
}

func (Float) Value

func (f Float) Value() any

type Generator

type Generator interface {
	GetImports() []string
	WriteConst(wr io.Writer) error
	WriteInitFunc(wr io.Writer) error
	WriteBody(wr io.Writer) error
}

type GeneratorFactory

type GeneratorFactory interface {
	Annotations() map[string][]AnnotationType // a map of name -> []AnnotationType
	New([]*TypedAnnotation) (Generator, error)
}

type IOrder

type IOrder interface {
	Order() Order
}

type Int

type Int struct {
	V int `@(("-" | "+")? Int) ","? `
}

func (Int) Value

func (i Int) Value() any

type Order

type Order int

Order

@Enum {
	First = 0
	High = 10
	AboveNormal = 20
	Normal = 30
	BelowNormal = 40
}
const (
	// OrderFirst is an Order of type First.
	OrderFirst Order = 0
	// OrderHigh is an Order of type High.
	OrderHigh Order = 10
	// OrderAboveNormal is an Order of type AboveNormal.
	OrderAboveNormal Order = 20
	// OrderNormal is an Order of type Normal.
	OrderNormal Order = 30
	// OrderBelowNormal is an Order of type BelowNormal.
	OrderBelowNormal Order = 40
)

func ParseOrder

func ParseOrder(value string) (Order, error)

ParseOrder converts a string to an Order.

func (Order) IsValid

func (x Order) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (Order) Name

func (x Order) Name() string

Name is the attribute of Order.

func (Order) String

func (x Order) String() string

String implements the Stringer interface.

func (Order) Val

func (x Order) Val() int

Val is the attribute of Order.

type Slice

type Slice struct {
	V []structure.ValueWrapper `"{" @@* "}"`
}

func (Slice) Value

func (s Slice) Value() any

type String

type String struct {
	V string `@(String | Ident) ","? `
}

func (String) Value

func (s String) Value() any

type TypedAnnotation

type TypedAnnotation struct {
	Type        AnnotationType
	Node        ast.Node
	Annotations *Annotations
	Parent      *TypedAnnotation
	FileInfo    *FileInfo
}

type Uint

type Uint struct {
	V uint `@Int ","? `
}

func (Uint) Value

func (u Uint) Value() any

Jump to

Keyboard shortcuts

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