Documentation ¶
Overview ¶
Package object provides the standard set of Risor object types.
For external users of Risor, often an object.Object interface will be type asserted to a specific object type, such as *object.Float.
For example:
switch obj := obj.(type) { case *object.String: // do something with obj.Value() case *object.Float: // do something with obj.Value() }
The Type() method of each object may also be used to get a string name of the object type, such as "string" or "float".
Index ¶
- Variables
- func AsError(obj Object) (*Error, *Error)
- func AsIterator(obj Object) (Iterator, *Error)
- func AsList(obj Object) (*List, *Error)
- func AsMap(obj Object) (*Map, *Error)
- func AsObjects(m map[string]any) (map[string]Object, error)
- func AsSet(obj Object) (*Set, *Error)
- func CompareTypes(a, b Object) int
- func Equals(a, b Object) bool
- func IsError(obj Object) bool
- func IsProxyableType(typ reflect.Type) bool
- func Keys(m map[string]Object) []string
- func NewArgumentsError(message string, args ...interface{}) errordeprecated
- func PrintableValue(obj Object) interface{}
- func ResolveIndex(idx int64, size int64) (int64, error)
- func ResolveIntSlice(slice Slice, size int64) (start int64, stop int64, err error)
- func SetTypeConverter(typ reflect.Type, conv TypeConverter)
- func WithCallFunc(ctx context.Context, fn CallFunc) context.Context
- func WithCloneCallFunc(ctx context.Context, fn CallFunc) context.Context
- func WithSpawnFunc(ctx context.Context, fn SpawnFunc) context.Context
- type ArgumentsErrordeprecated
- type ArrayConverter
- type AttrResolver
- type Bool
- func (b *Bool) Compare(other Object) (int, error)
- func (b Bool) Cost() int
- func (b *Bool) Equals(other Object) Object
- func (b Bool) GetAttr(name string) (Object, bool)
- func (b *Bool) HashKey() HashKey
- func (b *Bool) Inspect() string
- func (b *Bool) Interface() interface{}
- func (b *Bool) IsTruthy() bool
- func (b *Bool) MarshalJSON() ([]byte, error)
- func (b *Bool) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Bool) SetAttr(name string, value Object) error
- func (b *Bool) String() string
- func (b *Bool) Type() Type
- func (b *Bool) Value() bool
- type BoolConverter
- type Buffer
- func (b *Buffer) Compare(other Object) (int, error)
- func (b *Buffer) Cost() int
- func (b *Buffer) Equals(other Object) Object
- func (b *Buffer) GetAttr(name string) (Object, bool)
- func (b *Buffer) Inspect() string
- func (b *Buffer) Interface() interface{}
- func (b *Buffer) IsTruthy() bool
- func (b *Buffer) MarshalJSON() ([]byte, error)
- func (b *Buffer) Read(p []byte) (n int, err error)
- func (b *Buffer) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b *Buffer) SetAttr(name string, value Object) error
- func (b *Buffer) String() string
- func (b *Buffer) Type() Type
- func (b *Buffer) Value() *bytes.Buffer
- func (b *Buffer) Write(p []byte) (n int, err error)
- type BufferConverter
- type Builtin
- func (b *Builtin) Call(ctx context.Context, args ...Object) Object
- func (b Builtin) Cost() int
- func (b *Builtin) Equals(other Object) Object
- func (b *Builtin) GetAttr(name string) (Object, bool)
- func (b *Builtin) Inspect() string
- func (b *Builtin) Interface() interface{}
- func (b *Builtin) IsErrorHandler() bool
- func (b Builtin) IsTruthy() bool
- func (b *Builtin) Key() string
- func (b *Builtin) MarshalJSON() ([]byte, error)
- func (b *Builtin) Name() string
- func (b *Builtin) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Builtin) SetAttr(name string, value Object) error
- func (b *Builtin) String() string
- func (b *Builtin) Type() Type
- func (b *Builtin) Value() BuiltinFunction
- type BuiltinFunction
- type Byte
- func (b *Byte) Compare(other Object) (int, error)
- func (b Byte) Cost() int
- func (b *Byte) Equals(other Object) Object
- func (b Byte) GetAttr(name string) (Object, bool)
- func (b *Byte) HashKey() HashKey
- func (b *Byte) Inspect() string
- func (b *Byte) Interface() interface{}
- func (b *Byte) IsTruthy() bool
- func (b *Byte) MarshalJSON() ([]byte, error)
- func (b *Byte) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Byte) SetAttr(name string, value Object) error
- func (b *Byte) String() string
- func (b *Byte) Type() Type
- func (b *Byte) Value() byte
- type ByteConverter
- type ByteSlice
- func (b *ByteSlice) Clone() *ByteSlice
- func (b *ByteSlice) Compare(other Object) (int, error)
- func (b *ByteSlice) Contains(obj Object) *Bool
- func (b *ByteSlice) ContainsAny(obj Object) Object
- func (b *ByteSlice) ContainsRune(obj Object) Object
- func (b *ByteSlice) Cost() int
- func (b *ByteSlice) Count(obj Object) Object
- func (b *ByteSlice) DelItem(key Object) *Error
- func (b *ByteSlice) Equals(other Object) Object
- func (b *ByteSlice) GetAttr(name string) (Object, bool)
- func (b *ByteSlice) GetItem(key Object) (Object, *Error)
- func (b *ByteSlice) GetSlice(slice Slice) (Object, *Error)
- func (b *ByteSlice) HasPrefix(obj Object) Object
- func (b *ByteSlice) HasSuffix(obj Object) Object
- func (b *ByteSlice) HashKey() HashKey
- func (b *ByteSlice) Index(obj Object) Object
- func (b *ByteSlice) IndexAny(obj Object) Object
- func (b *ByteSlice) IndexByte(obj Object) Object
- func (b *ByteSlice) IndexRune(obj Object) Object
- func (b *ByteSlice) Inspect() string
- func (b *ByteSlice) Integers() []Object
- func (b *ByteSlice) Interface() interface{}
- func (b *ByteSlice) IsTruthy() bool
- func (b *ByteSlice) Iter() Iterator
- func (b *ByteSlice) Len() *Int
- func (b *ByteSlice) MarshalJSON() ([]byte, error)
- func (b *ByteSlice) Repeat(obj Object) Object
- func (b *ByteSlice) Replace(old, new, count Object) Object
- func (b *ByteSlice) ReplaceAll(old, new Object) Object
- func (b *ByteSlice) Reversed() *ByteSlice
- func (b *ByteSlice) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b ByteSlice) SetAttr(name string, value Object) error
- func (b *ByteSlice) SetItem(key, value Object) *Error
- func (b *ByteSlice) String() string
- func (b *ByteSlice) Type() Type
- func (b *ByteSlice) Value() []byte
- type ByteSliceConverter
- type CallFunc
- type Callable
- type Cell
- func (b Cell) Cost() int
- func (c *Cell) Equals(other Object) Object
- func (b Cell) GetAttr(name string) (Object, bool)
- func (c *Cell) Inspect() string
- func (c *Cell) Interface() interface{}
- func (b Cell) IsTruthy() bool
- func (c *Cell) MarshalJSON() ([]byte, error)
- func (c *Cell) RunOperation(opType op.BinaryOpType, right Object) Object
- func (c *Cell) Set(value Object)
- func (b Cell) SetAttr(name string, value Object) error
- func (c *Cell) String() string
- func (c *Cell) Type() Type
- func (c *Cell) Value() Object
- type Chan
- func (c *Chan) Capacity() int
- func (c *Chan) Close() (err error)
- func (c *Chan) Cost() int
- func (c *Chan) Entry() (IteratorEntry, bool)
- func (c *Chan) Equals(other Object) Object
- func (c *Chan) GetAttr(name string) (Object, bool)
- func (c *Chan) Inspect() string
- func (c *Chan) Interface() interface{}
- func (c *Chan) IsTruthy() bool
- func (c *Chan) Iter() Iterator
- func (c *Chan) MarshalJSON() ([]byte, error)
- func (c *Chan) Next(ctx context.Context) (Object, bool)
- func (c *Chan) Receive(ctx context.Context) (Object, error)
- func (c *Chan) RunOperation(opType op.BinaryOpType, right Object) Object
- func (c *Chan) Send(ctx context.Context, value Object) (err error)
- func (c *Chan) SetAttr(name string, value Object) error
- func (c *Chan) Type() Type
- func (c *Chan) Value() chan Object
- type Color
- func (b Color) Cost() int
- func (c *Color) Equals(other Object) Object
- func (c *Color) GetAttr(name string) (Object, bool)
- func (c *Color) Inspect() string
- func (c *Color) Interface() interface{}
- func (b Color) IsTruthy() bool
- func (c *Color) MarshalJSON() ([]byte, error)
- func (c *Color) RunOperation(opType op.BinaryOpType, right Object) Object
- func (c *Color) SetAttr(name string, value Object) error
- func (c *Color) String() string
- func (c *Color) Type() Type
- func (c *Color) Value() color.Color
- type Comparable
- type Container
- type ContextConverter
- type DirEntry
- func (d *DirEntry) Cost() int
- func (d *DirEntry) Equals(other Object) Object
- func (d *DirEntry) FileInfo() (*FileInfo, bool)
- func (d *DirEntry) GetAttr(name string) (Object, bool)
- func (d *DirEntry) Inspect() string
- func (d *DirEntry) Interface() interface{}
- func (d *DirEntry) IsTruthy() bool
- func (d *DirEntry) MarshalJSON() ([]byte, error)
- func (d *DirEntry) RunOperation(opType op.BinaryOpType, right Object) Object
- func (d *DirEntry) SetAttr(name string, value Object) error
- func (d *DirEntry) String() string
- func (d *DirEntry) Type() Type
- func (d *DirEntry) Value() ros.DirEntry
- type DynamicAttr
- func (d *DynamicAttr) Cost() int
- func (d *DynamicAttr) Equals(other Object) Object
- func (d *DynamicAttr) GetAttr(name string) (Object, bool)
- func (d *DynamicAttr) Inspect() string
- func (d *DynamicAttr) Interface() interface{}
- func (d *DynamicAttr) IsTruthy() bool
- func (d *DynamicAttr) MarshalJSON() ([]byte, error)
- func (d *DynamicAttr) ResolveAttr(ctx context.Context, name string) (Object, error)
- func (d *DynamicAttr) RunOperation(opType op.BinaryOpType, right Object) Object
- func (d *DynamicAttr) SetAttr(name string, value Object) error
- func (d *DynamicAttr) String() string
- func (d *DynamicAttr) Type() Type
- type DynamicConverter
- type Entry
- func (b Entry) Cost() int
- func (e *Entry) Equals(other Object) Object
- func (e *Entry) GetAttr(name string) (Object, bool)
- func (e *Entry) Inspect() string
- func (e *Entry) Interface() interface{}
- func (b Entry) IsTruthy() bool
- func (e *Entry) Key() Object
- func (e *Entry) MarshalJSON() ([]byte, error)
- func (e *Entry) Primary() Object
- func (e *Entry) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Entry) SetAttr(name string, value Object) error
- func (e *Entry) Type() Type
- func (e *Entry) Value() Object
- func (e *Entry) WithKeyAsPrimary() *Entry
- func (e *Entry) WithValueAsPrimary() *Entry
- type Error
- func ArgsErrorf(format string, args ...interface{}) *Error
- func AsBool(obj Object) (bool, *Error)
- func AsByte(obj Object) (byte, *Error)
- func AsBytes(obj Object) ([]byte, *Error)
- func AsFloat(obj Object) (float64, *Error)
- func AsInt(obj Object) (int64, *Error)
- func AsReader(obj Object) (io.Reader, *Error)
- func AsString(obj Object) (string, *Error)
- func AsStringSlice(obj Object) ([]string, *Error)
- func AsTime(obj Object) (result time.Time, err *Error)
- func AsWriter(obj Object) (io.Writer, *Error)
- func Errorf(format string, a ...interface{}) *Error
- func EvalErrorf(format string, args ...interface{}) *Error
- func NewArgsError(fn string, takes, given int) *Error
- func NewArgsRangeError(fn string, takesMin, takesMax, given int) *Error
- func NewError(err error) *Error
- func Sort(items []Object) *Error
- func TypeErrorf(format string, args ...interface{}) *Error
- func (e *Error) Compare(other Object) (int, error)
- func (b Error) Cost() int
- func (e *Error) Equals(other Object) Object
- func (e *Error) Error() string
- func (e *Error) GetAttr(name string) (Object, bool)
- func (e *Error) Inspect() string
- func (e *Error) Interface() interface{}
- func (e *Error) IsRaised() bool
- func (b Error) IsTruthy() bool
- func (e *Error) MarshalJSON() ([]byte, error)
- func (e *Error) Message() *String
- func (e *Error) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Error) SetAttr(name string, value Object) error
- func (e *Error) String() string
- func (e *Error) Type() Type
- func (e *Error) Unwrap() error
- func (e *Error) Value() error
- func (e *Error) WithRaised(value bool) *Error
- type ErrorConverter
- type File
- func (f *File) Close() error
- func (f *File) Cost() int
- func (f *File) Equals(other Object) Object
- func (f *File) GetAttr(name string) (Object, bool)
- func (f *File) Inspect() string
- func (f *File) Interface() interface{}
- func (b File) IsTruthy() bool
- func (f *File) Iter() Iterator
- func (f *File) MarshalJSON() ([]byte, error)
- func (f *File) Position() (int64, error)
- func (f *File) Read(p []byte) (n int, err error)
- func (f *File) RunOperation(opType op.BinaryOpType, right Object) Object
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (b File) SetAttr(name string, value Object) error
- func (f *File) String() string
- func (f *File) Type() Type
- func (f *File) Value() ros.File
- func (f *File) Write(p []byte) (n int, err error)
- type FileInfo
- func (f *FileInfo) Cost() int
- func (f *FileInfo) Equals(other Object) Object
- func (f *FileInfo) GetAttr(name string) (Object, bool)
- func (f *FileInfo) Inspect() string
- func (f *FileInfo) Interface() interface{}
- func (f *FileInfo) IsTruthy() bool
- func (f *FileInfo) MarshalJSON() ([]byte, error)
- func (f *FileInfo) RunOperation(opType op.BinaryOpType, right Object) Object
- func (f *FileInfo) SetAttr(name string, value Object) error
- func (f *FileInfo) String() string
- func (f *FileInfo) Type() Type
- func (f *FileInfo) Value() ros.FileInfo
- type FileIter
- func (b FileIter) Cost() int
- func (iter *FileIter) Entry() (IteratorEntry, bool)
- func (iter *FileIter) Equals(other Object) Object
- func (iter *FileIter) GetAttr(name string) (Object, bool)
- func (iter *FileIter) Inspect() string
- func (iter *FileIter) Interface() interface{}
- func (iter *FileIter) IsTruthy() bool
- func (iter *FileIter) MarshalJSON() ([]byte, error)
- func (iter *FileIter) Next(ctx context.Context) (Object, bool)
- func (iter *FileIter) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b FileIter) SetAttr(name string, value Object) error
- func (iter *FileIter) String() string
- func (iter *FileIter) Type() Type
- type FileMode
- func (m *FileMode) Compare(other Object) (int, error)
- func (m *FileMode) Cost() int
- func (m *FileMode) Equals(other Object) Object
- func (m *FileMode) GetAttr(name string) (Object, bool)
- func (m *FileMode) Inspect() string
- func (m *FileMode) Interface() interface{}
- func (m *FileMode) IsTruthy() bool
- func (m *FileMode) MarshalJSON() ([]byte, error)
- func (m *FileMode) RunOperation(opType op.BinaryOpType, right Object) Object
- func (m *FileMode) SetAttr(name string, value Object) error
- func (m *FileMode) String() string
- func (m *FileMode) Type() Type
- func (m *FileMode) Value() ros.FileMode
- type Float
- func (f *Float) Compare(other Object) (int, error)
- func (b Float) Cost() int
- func (f *Float) Equals(other Object) Object
- func (b Float) GetAttr(name string) (Object, bool)
- func (f *Float) HashKey() HashKey
- func (f *Float) Inspect() string
- func (f *Float) Interface() interface{}
- func (f *Float) IsTruthy() bool
- func (f *Float) MarshalJSON() ([]byte, error)
- func (f *Float) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Float) SetAttr(name string, value Object) error
- func (f *Float) String() string
- func (f *Float) Type() Type
- func (f *Float) Value() float64
- type Float32Converter
- type Float64Converter
- type FloatSlice
- func (f *FloatSlice) Clone() *FloatSlice
- func (f *FloatSlice) Contains(item Object) *Bool
- func (f *FloatSlice) Cost() int
- func (f *FloatSlice) DelItem(key Object) *Error
- func (f *FloatSlice) Equals(other Object) Object
- func (f *FloatSlice) GetAttr(name string) (Object, bool)
- func (f *FloatSlice) GetItem(key Object) (Object, *Error)
- func (f *FloatSlice) GetSlice(slice Slice) (Object, *Error)
- func (f *FloatSlice) Inspect() string
- func (f *FloatSlice) Integers() []Object
- func (f *FloatSlice) Interface() interface{}
- func (f *FloatSlice) IsTruthy() bool
- func (f *FloatSlice) Iter() Iterator
- func (f *FloatSlice) Len() *Int
- func (f *FloatSlice) MarshalJSON() ([]byte, error)
- func (f *FloatSlice) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b FloatSlice) SetAttr(name string, value Object) error
- func (f *FloatSlice) SetItem(key, value Object) *Error
- func (f *FloatSlice) String() string
- func (f *FloatSlice) Type() Type
- func (f *FloatSlice) Value() []float64
- type FloatSliceConverter
- type Function
- func (f *Function) Call(ctx context.Context, args ...Object) Object
- func (f *Function) Code() *compiler.Code
- func (b Function) Cost() int
- func (f *Function) Defaults() []Object
- func (f *Function) Equals(other Object) Object
- func (f *Function) FreeVars() []*Cell
- func (f *Function) Function() *compiler.Function
- func (f *Function) GetAttr(name string) (Object, bool)
- func (f *Function) Inspect() string
- func (f *Function) Instructions() []op.Code
- func (f *Function) Interface() interface{}
- func (b Function) IsTruthy() bool
- func (f *Function) LocalsCount() int
- func (f *Function) MarshalJSON() ([]byte, error)
- func (f *Function) Name() string
- func (f *Function) Parameters() []string
- func (f *Function) RequiredArgsCount() int
- func (f *Function) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Function) SetAttr(name string, value Object) error
- func (f *Function) String() string
- func (f *Function) Type() Type
- type FunctionOpts
- type GoAttribute
- type GoField
- func (f *GoField) Converter() (TypeConverter, bool)
- func (b GoField) Cost() int
- func (f *GoField) Equals(other Object) Object
- func (f *GoField) GetAttr(name string) (Object, bool)
- func (f *GoField) GoType() *GoType
- func (f *GoField) Inspect() string
- func (f *GoField) Interface() interface{}
- func (f *GoField) IsTruthy() bool
- func (f *GoField) MarshalJSON() ([]byte, error)
- func (f *GoField) Name() string
- func (f *GoField) ReflectType() reflect.Type
- func (f *GoField) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b GoField) SetAttr(name string, value Object) error
- func (f *GoField) Tag() reflect.StructTag
- func (f *GoField) Type() Type
- type GoMethod
- func (b GoMethod) Cost() int
- func (m *GoMethod) Equals(other Object) Object
- func (m *GoMethod) ErrorIndices() []int
- func (m *GoMethod) GetAttr(name string) (Object, bool)
- func (m *GoMethod) HasPointerReceiver() bool
- func (m *GoMethod) InType(i int) *GoType
- func (m *GoMethod) Inspect() string
- func (m *GoMethod) Interface() interface{}
- func (m *GoMethod) IsOutputError(index int) bool
- func (m *GoMethod) IsTruthy() bool
- func (m *GoMethod) MarshalJSON() ([]byte, error)
- func (m *GoMethod) Name() string
- func (m *GoMethod) NumIn() int
- func (m *GoMethod) NumOut() int
- func (m *GoMethod) OutType(i int) *GoType
- func (m *GoMethod) ProducesError() bool
- func (m *GoMethod) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b GoMethod) SetAttr(name string, value Object) error
- func (m *GoMethod) Type() Type
- type GoType
- func (t *GoType) AttributeNames() []string
- func (b GoType) Cost() int
- func (t *GoType) Equals(other Object) Object
- func (t *GoType) GetAttr(name string) (Object, bool)
- func (t *GoType) GetAttribute(name string) (GoAttribute, bool)
- func (t *GoType) GetConverter() (TypeConverter, error)
- func (t *GoType) HasDirectMethod(name string) bool
- func (t *GoType) IndirectType() *GoType
- func (t *GoType) Inspect() string
- func (t *GoType) Interface() interface{}
- func (t *GoType) IsPointerType() bool
- func (t *GoType) IsTruthy() bool
- func (t *GoType) MarshalJSON() ([]byte, error)
- func (t *GoType) Name() string
- func (t *GoType) New() reflect.Value
- func (t *GoType) PackagePath() string
- func (t *GoType) PointerType() *GoType
- func (t *GoType) ReflectType() reflect.Type
- func (t *GoType) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b GoType) SetAttr(name string, value Object) error
- func (t *GoType) Type() Type
- func (t *GoType) ValueType() *GoType
- type HashKey
- type Hashable
- type Int
- func (i *Int) Compare(other Object) (int, error)
- func (b Int) Cost() int
- func (i *Int) Equals(other Object) Object
- func (b Int) GetAttr(name string) (Object, bool)
- func (i *Int) HashKey() HashKey
- func (i *Int) Inspect() string
- func (i *Int) Interface() interface{}
- func (i *Int) IsTruthy() bool
- func (i *Int) Iter() Iterator
- func (i *Int) MarshalJSON() ([]byte, error)
- func (i *Int) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Int) SetAttr(name string, value Object) error
- func (i *Int) String() string
- func (i *Int) Type() Type
- func (i *Int) Value() int64
- type Int16Converter
- type Int32Converter
- type Int64Converter
- type Int8Converter
- type IntConverter
- type IntIter
- func (b IntIter) Cost() int
- func (iter *IntIter) Entry() (IteratorEntry, bool)
- func (iter *IntIter) Equals(other Object) Object
- func (iter *IntIter) GetAttr(name string) (Object, bool)
- func (iter *IntIter) Inspect() string
- func (iter *IntIter) Interface() interface{}
- func (iter *IntIter) IsTruthy() bool
- func (iter *IntIter) MarshalJSON() ([]byte, error)
- func (iter *IntIter) Next(ctx context.Context) (Object, bool)
- func (iter *IntIter) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b IntIter) SetAttr(name string, value Object) error
- func (iter *IntIter) String() string
- func (iter *IntIter) Type() Type
- type Iterable
- type Iterator
- type IteratorEntry
- type List
- func (ls *List) Append(obj Object)
- func (ls *List) Clear()
- func (ls *List) Compare(other Object) (int, error)
- func (ls *List) Contains(item Object) *Bool
- func (ls *List) Copy() *List
- func (ls *List) Cost() int
- func (ls *List) Count(obj Object) int64
- func (ls *List) DelItem(key Object) *Error
- func (ls *List) Each(ctx context.Context, fn Object) Object
- func (ls *List) Equals(other Object) Object
- func (ls *List) Extend(other *List)
- func (ls *List) Filter(ctx context.Context, fn Object) Object
- func (ls *List) GetAttr(name string) (Object, bool)
- func (ls *List) GetItem(key Object) (Object, *Error)
- func (ls *List) GetSlice(s Slice) (Object, *Error)
- func (ls *List) Index(obj Object) int64
- func (ls *List) Insert(index int64, obj Object)
- func (ls *List) Inspect() string
- func (ls *List) Interface() interface{}
- func (ls *List) IsTruthy() bool
- func (ls *List) Iter() Iterator
- func (ls *List) Keys() Object
- func (ls *List) Len() *Int
- func (ls *List) Map(ctx context.Context, fn Object) Object
- func (ls *List) MarshalJSON() ([]byte, error)
- func (ls *List) Pop(index int64) Object
- func (ls *List) Remove(obj Object)
- func (ls *List) Reverse()
- func (ls *List) Reversed() *List
- func (ls *List) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b List) SetAttr(name string, value Object) error
- func (ls *List) SetItem(key, value Object) *Error
- func (ls *List) Size() int
- func (ls *List) String() string
- func (ls *List) Type() Type
- func (ls *List) Value() []Object
- type ListIter
- func (b ListIter) Cost() int
- func (iter *ListIter) Entry() (IteratorEntry, bool)
- func (iter *ListIter) Equals(other Object) Object
- func (iter *ListIter) GetAttr(name string) (Object, bool)
- func (iter *ListIter) Inspect() string
- func (iter *ListIter) Interface() interface{}
- func (iter *ListIter) IsTruthy() bool
- func (iter *ListIter) MarshalJSON() ([]byte, error)
- func (iter *ListIter) Next(ctx context.Context) (Object, bool)
- func (iter *ListIter) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b ListIter) SetAttr(name string, value Object) error
- func (iter *ListIter) String() string
- func (iter *ListIter) Type() Type
- type Map
- func (m *Map) Clear()
- func (m *Map) Contains(key Object) *Bool
- func (m *Map) Copy() *Map
- func (m *Map) Cost() int
- func (m *Map) DelItem(key Object) *Error
- func (m *Map) Delete(key string) Object
- func (m *Map) Equals(other Object) Object
- func (m *Map) Get(key string) Object
- func (m *Map) GetAttr(name string) (Object, bool)
- func (m *Map) GetItem(key Object) (Object, *Error)
- func (m *Map) GetSlice(s Slice) (Object, *Error)
- func (m *Map) GetWithDefault(key string, defaultValue Object) Object
- func (m *Map) GetWithObject(key *String) Object
- func (m *Map) Inspect() string
- func (m *Map) Interface() interface{}
- func (m *Map) IsTruthy() bool
- func (m *Map) Iter() Iterator
- func (m *Map) Keys() *List
- func (m *Map) Len() *Int
- func (m *Map) ListItems() *List
- func (m *Map) MarshalJSON() ([]byte, error)
- func (m *Map) Pop(key string, def Object) Object
- func (m *Map) RunOperation(opType op.BinaryOpType, right Object) Object
- func (m *Map) Set(key string, value Object)
- func (m *Map) SetAttr(name string, value Object) error
- func (m *Map) SetDefault(key string, value Object) Object
- func (m *Map) SetItem(key, value Object) *Error
- func (m *Map) Size() int
- func (m *Map) SortedKeys() []string
- func (m *Map) String() string
- func (m *Map) StringKeys() []string
- func (m *Map) Type() Type
- func (m *Map) Update(other *Map)
- func (m *Map) Value() map[string]Object
- func (m *Map) Values() *List
- type MapConverter
- type MapIter
- func (b MapIter) Cost() int
- func (iter *MapIter) Entry() (IteratorEntry, bool)
- func (iter *MapIter) Equals(other Object) Object
- func (iter *MapIter) GetAttr(name string) (Object, bool)
- func (iter *MapIter) Inspect() string
- func (iter *MapIter) Interface() interface{}
- func (iter *MapIter) IsTruthy() bool
- func (iter *MapIter) MarshalJSON() ([]byte, error)
- func (iter *MapIter) Next(ctx context.Context) (Object, bool)
- func (iter *MapIter) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b MapIter) SetAttr(name string, value Object) error
- func (iter *MapIter) String() string
- func (iter *MapIter) Type() Type
- type Module
- func (m *Module) Call(ctx context.Context, args ...Object) Object
- func (m *Module) Code() *compiler.Code
- func (m *Module) Compare(other Object) (int, error)
- func (b Module) Cost() int
- func (m *Module) Equals(other Object) Object
- func (m *Module) GetAttr(name string) (Object, bool)
- func (m *Module) Inspect() string
- func (m *Module) Interface() interface{}
- func (b Module) IsTruthy() bool
- func (m *Module) MarshalJSON() ([]byte, error)
- func (m *Module) Name() *String
- func (m *Module) Override(name string, value Object) error
- func (m *Module) RunOperation(opType op.BinaryOpType, right Object) Object
- func (m *Module) SetAttr(name string, value Object) error
- func (m *Module) String() string
- func (m *Module) Type() Type
- func (m *Module) UseGlobals(globals []Object)
- type NilType
- func (n *NilType) Compare(other Object) (int, error)
- func (b NilType) Cost() int
- func (n *NilType) Equals(other Object) Object
- func (b NilType) GetAttr(name string) (Object, bool)
- func (n *NilType) HashKey() HashKey
- func (n *NilType) Inspect() string
- func (n *NilType) Interface() interface{}
- func (n *NilType) IsTruthy() bool
- func (n *NilType) MarshalJSON() ([]byte, error)
- func (n *NilType) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b NilType) SetAttr(name string, value Object) error
- func (n *NilType) String() string
- func (n *NilType) Type() Type
- type Object
- type Partial
- func (p *Partial) Args() []Object
- func (b Partial) Cost() int
- func (p *Partial) Equals(other Object) Object
- func (p *Partial) Function() Object
- func (b Partial) GetAttr(name string) (Object, bool)
- func (p *Partial) Inspect() string
- func (p *Partial) Interface() interface{}
- func (b Partial) IsTruthy() bool
- func (p *Partial) MarshalJSON() ([]byte, error)
- func (p *Partial) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Partial) SetAttr(name string, value Object) error
- func (p *Partial) Type() Type
- type PointerConverter
- type Proxy
- func (b Proxy) Cost() int
- func (p *Proxy) Equals(other Object) Object
- func (p *Proxy) GetAttr(name string) (Object, bool)
- func (p *Proxy) GoType() *GoType
- func (p *Proxy) Inspect() string
- func (p *Proxy) Interface() interface{}
- func (b Proxy) IsTruthy() bool
- func (p *Proxy) MarshalJSON() ([]byte, error)
- func (p *Proxy) RunOperation(opType op.BinaryOpType, right Object) Object
- func (p *Proxy) SetAttr(name string, value Object) error
- func (p *Proxy) String() string
- func (p *Proxy) Type() Type
- type ResolveAttrFunc
- type RuneConverter
- type Set
- func (s *Set) Add(items ...Object) Object
- func (s *Set) Clear()
- func (s *Set) Contains(key Object) *Bool
- func (s *Set) Cost() int
- func (s *Set) DelItem(key Object) *Error
- func (s *Set) Difference(other *Set) *Set
- func (s *Set) Equals(other Object) Object
- func (s *Set) GetAttr(name string) (Object, bool)
- func (s *Set) GetItem(key Object) (Object, *Error)
- func (s *Set) GetSlice(slice Slice) (Object, *Error)
- func (s *Set) Inspect() string
- func (s *Set) Interface() interface{}
- func (s *Set) Intersection(other *Set) *Set
- func (s *Set) IsTruthy() bool
- func (s *Set) Iter() Iterator
- func (s *Set) Keys() []HashKey
- func (s *Set) Len() *Int
- func (s *Set) List() *List
- func (s *Set) MarshalJSON() ([]byte, error)
- func (s *Set) Remove(items ...Object) Object
- func (s *Set) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Set) SetAttr(name string, value Object) error
- func (s *Set) SetItem(key, value Object) *Error
- func (s *Set) Size() int
- func (s *Set) SortedItems() []Object
- func (s *Set) String() string
- func (s *Set) Type() Type
- func (s *Set) Union(other *Set) *Set
- func (s *Set) Value() map[HashKey]Object
- type SetIter
- func (b SetIter) Cost() int
- func (iter *SetIter) Entry() (IteratorEntry, bool)
- func (iter *SetIter) Equals(other Object) Object
- func (iter *SetIter) GetAttr(name string) (Object, bool)
- func (iter *SetIter) Inspect() string
- func (iter *SetIter) Interface() interface{}
- func (iter *SetIter) IsTruthy() bool
- func (iter *SetIter) MarshalJSON() ([]byte, error)
- func (iter *SetIter) Next(ctx context.Context) (Object, bool)
- func (iter *SetIter) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b SetIter) SetAttr(name string, value Object) error
- func (iter *SetIter) String() string
- func (iter *SetIter) Type() Type
- type Slice
- type SliceConverter
- type SliceIter
- func (b SliceIter) Cost() int
- func (iter *SliceIter) Entry() (IteratorEntry, bool)
- func (iter *SliceIter) Equals(other Object) Object
- func (iter *SliceIter) GetAttr(name string) (Object, bool)
- func (iter *SliceIter) Inspect() string
- func (iter *SliceIter) Interface() interface{}
- func (iter *SliceIter) IsTruthy() bool
- func (iter *SliceIter) MarshalJSON() ([]byte, error)
- func (iter *SliceIter) Next(ctx context.Context) (Object, bool)
- func (iter *SliceIter) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b SliceIter) SetAttr(name string, value Object) error
- func (iter *SliceIter) String() string
- func (iter *SliceIter) Type() Type
- type SpawnFunc
- type String
- func (s *String) Compare(other Object) (int, error)
- func (s *String) Contains(obj Object) *Bool
- func (s *String) Cost() int
- func (s *String) Count(obj Object) Object
- func (s *String) DelItem(key Object) *Error
- func (s *String) Equals(other Object) Object
- func (s *String) Fields() Object
- func (s *String) GetAttr(name string) (Object, bool)
- func (s *String) GetItem(key Object) (Object, *Error)
- func (s *String) GetSlice(slice Slice) (Object, *Error)
- func (s *String) HasPrefix(obj Object) Object
- func (s *String) HasSuffix(obj Object) Object
- func (s *String) HashKey() HashKey
- func (s *String) Index(obj Object) Object
- func (s *String) Inspect() string
- func (s *String) Interface() interface{}
- func (s *String) IsTruthy() bool
- func (s *String) Iter() Iterator
- func (s *String) Join(obj Object) Object
- func (s *String) LastIndex(obj Object) Object
- func (s *String) Len() *Int
- func (s *String) MarshalJSON() ([]byte, error)
- func (s *String) ReplaceAll(old, new Object) Object
- func (s *String) Reversed() *String
- func (s *String) RunOperation(opType op.BinaryOpType, right Object) Object
- func (s *String) Runes() []Object
- func (b String) SetAttr(name string, value Object) error
- func (s *String) SetItem(key, value Object) *Error
- func (s *String) Split(obj Object) Object
- func (s *String) String() string
- func (s *String) ToLower() Object
- func (s *String) ToUpper() Object
- func (s *String) Trim(obj Object) Object
- func (s *String) TrimPrefix(obj Object) Object
- func (s *String) TrimSpace() Object
- func (s *String) TrimSuffix(obj Object) Object
- func (s *String) Type() Type
- func (s *String) Value() string
- type StringConverter
- type StructConverter
- type Thread
- func (t *Thread) Cost() int
- func (t *Thread) Equals(other Object) Object
- func (t *Thread) GetAttr(name string) (Object, bool)
- func (t *Thread) Inspect() string
- func (t *Thread) Interface() interface{}
- func (t *Thread) IsTruthy() bool
- func (t *Thread) MarshalJSON() ([]byte, error)
- func (t *Thread) RunOperation(opType op.BinaryOpType, right Object) Object
- func (t *Thread) SetAttr(name string, value Object) error
- func (t *Thread) Type() Type
- func (t *Thread) Wait(ctx context.Context) Object
- type Time
- func (t *Time) After(ctx context.Context, args ...Object) Object
- func (t *Time) Before(ctx context.Context, args ...Object) Object
- func (t *Time) Compare(other Object) (int, error)
- func (b Time) Cost() int
- func (t *Time) Equals(other Object) Object
- func (t *Time) Format(ctx context.Context, args ...Object) Object
- func (t *Time) GetAttr(name string) (Object, bool)
- func (t *Time) Inspect() string
- func (t *Time) Interface() interface{}
- func (t *Time) IsTruthy() bool
- func (t *Time) MarshalJSON() ([]byte, error)
- func (t *Time) RunOperation(opType op.BinaryOpType, right Object) Object
- func (b Time) SetAttr(name string, value Object) error
- func (t *Time) String() string
- func (t *Time) Type() Type
- func (t *Time) UTC(ctx context.Context, args ...Object) Object
- func (t *Time) Unix(ctx context.Context, args ...Object) Object
- func (t *Time) Value() time.Time
- type TimeConverter
- type Type
- type TypeConverter
- type Uint16Converter
- type Uint32Converter
- type Uint64Converter
- type Uint8Converter
- type UintConverter
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AsIterator ¶ added in v0.10.0
func AsObjects ¶ added in v0.14.0
AsObjects transform a map containing arbitrary Go types to a map of Risor objects, using the best type converter for each type. If an item in the map is of a type that can't be converted, an error is returned.
func CompareTypes ¶
func IsProxyableType ¶
func NewArgumentsError
deprecated
func PrintableValue ¶ added in v1.7.0
func PrintableValue(obj Object) interface{}
PrintableValue returns a value that should be used when printing an object.
func ResolveIndex ¶
ResolveIndex checks that the index is inbounds and transforms a negative index into the corresponding positive index. If the index is out of bounds, an error is returned.
func ResolveIntSlice ¶
ResolveIntSlice checks that the slice start and stop indices are inbounds and transforms negative indices into the corresponding positive indices. If the slice is out of bounds, an error is returned.
func SetTypeConverter ¶
func SetTypeConverter(typ reflect.Type, conv TypeConverter)
SetTypeConverter sets a TypeConverter for the given Go type. This is not typically used, since the default converters should typically be sufficient.
func WithCallFunc ¶
WithCallFunc adds an CallFunc to the context, which can be used by objects to call a Risor function at runtime.
func WithCloneCallFunc ¶ added in v1.4.0
WithCloneCallFunc returns a context with a "clone-call" function associated. This function can be used to clone a Risor VM and then call a function on it synchronously.
Types ¶
type ArgumentsError
deprecated
type ArrayConverter ¶
type ArrayConverter struct {
// contains filtered or unexported fields
}
ArrayConverter converts between []T and the Risor equivalent of []T.
func (*ArrayConverter) From ¶
func (c *ArrayConverter) From(iface interface{}) (Object, error)
func (*ArrayConverter) To ¶
func (c *ArrayConverter) To(obj Object) (interface{}, error)
type AttrResolver ¶ added in v0.10.0
AttrResolver is an interface used to resolve dynamic attributes on an object.
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool wraps bool and implements Object and Hashable interface.
func (*Bool) MarshalJSON ¶
func (*Bool) RunOperation ¶
func (b *Bool) RunOperation(opType op.BinaryOpType, right Object) Object
type BoolConverter ¶
type BoolConverter struct{}
BoolConverter converts between bool and *Bool.
func (*BoolConverter) From ¶
func (c *BoolConverter) From(obj interface{}) (Object, error)
func (*BoolConverter) To ¶
func (c *BoolConverter) To(obj Object) (interface{}, error)
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func NewBufferFromBytes ¶
func (*Buffer) MarshalJSON ¶
func (*Buffer) RunOperation ¶
func (b *Buffer) RunOperation(opType op.BinaryOpType, right Object) Object
type BufferConverter ¶
type BufferConverter struct{}
BufferConverter converts between *bytes.Buffer and *Buffer.
func (*BufferConverter) From ¶
func (c *BufferConverter) From(obj interface{}) (Object, error)
func (*BufferConverter) To ¶
func (c *BufferConverter) To(obj Object) (interface{}, error)
type Builtin ¶
type Builtin struct {
// contains filtered or unexported fields
}
Builtin wraps func and implements Object interface.
func NewBuiltin ¶
func NewBuiltin(name string, fn BuiltinFunction, module ...*Module) *Builtin
func NewErrorHandler ¶
func NewErrorHandler(name string, fn BuiltinFunction, module ...*Module) *Builtin
func NewNoopBuiltin ¶
NewNoopBuiltin creates a builtin function that has no effect.
func (*Builtin) IsErrorHandler ¶
func (*Builtin) MarshalJSON ¶
func (*Builtin) RunOperation ¶
func (b *Builtin) RunOperation(opType op.BinaryOpType, right Object) Object
func (*Builtin) Value ¶
func (b *Builtin) Value() BuiltinFunction
type BuiltinFunction ¶
BuiltinFunction holds the type of a built-in function.
type Byte ¶
type Byte struct {
// contains filtered or unexported fields
}
Byte wraps byte and implements Object and Hashable interface.
func (*Byte) MarshalJSON ¶
func (*Byte) RunOperation ¶
func (b *Byte) RunOperation(opType op.BinaryOpType, right Object) Object
type ByteConverter ¶
type ByteConverter struct{}
ByteConverter converts between byte and *Byte.
func (*ByteConverter) From ¶
func (c *ByteConverter) From(obj interface{}) (Object, error)
func (*ByteConverter) To ¶
func (c *ByteConverter) To(obj Object) (interface{}, error)
type ByteSlice ¶
type ByteSlice struct {
// contains filtered or unexported fields
}
func NewByteSlice ¶
func (*ByteSlice) ContainsAny ¶
func (*ByteSlice) ContainsRune ¶
func (*ByteSlice) MarshalJSON ¶
func (*ByteSlice) ReplaceAll ¶
func (*ByteSlice) RunOperation ¶
func (b *ByteSlice) RunOperation(opType op.BinaryOpType, right Object) Object
type ByteSliceConverter ¶
type ByteSliceConverter struct{}
ByteSliceConverter converts between []byte and *ByteSlice.
func (*ByteSliceConverter) From ¶
func (c *ByteSliceConverter) From(obj interface{}) (Object, error)
func (*ByteSliceConverter) To ¶
func (c *ByteSliceConverter) To(obj Object) (interface{}, error)
type CallFunc ¶
CallFunc is a type signature for a function that can call a Risor function.
func GetCallFunc ¶
GetCallFunc returns the CallFunc from the context, if it exists.
type Callable ¶ added in v0.17.0
type Callable interface { // Call invokes the callable with the given arguments and returns the result. Call(ctx context.Context, args ...Object) Object }
Callable is an interface that exposes a Call method.
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
func (*Cell) MarshalJSON ¶
func (*Cell) RunOperation ¶
func (c *Cell) RunOperation(opType op.BinaryOpType, right Object) Object
type Chan ¶ added in v1.4.0
type Chan struct {
// contains filtered or unexported fields
}
func (*Chan) Entry ¶ added in v1.4.0
func (c *Chan) Entry() (IteratorEntry, bool)
func (*Chan) MarshalJSON ¶ added in v1.4.0
func (*Chan) RunOperation ¶ added in v1.4.0
func (c *Chan) RunOperation(opType op.BinaryOpType, right Object) Object
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
func (*Color) MarshalJSON ¶
func (*Color) RunOperation ¶
func (c *Color) RunOperation(opType op.BinaryOpType, right Object) Object
type Comparable ¶
Comparable is an interface used to compare two objects.
-1 if this < other 0 if this == other 1 if this > other
type Container ¶
type Container interface { Iterable // GetItem implements the [key] operator for a container type. GetItem(key Object) (Object, *Error) // GetSlice implements the [start:stop] operator for a container type. GetSlice(s Slice) (Object, *Error) // SetItem implements the [key] = value operator for a container type. SetItem(key, value Object) *Error // DelItem implements the del [key] operator for a container type. DelItem(key Object) *Error // Contains returns true if the given item is found in this container. Contains(item Object) *Bool // Len returns the number of items in this container. Len() *Int }
type ContextConverter ¶
type ContextConverter struct{}
ContextConverter converts between context.Context and Context.
func (*ContextConverter) From ¶
func (c *ContextConverter) From(obj interface{}) (Object, error)
func (*ContextConverter) To ¶
func (c *ContextConverter) To(obj Object) (interface{}, error)
type DirEntry ¶
type DirEntry struct {
// contains filtered or unexported fields
}
func (*DirEntry) MarshalJSON ¶
func (*DirEntry) RunOperation ¶
func (d *DirEntry) RunOperation(opType op.BinaryOpType, right Object) Object
type DynamicAttr ¶ added in v0.10.0
type DynamicAttr struct {
// contains filtered or unexported fields
}
DynamicAttr is an Object that represents an attribute that can be dynamically resolved to a concrete Object at runtime.
func NewDynamicAttr ¶ added in v0.10.0
func NewDynamicAttr(name string, fn ResolveAttrFunc) *DynamicAttr
func (*DynamicAttr) Cost ¶ added in v0.10.0
func (d *DynamicAttr) Cost() int
func (*DynamicAttr) Equals ¶ added in v0.10.0
func (d *DynamicAttr) Equals(other Object) Object
func (*DynamicAttr) GetAttr ¶ added in v0.10.0
func (d *DynamicAttr) GetAttr(name string) (Object, bool)
func (*DynamicAttr) Inspect ¶ added in v0.10.0
func (d *DynamicAttr) Inspect() string
func (*DynamicAttr) Interface ¶ added in v0.10.0
func (d *DynamicAttr) Interface() interface{}
func (*DynamicAttr) IsTruthy ¶ added in v0.10.0
func (d *DynamicAttr) IsTruthy() bool
func (*DynamicAttr) MarshalJSON ¶ added in v0.10.0
func (d *DynamicAttr) MarshalJSON() ([]byte, error)
func (*DynamicAttr) ResolveAttr ¶ added in v0.10.0
func (*DynamicAttr) RunOperation ¶ added in v0.10.0
func (d *DynamicAttr) RunOperation(opType op.BinaryOpType, right Object) Object
func (*DynamicAttr) SetAttr ¶ added in v0.10.0
func (d *DynamicAttr) SetAttr(name string, value Object) error
func (*DynamicAttr) String ¶ added in v0.10.0
func (d *DynamicAttr) String() string
func (*DynamicAttr) Type ¶ added in v0.10.0
func (d *DynamicAttr) Type() Type
type DynamicConverter ¶
type DynamicConverter struct{}
DynamicConverter converts between interface{} and the appropriate Risor type. This is slow and should only be used to handle unknown types.
func (*DynamicConverter) From ¶
func (c *DynamicConverter) From(obj interface{}) (Object, error)
func (*DynamicConverter) To ¶
func (c *DynamicConverter) To(obj Object) (interface{}, error)
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
func (*Entry) MarshalJSON ¶
func (*Entry) RunOperation ¶
func (e *Entry) RunOperation(opType op.BinaryOpType, right Object) Object
func (*Entry) WithKeyAsPrimary ¶
func (*Entry) WithValueAsPrimary ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error wraps a Go error interface and implements Object.
func ArgsErrorf ¶ added in v1.7.0
ArgsErrorf returns a Risor Error object containing an arguments error.
func AsStringSlice ¶ added in v1.1.0
func EvalErrorf ¶ added in v1.7.0
EvalErrorf returns a Risor Error object containing an eval error.
func NewArgsError ¶
func NewArgsRangeError ¶
func Sort ¶
Sort a list in place. If the list contains a non-comparable object, an error is returned.
func TypeErrorf ¶ added in v1.7.0
TypeErrorf returns a Risor Error object containing a type error.
func (*Error) MarshalJSON ¶
func (*Error) RunOperation ¶
func (e *Error) RunOperation(opType op.BinaryOpType, right Object) Object
func (*Error) WithRaised ¶ added in v1.7.0
type ErrorConverter ¶
type ErrorConverter struct{}
ErrorConverter converts between error and *Error or *String.
func (*ErrorConverter) From ¶
func (c *ErrorConverter) From(obj interface{}) (Object, error)
func (*ErrorConverter) To ¶
func (c *ErrorConverter) To(obj Object) (interface{}, error)
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) MarshalJSON ¶
func (*File) RunOperation ¶
func (f *File) RunOperation(opType op.BinaryOpType, right Object) Object
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
func NewFileInfo ¶
func (*FileInfo) MarshalJSON ¶
func (*FileInfo) RunOperation ¶
func (f *FileInfo) RunOperation(opType op.BinaryOpType, right Object) Object
type FileIter ¶ added in v0.10.0
type FileIter struct {
// contains filtered or unexported fields
}
func NewFileIter ¶ added in v0.10.0
func (*FileIter) Entry ¶ added in v0.10.0
func (iter *FileIter) Entry() (IteratorEntry, bool)
func (*FileIter) MarshalJSON ¶ added in v0.10.0
func (*FileIter) RunOperation ¶ added in v0.10.0
func (iter *FileIter) RunOperation(opType op.BinaryOpType, right Object) Object
type FileMode ¶
type FileMode struct {
// contains filtered or unexported fields
}
func NewFileMode ¶
func (*FileMode) MarshalJSON ¶
func (*FileMode) RunOperation ¶
func (m *FileMode) RunOperation(opType op.BinaryOpType, right Object) Object
type Float ¶
type Float struct {
// contains filtered or unexported fields
}
Float wraps float64 and implements Object and Hashable interfaces.
func (*Float) MarshalJSON ¶
func (*Float) RunOperation ¶
func (f *Float) RunOperation(opType op.BinaryOpType, right Object) Object
type Float32Converter ¶
type Float32Converter struct{}
Float32Converter converts between float32 and *Float.
func (*Float32Converter) From ¶
func (c *Float32Converter) From(obj interface{}) (Object, error)
func (*Float32Converter) To ¶
func (c *Float32Converter) To(obj Object) (interface{}, error)
type Float64Converter ¶
type Float64Converter struct{}
Float64Converter converts between float64 and *Float.
func (*Float64Converter) From ¶
func (c *Float64Converter) From(obj interface{}) (Object, error)
func (*Float64Converter) To ¶
func (c *Float64Converter) To(obj Object) (interface{}, error)
type FloatSlice ¶
type FloatSlice struct {
// contains filtered or unexported fields
}
func NewFloatSlice ¶
func NewFloatSlice(value []float64) *FloatSlice
func (*FloatSlice) Clone ¶
func (f *FloatSlice) Clone() *FloatSlice
func (*FloatSlice) Contains ¶
func (f *FloatSlice) Contains(item Object) *Bool
func (*FloatSlice) Cost ¶
func (f *FloatSlice) Cost() int
func (*FloatSlice) DelItem ¶
func (f *FloatSlice) DelItem(key Object) *Error
func (*FloatSlice) Equals ¶
func (f *FloatSlice) Equals(other Object) Object
func (*FloatSlice) Inspect ¶
func (f *FloatSlice) Inspect() string
func (*FloatSlice) Integers ¶
func (f *FloatSlice) Integers() []Object
func (*FloatSlice) Interface ¶
func (f *FloatSlice) Interface() interface{}
func (*FloatSlice) IsTruthy ¶
func (f *FloatSlice) IsTruthy() bool
func (*FloatSlice) Iter ¶
func (f *FloatSlice) Iter() Iterator
func (*FloatSlice) Len ¶
func (f *FloatSlice) Len() *Int
func (*FloatSlice) MarshalJSON ¶
func (f *FloatSlice) MarshalJSON() ([]byte, error)
func (*FloatSlice) RunOperation ¶
func (f *FloatSlice) RunOperation(opType op.BinaryOpType, right Object) Object
func (*FloatSlice) SetItem ¶
func (f *FloatSlice) SetItem(key, value Object) *Error
func (*FloatSlice) String ¶
func (f *FloatSlice) String() string
func (*FloatSlice) Type ¶
func (f *FloatSlice) Type() Type
func (*FloatSlice) Value ¶
func (f *FloatSlice) Value() []float64
type FloatSliceConverter ¶
type FloatSliceConverter struct{}
FloatSliceConverter converts between []float64 and *FloatSlice.
func (*FloatSliceConverter) From ¶
func (c *FloatSliceConverter) From(obj interface{}) (Object, error)
func (*FloatSliceConverter) To ¶
func (c *FloatSliceConverter) To(obj Object) (interface{}, error)
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function is a function that has been compiled to bytecode.
func NewClosure ¶
func NewFunction ¶
func (*Function) Instructions ¶
func (*Function) LocalsCount ¶
func (*Function) MarshalJSON ¶
func (*Function) Parameters ¶
func (*Function) RequiredArgsCount ¶
func (*Function) RunOperation ¶
func (f *Function) RunOperation(opType op.BinaryOpType, right Object) Object
type FunctionOpts ¶
type GoAttribute ¶
type GoAttribute interface { // Name of the attribute. Name() string }
GoAttribute is an interface to represent an attribute on a Go type. This could be either a field or a method.
type GoField ¶
type GoField struct {
// contains filtered or unexported fields
}
GoField represents a single field on a Go type that can be read or written.
func (*GoField) Converter ¶
func (f *GoField) Converter() (TypeConverter, bool)
func (*GoField) MarshalJSON ¶
func (*GoField) ReflectType ¶
func (*GoField) RunOperation ¶
func (f *GoField) RunOperation(opType op.BinaryOpType, right Object) Object
type GoMethod ¶
type GoMethod struct {
// contains filtered or unexported fields
}
GoMethod represents a single method on a Go type. This exposes the method to Risor for reflection and proxying.
func (*GoMethod) ErrorIndices ¶
func (*GoMethod) HasPointerReceiver ¶ added in v0.13.0
func (*GoMethod) IsOutputError ¶
func (*GoMethod) MarshalJSON ¶
func (*GoMethod) ProducesError ¶
func (*GoMethod) RunOperation ¶
func (m *GoMethod) RunOperation(opType op.BinaryOpType, right Object) Object
type GoType ¶
type GoType struct {
// contains filtered or unexported fields
}
GoType wraps a single native Go type to make it easier to work with in Risor and also to be able to represent the type as a Risor object.
func NewGoType ¶
NewGoType registers and returns a Risor GoType for the type of the given native Go object. This is safe for concurrent use by multiple goroutines. A type registry is maintained behind the scenes to ensure that each type is only registered once.
func (*GoType) AttributeNames ¶
func (*GoType) GetAttribute ¶
func (t *GoType) GetAttribute(name string) (GoAttribute, bool)
func (*GoType) GetConverter ¶ added in v0.13.0
func (t *GoType) GetConverter() (TypeConverter, error)
func (*GoType) HasDirectMethod ¶ added in v0.13.0
func (*GoType) IndirectType ¶
func (*GoType) IsPointerType ¶ added in v0.13.0
func (*GoType) MarshalJSON ¶
func (*GoType) PackagePath ¶
func (*GoType) PointerType ¶ added in v0.13.0
func (*GoType) ReflectType ¶
func (*GoType) RunOperation ¶
func (t *GoType) RunOperation(opType op.BinaryOpType, right Object) Object
type HashKey ¶
type HashKey struct { // Type of the object being referenced. Type Type // FltValue is used as the key for floats. FltValue float64 // IntValue is used as the key for integers. IntValue int64 // StrValue is used as the key for strings. StrValue string }
HashKey is used to identify unique values in a set.
type Hashable ¶
type Hashable interface { // Hash returns a hash key for the given object. HashKey() HashKey }
Hashable types can be hashed and consequently used in a set.
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int wraps int64 and implements Object and Hashable interfaces.
func (*Int) MarshalJSON ¶
func (*Int) RunOperation ¶
func (i *Int) RunOperation(opType op.BinaryOpType, right Object) Object
type Int16Converter ¶
type Int16Converter struct{}
Int16Converter converts between int16 and *Int.
func (*Int16Converter) From ¶
func (c *Int16Converter) From(obj interface{}) (Object, error)
func (*Int16Converter) To ¶
func (c *Int16Converter) To(obj Object) (interface{}, error)
type Int32Converter ¶
type Int32Converter struct{}
Int32Converter converts between int32 and *Int.
func (*Int32Converter) From ¶
func (c *Int32Converter) From(obj interface{}) (Object, error)
func (*Int32Converter) To ¶
func (c *Int32Converter) To(obj Object) (interface{}, error)
type Int64Converter ¶
type Int64Converter struct{}
Int64Converter converts between int64 and *Int.
func (*Int64Converter) From ¶
func (c *Int64Converter) From(obj interface{}) (Object, error)
func (*Int64Converter) To ¶
func (c *Int64Converter) To(obj Object) (interface{}, error)
type Int8Converter ¶
type Int8Converter struct{}
Int8Converter converts between int8 and *Int.
func (*Int8Converter) From ¶
func (c *Int8Converter) From(obj interface{}) (Object, error)
func (*Int8Converter) To ¶
func (c *Int8Converter) To(obj Object) (interface{}, error)
type IntConverter ¶
type IntConverter struct{}
IntConverter converts between int and *Int.
func (*IntConverter) From ¶
func (c *IntConverter) From(obj interface{}) (Object, error)
func (*IntConverter) To ¶
func (c *IntConverter) To(obj Object) (interface{}, error)
type IntIter ¶ added in v1.4.0
type IntIter struct {
// contains filtered or unexported fields
}
func NewIntIter ¶ added in v1.4.0
func (*IntIter) Entry ¶ added in v1.4.0
func (iter *IntIter) Entry() (IteratorEntry, bool)
func (*IntIter) MarshalJSON ¶ added in v1.4.0
func (*IntIter) RunOperation ¶ added in v1.4.0
func (iter *IntIter) RunOperation(opType op.BinaryOpType, right Object) Object
type Iterable ¶ added in v0.10.0
type Iterable interface {
Iter() Iterator
}
Iterable is an interface that exposes an iterator for an Object.
type Iterator ¶
type Iterator interface { Object // Next advances the iterator and then returns the current object and a // bool indicating whether the returned item is valid. Once Next() has been // called, the Entry() method can be used to get an IteratorEntry. Next(context.Context) (Object, bool) // Entry returns the current entry in the iterator and a bool indicating // whether the returned item is valid. Entry() (IteratorEntry, bool) }
Iterator is an interface used to iterate over a container.
type IteratorEntry ¶
IteratorEntry is a single item returned by an iterator.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List of objects
func NewStringList ¶
func (*List) MarshalJSON ¶
func (*List) RunOperation ¶
func (ls *List) RunOperation(opType op.BinaryOpType, right Object) Object
type ListIter ¶
type ListIter struct {
// contains filtered or unexported fields
}
func NewListIter ¶
func (*ListIter) Entry ¶
func (iter *ListIter) Entry() (IteratorEntry, bool)
func (*ListIter) MarshalJSON ¶
func (*ListIter) RunOperation ¶
func (iter *ListIter) RunOperation(opType op.BinaryOpType, right Object) Object
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func (*Map) GetWithObject ¶
func (*Map) MarshalJSON ¶
func (*Map) RunOperation ¶
func (m *Map) RunOperation(opType op.BinaryOpType, right Object) Object
func (*Map) SortedKeys ¶
func (*Map) StringKeys ¶
type MapConverter ¶
type MapConverter struct {
// contains filtered or unexported fields
}
MapConverter converts between map[string]interface{} and *Map.
func (*MapConverter) From ¶
func (c *MapConverter) From(obj interface{}) (Object, error)
func (*MapConverter) To ¶
func (c *MapConverter) To(obj Object) (interface{}, error)
type MapIter ¶
type MapIter struct {
// contains filtered or unexported fields
}
func NewMapIter ¶
func (*MapIter) Entry ¶
func (iter *MapIter) Entry() (IteratorEntry, bool)
func (*MapIter) MarshalJSON ¶
func (*MapIter) RunOperation ¶
func (iter *MapIter) RunOperation(opType op.BinaryOpType, right Object) Object
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func NewBuiltinsModule ¶
func NewBuiltinsModule(name string, contents map[string]Object, callableOption ...BuiltinFunction) *Module
func (*Module) MarshalJSON ¶
func (*Module) Override ¶ added in v1.3.0
Override provides a mechanism to modify module attributes after loading. Whether or not this is exposed to Risor scripts changes the security posture of reusing modules. By default, this is not exposed to scripting. Overriding with a value of nil is equivalent to deleting the attribute.
func (*Module) RunOperation ¶
func (m *Module) RunOperation(opType op.BinaryOpType, right Object) Object
func (*Module) UseGlobals ¶ added in v0.15.0
type NilType ¶
type NilType struct {
// contains filtered or unexported fields
}
func (*NilType) MarshalJSON ¶
func (*NilType) RunOperation ¶
func (n *NilType) RunOperation(opType op.BinaryOpType, right Object) Object
type Object ¶
type Object interface { // Type of the object. Type() Type // Inspect returns a string representation of the given object. Inspect() string // Interface converts the given object to a native Go value. Interface() interface{} // Returns True if the given object is equal to this object. Equals(other Object) Object // GetAttr returns the attribute with the given name from this object. GetAttr(name string) (Object, bool) // SetAttr sets the attribute with the given name on this object. SetAttr(name string, value Object) error // IsTruthy returns true if the object is considered "truthy". IsTruthy() bool // RunOperation runs an operation on this object with the given // right-hand side object. RunOperation(opType op.BinaryOpType, right Object) Object // Cost returns the incremental processing cost of this object. Cost() int }
Object is the interface that all object types in Risor must implement.
func BinaryOp ¶
func BinaryOp(opType op.BinaryOpType, a, b Object) (Object, error)
BinaryOp performs a binary operation on two objects, given an operator.
func Compare ¶
func Compare(opType op.CompareOpType, a, b Object) (Object, error)
Compare two objects using the given comparison operator. An Error object is returned if either of the objects is not comparable.
func FromGoType ¶
func FromGoType(obj interface{}) Object
type Partial ¶
type Partial struct {
// contains filtered or unexported fields
}
Partial is a partially applied function
func NewPartial ¶
func (*Partial) MarshalJSON ¶
func (*Partial) RunOperation ¶
func (p *Partial) RunOperation(opType op.BinaryOpType, right Object) Object
type PointerConverter ¶
type PointerConverter struct {
// contains filtered or unexported fields
}
PointerConverter converts between *T and the Risor equivalent of T.
func (*PointerConverter) From ¶
func (c *PointerConverter) From(obj interface{}) (Object, error)
func (*PointerConverter) To ¶
func (c *PointerConverter) To(obj Object) (interface{}, error)
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a Risor type that proxies method calls to a wrapped Go struct. Only the public methods of the Go type are proxied.
func NewProxy ¶
NewProxy returns a new Risor proxy object that wraps the given Go This operation may fail if the Go type has attributes whose types cannot be converted to Risor types.
func (*Proxy) MarshalJSON ¶
func (*Proxy) RunOperation ¶
func (p *Proxy) RunOperation(opType op.BinaryOpType, right Object) Object
type ResolveAttrFunc ¶ added in v0.10.0
type RuneConverter ¶
type RuneConverter struct{}
RuneConverter converts between rune and *String.
func (*RuneConverter) From ¶
func (c *RuneConverter) From(obj interface{}) (Object, error)
func (*RuneConverter) To ¶
func (c *RuneConverter) To(obj Object) (interface{}, error)
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func NewSetWithSize ¶
func (*Set) Difference ¶
Difference returns a new set that is the difference of the two sets.
func (*Set) Intersection ¶
Intersection returns a new set that is the intersection of the two sets.
func (*Set) MarshalJSON ¶
func (*Set) RunOperation ¶
func (s *Set) RunOperation(opType op.BinaryOpType, right Object) Object
func (*Set) SortedItems ¶
type SetIter ¶
type SetIter struct {
// contains filtered or unexported fields
}
func NewSetIter ¶
func (*SetIter) Entry ¶
func (iter *SetIter) Entry() (IteratorEntry, bool)
func (*SetIter) MarshalJSON ¶
func (*SetIter) RunOperation ¶
func (iter *SetIter) RunOperation(opType op.BinaryOpType, right Object) Object
type SliceConverter ¶
type SliceConverter struct {
// contains filtered or unexported fields
}
SliceConverter converts between []T and the Risor equivalent of []T.
func (*SliceConverter) From ¶
func (c *SliceConverter) From(iface interface{}) (Object, error)
func (*SliceConverter) To ¶
func (c *SliceConverter) To(obj Object) (interface{}, error)
type SliceIter ¶
type SliceIter struct {
// contains filtered or unexported fields
}
func NewSliceIter ¶
func (*SliceIter) Entry ¶
func (iter *SliceIter) Entry() (IteratorEntry, bool)
func (*SliceIter) MarshalJSON ¶
func (*SliceIter) RunOperation ¶
func (iter *SliceIter) RunOperation(opType op.BinaryOpType, right Object) Object
type SpawnFunc ¶ added in v1.4.0
SpawnFunc is a type signature for a function that can spawn a Risor thread.
type String ¶
type String struct {
// contains filtered or unexported fields
}
func (*String) MarshalJSON ¶
func (*String) ReplaceAll ¶
func (*String) RunOperation ¶
func (s *String) RunOperation(opType op.BinaryOpType, right Object) Object
func (*String) TrimPrefix ¶
func (*String) TrimSuffix ¶
type StringConverter ¶
type StringConverter struct{}
StringConverter converts between string and *String.
func (*StringConverter) From ¶
func (c *StringConverter) From(obj interface{}) (Object, error)
func (*StringConverter) To ¶
func (c *StringConverter) To(obj Object) (interface{}, error)
type StructConverter ¶
type StructConverter struct {
// contains filtered or unexported fields
}
StructConverter converts between a Go struct and a Risor Proxy. Works with structs as values or pointers.
func (*StructConverter) From ¶
func (c *StructConverter) From(obj interface{}) (Object, error)
func (*StructConverter) To ¶
func (c *StructConverter) To(obj Object) (interface{}, error)
type Thread ¶ added in v1.4.0
type Thread struct {
// contains filtered or unexported fields
}
func (*Thread) MarshalJSON ¶ added in v1.4.0
func (*Thread) RunOperation ¶ added in v1.4.0
func (t *Thread) RunOperation(opType op.BinaryOpType, right Object) Object
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
func (*Time) MarshalJSON ¶
func (*Time) RunOperation ¶
func (t *Time) RunOperation(opType op.BinaryOpType, right Object) Object
type TimeConverter ¶
type TimeConverter struct{}
TimeConverter converts between time.Time and *Time.
func (*TimeConverter) From ¶
func (c *TimeConverter) From(obj interface{}) (Object, error)
func (*TimeConverter) To ¶
func (c *TimeConverter) To(obj Object) (interface{}, error)
type Type ¶
type Type string
Type of an object as a string.
const ( BOOL Type = "bool" BUFFER Type = "buffer" BUILTIN Type = "builtin" BYTE Type = "byte" BYTE_SLICE Type = "byte_slice" CELL Type = "cell" CHANNEL Type = "channel" COLOR Type = "color" COMPLEX Type = "complex" COMPLEX_SLICE Type = "complex_slice" DIR_ENTRY Type = "dir_entry" DYNAMIC_ATTR Type = "dynamic_attr" ERROR Type = "error" FILE Type = "file" FILE_INFO Type = "file_info" FILE_ITER Type = "file_iter" FILE_MODE Type = "file_mode" FLOAT Type = "float" FLOAT_SLICE Type = "float_slice" FUNCTION Type = "function" GO_FIELD Type = "go_field" GO_METHOD Type = "go_method" GO_TYPE Type = "go_type" INT Type = "int" INT_ITER Type = "int_iter" ITER_ENTRY Type = "iter_entry" LIST Type = "list" LIST_ITER Type = "list_iter" MAP Type = "map" MAP_ITER Type = "map_iter" MODULE Type = "module" NIL Type = "nil" PARTIAL Type = "partial" PROXY Type = "proxy" RESULT Type = "result" SET Type = "set" SET_ITER Type = "set_iter" SLICE_ITER Type = "slice_iter" STRING Type = "string" STRING_ITER Type = "string_iter" THREAD Type = "thread" TIME Type = "time" )
Type constants
type TypeConverter ¶
type TypeConverter interface { // To converts to a Go object from a Risor object. To(Object) (interface{}, error) // From converts a Go object to a Risor object. From(interface{}) (Object, error) }
TypeConverter is an interface used to convert between Go and Risor objects for a single Go type.
func NewTypeConverter ¶
func NewTypeConverter(typ reflect.Type) (TypeConverter, error)
NewTypeConverter returns a TypeConverter for the given Go kind and type. Converters are cached internally for reuse.
type Uint16Converter ¶
type Uint16Converter struct{}
Uint16Converter converts between uint16 and *Int.
func (*Uint16Converter) From ¶
func (c *Uint16Converter) From(obj interface{}) (Object, error)
func (*Uint16Converter) To ¶
func (c *Uint16Converter) To(obj Object) (interface{}, error)
type Uint32Converter ¶
type Uint32Converter struct{}
Uint32Converter converts between uint32 and *Int.
func (*Uint32Converter) From ¶
func (c *Uint32Converter) From(obj interface{}) (Object, error)
func (*Uint32Converter) To ¶
func (c *Uint32Converter) To(obj Object) (interface{}, error)
type Uint64Converter ¶
type Uint64Converter struct{}
Uint64Converter converts between uint64 and *Int.
func (*Uint64Converter) From ¶
func (c *Uint64Converter) From(obj interface{}) (Object, error)
func (*Uint64Converter) To ¶
func (c *Uint64Converter) To(obj Object) (interface{}, error)
type Uint8Converter ¶
type Uint8Converter struct{}
Uint8Converter converts between uint8 and *Int.
func (*Uint8Converter) From ¶
func (c *Uint8Converter) From(obj interface{}) (Object, error)
func (*Uint8Converter) To ¶
func (c *Uint8Converter) To(obj Object) (interface{}, error)
type UintConverter ¶
type UintConverter struct{}
UintConverter converts between uint and *Int.
func (*UintConverter) From ¶
func (c *UintConverter) From(obj interface{}) (Object, error)
func (*UintConverter) To ¶
func (c *UintConverter) To(obj Object) (interface{}, error)
Source Files ¶
- base.go
- bool.go
- buffer.go
- builtin.go
- byte.go
- byte_slice.go
- cell.go
- chan.go
- color.go
- context_values.go
- dir_entry.go
- dynamic_attr.go
- error.go
- errors.go
- file.go
- file_info.go
- file_iter.go
- file_mode.go
- float.go
- float_slice.go
- function.go
- go_field.go
- go_method.go
- go_type.go
- int.go
- int_iter.go
- iter_entry.go
- list.go
- list_iter.go
- map.go
- map_iter.go
- module.go
- nil.go
- object.go
- operations.go
- partial.go
- proxy.go
- set.go
- set_iter.go
- slice_iter.go
- sort.go
- spawn.go
- string.go
- thread.go
- time.go
- typeconv.go