Documentation ¶
Overview ¶
Package headalyzer contains the core logic for the headalyzer tool
Index ¶
- func LoadFile(path string) ([]Constant, []Option, []Hint, error)
- func LoadString(text, apparantPath string) ([]Constant, []Option, []Hint, error)
- func ResolveHint(hints []Hint, symbol Symbol, section, key, defaultval string) (string, bool)
- func ResolveOption(opts []Option, section, key string, defaults []Option) (string, bool)
- type Case
- type Constant
- type Hint
- type IntConstant
- type Option
- type StringConstant
- type Symbol
- type Type
- type UnrepresentableError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadString ¶
LoadString reads a headalyzer definition file which is stored as a string and returns the list of constants.
apparantPath may be empty to use the default value.
func ResolveHint ¶
ResolveHint can be used to find a hint which matches a specific symbol, section, and key, and returns the appropriate value. If the hint is found, the bool return value will be 'true', otherwise it will be 'false' and the returned string will be the given defaultval.
If multiple hints match, the one with the highest index is used.
func ResolveOption ¶
ResolveOption can be used to resolve the value of a given section, key tuple. Non-default options always have precedence. The defaults parameter may be nil.
If an option is defined more than once in an option list, the most recent one (iterating from index 0) takes precedence.
Types ¶
type Case ¶
type Case string
Case represents one of several ways of casing a collection of symbol components.
const ( // CamelCase indicates that Symbol.CamelCase() should be used CamelCase Case = "CamelCase" // UpperCamelCase indicates that Symbol.UpperCamelCase() should be used UpperCamelCase Case = "UpperCamelCase" // LowerCamelCase indicates that Symbol.LowerCamelCase() should be used LowerCamelCase Case = "LowerCamelCase" // SnakeCase indicates that Symbol.SnakeCase() should be used SnakeCase Case = "SnakeCase" // CapitalSnakeCase indicates that Symbol.CapitalSnakeCase() should be // used CapitalSnakeCase Case = "CapitalSnakeCase" )
type Constant ¶
type Constant interface { // Return this constant's type GetType() Type String() string // The name of the constant Symbol() Symbol // What should be generated as text Text() string }
A Constant represents any constant that Headalyzer understands.
type IntConstant ¶
type IntConstant struct {
// contains filtered or unexported fields
}
IntConstant represents a constant of type Int
func (IntConstant) String ¶
func (i IntConstant) String() string
func (IntConstant) Symbol ¶
func (i IntConstant) Symbol() Symbol
Symbol returns the symbol for this int constant
func (IntConstant) Text ¶
func (i IntConstant) Text() string
type Option ¶
Option is used to represent generator-specific options, it's meaning is entirely defined by the generator in question.
By convention, the Section should be the generator name to which the option applies, the Key a configuration key, and the Value the set value. The generator may cast the Value to another type (such as a number) internally if it wishes.
type StringConstant ¶
type StringConstant struct {
// contains filtered or unexported fields
}
StringConstant represents a constant of type String
func (StringConstant) GetType ¶
func (s StringConstant) GetType() Type
GetType always returns String
func (StringConstant) String ¶
func (s StringConstant) String() string
func (StringConstant) Symbol ¶
func (s StringConstant) Symbol() Symbol
Symbol returns the symbol for this string constant
func (StringConstant) Text ¶
func (s StringConstant) Text() string
Text returns the generated text for the string constant
type Symbol ¶
type Symbol struct {
// contains filtered or unexported fields
}
A Symbol represents what how a Constant is referred to. It is a list of components which may be joined in one of several ways. For example, the symbol ["My", "Cool", "Constant"] might be generated ad "MY_COOL_CONSTANT" in a C macro definition, and "MyCoolConstant" in a Go constant definition.
func MakeSymbol ¶
MakeSymbol creates a Symbol from a list of components.
func (Symbol) CamelCase ¶
CamelCase applies camel-case to the symbol without modifying the case of the first component.
My Cool Constant -> MyCoolConstant my cool constant -> myCoolConstant
func (Symbol) CapitalSnakeCase ¶
CapitalSnakeCase applies snake-case to the symbol and makes all letters upper case.
My Cool Constant -> MY_COOL_CONSTANT
my cool constant -> MY_COOL_CONSTANT
my Cool Constant -> MY_COOL_CONSTANT
func (Symbol) LowerCamelCase ¶
LowerCamelCase applies camel-case to the symbol, explicitly guaranteeing the first component starts with a lower case letter.
My Cool Constant -> myCoolConstant my cool constant -> myCoolConstant
func (Symbol) SnakeCase ¶
SnakeCase applies snake-case to the symbol without modifying the case of the components.
My Cool Constant -> My_Cool_Constant
my cool constant -> my_cool_constant
my Cool Constant -> my_Cool_Constant
func (Symbol) UpperCamelCase ¶
UpperCamelCase applies camel-case to the symbol, explicitly guaranteeing the first component starts with an upper case letter.
My Cool Constant -> MyCoolConstant my cool constant -> MyCoolConstant
type Type ¶
type Type string
Type is used to distinguish types that Headalyzer knows about.
const ( // Int represents signed integer values of unspecified length, no // guarantees will be made about storage size Int Type = "int" // Int64 represents signed 64 bit integers Int64 Type = "int64" // Int32 represents signed 32 bit integers Int32 Type = "int32" // Int16 represents signed 16 bit integers Int16 Type = "int16" // Int8 represents signed 8 bit integers Int8 Type = "int8" // Uint represents unsigned integer values of unspecified length, no // guarantees will be // made about storage size Uint Type = "uint" // Uint64 represents unsigned 64 bit integers Uint64 Type = "uint64" // Uint32 represents unsigned 32 bit integers Uint32 Type = "uint32" // Uint16 represents unsigned 16 bit integers Uint16 Type = "uint16" // Uint8 represents unsigned 8 bit integers Uint8 Type = "uint8" // String represents string constants String Type = "string" // Untyped represents constants which are not typed Untyped Type = "untyped" )
type UnrepresentableError ¶
type UnrepresentableError struct { // Human-readable representation of the constant Constant string // Reason why the generator cannot represent the value Reason string }
UnrepresentableError indicates that the generator cannot represent the constant value.
func (*UnrepresentableError) Error ¶
func (e *UnrepresentableError) Error() string
Directories ¶
Path | Synopsis |
---|---|
Package c implement the C header file generator for Headalyzer.
|
Package c implement the C header file generator for Headalyzer. |
Package shell implement the make generator for Headalyzer
|
Package shell implement the make generator for Headalyzer |
Package shell implement the shell generator for Headalyzer
|
Package shell implement the shell generator for Headalyzer |
Package systemverilog implement the systemverilog header file generator for Headalyzer.
|
Package systemverilog implement the systemverilog header file generator for Headalyzer. |