object

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package object defines all available object types in Tamarin.

For external users of Tamarin, most 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

Constants

View Source
const (
	INTEGER_OBJ       = "INTEGER"
	FLOAT_OBJ         = "FLOAT"
	BOOLEAN_OBJ       = "BOOLEAN"
	NULL_OBJ          = "NULL"
	RETURN_VALUE_OBJ  = "RETURN_VALUE"
	BREAK_VALUE_OBJ   = "BREAK_VALUE"
	ERROR_OBJ         = "ERROR"
	FUNCTION_OBJ      = "FUNCTION"
	STRING_OBJ        = "STRING"
	BUILTIN_OBJ       = "BUILTIN"
	ARRAY_OBJ         = "ARRAY"
	HASH_OBJ          = "HASH"
	FILE_OBJ          = "FILE"
	REGEXP_OBJ        = "REGEXP"
	SET_OBJ           = "SET"
	MODULE_OBJ        = "MODULE"
	RESULT_OBJ        = "RESULT"
	HTTP_RESPONSE_OBJ = "HTTP_RESPONSE"
	DB_CONNECTION_OBJ = "DB_CONNECTION"
	TIME_OBJ          = "TIME"
	PROXY_OBJ         = "PROXY"
)

Type constants

Variables

View Source
var (
	NULL  = &Null{}
	TRUE  = &Boolean{Value: true}
	FALSE = &Boolean{Value: false}
)

Functions

func AsArray added in v0.0.4

func AsArray(obj Object) (*Array, *Error)

func AsHash added in v0.0.9

func AsHash(obj Object) (*Hash, *Error)

func AsSet added in v0.0.9

func AsSet(obj Object) (*Set, *Error)

func CompareTypes added in v0.0.9

func CompareTypes(a, b Object) int

func IsError

func IsError(obj Object) bool

func ToGoType

func ToGoType(obj Object) interface{}

Types

type Array

type Array struct {
	// Elements holds the individual members of the array we're wrapping.
	Elements []Object
}

Array wraps Object array and implements Object interface.

func NewStringArray added in v0.0.4

func NewStringArray(s []string) *Array

func (*Array) Compare added in v0.0.9

func (ao *Array) Compare(other Object) (int, error)

func (*Array) Inspect

func (ao *Array) Inspect() string

Inspect returns a string-representation of the given object.

func (*Array) InvokeMethod

func (ao *Array) InvokeMethod(method string, args ...Object) Object

InvokeMethod invokes a method against the object. (Built-in methods only.)

func (*Array) Reversed added in v0.0.9

func (ao *Array) Reversed() *Array

func (*Array) String

func (ao *Array) String() string

func (*Array) ToInterface

func (ao *Array) ToInterface() interface{}

func (*Array) Type

func (ao *Array) Type() Type

Type returns the type of this object.

type Boolean

type Boolean struct {
	// Value holds the boolean value we wrap.
	Value bool
}

Boolean wraps bool and implements Object and Hashable interface.

func NewBoolean added in v0.0.4

func NewBoolean(value bool) *Boolean

func (*Boolean) Compare added in v0.0.9

func (b *Boolean) Compare(other Object) (int, error)

func (*Boolean) HashKey

func (b *Boolean) HashKey() Key

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) InvokeMethod

func (b *Boolean) InvokeMethod(method string, args ...Object) Object

func (*Boolean) String

func (b *Boolean) String() string

func (*Boolean) ToInterface

func (b *Boolean) ToInterface() interface{}

func (*Boolean) Type

func (b *Boolean) Type() Type

type BooleanConverter added in v0.0.9

type BooleanConverter struct{}

BooleanConverter converts between bool and Boolean.

func (*BooleanConverter) From added in v0.0.9

func (c *BooleanConverter) From(obj interface{}) (Object, error)

func (*BooleanConverter) To added in v0.0.9

func (c *BooleanConverter) To(obj Object) (interface{}, error)

func (*BooleanConverter) Type added in v0.0.9

func (c *BooleanConverter) Type() reflect.Type

type BreakValue added in v0.0.6

type BreakValue struct{}

BreakValue is an implementation detail used to handle break statements

func (*BreakValue) Inspect added in v0.0.6

func (rv *BreakValue) Inspect() string

func (*BreakValue) InvokeMethod added in v0.0.6

func (rv *BreakValue) InvokeMethod(method string, args ...Object) Object

