core

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxArgs = 65536

Variables

View Source
var (
	ErrMissedArgument        = errors.New("missed argument")
	ErrInvalidArgument       = errors.New("invalid argument")
	ErrInvalidArgumentNumber = errors.New("invalid argument number")
	ErrInvalidType           = errors.New("invalid type")
	ErrInvalidOperation      = errors.New("invalid operation")
	ErrNotFound              = errors.New("not found")
	ErrNotUnique             = errors.New("not unique")
	ErrTerminated            = errors.New("operation is terminated")
	ErrUnexpected            = errors.New("unexpected error")
	ErrTimeout               = errors.New("operation timed out")
	ErrNotImplemented        = errors.New("not implemented")
)

Functions

func Error

func Error(err error, msg string) error

func Errorf added in v0.4.0

func Errorf(err error, format string, args ...interface{}) error

func Errors

func Errors(err ...error) error

func IsNil

func IsNil(input interface{}) bool

func IsTypeOf

func IsTypeOf(value Value, check Type) bool

IsTypeOf return true when value's type is equal to check type. Returns false, otherwise.

func NewRootScope

func NewRootScope() (*Scope, CloseFunc)

func ParamsFrom

func ParamsFrom(ctx context.Context) (map[string]Value, error)

func ParamsWith

func ParamsWith(ctx context.Context, params map[string]Value) context.Context

func SourceError

func SourceError(src SourceMap, err error) error

func TypeError

func TypeError(actual Type, expected ...Type) error

func ValidateArgs

func ValidateArgs(args []Value, minimum, maximum int) error

func ValidateType

func ValidateType(value Value, required ...Type) error

ValidateType checks the match of value's type and required types.

func ValidateValueTypePairs added in v0.5.0

func ValidateValueTypePairs(pairs ...PairValueType) error

ValidateValueTypePairs validate pairs of Values and Types. Returns error when type didn't match

Types

type Cloneable

type Cloneable interface {
	Value
	Clone() Cloneable
}

type CloseFunc

type CloseFunc func() error

type Expression

type Expression interface {
	Exec(ctx context.Context, scope *Scope) (Value, error)
}

type Function

type Function = func(ctx context.Context, args ...Value) (Value, error)

type OperatorExpression

type OperatorExpression interface {
	Expression
	Eval(ctx context.Context, left, right Value) (Value, error)
}

type PairValueType added in v0.5.0

type PairValueType struct {
	Value Value
	Types []Type
}

PairValueType is a supporting structure that used in validateValueTypePairs.

type RootScope added in v0.5.0

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

func (*RootScope) AddDisposable added in v0.5.0

func (s *RootScope) AddDisposable(disposable io.Closer)

func (*RootScope) Close added in v0.5.0

func (s *RootScope) Close() error

type Scope

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

func (*Scope) Fork

func (s *Scope) Fork() *Scope

func (*Scope) GetVariable

func (s *Scope) GetVariable(name string) (Value, error)

func (*Scope) HasVariable

func (s *Scope) HasVariable(name string) bool

func (*Scope) MustGetVariable added in v0.5.0

func (s *Scope) MustGetVariable(name string) Value

func (*Scope) SetVariable

func (s *Scope) SetVariable(name string, val Value) error

func (*Scope) UpdateVariable added in v0.5.0

func (s *Scope) UpdateVariable(name string, val Value) error

type SourceMap

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

func NewSourceMap

func NewSourceMap(text string, line, col int) SourceMap

func (SourceMap) Column

func (s SourceMap) Column() int

func (SourceMap) Line

func (s SourceMap) Line() int

func (SourceMap) String

func (s SourceMap) String() string

type Type

type Type int64
const (
	NoneType         Type = 0
	BooleanType      Type = 1
	IntType          Type = 2
	FloatType        Type = 3
	StringType       Type = 4
	DateTimeType     Type = 5
	ArrayType        Type = 6
	ObjectType       Type = 7
	HTMLElementType  Type = 8
	HTMLDocumentType Type = 9
	BinaryType       Type = 10
	CustomType       Type = 99
)

func (Type) String

func (t Type) String() string

type Value

type Value interface {
	json.Marshaler
	Type() Type
	String() string
	Compare(other Value) int
	Unwrap() interface{}
	Hash() uint64
	Copy() Value
}

Value represents an interface of any type that needs to be used during runtime

func ParamFrom

func ParamFrom(ctx context.Context, name string) (Value, error)

Jump to

Keyboard shortcuts

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