generators

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 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 TemplateHelperShapeVariantToName

func TemplateHelperShapeVariantToName(x shape.Shape) string

Types

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) OptionallyImport added in v1.20.2

func (g *DeSerJSONGenerator) OptionallyImport(x string) string

func (*DeSerJSONGenerator) SupportNativeJSONMarshal added in v1.20.1

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

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 SchemaGenerator

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

func NewSchemaGenerator

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

func (*SchemaGenerator) Generate

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

func (*SchemaGenerator) VariantName added in v1.20.2

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

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) ShapeToString

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

func (*ShapeGenerator) VariantName

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

type VisitorGenerator

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

func NewVisitorGenerator

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

func (*VisitorGenerator) Generate

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

func (*VisitorGenerator) VariantName added in v1.20.2

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

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