Documentation
¶
Overview ¶
Package generator contains code generator for YAML marshalling and unmarshalling methods.
Index ¶
- type EngineGenerator
- type Generator
- func (g *Generator) AddType(v any)
- func (g *Generator) Generate(w io.Writer) error
- func (g *Generator) SetBuildTags(buildTags string)
- func (g *Generator) SetDisallowUnknownFields(disallow bool)
- func (g *Generator) SetEncodePointerReceiver(useReceiver bool)
- func (g *Generator) SetEngineGenerator(eg EngineGenerator)
- func (g *Generator) SetInlineEmbedded(inlineEmbedded bool)
- func (g *Generator) SetOmitempty(omitempty bool)
- func (g *Generator) SetPkgName(pkgName string)
- func (g *Generator) SetPkgPath(pkgPath string)
- type ImplementationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EngineGenerator ¶
type EngineGenerator interface {
// Packages returns information for packages used by engine as map
// using package path as key and alias as value
Packages() map[string]string
// WarningSuppressors returns a list of types used to create stub variables
// to suppress warnings
WarningSuppressors() []string
// GenerateUnmarshalers generates unmarshalling methods for target type
// using provided decodeFuncName and typeName. The generated code is written into dst.
// Decode function has following signature:
//
// func(yamly.Decoder, *typeName)
GenerateUnmarshalers(dst io.Writer, decodeFuncName, typeName string) error
// GenerateMarshalers generates marshalling methods for target type
// using provided encodeFuncName and typeName. The generated code is written into dst.
// Encode function has following signature:
//
// func(yamly.Encoder, typeName)
GenerateMarshalers(dst io.Writer, encodeFuncName, typeName string) error
// UnmarshalersImplementationCheck checks if provided type t implements any of engine-specific
// unmarshalling interfaces.
// If it does, UnmarshalersImplementationCheck generates code using implemented method, writing it into dst.
UnmarshalersImplementationCheck(dst io.Writer, t reflect.Type, outArg string, indent int) (ImplementationResult, error)
// MarshalersImplementationCheck checks if provided type t implements any of engine-specific
// marshalling interfaces.
// If it does, MarshalersImplementationCheck generates code using implemented method, writing it into dst.
MarshalersImplementationCheck(dst io.Writer, t reflect.Type, inArg string, indent int) (ImplementationResult, error)
// GenerateUnmarshalEmptyInterfaceAssertions generates code with type assertions for empty interface
// (interface{} or any) using unmarshalling interfaces.
GenerateUnmarshalEmptyInterfaceAssertions(dst io.Writer, outArg string, indent int) error
// GenerateMarshalEmptyInterfaceAssertions generates code with type assertions for empty interface
// (interface{} or any) using marshalling interfaces.
GenerateMarshalEmptyInterfaceAssertions(dst io.Writer, inArg string, indent int) error
}
EngineGenerator interface contains engine-specific methods
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is used to generate code for YAML (un)marshalling methods in runtime.
func (*Generator) Generate ¶
Generate generates code for marshalling methods, writing it into given io.Writer.
func (*Generator) SetBuildTags ¶
func (*Generator) SetDisallowUnknownFields ¶
func (*Generator) SetEncodePointerReceiver ¶
func (*Generator) SetEngineGenerator ¶
func (g *Generator) SetEngineGenerator(eg EngineGenerator)
SetEngineGenerator defines engine for Generator. Engine represents a "backend" for generator, including lexer, parser etc.
func (*Generator) SetInlineEmbedded ¶
func (*Generator) SetOmitempty ¶
func (*Generator) SetPkgName ¶
func (*Generator) SetPkgPath ¶
type ImplementationResult ¶
type ImplementationResult int8
ImplementationResult defines whether type implements any engine interface or not
const ( // ImplementationResultFalse is equal to boolean false, meaning type does not implement any interface ImplementationResultFalse ImplementationResult = iota // ImplementationResultTrue is equal to boolean true, meaning type does implement any of engine interfaces ImplementationResultTrue // ImplementationResultConditional indicates that type can implement one of engine interfaces, // but this depends not only on the type, but additional conditions (like if yamly.Decoder implements more // specific yamly.ExtendedDecoder). ImplementationResultConditional )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bootstrap contains generator for bootstrap main with actual generating with generator.Generator
|
Package bootstrap contains generator for bootstrap main with actual generating with generator.Generator |
|
Package parser contains parser for package name and path.
|
Package parser contains parser for package name and path. |
Click to show internal directories.
Click to hide internal directories.