generators

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Header = `// Code generated by ` + shared.Program + `. DO NOT EDIT.`
)

Variables

This section is empty.

Functions

func AdaptUnionToOldVersionOfGenerator

func AdaptUnionToOldVersionOfGenerator(union shape.UnionLike) ([]string, map[string][]Branching)

func PtrStr

func PtrStr(x string) *string

func TemplateHelperShapeVariantToName

func TemplateHelperShapeVariantToName(x shape.Shape) string

Types

type Branching

type Branching struct {
	Lit  *string
	List *string
	Map  *string
}

type DeSerJSONGenerator

type DeSerJSONGenerator struct {
	Union shape.UnionLike
	// contains filtered or unexported fields
}

func NewDeSerJSONGenerator

func NewDeSerJSONGenerator(union shape.UnionLike, helper *Helpers) *DeSerJSONGenerator

func (*DeSerJSONGenerator) Generate

func (g *DeSerJSONGenerator) Generate() ([]byte, error)

func (*DeSerJSONGenerator) IsStruct

func (g *DeSerJSONGenerator) IsStruct(x shape.Shape) bool

func (*DeSerJSONGenerator) JSONFieldName

func (g *DeSerJSONGenerator) JSONFieldName(x shape.FieldLike) string

func (*DeSerJSONGenerator) JSONVariantName

func (g *DeSerJSONGenerator) JSONVariantName(x shape.Shape) string

func (*DeSerJSONGenerator) MarshalTemplate

func (g *DeSerJSONGenerator) MarshalTemplate(field *shape.FieldLike, depth int) string

func (*DeSerJSONGenerator) UnmarshalTemplate

func (g *DeSerJSONGenerator) UnmarshalTemplate(field *shape.FieldLike, depth int) string

func (*DeSerJSONGenerator) VariantName

func (g *DeSerJSONGenerator) VariantName(x shape.Shape) string

type DeriveFuncMatchGenerator

type DeriveFuncMatchGenerator struct {
	Header      string
	PackageName string
	MatchSpec   MatchSpec
}

func (*DeriveFuncMatchGenerator) Generate

func (g *DeriveFuncMatchGenerator) Generate() ([]byte, error)

type FunctionMatchGenerator

type FunctionMatchGenerator struct {
	Header      string
	PackageName string
	MaxSize     int
}

func (*FunctionMatchGenerator) Generate

func (t *FunctionMatchGenerator) Generate() ([]byte, error)

type GenerateOption

type GenerateOption func(o *generatorOptions)

func WithBufferedImports

func WithBufferedImports() GenerateOption

func WithPackageName

func WithPackageName(name string) GenerateOption

type Generator

type Generator interface {
	Generate() ([]byte, error)
}

type Helpers

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

func NewHelper

func NewHelper(fs ...GenerateOption) *Helpers

func (*Helpers) Func

func (help *Helpers) Func() template.FuncMap

func (*Helpers) RenderBufferedHeader

func (help *Helpers) RenderBufferedHeader() string

func (*Helpers) RenderBufferedImport

func (help *Helpers) RenderBufferedImport() string

func (*Helpers) RenderHeader

func (help *Helpers) RenderHeader() string

func (*Helpers) RenderImport

func (help *Helpers) RenderImport(importName ...string) string

type InferredDeriveFuncMatchInfo

type InferredDeriveFuncMatchInfo struct {
	PackageName string
	// contains filtered or unexported fields
}

func InferDeriveFuncMatchFromFile

func InferDeriveFuncMatchFromFile(filename string) (*InferredDeriveFuncMatchInfo, error)

func (*InferredDeriveFuncMatchInfo) MatchSpec

func (f *InferredDeriveFuncMatchInfo) MatchSpec(name string) (*MatchSpec, error)

func (*InferredDeriveFuncMatchInfo) Visit

type MatchBuilder

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

func NewMatchBuilder

func NewMatchBuilder() *MatchBuilder

func (*MatchBuilder) AddCase

func (b *MatchBuilder) AddCase(name string, inputs ...string) error

func (*MatchBuilder) Build

