converter

package
v2.0.0-...-87fb603 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalPackage         = errors.New("use of internal package")
	ErrUnexported              = errors.New("use of unexported name")
	ErrGeneric                 = errors.New("use of uninstantiated generic")
	ErrCGo                     = errors.New("use of CGo")
	ErrInvalid                 = errors.New("use of invalid type")
	ErrInterfaceTypeConstraint = errors.New("interface contains type constraint")
	ErrIncomplete              = errors.New("use of incomplete (or unallocatable) type")
)

Functions

func ReceiverRyeTypeName

func ReceiverRyeTypeName(t types.Type, tset *typeset.TypeSet) string

ReceiverRyeTypeName returns the name of the actual type when the type is used as a receiver in a Rye method. In other words, this function returns the string should come before the "//" in Rye method names.

Types

type ConverterError

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

func (*ConverterError) Error

func (e *ConverterError) Error() string

Error returns a short error message.

func (*ConverterError) String

func (e *ConverterError) String() string

String returns a full multi-line error message containing all errors.

func (*ConverterError) Unwrap

func (e *ConverterError) Unwrap() []error

type ConverterSet

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

func NewConverterSet

func NewConverterSet(tset *typeset.TypeSet, basePkg string) *ConverterSet

NewConverterSet creates a new ConverterSet. basePkg is the package path Ryegen was initiated in (usually "main").

func (*ConverterSet) Add

func (cs *ConverterSet) Add(typ types.Type, dir Direction, debugName string) (converterName string)

Add adds a converter to the ConverterSet, meaning it will end up in the generated code. debugName is used for printing error messages and generating debug info, optional. Returns the name of the resulting converter function.

func (*ConverterSet) Code

func (cs *ConverterSet) Code() ([]byte, *Graph, error)

Code returns all of the generated converter Go code. The returned Graph can be used to get information about the resulting converter graph. Call Graph.Contains to find out which converters are still usable. If the returned error is a ConverterError, the returned code is still valid, but the erroneous converters and any converters associated with them are not included. Call ConverterError.String to get a detailed list of all errors.

type Direction

type Direction uint8
const (
	ToRye Direction = iota
	FromRye
)

func (Direction) Opposite

func (d Direction) Opposite() Direction

func (Direction) String

func (d Direction) String() string

String returns the PascalCase string representation ("ToRye" or "FromRye").

func (Direction) StringCamelCase

func (d Direction) StringCamelCase() string

StringCamelCase returns the camelCase string representation ("toRye" or "fromRye").

type Graph

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

Graph represents a resulting converter graph. All methods will return a reasonable result if the *Graph is nil.

func (*Graph) Contains

func (g *Graph) Contains(t types.Type, dir Direction) bool

Contains returns whether the graph contains a complete and valid node with the given type and direction.

func (*Graph) DebugDOTCode

func (g *Graph) DebugDOTCode(nodeRe *regexp.Regexp) []byte

DebugDOTCode generates DOT (graphviz) code for the converter dependency graph. If nodeRe is nil, all nodes are included. If nodeRe is non-nil, all nodes depending on any matching nodes are included.

func (*Graph) Nodes

func (g *Graph) Nodes() iter.Seq[GraphNode]

Nodes returns all complete and valid nodes sorted.

type GraphNode

type GraphNode struct {
	Type types.Type
	Dir  Direction
}

Directories

Path Synopsis
Package typeset handles type stringification and automatic struct aliasing.
Package typeset handles type stringification and automatic struct aliasing.
Package walktypes simplifies recursively iterating over types from the Go types package.
Package walktypes simplifies recursively iterating over types from the Go types package.

Jump to

Keyboard shortcuts

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