codegen

package
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: MIT Imports: 14 Imported by: 12 modules, 11 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Key                string
	Init               string
	OmitEmpty          string
	TimeLayout         string
	NullType           string
	Name               string
	Accessor           string
	Mutator            string
	Receiver           string //alias and type name
	Alias              string //object alias name
	Var                string //variable for this field
	Type               string
	RawType            string
	HelperType         string
	ComponentType      string
	RawComponentType   string
	IsPointerComponent bool

	PointerModifier     string //takes field pointer, "&" if field is not a pointer type
	DereferenceModifier string //take pointer value, i.e "*" if field has a pointer type

	ComponentPointerModifier     string //takes item pointer if needed,i.e
	ComponentDereferenceModifier string //de reference value if needed, i.e
	ComponentInitModifier        string //takes item pointer if type is not a pointer type
	ComponentInit                string //initialises component type

	DecodingMethod  string
	EncodingMethod  string
	PoolName        string //pool name associated with this field
	ResetDependency string
	Reset           string
	IsAnonymous     bool
	IsPointer       bool
	IsSlice         bool

	GojayMethod string
}

Field represents a field.

func NewField

func NewField(owner *Struct, field *toolbox.FieldInfo, fieldType *toolbox.TypeInfo) (*Field, error)

NewField returns a new field

type Generator

type Generator struct {
	Pkg     string
	Code    string
	Init    string
	Imports string
	// contains filtered or unexported fields
}

Generator holds the content to generate the gojay code

func NewGenerator

func NewGenerator(options *Options) *Generator

NewGenerator creates a new generator with the given options

func (*Generator) Generate

func (g *Generator) Generate() error

Generate generates the gojay implementation code

func (*Generator) Type

func (g *Generator) Type(typeName string) *toolbox.TypeInfo

Returns the type from the the fileInfo

type Options

type Options struct {
	Source      string
	Dest        string
	Types       []string
	PoolObjects bool
	TagName     string
	Pkg         string
}

func NewOptionsWithFlagSet

func NewOptionsWithFlagSet(set *flag.FlagSet) *Options

NewOptionsWithFlagSet creates a new options for the supplide flagset

func (*Options) Validate

func (o *Options) Validate() error

type Struct

type Struct struct {
	*toolbox.TypeInfo

	*Generator
	Alias string
	Init  string
	Body  string
	// contains filtered or unexported fields
}

func NewStruct

func NewStruct(info *toolbox.TypeInfo, generator *Generator) *Struct

func (*Struct) Generate

func (s *Struct) Generate() (string, error)

Generate generates decoderCode + structRelease + encoderCode

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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