func (b *MatchBuilder) Build() (*MatchSpec, error)

func (*MatchBuilder) SetInputs

func (b *MatchBuilder) SetInputs(types ...string) error

func (*MatchBuilder) SetName

func (b *MatchBuilder) SetName(name string) error

type MatchSpec

type MatchSpec struct {
	Name   string
	Names  []string
	Inputs []string
	Cases  [][]string
}

type ReducerBreadthFirstGenerator

type ReducerBreadthFirstGenerator struct {
	Name     variantName
	Types    []typeName
	Branches map[typeName][]Branching
	Helper   *Helpers
	// contains filtered or unexported fields
}

func NewReducerBreadthFirstGenerator

func NewReducerBreadthFirstGenerator(
	union shape.UnionLike,
	helper *Helpers,
) *ReducerBreadthFirstGenerator

func (*ReducerBreadthFirstGenerator) Generate

func (t *ReducerBreadthFirstGenerator) Generate() ([]byte, error)

type ReducerDefaultReductionGenerator

type ReducerDefaultReductionGenerator struct {
	Name   variantName
	Types  []typeName
	Helper *Helpers
	// contains filtered or unexported fields
}

func NewReducerDefaultReductionGenerator

func NewReducerDefaultReductionGenerator(
	union shape.UnionLike,
	helper *Helpers,
) *ReducerDefaultReductionGenerator

func (*ReducerDefaultReductionGenerator) Generate

func (t *ReducerDefaultReductionGenerator) Generate() ([]byte, error)

type ReducerDepthFirstGenerator

type ReducerDepthFirstGenerator struct {
	Name     variantName
	Types    []typeName
	Branches map[typeName][]Branching
	// contains filtered or unexported fields
}

func NewReducerDepthFirstGenerator

func NewReducerDepthFirstGenerator(union shape.UnionLike, helper *Helpers) *ReducerDepthFirstGenerator

func (*ReducerDepthFirstGenerator) Generate

func (t *ReducerDepthFirstGenerator) Generate() ([]byte, error)

type SchemaGenerator

type SchemaGenerator struct {
	Types  []string
	Name   string
	Helper *Helpers
	// contains filtered or unexported fields
}

func NewSchemaGenerator

func NewSchemaGenerator(union shape.UnionLike, helper *Helpers) *SchemaGenerator

func (*SchemaGenerator) Generate

func (g *SchemaGenerator) Generate() ([]byte, error)

type ShapeGenerator

type ShapeGenerator struct {
	Union shape.UnionLike
	// contains filtered or unexported fields
}

func NewShapeGenerator

func NewShapeGenerator(union shape.UnionLike, helper *Helpers) *ShapeGenerator

func (*ShapeGenerator) Generate

func (g *ShapeGenerator) Generate() ([]byte, error)

func (*ShapeGenerator) ImportPkg

func (g *ShapeGenerator) ImportPkg() []string

func (*ShapeGenerator) ShapeToString

func (g *ShapeGenerator) ShapeToString(x shape.Shape, depth int) string

func (*ShapeGenerator) VariantName

func (g *ShapeGenerator) VariantName(x shape.Shape) string

type VisitorDefaultGenerator

type VisitorDefaultGenerator struct {
	Name   string
	Types  []string
	Helper *Helpers
	// contains filtered or unexported fields
}

func NewVisitorDefaultGenerator

func NewVisitorDefaultGenerator(union shape.UnionLike, helper *Helpers) *VisitorDefaultGenerator

func (*VisitorDefaultGenerator) Generate

func (g *VisitorDefaultGenerator) Generate() ([]byte, error)

type VisitorGenerator

type VisitorGenerator struct {
	Types  []string
	Name   string
	Helper *Helpers
	// contains filtered or unexported fields
}

func NewVisitorGenerator

func NewVisitorGenerator(union shape.UnionLike, helper *Helpers) *VisitorGenerator

func (*VisitorGenerator) Generate

func (g *VisitorGenerator) Generate() ([]byte, error)

Directories

Path Synopsis
Code generated by mkunion.
Code generated by mkunion.

Jump to

Keyboard shortcuts

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