reflect

package
v0.0.0-...-20810c9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Converters = ConversionRegistry{
				// contains filtered or unexported fields
	}
	Calculators = CalculatorRegistry{}
)
View Source
var (
	TypeFloat   = NewType("float")
	TypeInteger = NewType("integer")
	TypeBoolean = NewType("boolean")
	TypeMap     = NewType("map").WithProps([]Prop{
		{name: "size", t: TypeInteger},
	})
	TypeList = NewType("list").WithProps([]Prop{
		{name: "size", t: TypeInteger},
	})
	TypePoint2D = NewType("point2d").WithProps([]Prop{
		{name: "x", t: TypeFloat},
		{name: "y", t: TypeFloat},
	})
	TypePoint3D = NewType("point3d").WithProps([]Prop{
		{name: "x", t: TypeFloat},
		{name: "y", t: TypeFloat},
		{name: "z", t: TypeFloat},
	})
	TypeScale2D  = TypePoint2D.Alias("scale2d")
	TypeScale3D  = TypePoint3D.Alias("scale3d")
	TypeVector2D = NewType("vector2d").WithProps([]Prop{
		{name: "x", t: TypeFloat},
		{name: "y", t: TypeFloat},
		{name: "length", t: TypeFloat},
	})
	TypeVector3D = NewType("vector3d").WithProps([]Prop{
		{name: "x", t: TypeFloat},
		{name: "y", t: TypeFloat},
		{name: "z", t: TypeFloat},
		{name: "length", t: TypeFloat},
	})
	TypeAngle = NewType("angle").WithProps([]Prop{
		{name: "radians", t: TypeFloat},
		{name: "degrees", t: TypeFloat},
	})
	TypeQuaternion = NewType("quaternion").WithProps([]Prop{
		{name: "v", t: TypeVector3D},
		{name: "t", t: TypeAngle},
	})
	TypeSprite = NewType("sprite").WithProps([]Prop{
		{name: "angle", t: TypeAngle},
		{name: "position", t: TypePoint2D},
		{name: "alignment", t: TypePoint2D},
		{name: "size", t: TypePoint2D},
		{name: "scale", t: TypeScale2D},
	})
	TypeBone = NewType("bone").WithSelfProps(func(bone *Type) []Prop {
		return []Prop{
			{name: "offset", t: TypeVector3D},
			{name: "rotation", t: TypeQuaternion},
			{name: "children", t: TypeMap.AsMapOf(bone)},
		}
	})
	TypeSkeleton = NewType("skeleton").WithProps([]Prop{
		{name: "bones", t: TypeMap.AsMapOf(TypeBone)},
	})
	TypeMesh = NewType("mesh").WithProps([]Prop{
		{name: "position", t: TypePoint3D},
		{name: "rotation", t: TypeQuaternion},
		{name: "scale", t: TypeScale3D},
		{name: "skeleton", t: TypeSkeleton},
	})
)

Functions

This section is empty.

Types

type Calculator

type Calculator interface {
	Size() int
	Zero() Value
	DistanceSq(a Value, b Value) float32
	AddScaled(out Value, a Value, b Value, bScale float32)
	Mul(out Value, a Value, scale Value)
}

type CalculatorRegistry

type CalculatorRegistry map[ID]Calculator

func (CalculatorRegistry) Get

func (CalculatorRegistry) Set

func (r CalculatorRegistry) Set(t *Type, c Calculator)

type ConversionRegistry

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

func (ConversionRegistry) Get

func (r ConversionRegistry) Get(from *Type, to *Type) Converter

func (ConversionRegistry) Set

func (r ConversionRegistry) Set(from *Type, to *Type, converter Converter)

type Converter

type Converter func(from Value, out Value)

type Float

type Float float32

func (Float) Get

func (f Float) Get(prop string) Value

func (Float) Set

func (f Float) Set(values []PropValue)

func (Float) Type

func (f Float) Type() *Type

type ID

type ID = uint16

type Incrementor

type Incrementor[V constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func NewIncrementor

func NewIncrementor[V constraints.Ordered](start V, increment V) Incrementor[V]

func (Incrementor[V]) Get

func (i Incrementor[V]) Get() V

type Iterator

type Iterator[K comparable, V any] interface {
	Next() bool
	Get() V
	Set(value V)
	Key() K
	Remove()
	Reset()
}

func IterateMap

func IterateMap[K comparable, V any](m map[K]V) Iterator[K, V]

func IterateSlice

func IterateSlice[V any](slice []V) Iterator[int, V]

type Prop

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

type PropValue

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

type Type

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

func NewType

func NewType(name string) *Type

func (Type) Alias

func (t Type) Alias(name string) *Type

func (Type) AsListOf

func (t Type) AsListOf(listOf *Type) *Type

func (*Type) AsMapOf

func (t *Type) AsMapOf(mapOf *Type) *Type

func (Type) Copy

func (t Type) Copy() *Type

func (Type) ID

func (t Type) ID() ID

func (Type) Key

func (t Type) Key() *Type

func (Type) Name

func (t Type) Name() string

func (Type) Props

func (t Type) Props() []Prop

func (Type) Value

func (t Type) Value() *Type

func (Type) WithProps

func (t Type) WithProps(props []Prop) *Type

func (Type) WithSelfProps

func (t Type) WithSelfProps(props func(self *Type) []Prop) *Type

type Value

type Value interface {
	Type() *Type
	Get(prop string) Value
	Set(values []PropValue)
}

type Vector3D

type Vector3D struct {
	X float32
	Y float32
}

func (Vector3D) Get

func (v Vector3D) Get(prop string) Value

func (*Vector3D) Set

func (v *Vector3D) Set(values []PropValue)

func (Vector3D) Type

func (v Vector3D) Type() *Type

Jump to

Keyboard shortcuts

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