codegen

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "unknown"

Functions

This section is empty.

Types

type CodeGenerator

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

CodeGenerator manages batch generation of SSZ methods for multiple types

func NewCodeGenerator

func NewCodeGenerator(dynSsz *dynssz.DynSsz) *CodeGenerator

NewCodeGenerator creates a new code generator instance

func (*CodeGenerator) BuildFile

func (cg *CodeGenerator) BuildFile(fileName string, opts ...CodeGeneratorOption)

func (*CodeGenerator) Generate

func (cg *CodeGenerator) Generate() error

func (*CodeGenerator) GenerateToMap

func (cg *CodeGenerator) GenerateToMap() (map[string]string, error)

GenerateToMap generates code for all requested types and returns it as a map of file name to code

type CodeGeneratorFileOptions

type CodeGeneratorFileOptions struct {
	Package string
	Types   []*CodeGeneratorTypeOptions
}

type CodeGeneratorOption

type CodeGeneratorOption func(*CodeGeneratorOptions)

func WithCreateLegacyFn

func WithCreateLegacyFn() CodeGeneratorOption

WithCreateLegacyFn creates code with legacy methods that use the global dynssz instance this is useful to generate code that is compatible with the legacy fastssz interfaces

func WithGoTypesType

func WithGoTypesType(t types.Type, typeOpts ...CodeGeneratorOption) CodeGeneratorOption

func WithMaxSizeHints

func WithMaxSizeHints(hints []dynssz.SszMaxSizeHint) CodeGeneratorOption

func WithNoHashTreeRoot

func WithNoHashTreeRoot() CodeGeneratorOption

func WithNoMarshalSSZ

func WithNoMarshalSSZ() CodeGeneratorOption

func WithNoSizeSSZ

func WithNoSizeSSZ() CodeGeneratorOption

func WithNoUnmarshalSSZ

func WithNoUnmarshalSSZ() CodeGeneratorOption

func WithReflectType

func WithReflectType(t reflect.Type, typeOpts ...CodeGeneratorOption) CodeGeneratorOption

func WithSizeHints

func WithSizeHints(hints []dynssz.SszSizeHint) CodeGeneratorOption

func WithTypeHints

func WithTypeHints(hints []dynssz.SszTypeHint) CodeGeneratorOption

WithTypeHints creates code with type hints for the dynamic expressions this is useful to generate code that is compatible with the dynamic expressions

func WithoutDynamicExpressions

func WithoutDynamicExpressions() CodeGeneratorOption

WithoutDynamicExpressions creates code that uses static sizes only and ignores dynamic expressions this is useful to generate code with maximum performance characteristics for the default preset, while maintaining the expression flexibility for other presets via the slower reflection-based methods this option is not compatible with WithCreateDynamicFn

type CodeGeneratorOptions

type CodeGeneratorOptions struct {
	NoMarshalSSZ              bool
	NoUnmarshalSSZ            bool
	NoSizeSSZ                 bool
	NoHashTreeRoot            bool
	CreateLegacyFn            bool
	WithoutDynamicExpressions bool
	NoFastSsz                 bool
	SizeHints                 []dynssz.SszSizeHint
	MaxSizeHints              []dynssz.SszMaxSizeHint
	TypeHints                 []dynssz.SszTypeHint
	Types                     []CodeGeneratorTypeOption
}

type CodeGeneratorTypeOption

type CodeGeneratorTypeOption struct {
	ReflectType reflect.Type
	GoTypesType types.Type
	Opts        []CodeGeneratorOption
}

type CodeGeneratorTypeOptions

type CodeGeneratorTypeOptions struct {
	ReflectType reflect.Type
	GoTypesType types.Type
	TypeName    string
	Options     CodeGeneratorOptions
	Descriptor  *dynssz.TypeDescriptor
}

type CodegenInfo

type CodegenInfo struct {
	Type types.Type
}

type Parser

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

func NewParser

func NewParser() *Parser

func (*Parser) GetTypeDescriptor

func (p *Parser) GetTypeDescriptor(typ types.Type, typeHints []dynssz.SszTypeHint, sizeHints []dynssz.SszSizeHint, maxSizeHints []dynssz.SszMaxSizeHint) (*dynssz.TypeDescriptor, error)

type TypeImport

type TypeImport struct {
	Alias string
	Path  string
}

type TypePrinter

type TypePrinter struct {
	CurrentPkg string

	UseRune bool
	// contains filtered or unexported fields
}

func NewTypePrinter

func NewTypePrinter(currentPkg string) *TypePrinter

func (*TypePrinter) AddAlias

func (p *TypePrinter) AddAlias(path, alias string)

func (*TypePrinter) AddImport

func (p *TypePrinter) AddImport(path, alias string) string

func (*TypePrinter) Aliases

func (p *TypePrinter) Aliases() map[string]string

func (*TypePrinter) Imports

func (p *TypePrinter) Imports() map[string]string

func (*TypePrinter) InnerTypeString

func (p *TypePrinter) InnerTypeString(t *dynssz.TypeDescriptor) string

InnerTypeString returns the string representation of the inner type of the type and tracks uses of imports.

func (*TypePrinter) TypeString

func (p *TypePrinter) TypeString(t *dynssz.TypeDescriptor) string

TypeString returns the string representation of the type and tracks uses of imports.

func (*TypePrinter) TypeStringWithoutTracking

func (p *TypePrinter) TypeStringWithoutTracking(t *dynssz.TypeDescriptor) string

TypeStringWithoutTracking returns the string representation of the type without tracking imports.

Jump to

Keyboard shortcuts

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