interpreters

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Always

func Always(inst *Instance) bool

Always is a predicate that returns true for every call.

func Never

func Never(inst *Instance) bool

Never is a predicate that returns false for every call.

Types

type BitfieldHandler

type BitfieldHandler func(values map[uint32]string)

BitfieldHandler is for bitfields.

type Description

type Description struct {
	// contains filtered or unexported fields
}

Description is the meta information about a data interpreter. A description is an immutable object that provides new descriptions with any modification.

func New

func New() *Description

New returns an empty description.

func (*Description) As

func (desc *Description) As(fieldRange FieldRange) *Description

As sets the value range for the previously added field.

func (*Description) For

func (desc *Description) For(data []byte) *Instance

For returns an instance of an interpreter with the given data slice as backing buffer.

func (*Description) Refining

func (desc *Description) Refining(key string, byteStart int, byteCount int, refined *Description, predicate Predicate) *Description

Refining adds another description within the given one. The provided predicate determines whether the refined description is active.

func (*Description) With

func (desc *Description) With(key string, byteStart int, byteCount int) *Description

With extends the given description with a new field. The returned description is a new, separated object from the originating one.

type EnumValueHandler

type EnumValueHandler func(values map[uint32]string)

EnumValueHandler is for enumerated (mapped) values.

type FieldRange

type FieldRange func(*Simplifier) bool

FieldRange is a function specializing the range of a field to a simplifier.

func Bitfield

func Bitfield(values map[uint32]string) FieldRange

Bitfield creates a field range describing bitfield values.

func EnumValue

func EnumValue(values map[uint32]string) FieldRange

EnumValue creates a field range describing enumerated values.

func FormattedRangedValue

func FormattedRangedValue(minValue, maxValue int64, formatter RawValueFormatter) FieldRange

FormattedRangedValue is similar to RangedValue, and adds a formatting function.

func ObjectID

func ObjectID() FieldRange

ObjectID creates a field range describing object identifier.

func RangedValue

func RangedValue(minValue, maxValue int64) FieldRange

RangedValue creates a field range for specific minimum and maximum values.

func RotationValue added in v1.5.0

func RotationValue(minValue, maxValue int64) FieldRange

RotationValue creates a field range for a rotational property.

func SpecialValue

func SpecialValue(specialType string) FieldRange

SpecialValue creates a field range for special fields. Currently known special values: * BinaryCodedDecimal - for keypads storing their number as BCD * LevelTexture - index value into level texture list * MaterialOrLevelTexture - index value into level texture list, or material (bit 7 toggles) * VariableKey - for actions * VariableCondition - for action conditions * ObjectTriple - for 0x00CCSSTT selection * ObjectHeight - for level height value 0..255 * MoveTileHeight - for change tile height action * TileHeight - tile heights * TileType - tile types * Unknown - It is unclear whether this field would have any effect, none identified so far * Ignored - Although values have been found in this field, they don't appear to have any effect * Mistake - It is assumed that these values should have been placed somewhere else. Typical example: Container content * Internal - Fields that are handled mainly by the engine and shouldn't be modified.

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance is one instantiated interpreter for a data block, based on a predetermined description.

func (*Instance) ActiveRefinements

func (inst *Instance) ActiveRefinements() (keys []string)

ActiveRefinements returns an array of all keys where the corresponding refinement is active (The corresponding predicate returns true).

func (*Instance) Describe

func (inst *Instance) Describe(key string, simplifier *Simplifier)

Describe returns the description of a value key.

func (*Instance) Get

func (inst *Instance) Get(key string) uint32

Get returns the value associated with the given key. Should there be no value for the requested key, the function returns 0.

func (*Instance) Keys

func (inst *Instance) Keys() []string

Keys returns an array of all registered keys, sorted by start index.

func (*Instance) Raw

func (inst *Instance) Raw() []byte

Raw returns the raw array.

func (*Instance) Refined

func (inst *Instance) Refined(key string) (refined *Instance)

Refined returns an instance that was nested according to the description. This method returns an instance for registered refinements even if their predicate would not specify them being active. Should the refinement not exist, an instance without any fields will be returned.

func (*Instance) Set

func (inst *Instance) Set(key string, value uint32)

Set stores the provided value with the given key. Should there be no registration for the key, the function does nothing.

func (*Instance) Undefined

func (inst *Instance) Undefined() []byte

Undefined returns a byte array that specifies which bits were not specified. The array has the same length as the underlying buffer and has all bits set to 1 where no field or active refinement is present.

type ObjectIDHandler

type ObjectIDHandler func()

ObjectIDHandler is for object identifier in a level.

type Predicate

type Predicate func(inst *Instance) bool

Predicate is a function that specifies whether a certain description is active within another.

type RawValueFormatter

type RawValueFormatter func(value int) string

RawValueFormatter provides the format function for given value. If nothing special is to be displayed, an empty string should be returned. The handler is responsible for adding the number value representation.

type RawValueHandler

type RawValueHandler func(minValue, maxValue int64, formatter RawValueFormatter)

RawValueHandler is for a simple value range.

type RotationHandler added in v1.5.0

type RotationHandler func(minValue, maxValue int64)

RotationHandler is for circular values.

type Simplifier

type Simplifier struct {
	// contains filtered or unexported fields
}

Simplifier forwards descriptions in a way the requester can use.

func NewSimplifier

func NewSimplifier(rawValueHandler RawValueHandler) *Simplifier

NewSimplifier returns a new instance of a simplifier, with the minimal handler set.

func (*Simplifier) SetBitfieldHandler

func (simpl *Simplifier) SetBitfieldHandler(handler BitfieldHandler)

SetBitfieldHandler registers the handler for bitfields.

func (*Simplifier) SetEnumValueHandler

func (simpl *Simplifier) SetEnumValueHandler(handler EnumValueHandler)

SetEnumValueHandler registers the handler for enumerations.

func (*Simplifier) SetObjectIDHandler

func (simpl *Simplifier) SetObjectIDHandler(handler ObjectIDHandler)

SetObjectIDHandler registers the handler for object indices.

func (*Simplifier) SetRotationHandler added in v1.5.0

func (simpl *Simplifier) SetRotationHandler(handler RotationHandler)

SetRotationHandler registers the handler for rotation values.

func (*Simplifier) SetSpecialHandler

func (simpl *Simplifier) SetSpecialHandler(specialType string, handler SpecialHandler)

SetSpecialHandler registers the handler for special values.

type SpecialHandler

type SpecialHandler func()

SpecialHandler is for rare occasions.

Jump to

Keyboard shortcuts

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