Documentation
¶
Index ¶
- Variables
- type CodeGenerator
- type CodeGeneratorFileOptions
- type CodeGeneratorOption
- func WithCreateLegacyFn() CodeGeneratorOption
- func WithGoTypesType(t types.Type, typeOpts ...CodeGeneratorOption) CodeGeneratorOption
- func WithMaxSizeHints(hints []dynssz.SszMaxSizeHint) CodeGeneratorOption
- func WithNoHashTreeRoot() CodeGeneratorOption
- func WithNoMarshalSSZ() CodeGeneratorOption
- func WithNoSizeSSZ() CodeGeneratorOption
- func WithNoUnmarshalSSZ() CodeGeneratorOption
- func WithReflectType(t reflect.Type, typeOpts ...CodeGeneratorOption) CodeGeneratorOption
- func WithSizeHints(hints []dynssz.SszSizeHint) CodeGeneratorOption
- func WithTypeHints(hints []dynssz.SszTypeHint) CodeGeneratorOption
- func WithoutDynamicExpressions() CodeGeneratorOption
- type CodeGeneratorOptions
- type CodeGeneratorTypeOption
- type CodeGeneratorTypeOptions
- type CodegenInfo
- type Parser
- type TypeImport
- type TypePrinter
- func (p *TypePrinter) AddAlias(path, alias string)
- func (p *TypePrinter) AddImport(path, alias string) string
- func (p *TypePrinter) Aliases() map[string]string
- func (p *TypePrinter) Imports() map[string]string
- func (p *TypePrinter) InnerTypeString(t *dynssz.TypeDescriptor) string
- func (p *TypePrinter) TypeString(t *dynssz.TypeDescriptor) string
- func (p *TypePrinter) TypeStringWithoutTracking(t *dynssz.TypeDescriptor) string
Constants ¶
This section is empty.
Variables ¶
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 Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
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 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.