Documentation ¶
Overview ¶
Package fapi creates a generic public API for xirho function types.
The For function uses reflection to gather a list of modifiable parameters. This can be used to implement serialization formats or to provide user interfaces for functions. Parameter types are based on semantics rather than on representation to allow for more natural user interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Affine ¶
type Affine struct {
// contains filtered or unexported fields
}
Affine is an affine transform function parameter.
type Angle ¶
type Angle struct {
// contains filtered or unexported fields
}
Angle is an angle function parameter. External interfaces wrap its value into the interval (-pi, pi].
type Complex ¶
type Complex struct {
// contains filtered or unexported fields
}
Complex is an unconstrained function parameter in R^2.
type Flag ¶
type Flag struct {
// contains filtered or unexported fields
}
Flag is a boolean function parameter.
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
Func is a function parameter that is itself a function. After the parameter name, a Func field may include an additional comma-separated tag containing the string "optional". Func fields marked optional may be set to nil. For example:
type Example struct { NillableFunc `xirho:"func,optional"` }
func (Func) IsOptional ¶
IsOptional returns whether the function may be set to nil.
type FuncList ¶
type FuncList struct {
// contains filtered or unexported fields
}
FuncList is a function parameter holding a list of functions.
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int is an integer function parameter. After the parameter name, an Int field may include two additional comma-separated tags to define the lowest and highest permitted values. For example, to define a parameter allowing the user to choose any integer in [-3, 12], do:
type Example struct { P xirho.Int `xirho:"p,-3,12"` }
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a function parameter to choose among a list of strings. After the parameter name, a List field may include any number of additional comma-separated tags to define the display names of each option. For example, to define a parameter allowing the user to choose between "fast", "accurate", or "balanced", do:
type Example struct { Method xirho.List `xirho:"method,fast,accurate,balanced"` }
type NotFinite ¶
type NotFinite struct { // Param is the parameter which the caller attempted to set. Param Param }
NotFinite is an error returned when attempting to set an Angle, Real, Complex, Vec3, or Affine parameter to a value with a component that is not finite.
type NotOptional ¶
type NotOptional struct { // Param is the parameter which the caller attempted to set. Param Param }
NotOptional is an error returned when attempting to set a Func to nil when the Func is not marked as optional.
func (NotOptional) Error ¶
func (err NotOptional) Error() string
Error returns a formatted error message.
type OutOfBoundsInt ¶
type OutOfBoundsInt struct { // Param is the parameter which the caller attempted to set. Param Param // Value is the value which the caller attempted to use. Value int64 // Lo and Hi are the minimum and maximum allowed values, inclusive. Lo, Hi int64 }
OutOfBoundsInt is an error returned when attempting to set an Int or List to a value which is out of the parameter's defined limits.
func (OutOfBoundsInt) Error ¶
func (err OutOfBoundsInt) Error() string
Error returns a formatted error message.
type OutOfBoundsReal ¶
type OutOfBoundsReal struct { // Param is the parameter which the caller attempted to set. Param Param // Value is the value which the caller attempted to use. Value float64 // Lo and Hi are the minimum and maximum allowed values, inclusive. Lo, Hi float64 }
OutOfBoundsReal is an error returned when attempting to set a Real to a value which is out of the parameter's defined limits.
func (OutOfBoundsReal) Error ¶
func (err OutOfBoundsReal) Error() string
Error returns a formatted error message.
type Param ¶
type Param interface { // Name returns the parameter name. Name() string // contains filtered or unexported methods }
Param is a user-controlled function parameter. Each implementing type has a setter and a getter for a corresponding xirho.Param type.
func For ¶
For collects a xirho.F's exported parameters. Each returned parameter has its name set according to the first comma-separated section of the field's "xirho" struct tag, defaulting to the field name. E.g., the JuliaN variation is defined as such:
type JuliaN struct { Power xirho.Int `xirho:"power"` Dist xirho.Real `xirho:"dist"` }
Certain parameters provide additional options; see the documentation for each for details.
type Real ¶
type Real struct {
// contains filtered or unexported fields
}
Real is a floating-point function parameter. After the parameter name, a Real field may include two additional comma-separated tags to define the lowest and highest permitted values. For example, to define a parameter allowing the user to choose any real in [-2π, 2π], do:
type Example struct { P xirho.Real `xirho:"p,-6.283185307179586,6.283185307179586"` }