func (*BreakValue) ToInterface added in v0.0.6

func (rv *BreakValue) ToInterface() interface{}

func (*BreakValue) Type added in v0.0.6

func (rv *BreakValue) Type() Type

type Builtin

type Builtin struct {
	// The function that this object wraps.
	Fn BuiltinFunction

	// The name of the function.
	Name string

	// The module the function originates from (optional)
	Module *Module

	// The name of the module this function origiantes from.
	// This is only used for overriding builtins.
	ModuleName string
}

Builtin wraps func and implements Object interface.

func NewNoopBuiltin added in v0.0.6

func NewNoopBuiltin(Name string, Module *Module) *Builtin

NewNoopBuiltin creates a builtin function that has no effect.

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

Inspect returns a string-representation of the given object.

func (*Builtin) InvokeMethod

func (b *Builtin) InvokeMethod(method string, args ...Object) Object

InvokeMethod invokes a method against the object. (Built-in methods only.)

func (*Builtin) Key added in v0.0.6

func (b *Builtin) Key() string

Returns a string that uniquely identifies this builtin function.

func (*Builtin) String added in v0.0.6

func (b *Builtin) String() string

func (*Builtin) ToInterface

func (b *Builtin) ToInterface() interface{}

ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.

It might also be helpful for embedded users.

func (*Builtin) Type

func (b *Builtin) Type() Type

Type returns the type of this object.

type BuiltinFunction

type BuiltinFunction func(ctx context.Context, args ...Object) Object

BuiltinFunction holds the type of a built-in function.

type Comparable added in v0.0.9

type Comparable interface {
	Compare(other Object) (int, error)
}

Comparable is an interface used to compare two objects.

-1 if this < other
 0 if this == other
 1 if this > other

type DatabaseConnection

type DatabaseConnection struct {
	Conn interface{}
}

func (*DatabaseConnection) Inspect

func (c *DatabaseConnection) Inspect() string

func (*DatabaseConnection) InvokeMethod

func (c *DatabaseConnection) InvokeMethod(method string, args ...Object) Object

func (*DatabaseConnection) ToInterface

func (c *DatabaseConnection) ToInterface() interface{}

func (*DatabaseConnection) Type

func (c *DatabaseConnection) Type() Type

type DefaultProxyManager added in v0.0.9

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

DefaultProxyManager implements the ProxyManager interface.

func NewProxyManager added in v0.0.9

func NewProxyManager(opts ProxyManagerOpts) (*DefaultProxyManager, error)

NewProxyManager creates a ProxyManager that can be used to proxy method calls to various struct types. The provided type conversion functions are used to translate between Go and Tamarin types.

func (*DefaultProxyManager) Call added in v0.0.9

func (p *DefaultProxyManager) Call(obj interface{}, method string, args ...Object) Object

func (*DefaultProxyManager) GetType added in v0.0.9

func (p *DefaultProxyManager) GetType(obj interface{}) (*ProxyType, bool)

func (*DefaultProxyManager) HasType added in v0.0.9

func (p *DefaultProxyManager) HasType(obj interface{}) bool

func (*DefaultProxyManager) RegisterType added in v0.0.9

func (p *DefaultProxyManager) RegisterType(obj interface{}) (*ProxyType, error)

type Error

type Error struct {
	// Message contains the error-message we're wrapping
	Message string
}

Error wraps string and implements Object interface.

func AsFloat added in v0.0.4

func AsFloat(obj Object) (float64, *Error)

func AsInteger added in v0.0.4

func AsInteger(obj Object) (int64, *Error)

func AsString added in v0.0.4

func AsString(obj Object) (result string, err *Error)

func AsTime added in v0.0.4

func AsTime(obj Object) (result time.Time, err *Error)

func NewError

func NewError(format string, a ...interface{}) *Error

func (*Error) Compare added in v0.0.9

func (e *Error) Compare(other Object) (int, error)

func (*Error) Inspect

func (e *Error) Inspect() string

Inspect returns a string-representation of the given object.

func (*Error) InvokeMethod

func (e *Error) InvokeMethod(method string, args ...Object) Object

InvokeMethod invokes a method against the object. (Built-in methods only.)

func (*Error) ToInterface

func (e *Error) ToInterface() interface{}

ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.

It might also be helpful for embedded users.

func (*Error) Type

func (e *Error) Type() Type

