Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Boolean Bool = "bool" Uint8 = "uint8" Uint16 = "uint16" Uint32 = "uint32" Uint64 = "uint64" // Signed ints Int8 = "int8" Int16 = "int16" Int32 = "int32" Int64 = "int64" // String, UUID, JSON String = "string" Uuid = "uuid" Json = "json" // Date, DateTime, and Interval Date = "date" // days since 2970 DateTimeSecs = "dateTimeSecs" // seconds since 1970 DateTimeMillis = "dateTimeMillis" // milliseconds since 1970 DurationDays = "durationDays" // days elapsed DurationSecs = "durationSecs" // seconds elapsed DurationMillis = "durationMillis" // elapsed milliseconds // Aray, Enum, List, Map, Maybe, Object, Set Array = "array" Enum = "enum" List = "list" Map = "map" Maybe = "maybe" Object = "object" Set = "set" Main = "main" // name of main function )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseGenerator ¶
type BaseGenerator struct {
// contains filtered or unexported fields
}
BaseGenerator contains the base parts of the Generator interface
func (BaseGenerator) CurrentSrc ¶
func (bg BaseGenerator) CurrentSrc() writer.Writer[string]
CurrentSrc returns the writer for the current src
func (*BaseGenerator) Dir ¶
func (bg *BaseGenerator) Dir(name string)
Dir panics if dir already exists, or creating the dir has an error
func (BaseGenerator) GetBasePath ¶
func (bg BaseGenerator) GetBasePath() string
GetBasePath panics if SetBasePath has not been called
func (*BaseGenerator) SetBasePath ¶
func (bg *BaseGenerator) SetBasePath(bp string)
SetBasePath panics if the base path has already been set
func (*BaseGenerator) Src ¶
func (bg *BaseGenerator) Src(name string)
Src panics if the file already exists
type Dir ¶
type Dir struct { Sources []Src // Init is an optional initialization function for the directory. // The set of all Init functions execute in some arbitrary order at runtime. // Depending on the target language, they may all execute before main starts, or they may execute some time later, such // as when files that need them are loaded. Init union.Maybe[FuncDef] }
Dir is a directory of source files
type FuncDef ¶
type FuncDef struct { Params []VarDef // Parameters of function LocalConsts map[string]VarDef // Local constants LocalVars map[string]VarDef // Local vars Results []VarDef // Results of function }
FuncDef is a function definition
type Generator ¶
type Generator interface { // Return the base path to generate dirs under GetBasePath() string // Set the base path once to generate dirs under. Setting again panics. SetBasePath(basePath string) Generator // Creates a directory, or wipes out the contents (assuming they are from a prior run of the same generator). // The caller must generate parent directories before child directories, or a panic occurs. // This will be the current directory until another call is made Dir(name string) Generator // Creates a src file in the current directory // This will be the current source file under another call is made Src(name string) Generator // Create global constants in the current source file GlobalConsts(constants ...VarDef) Generator // Create global vars in the current source file GlobalVars(globals ...VarDef) Generator // Create types in the current source file Types(objects ...ObjectDef) Generator // Create funcs in the current source file Funcs(funcs ...FuncDef) Generator }
Generator is the interface describing an easy to use fluent API for generating packages of code. If anything goes wrong, the generator panics.
type Src ¶
type Src struct { GlobalConsts map[string]VarDef GlobalVars map[string]VarDef Objects map[string]ObjectDef Funcs map[string]FuncDef }
Src is a source file
type TypeDef ¶
type TypeDef struct { Type string // The type ArrayBounds []int // The bounds of an array, cannot be empty Name string // The name of an enum or object Names []string // The names of enum constants or object generics - zero-based indexes are the enum values, strings are the names ListDimension int // The dimension of the list (eg, list of string, list of list of string, etc), cannot be 0 KeyType *TypeDef // The map key type ValueType *TypeDef // The array element type, list element type, map value type, maybe type, or set type }
Click to show internal directories.
Click to hide internal directories.