Documentation
¶
Index ¶
- func ClearField(s *segment.Struct, fieldNum uint16, ft field.Type)
- func GetValue(s *segment.Struct, fieldNum uint16) interfaces.Value
- func RealStruct(s interfaces.Struct) *segment.Struct
- func SetField(s *segment.Struct, fieldNum uint16, ft field.Type, v any)
- func XXXNewStruct(v *segment.Struct, descr interfaces.StructDescr) interfaces.Struct
- type FieldDescrImpl
- func (f FieldDescrImpl) EnumGroup() interfaces.EnumGroup
- func (f FieldDescrImpl) FieldNum() uint16
- func (f FieldDescrImpl) IsEnum() bool
- func (f FieldDescrImpl) IsMap() bool
- func (f FieldDescrImpl) ItemType() string
- func (f FieldDescrImpl) MapKeyType() field.Type
- func (f FieldDescrImpl) MapValueType() field.Type
- func (f FieldDescrImpl) Name() string
- func (f FieldDescrImpl) Type() field.Type
- type ItemType
- type ListBools
- type ListBytes
- type ListNumbers
- type ListStrings
- type ListStructs
- type MapImpl
- func (m MapImpl[K, V]) Delete(key interfaces.Value)
- func (m MapImpl[K, V]) Get(key interfaces.Value) interfaces.Value
- func (m MapImpl[K, V]) Has(key interfaces.Value) bool
- func (m MapImpl[K, V]) KeyType() field.Type
- func (m MapImpl[K, V]) Len() int
- func (m MapImpl[K, V]) Range(f func(key, val interfaces.Value) bool)
- func (m MapImpl[K, V]) Set(key interfaces.Value, val interfaces.Value)
- func (m MapImpl[K, V]) ValueType() field.Type
- type PackageDescrImpl
- type StructDescrImpl
- func (s StructDescrImpl) FieldDescrByIndex(index int) interfaces.FieldDescr
- func (s StructDescrImpl) FieldDescrByName(name string) interfaces.FieldDescr
- func (s StructDescrImpl) Fields() []interfaces.FieldDescr
- func (s StructDescrImpl) FullPath() string
- func (s StructDescrImpl) New() interfaces.Struct
- func (s StructDescrImpl) Package() string
- func (s StructDescrImpl) StructName() string
- type StructDescrsImpl
- type StructImpl
- func (s StructImpl) ClawInternal(pragma.DoNotImplement)
- func (s StructImpl) Clear(desc interfaces.FieldDescr)
- func (s StructImpl) Descriptor() interfaces.StructDescr
- func (s StructImpl) Fields() iter.Seq2[interfaces.FieldDescr, interfaces.Value]
- func (s StructImpl) Get(descr interfaces.FieldDescr) interfaces.Value
- func (s StructImpl) Has(descr interfaces.FieldDescr) bool
- func (s StructImpl) New() interfaces.Struct
- func (s StructImpl) NewField(descr interfaces.FieldDescr) interfaces.Value
- func (s StructImpl) Range(f func(interfaces.FieldDescr, interfaces.Value) bool)
- func (s StructImpl) Set(descr interfaces.FieldDescr, v interfaces.Value)
- func (s StructImpl) Struct() *segment.Struct
- type Value
- func ValueOfBool(v bool) Value
- func ValueOfBytes(v []byte) Value
- func ValueOfEnum[N ~uint8 | ~uint16](v N, enumGroup interfaces.EnumGroup) Value
- func ValueOfList(v interfaces.List) Value
- func ValueOfMap(v interfaces.Map) Value
- func ValueOfNumber[N interfaces.Number](v N) Value
- func ValueOfString(v string) Value
- func ValueOfStruct(v interfaces.Struct) Value
- func (v Value) Any() any
- func (v Value) Bool() bool
- func (v Value) Bytes() []byte
- func (v Value) Enum() interfaces.Enum
- func (v Value) Float() float64
- func (v Value) Int() int64
- func (v Value) List() interfaces.List
- func (v Value) Map() interfaces.Map
- func (v Value) String() string
- func (v Value) Struct() interfaces.Struct
- func (v Value) Uint() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearField ¶
ClearField clears a field by setting it to its zero value.
func GetValue ¶
func GetValue(s *segment.Struct, fieldNum uint16) interfaces.Value
GetValue allows us to get a Value from the internal Struct representation. If the value of the field is not set, GetValue() returns nil.
func RealStruct ¶
func RealStruct(s interfaces.Struct) *segment.Struct
RealStruct extracts the *segment.Struct that holds all the data (not a reflect.Struct).
func XXXNewStruct ¶
func XXXNewStruct(v *segment.Struct, descr interfaces.StructDescr) interfaces.Struct
XXXNewStruct wraps our internal *segment.Struct objects in the reflect.Struct type. This is used in our generated code to implement the ClawStruct() method.
Types ¶
type FieldDescrImpl ¶
type FieldDescrImpl struct {
FD *mapping.FieldDescr
SD interfaces.StructDescr
EG interfaces.EnumGroup
}
FieldDescrImpl describes a field inside a Struct type.
func (FieldDescrImpl) EnumGroup ¶
func (f FieldDescrImpl) EnumGroup() interfaces.EnumGroup
EnumGroup returns the EnumGroup for the field. If the field is not an enum, this will panic. Use IsEnum() if you want to check before calling this.
func (FieldDescrImpl) FieldNum ¶
func (f FieldDescrImpl) FieldNum() uint16
FieldNum returns the field number in the Struct.
func (FieldDescrImpl) IsEnum ¶
func (f FieldDescrImpl) IsEnum() bool
IsEnum indicates if the field is an enumerator.
func (FieldDescrImpl) IsMap ¶
func (f FieldDescrImpl) IsMap() bool
IsMap returns true if this field is a map type.
func (FieldDescrImpl) ItemType ¶
func (f FieldDescrImpl) ItemType() string
ItemType returns the Struct type in a []Struct. If this is not a []Struct, then this will panic.
func (FieldDescrImpl) MapKeyType ¶
func (f FieldDescrImpl) MapKeyType() field.Type
MapKeyType returns the key type for map fields.
func (FieldDescrImpl) MapValueType ¶
func (f FieldDescrImpl) MapValueType() field.Type
MapValueType returns the value type for map fields.
func (FieldDescrImpl) Name ¶
func (f FieldDescrImpl) Name() string
Name returns the name of the field.
func (FieldDescrImpl) Type ¶
func (f FieldDescrImpl) Type() field.Type
Type returns the type of the field.
type ListBools ¶
type ListBools struct {
// contains filtered or unexported fields
}
func NewListBools ¶
func (ListBools) Append ¶
func (l ListBools) Append(v interfaces.Value)
func (ListBools) New ¶
func (l ListBools) New() interfaces.Struct
type ListBytes ¶
type ListBytes struct {
// contains filtered or unexported fields
}
func NewListBytes ¶
func (ListBytes) Append ¶
func (l ListBytes) Append(v interfaces.Value)
func (ListBytes) New ¶
func (l ListBytes) New() interfaces.Struct
type ListNumbers ¶
type ListNumbers[N interfaces.Number] struct { // contains filtered or unexported fields }
func NewListNumbers ¶
func NewListNumbers[N interfaces.Number](items []N) ListNumbers[N]
func (ListNumbers[N]) Append ¶
func (l ListNumbers[N]) Append(v interfaces.Value)
func (ListNumbers[N]) Get ¶
func (l ListNumbers[N]) Get(i int) interfaces.Value
func (ListNumbers[N]) Len ¶
func (l ListNumbers[N]) Len() int
func (ListNumbers[N]) New ¶
func (l ListNumbers[N]) New() interfaces.Struct
func (ListNumbers[N]) Set ¶
func (l ListNumbers[N]) Set(i int, v interfaces.Value)
func (ListNumbers[N]) Type ¶
func (l ListNumbers[N]) Type() field.Type
type ListStrings ¶
type ListStrings struct {
// contains filtered or unexported fields
}
func NewListStrings ¶
func NewListStrings(items []string) ListStrings
func (ListStrings) Append ¶
func (l ListStrings) Append(v interfaces.Value)
func (ListStrings) Get ¶
func (l ListStrings) Get(i int) interfaces.Value
func (ListStrings) Len ¶
func (l ListStrings) Len() int
func (ListStrings) New ¶
func (l ListStrings) New() interfaces.Struct
func (ListStrings) Set ¶
func (l ListStrings) Set(i int, v interfaces.Value)
func (ListStrings) Type ¶
func (l ListStrings) Type() field.Type
type ListStructs ¶
type ListStructs struct {
// contains filtered or unexported fields
}
func NewListStructs ¶
func NewListStructs(items []*segment.Struct, m *mapping.Map) ListStructs
func (ListStructs) Append ¶
func (l ListStructs) Append(v interfaces.Value)
func (ListStructs) Get ¶
func (l ListStructs) Get(i int) interfaces.Value
func (ListStructs) Len ¶
func (l ListStructs) Len() int
func (ListStructs) New ¶
func (l ListStructs) New() interfaces.Struct
func (ListStructs) Set ¶
func (l ListStructs) Set(i int, v interfaces.Value)
func (ListStructs) Type ¶
func (l ListStructs) Type() field.Type
type MapImpl ¶
MapImpl is a generic map implementation that wraps segment.Maps. It provides a type-erased interface for reflection access to maps.
func NewMapImpl ¶
func NewMapImpl[K segment.MapKey, V any](m *segment.Maps[K, V], keyType, valType field.Type, valDescr *StructDescrImpl) MapImpl[K, V]
NewMapImpl creates a new MapImpl wrapping a segment.Maps.
func (MapImpl[K, V]) Delete ¶
func (m MapImpl[K, V]) Delete(key interfaces.Value)
func (MapImpl[K, V]) Get ¶
func (m MapImpl[K, V]) Get(key interfaces.Value) interfaces.Value
func (MapImpl[K, V]) Set ¶
func (m MapImpl[K, V]) Set(key interfaces.Value, val interfaces.Value)
type PackageDescrImpl ¶
type PackageDescrImpl struct {
Name string
Path string
ImportDescrs []interfaces.PackageDescr
EnumGroupsDescrs interfaces.EnumGroups
StructsDescrs interfaces.StructDescrs
// contains filtered or unexported fields
}
PackageDescrImpl is the implementation of PackageDescr.
func (*PackageDescrImpl) Enums ¶
func (p *PackageDescrImpl) Enums() interfaces.EnumGroups
Enums is a list of the Enum declarations.
func (*PackageDescrImpl) FullPath ¶
func (p *PackageDescrImpl) FullPath() string
FullPath returns the full path of the package.
func (*PackageDescrImpl) Imports ¶
func (p *PackageDescrImpl) Imports() []interfaces.PackageDescr
Imports is a list of imported claw files.
func (*PackageDescrImpl) PackageName ¶
func (p *PackageDescrImpl) PackageName() string
PackageName returns the name of the package.
func (*PackageDescrImpl) Structs ¶
func (p *PackageDescrImpl) Structs() interfaces.StructDescrs
Messages is a list of the top-level message declarations.
type StructDescrImpl ¶
type StructDescrImpl struct {
Name string
Pkg string
Path string
FieldList []interfaces.FieldDescr
Mapping *mapping.Map
// contains filtered or unexported fields
}
StructDescrImpl implements StructDescr.
func (StructDescrImpl) FieldDescrByIndex ¶
func (s StructDescrImpl) FieldDescrByIndex(index int) interfaces.FieldDescr
FieldDescByIndex returns the FieldDescr by index. If the index is out of bounds this will panic.
func (StructDescrImpl) FieldDescrByName ¶
func (s StructDescrImpl) FieldDescrByName(name string) interfaces.FieldDescr
FieldDescrByName returns the FieldDescr by the name of the field. If the field is not found, this will be nil.
func (StructDescrImpl) Fields ¶
func (s StructDescrImpl) Fields() []interfaces.FieldDescr
Fields will return a list of field descriptions.
func (StructDescrImpl) FullPath ¶
func (s StructDescrImpl) FullPath() string
FullPath will return the full path of the package as used in Go import statements.
func (StructDescrImpl) New ¶
func (s StructDescrImpl) New() interfaces.Struct
New creates a new interfaces.Struct based on this StructDescrImpl.
func (StructDescrImpl) Package ¶
func (s StructDescrImpl) Package() string
Package will be return name package name this struct was defined in.
func (StructDescrImpl) StructName ¶
func (s StructDescrImpl) StructName() string
Struct Name will be the name of the struct.
type StructDescrsImpl ¶
type StructDescrsImpl struct {
Descrs []interfaces.StructDescr
// contains filtered or unexported fields
}
StructDescrsImpl implements interfaces.StructDescrs. This stores a list of Struct inside a package.
func (StructDescrsImpl) ByName ¶
func (s StructDescrsImpl) ByName(name string) interfaces.StructDescr
ByName returns the StructDescr for a Struct named s. It returns nil if not found.
func (StructDescrsImpl) Get ¶
func (s StructDescrsImpl) Get(i int) interfaces.StructDescr
Get returns the ith StructDescr. It panics if out of bounds.
func (StructDescrsImpl) Len ¶
func (s StructDescrsImpl) Len() int
Len reports the number of messages.
type StructImpl ¶
type StructImpl struct {
// contains filtered or unexported fields
}
func NewStruct ¶
func NewStruct(s *segment.Struct, descr interfaces.StructDescr) StructImpl
func (StructImpl) ClawInternal ¶
func (s StructImpl) ClawInternal(pragma.DoNotImplement)
func (StructImpl) Clear ¶
func (s StructImpl) Clear(desc interfaces.FieldDescr)
func (StructImpl) Descriptor ¶
func (s StructImpl) Descriptor() interfaces.StructDescr
func (StructImpl) Fields ¶
func (s StructImpl) Fields() iter.Seq2[interfaces.FieldDescr, interfaces.Value]
Fields returns an iterator over all field descriptors and values in the struct.
func (StructImpl) Get ¶
func (s StructImpl) Get(descr interfaces.FieldDescr) interfaces.Value
func (StructImpl) Has ¶
func (s StructImpl) Has(descr interfaces.FieldDescr) bool
func (StructImpl) New ¶
func (s StructImpl) New() interfaces.Struct
func (StructImpl) NewField ¶
func (s StructImpl) NewField(descr interfaces.FieldDescr) interfaces.Value
func (StructImpl) Range ¶
func (s StructImpl) Range(f func(interfaces.FieldDescr, interfaces.Value) bool)
Range iterates over fields using a callback function (legacy method). Consider using Fields() for better composability with Go 1.24 iterators.
func (StructImpl) Set ¶
func (s StructImpl) Set(descr interfaces.FieldDescr, v interfaces.Value)
func (StructImpl) Struct ¶
func (s StructImpl) Struct() *segment.Struct
Struct extracts the *segment.Struct that holds all the data (not a reflect.Struct).
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value represents a read-only Claw value. This can be used to retrieve a value or set a value.
func ValueOfBytes ¶
ValueOfBytes returns a Value that represents []byte. Can be nil.
func ValueOfEnum ¶
func ValueOfEnum[N ~uint8 | ~uint16](v N, enumGroup interfaces.EnumGroup) Value
ValueOfEnum returns a Value that represents an enumerator.
func ValueOfList ¶
func ValueOfList(v interfaces.List) Value
ValueOfList returns a Value that represents List.
func ValueOfMap ¶
func ValueOfMap(v interfaces.Map) Value
ValueOfMap returns a Value that represents a Map.
func ValueOfNumber ¶
func ValueOfNumber[N interfaces.Number](v N) Value
ValueOfNumber returns a Value representing a number type.
func ValueOfString ¶
ValueOfString returns a Value that represents a string.
func ValueOfStruct ¶
func ValueOfStruct(v interfaces.Struct) Value
ValueOfStruct returns a Value that represents a Struct.
func (Value) Any ¶
Any decodes the value into the any type. If the value isn't valid, this panics. Here are a list of the decodes:
- Enumerators will decode into the interfaces.Enum type
- Bool will decode to the bool type
- Numbers(int*, uint*, float*) decode into their Go equivalent
- String into the string type
- Bytes into the []byte type
- Struct into reflect.Struct
- List of bools into []bool
- List of Numbers into []<go number type>
- List of String into []string
- List of Bytes into [][]byte
- List of Struct into a []reflect.Struct
func (Value) Bool ¶
Bool returns the boolean value stored in Value. If Value is not a bool type, this will panic.
func (Value) Bytes ¶
Bytes returns the Bytes value stored in Value. If Value is not a Bytes type, this will panic.
func (Value) Enum ¶
func (v Value) Enum() interfaces.Enum
Enum returns the enumerated value stored in Value. If Value is not an Enum type, this will panic.
func (Value) Float ¶
Float returns the Float value stored in Value. If Value is not a Float type, this will panic.
func (Value) Int ¶
Int returns the integer value stored in Value. If Value is not an integer type, this will panic.
func (Value) List ¶
func (v Value) List() interfaces.List
List returns the List value stored in Value. If Value is not some list type, this will panic.
func (Value) Map ¶
func (v Value) Map() interfaces.Map
Map returns the Map value stored in Value. If Value is not a map type, this will panic.
func (Value) String ¶
String returns the string value stored in Value. String returns the string v's underlying value, as a string. String is a special case because of Go's String method convention. Unlike the other getters, it does not panic if v's Kind is not String. Instead, it returns a string of the form "<T value>" where T is v's type. The fmt package treats Values specially. It does not call their String method implicitly but instead prints the concrete values they hold.
func (Value) Struct ¶
func (v Value) Struct() interfaces.Struct
Struct returns the Struct value stored in Value. If Value is not a Struct type, this will panic.