Type returns the type of this object.

type ErrorConverter added in v0.0.9

type ErrorConverter struct{}

func (*ErrorConverter) From added in v0.0.9

func (c *ErrorConverter) From(obj interface{}) (Object, error)

func (*ErrorConverter) To added in v0.0.9

func (c *ErrorConverter) To(obj Object) (interface{}, error)

func (*ErrorConverter) Type added in v0.0.9

func (c *ErrorConverter) Type() reflect.Type

type Float

type Float struct {
	// Value holds the float64 wrapped by this object.
	Value float64
}

Float wraps float64 and implements Object and Hashable interfaces.

func NewFloat added in v0.0.4

func NewFloat(value float64) *Float

func (*Float) Compare added in v0.0.9

func (f *Float) Compare(other Object) (int, error)

func (*Float) HashKey

func (f *Float) HashKey() Key

func (*Float) Inspect

func (f *Float) Inspect() string

func (*Float) InvokeMethod

func (f *Float) InvokeMethod(method string, args ...Object) Object

func (*Float) String

func (f *Float) String() string

func (*Float) ToInterface

func (f *Float) ToInterface() interface{}

func (*Float) Type

func (f *Float) Type() Type

type Float32Converter added in v0.0.9

type Float32Converter struct{}

Float32Converter converts between float32 and Float.

func (*Float32Converter) From added in v0.0.9

func (c *Float32Converter) From(obj interface{}) (Object, error)

func (*Float32Converter) To added in v0.0.9

func (c *Float32Converter) To(obj Object) (interface{}, error)

func (*Float32Converter) Type added in v0.0.9

func (c *Float32Converter) Type() reflect.Type

type Float64Converter added in v0.0.9

type Float64Converter struct{}

Float64Converter converts between float64 and Float.

func (*Float64Converter) From added in v0.0.9

func (c *Float64Converter) From(obj interface{}) (Object, error)

func (*Float64Converter) To added in v0.0.9

func (c *Float64Converter) To(obj Object) (interface{}, error)

func (*Float64Converter) Type added in v0.0.9

func (c *Float64Converter) Type() reflect.Type

type Function

type Function struct {
	Parameters []*ast.Identifier
	Body       *ast.BlockStatement
	Defaults   map[string]ast.Expression
	Scope      interface{} // avoids circular package dependency; is a scope.Scope
}

Function wraps ast.Identifier array and ast.BlockStatement and implements Object interface.

func (*Function) Inspect

func (f *Function) Inspect() string

Inspect returns a string-representation of the given object.

func (*Function) InvokeMethod

func (f *Function) InvokeMethod(method string, args ...Object) Object

InvokeMethod invokes a method against the object. (Built-in methods only.)

func (*Function) ToInterface

func (f *Function) ToInterface() interface{}

ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.

It might also be helpful for embedded users.

func (*Function) Type

func (f *Function) Type() Type

Type returns the type of this object.

type Hash

type Hash struct {
	Map map[string]Object
}

func NewHash added in v0.0.9

func NewHash(m map[string]interface{}) *Hash

func (*Hash) Delete added in v0.0.9

func (h *Hash) Delete(key string) Object

func (*Hash) Get

func (h *Hash) Get(key string) Object

func (*Hash) GetWithObject

func (h *Hash) GetWithObject(key *String) Object

func (*Hash) Inspect

func (h *Hash) Inspect() string

func (*Hash) InvokeMethod

func (h *Hash) InvokeMethod(method string, args ...Object) Object

func (*Hash) Keys added in v0.0.9

func (h *Hash) Keys() *Array

func (*Hash) Set added in v0.0.9

func (h *Hash) Set(key string, value Object)

func (*Hash) Size added in v0.0.9

func (h *Hash) Size() int

func (*Hash) ToInterface

func (h *Hash) ToInterface() interface{}

func (*Hash) Type

func (h *Hash) Type() Type

func (*Hash) Values added in v0.0.9

func (h *Hash) Values() *Array

type Hashable

type Hashable interface {

	// HashKey returns a hash key for the given object.
	HashKey() Key
}

Hashable types can be hashed and consequently used in a set.

type HttpResponse

type HttpResponse struct {
	Response *http.Response
}

func (*HttpResponse) Inspect

func (r *HttpResponse) Inspect() string

func (*HttpResponse) InvokeMethod

func (r *HttpResponse) InvokeMethod(method string, args ...Object) Object

