Documentation ¶
Overview ¶
Domain model, outputs of parser, inputs for generator. No dependencies here.
Index ¶
- Variables
- func IsFixedSize[T StructField | SimpleFieldType | ArrayFieldType | SliceFieldType | int](a T) bool
- func ParenthesizeIntExpr(expr string) string
- type ArrayFieldType
- func (t ArrayFieldType) ElType() FieldType
- func (t ArrayFieldType) IsInteger() bool
- func (t ArrayFieldType) IsSequence() bool
- func (t ArrayFieldType) LenExpr() string
- func (t ArrayFieldType) Length() int
- func (t ArrayFieldType) Name() string
- func (t ArrayFieldType) Size() int
- func (t ArrayFieldType) SizeExpr() string
- type FieldType
- type InputStruct
- type SequenceFieldType
- type SimpleFieldType
- type SliceFieldType
- type StructField
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnsupportedType = errors.New("unsupported type")
Functions ¶
func IsFixedSize ¶
func IsFixedSize[ T StructField | SimpleFieldType | ArrayFieldType | SliceFieldType | int](a T) bool
Returns true if total argument's size can be interpreted as known at declaration time. E.g. (primitives, arrays). NOT slices.
func ParenthesizeIntExpr ¶
Adds parentheses to Go's int expression if it is a) not a simple int value, b) not already cast to int.
Types ¶
type ArrayFieldType ¶
type ArrayFieldType struct {
// contains filtered or unexported fields
}
func NewArrayFieldType ¶
func NewArrayFieldType(length int, el FieldType) *ArrayFieldType
func (ArrayFieldType) ElType ¶
func (t ArrayFieldType) ElType() FieldType
func (ArrayFieldType) IsInteger ¶
func (t ArrayFieldType) IsInteger() bool
func (ArrayFieldType) IsSequence ¶
func (t ArrayFieldType) IsSequence() bool
func (ArrayFieldType) LenExpr ¶
func (t ArrayFieldType) LenExpr() string
func (ArrayFieldType) Length ¶
func (t ArrayFieldType) Length() int
func (ArrayFieldType) Name ¶
func (t ArrayFieldType) Name() string
func (ArrayFieldType) Size ¶
func (t ArrayFieldType) Size() int
func (ArrayFieldType) SizeExpr ¶
func (t ArrayFieldType) SizeExpr() string
type FieldType ¶
type FieldType interface { Name() string // Total size of the field. // If Size() < 0, then size is not fixed, and SizeExpr() should be used. Size() int // Expression that determines the size of the field. // Should always be constructed in a way to return int type. SizeExpr() string // Don't confuse with IsInt. Checks if type is intX OR uintX OR byte IsInteger() bool // Should return true if the type is an array or slice IsSequence() bool }
type InputStruct ¶
type InputStruct struct {
// contains filtered or unexported fields
}
func NewInputStruct ¶
func NewInputStruct(name string, typ *types.Struct) *InputStruct
func (InputStruct) Field ¶
func (s InputStruct) Field(idx int) StructField
func (InputStruct) FieldCount ¶
func (s InputStruct) FieldCount() int
func (InputStruct) Name ¶
func (s InputStruct) Name() string
func (*InputStruct) SetFields ¶
func (s *InputStruct) SetFields(f []StructField)
func (InputStruct) Type ¶
func (s InputStruct) Type() *types.Struct
type SequenceFieldType ¶
Field type that is a sequence, i.e. array or slice, which have a number of certain elements
type SimpleFieldType ¶
type SimpleFieldType struct {
// contains filtered or unexported fields
}
func NewSimpleFieldType ¶
func NewSimpleFieldType(name string, size int, underlying *SimpleFieldType) *SimpleFieldType
func (SimpleFieldType) BitSize ¶
func (t SimpleFieldType) BitSize() int
func (SimpleFieldType) IsInteger ¶
func (bt SimpleFieldType) IsInteger() bool
func (SimpleFieldType) IsSequence ¶
func (t SimpleFieldType) IsSequence() bool
func (SimpleFieldType) Name ¶
func (t SimpleFieldType) Name() string
func (SimpleFieldType) Size ¶
func (t SimpleFieldType) Size() int
func (SimpleFieldType) SizeExpr ¶
func (t SimpleFieldType) SizeExpr() string
func (SimpleFieldType) Underlying ¶
func (t SimpleFieldType) Underlying() *SimpleFieldType
type SliceFieldType ¶
type SliceFieldType struct {
// contains filtered or unexported fields
}
func NewSliceFieldType ¶
func NewSliceFieldType(lenExpr string, el FieldType) *SliceFieldType
func (SliceFieldType) ElType ¶
func (t SliceFieldType) ElType() FieldType
func (SliceFieldType) IsInteger ¶
func (t SliceFieldType) IsInteger() bool
func (SliceFieldType) IsSequence ¶
func (t SliceFieldType) IsSequence() bool
func (SliceFieldType) LenExpr ¶
func (t SliceFieldType) LenExpr() string
func (SliceFieldType) Name ¶
func (t SliceFieldType) Name() string
func (SliceFieldType) Size ¶
func (t SliceFieldType) Size() int
func (SliceFieldType) SizeExpr ¶
func (t SliceFieldType) SizeExpr() string
type StructField ¶
type StructField struct {
// contains filtered or unexported fields
}
func NewStructField ¶
func NewStructField(name string, typ FieldType, tag map[string]string) StructField
func (StructField) Name ¶
func (f StructField) Name() string
func (StructField) Type ¶
func (f StructField) Type() FieldType
Click to show internal directories.
Click to hide internal directories.