func (*HttpResponse) JSON

func (r *HttpResponse) JSON() (target interface{}, err error)

func (*HttpResponse) Text

func (r *HttpResponse) Text() (string, error)

func (*HttpResponse) ToInterface

func (r *HttpResponse) ToInterface() interface{}

func (*HttpResponse) Type

func (r *HttpResponse) Type() Type

type Int64Converter added in v0.0.9

type Int64Converter struct{}

Int64Converter converts between int64 and Integer.

func (*Int64Converter) From added in v0.0.9

func (c *Int64Converter) From(obj interface{}) (Object, error)

func (*Int64Converter) To added in v0.0.9

func (c *Int64Converter) To(obj Object) (interface{}, error)

func (*Int64Converter) Type added in v0.0.9

func (c *Int64Converter) Type() reflect.Type

type IntConverter added in v0.0.9

type IntConverter struct{}

IntConverter converts between int and Integer.

func (*IntConverter) From added in v0.0.9

func (c *IntConverter) From(obj interface{}) (Object, error)

func (*IntConverter) To added in v0.0.9

func (c *IntConverter) To(obj Object) (interface{}, error)

func (*IntConverter) Type added in v0.0.9

func (c *IntConverter) Type() reflect.Type

type Integer

type Integer struct {
	// Value holds the int64 wrapped by this object.
	Value int64
}

Integer wraps int64 and implements Object and Hashable interfaces.

func NewInteger added in v0.0.4

func NewInteger(value int64) *Integer

func (*Integer) Compare added in v0.0.9

func (i *Integer) Compare(other Object) (int, error)

func (*Integer) HashKey

func (i *Integer) HashKey() Key

func (*Integer) Inspect

func (i *Integer) Inspect() string

func (*Integer) InvokeMethod

func (i *Integer) InvokeMethod(method string, args ...Object) Object

func (*Integer) String

func (i *Integer) String() string

func (*Integer) ToInterface

func (i *Integer) ToInterface() interface{}

func (*Integer) Type

func (i *Integer) Type() Type

type Key added in v0.0.9

type Key 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
}

Key is used to identify unique values in a set.

type MapStringIfaceConverter added in v0.0.9

type MapStringIfaceConverter struct{}

MapStringIfaceConverter converts between map[string]interface{} and Hash.

func (*MapStringIfaceConverter) From added in v0.0.9

func (c *MapStringIfaceConverter) From(obj interface{}) (Object, error)

func (*MapStringIfaceConverter) To added in v0.0.9

func (c *MapStringIfaceConverter) To(obj Object) (interface{}, error)

func (*MapStringIfaceConverter) Type added in v0.0.9

type Module

type Module struct {
	Name  string
	Scope interface{}
}

func (*Module) Compare added in v0.0.9

func (m *Module) Compare(other Object) (int, error)

func (*Module) Inspect

func (m *Module) Inspect() string

func (*Module) InvokeMethod

func (m *Module) InvokeMethod(method string, args ...Object) Object

func (*Module) String

func (m *Module) String() string

func (*Module) ToInterface

func (m *Module) ToInterface() interface{}

func (*Module) Type

func (m *Module) Type() Type

type Null

type Null struct{}

Null wraps nothing and implements our Object interface.

func (*Null) Compare added in v0.0.9

func (n *Null) Compare(other Object) (int, error)

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) InvokeMethod

func (n *Null) InvokeMethod(method string, args ...Object) Object

func (*Null) ToInterface

func (n *Null) ToInterface() interface{}

func (*Null) Type

func (n *Null) Type() Type

type Object

type Object interface {

	// Type of this object.
	Type() Type

	// Inspect returns a string-representation of the given object.
	Inspect() string

	// InvokeMethod invokes a method against the object.
	// (Built-in methods only.)
	InvokeMethod(method string, args ...Object) Object

	// ToInterface converts the given object to a "native" golang value,
	// which is required to ensure that we can use the object in our
	// `sprintf` or `printf` primitives.
	ToInterface() interface{}
}

Object is the interface that all object types in Tamarin must implement.

func FromGoType

func FromGoType(obj interface{}) Object

type Proxy added in v0.0.9

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

Proxy is a Tamarin type that proxies method calls to a wrapped Go struct. Only the public methods of the Go type are proxied.

func NewProxy added in v0.0.9

func NewProxy(mgr ProxyManager, obj interface{}) *Proxy

NewProxy returns a new Tamarin proxy object that wraps the given Go object. The Go type should previously been registered with the ProxyManager.

func (*Proxy) Inspect added in v0.0.9

func (p *Proxy) Inspect() string

func (*Proxy) InvokeMethod added in v0.0.9

func (p *Proxy) InvokeMethod(method string, args ...Object) Object

func (*Proxy) String added in v0.0.9

func (p *Proxy) String() string

func (*Proxy) ToInterface added in v0.0.9

func (p *Proxy) ToInterface() interface{}

func (*Proxy) Type added in v0.0.9

func (p *Proxy) Type() Type

type ProxyManager added in v0.0.9

type ProxyManager interface {

	// RegisterType determines type and method information for the provided
	// object and saves that information for use in later method call proxying.
	RegisterType(obj interface{}) (*ProxyType, error)

	// HasType returns true if the type of the objects has been registered.
	HasType(obj interface{}) bool

	// Call the named method on the object with the given arguments.
	// The type of the object must have been previously registered, otherwise
	// a Tamarin error object is returned.
	Call(obj interface{}, method string, args ...Object) Object
}

ProxyManager is an interface that defines a way to register Go types and call methods on instances of those types.

type ProxyManagerOpts added in v0.0.9

type ProxyManagerOpts struct {
	Types      []any
	Converters []TypeConverter
	NoDefaults bool
}

type ProxyMethod added in v0.0.9

type ProxyMethod struct {
	Name             string
	Method           reflect.Method
	NumIn            int
	NumOut           int
	InputConverters  []TypeConverter
	OutputConverters []TypeConverter
	OutputHasErr     bool
}

ProxyMethod represents a single method on a Go type that can be proxied.

type ProxyType added in v0.0.9

type ProxyType struct {
	NumMethod int
	Methods   []*ProxyMethod
	Value     interface{}
	Type      reflect.Type
}

ProxyType represents a single Go type whose methods can be proxied.

type Regexp

type Regexp struct {
	// Value holds the string value this object wraps.
	Value string

	// Flags holds the flags for the object
	Flags string
}

Regexp wraps regular-expressions and implements the Object interface.

func (*Regexp) Compare added in v0.0.9

func (r *Regexp) Compare(other Object) (int, error)

func (*Regexp) Inspect

func (r *Regexp) Inspect() string

func (*Regexp) InvokeMethod

func (r *Regexp) InvokeMethod(method string, args ...Object) Object

func (*Regexp) ToInterface

func (r *Regexp) ToInterface() interface{}

func (*Regexp) Type

func (r *Regexp) Type() Type

type Result

type Result struct {
	Ok  Object
	Err Object
}

Result contains one of: an "ok" value and an "err" value

func NewErrorResult

func NewErrorResult(format string, a ...interface{}) *Result

func NewOkResult added in v0.0.4

func NewOkResult(value Object) *Result

func (*Result) Inspect

func (rv *Result) Inspect() string

func (*Result) InvokeMethod

func (rv *Result) InvokeMethod(method string, args ...Object) Object

func (*Result) IsErr added in v0.0.7

func (rv *Result) IsErr() bool

func (*Result) IsOk

func (rv *Result) IsOk() bool

func (*Result) String

func (rv *Result) String() string

func (*Result) ToInterface

func (rv *Result) ToInterface() interface{}

func (*Result) Type

func (rv *Result) Type() Type

type ReturnValue

type ReturnValue struct {
	// Value is the object that is to be returned
	Value Object
}

ReturnValue wraps Object and implements Object interface.

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

Inspect returns a string-representation of the given object.

func (*ReturnValue) InvokeMethod

func (rv *ReturnValue) InvokeMethod(method string, args ...Object) Object

InvokeMethod invokes a method against the object. (Built-in methods only.)

func (*ReturnValue) ToInterface

func (rv *ReturnValue) ToInterface() interface{}

ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.

It might also be helpful for embedded users.

func (*ReturnValue) Type

func (rv *ReturnValue) Type() Type

Type returns the type of this object.

type Set

type Set struct {
	Items map[Key]Object
}

func NewSetWithSize added in v0.0.9

func NewSetWithSize(size int) *Set

func (*Set) Add added in v0.0.9

func (s *Set) Add(items ...Object) error

func (*Set) Array

func (s *Set) Array() *Array

func (*Set) Contains added in v0.0.9

func (s *Set) Contains(items ...Object) bool

func (*Set) Difference added in v0.0.9

func (s *Set) Difference(other *Set) *Set

Difference returns a new set that is the difference of the two sets.

func (*Set) Inspect

func (s *Set) Inspect() string

func (*Set) Intersection added in v0.0.9

func (s *Set) Intersection(other *Set) *Set

Intersection returns a new set that is the intersection of the two sets.

func (*Set) InvokeMethod

func (s *Set) InvokeMethod(method string, args ...Object) Object

func (*Set) Remove added in v0.0.9

func (s *Set) Remove(items ...Object) error

func (*Set) Size added in v0.0.9

func (s *Set) Size() int

func (*Set) ToInterface

func (s *Set) ToInterface() interface{}

func (*Set) Type

func (s *Set) Type() Type

func (*Set) Union added in v0.0.9

func (s *Set) Union(other *Set) *Set

Union returns a new set that is the union of the two sets.

type String

type String struct {
	// Value holds the string wrapped by this object.
	Value string
}

String wraps string and implements Object and Hashable interfaces.

func NewString added in v0.0.4

func NewString(s string) *String

func (*String) Compare added in v0.0.9

func (s *String) Compare(other Object) (int, error)

func (*String) HashKey

func (s *String) HashKey() Key

func (*String) Inspect

func (s *String) Inspect() string

func (*String) InvokeMethod

func (s *String) InvokeMethod(method string, args ...Object) Object

func (*String) Reversed added in v0.0.9

func (s *String) Reversed() *String

func (*String) String

func (s *String) String() string

func (*String) ToInterface

func (s *String) ToInterface() interface{}

func (*String) Type

func (s *String) Type() Type

type StringConverter added in v0.0.9

type StringConverter struct{}

StringConverter converts between string and String.

func (*StringConverter) From added in v0.0.9

func (c *StringConverter) From(obj interface{}) (Object, error)

func (*StringConverter) To added in v0.0.9

func (c *StringConverter) To(obj Object) (interface{}, error)

func (*StringConverter) Type added in v0.0.9

func (c *StringConverter) Type() reflect.Type

type StructConverter added in v0.0.9

type StructConverter struct {
	Prototype interface{}
}

StructConverter converts between a struct and a Hash via JSON marshaling.

func (*StructConverter) From added in v0.0.9

func (c *StructConverter) From(obj interface{}) (Object, error)

func (*StructConverter) To added in v0.0.9

func (c *StructConverter) To(obj Object) (interface{}, error)

func (*StructConverter) Type added in v0.0.9

func (c *StructConverter) Type() reflect.Type

type Time added in v0.0.4

type Time struct {
	Value time.Time
}

func NewTime added in v0.0.9

func NewTime(t time.Time) *Time

func (*Time) Compare added in v0.0.9

func (t *Time) Compare(other Object) (int, error)

func (*Time) Inspect added in v0.0.4

func (t *Time) Inspect() string

func (*Time) InvokeMethod added in v0.0.4

func (t *Time) InvokeMethod(method string, args ...Object) Object

func (*Time) String added in v0.0.4

func (t *Time) String() string

func (*Time) ToInterface added in v0.0.4

func (t *Time) ToInterface() interface{}

func (*Time) Type added in v0.0.4

func (t *Time) Type() Type

type TimeConverter added in v0.0.9

type TimeConverter struct{}

TimeConverter converts between time.Time and Time.

func (*TimeConverter) From added in v0.0.9

func (c *TimeConverter) From(obj interface{}) (Object, error)

func (*TimeConverter) To added in v0.0.9

func (c *TimeConverter) To(obj Object) (interface{}, error)

func (*TimeConverter) Type added in v0.0.9

func (c *TimeConverter) Type() reflect.Type

type Type

type Type string

Type defines the type of an object.

type TypeConverter added in v0.0.9

type TypeConverter interface {

	// To converts a Tamarin object to a Go object.
	To(Object) (interface{}, error)

	// From converts a Go object to a Tamarin object.
	From(interface{}) (Object, error)

	// Type that this TypeConverter is responsbile for.
	Type() reflect.Type
}

TypeConverter is an interface used to convert between Go and Tamarin objects for a single Go type. There may be a way to use generics here...

Jump to

Keyboard shortcuts

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