types

package
v0.0.0-...-97dcd37 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package types contains the types, traits, and utilities common to all components of expression handling.

Index

Constants

View Source
const (
	// Int constants used for comparison results.
	IntZero   = Int(0)
	IntOne    = Int(1)
	IntNegOne = Int(-1)
)

Variables

View Source
var (
	// BoolType singleton.
	BoolType = NewTypeValue("bool",
		traits.ComparerType,
		traits.NegatorType)

	False = Bool(false)
	True  = Bool(true)
)
View Source
var (
	// NullType singleton.
	NullType = NewTypeValue("null_type")
	// NullValue singleton.
	NullValue = Null(structpb.NullValue_NULL_VALUE)
)
View Source
var (
	// BytesType singleton.
	BytesType = NewTypeValue("bytes",
		traits.AdderType,
		traits.ComparerType,
		traits.SizerType)
)
View Source
var (
	// DurationType singleton.
	DurationType = NewTypeValue("google.protobuf.Duration",
		traits.AdderType,
		traits.ComparerType,
		traits.NegatorType,
		traits.ReceiverType,
		traits.SubtractorType)
)
View Source
var (
	// DynType singleton.
	DynType = NewTypeValue("dyn")
)
View Source
var (
	// ErrType singleton.
	ErrType = NewTypeValue("error")
)
View Source
var (
	// IteratorType singleton.
	IteratorType = NewTypeValue("iterator", traits.IteratorType)
)
View Source
var (
	// MapType singleton.
	MapType = NewTypeValue("map",
		traits.ContainerType,
		traits.IndexerType,
		traits.IterableType,
		traits.SizerType)
)
View Source
var (
	// StringType singleton.
	StringType = NewTypeValue("string",
		traits.AdderType,
		traits.ComparerType,
		traits.MatcherType,
		traits.SizerType)
)
View Source
var (
	// TimestampType singleton.
	TimestampType = NewTypeValue("google.protobuf.Timestamp",
		traits.AdderType,
		traits.ComparerType,
		traits.ReceiverType,
		traits.SubtractorType)
)
View Source
var (
	// TypeType is the type of a TypeValue.
	TypeType = NewTypeValue("type")
)
View Source
var (
	// UnknownType singleton.
	UnknownType = NewTypeValue("unknown")
)

Functions

func IsBool

func IsBool(elem interface{}) bool

IsBool returns whether the input ref.Value or ref.Type is equal to BoolType.

func IsDyn

func IsDyn(elem interface{}) bool

IsDyn indicates whether the input ref.Value or ref.Type is equal to DynType.

func IsError

func IsError(elem interface{}) bool

IsError returns whether the input element ref.Type or ref.Value is equal to the ErrType singleton.

func IsUnknown

func IsUnknown(elem interface{}) bool

IsUnknown returns whether the element ref.Type or ref.Value is equal to the UnknownType singleton.

func IsUnknownOrError

func IsUnknownOrError(elem interface{}) bool

IsUnknownOrError returns whether the input element ref.Type or ref.Value is an ErrType or UnknonwType.

func NativeToValue

func NativeToValue(value interface{}) ref.Value

func NewDynamicList

func NewDynamicList(value interface{}) traits.Lister

NewDynamicList returns a traits.Lister with heterogenous elements. value should be an array of "native" types, i.e. any type that NativeToValue() can convert to a ref.Value.

func NewDynamicMap

func NewDynamicMap(value interface{}) traits.Mapper

NewDynamicMap returns a traits.Mapper value with dynamic key, value pairs.

func NewJsonList

func NewJsonList(l *structpb.ListValue) traits.Lister

NewJsonList creates a traits.Lister implementation backed by a JSON list that has been encoded in protocol buffer form.

func NewJsonStruct

func NewJsonStruct(st *structpb.Struct) traits.Mapper

func NewObject

func NewObject(value proto.Message) ref.Value

NewObject returns an object based on a proto.Message value which handles conversion between protobuf type values and expression type values. Objects support indexing and iteration.

func NewProvider

func NewProvider(types ...proto.Message) ref.TypeProvider

NewProvider accepts a list of proto message instances and returns a type provider which can create new instances of the provided message or any message that proto depends upon in its FileDescriptor.

func NewStringList

func NewStringList(elems []string) traits.Lister

NewStringList returns a traits.Lister containing only strings.

func NewValueList

func NewValueList(elems []ref.Value) traits.Lister

NewValueList returns a traits.Lister with ref.Value elements.

Types

type Bool

type Bool bool

Bool type that implements ref.Value and supports comparison and negation.

func (Bool) Compare

func (b Bool) Compare(other ref.Value) ref.Value

func (Bool) ConvertToNative

func (b Bool) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Bool) ConvertToType

func (b Bool) ConvertToType(typeVal ref.Type) ref.Value

func (Bool) Equal

func (b Bool) Equal(other ref.Value) ref.Value

func (Bool) Negate

func (b Bool) Negate() ref.Value

func (Bool) Type

func (b Bool) Type() ref.Type

func (Bool) Value

func (b Bool) Value() interface{}

type Bytes

type Bytes []byte

Bytes type that implements ref.Value and supports add, compare, and size operations.

func (Bytes) Add

func (b Bytes) Add(other ref.Value) ref.Value

func (Bytes) Compare

func (b Bytes) Compare(other ref.Value) ref.Value

func (Bytes) ConvertToNative

func (b Bytes) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Bytes) ConvertToType

func (b Bytes) ConvertToType(typeVal ref.Type) ref.Value

func (Bytes) Equal

func (b Bytes) Equal(other ref.Value) ref.Value

func (Bytes) Size

func (b Bytes) Size() ref.Value

func (Bytes) Type

func (b Bytes) Type() ref.Type

func (Bytes) Value

func (b Bytes) Value() interface{}

type Double

type Double float64

Double type that implements ref.Value, comparison, and mathematical operations.

func (Double) Add

func (d Double) Add(other ref.Value) ref.Value

func (Double) Compare

func (d Double) Compare(other ref.Value) ref.Value

func (Double) ConvertToNative

func (d Double) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Double) ConvertToType

func (d Double) ConvertToType(typeVal ref.Type) ref.Value

func (Double) Divide

func (d Double) Divide(other ref.Value) ref.Value

func (Double) Equal

func (d Double) Equal(other ref.Value) ref.Value

func (Double) Multiply

func (d Double) Multiply(other ref.Value) ref.Value

func (Double) Negate

func (d Double) Negate() ref.Value

func (Double) Subtract

func (d Double) Subtract(subtrahend ref.Value) ref.Value

func (Double) Type

func (d Double) Type() ref.Type

func (Double) Value

func (d Double) Value() interface{}

type Duration

type Duration struct {
	*dpb.Duration
}

Duration type that implements ref.Value and supports add, compare, negate, and subtract operators. This type is also a receiver which means it can participate in dispatch to receiver functions.

func (Duration) Add

func (d Duration) Add(other ref.Value) ref.Value

func (Duration) Compare

func (d Duration) Compare(other ref.Value) ref.Value

func (Duration) ConvertToNative

func (d Duration) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Duration) ConvertToType

func (d Duration) ConvertToType(typeVal ref.Type) ref.Value

func (Duration) Equal

func (d Duration) Equal(other ref.Value) ref.Value

func (Duration) Negate

func (d Duration) Negate() ref.Value

func (Duration) Receive

func (d Duration) Receive(function string, overload string, args []ref.Value) ref.Value

func (Duration) Subtract

func (d Duration) Subtract(subtrahend ref.Value) ref.Value

func (Duration) Type

func (d Duration) Type() ref.Type

func (Duration) Value

func (d Duration) Value() interface{}

type Err

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

Err type which extends the built-in go error and implements ref.Value.

func NewErr

func NewErr(format string, args ...interface{}) *Err

func (*Err) ConvertToNative

func (e *Err) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (*Err) ConvertToType

func (e *Err) ConvertToType(typeVal ref.Type) ref.Value

func (*Err) Equal

func (e *Err) Equal(other ref.Value) ref.Value

func (*Err) String

func (e *Err) String() string

func (*Err) Type

func (e *Err) Type() ref.Type

func (*Err) Value

func (e *Err) Value() interface{}

type Int

type Int int64

Int type that implements ref.Value as well as comparison and math operators.

func (Int) Add

func (i Int) Add(other ref.Value) ref.Value

func (Int) Compare

func (i Int) Compare(other ref.Value) ref.Value

func (Int) ConvertToNative

func (i Int) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Int) ConvertToType

func (i Int) ConvertToType(typeVal ref.Type) ref.Value

func (Int) Divide

func (i Int) Divide(other ref.Value) ref.Value

func (Int) Equal

func (i Int) Equal(other ref.Value) ref.Value

func (Int) Modulo

func (i Int) Modulo(other ref.Value) ref.Value

func (Int) Multiply

func (i Int) Multiply(other ref.Value) ref.Value

func (Int) Negate

func (i Int) Negate() ref.Value

func (Int) Subtract

func (i Int) Subtract(subtrahend ref.Value) ref.Value

func (Int) Type

func (i Int) Type() ref.Type

func (Int) Value

func (i Int) Value() interface{}

type Null

type Null structpb.NullValue

Null type implementation.

func (Null) ConvertToNative

func (n Null) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Null) ConvertToType

func (n Null) ConvertToType(typeVal ref.Type) ref.Value

func (Null) Equal

func (n Null) Equal(other ref.Value) ref.Value

func (Null) Type

func (n Null) Type() ref.Type

func (Null) Value

func (n Null) Value() interface{}

type String

type String string

String type implementation which supports addition, comparison, matching, and size functions.

func (String) Add

func (s String) Add(other ref.Value) ref.Value

func (String) Compare

func (s String) Compare(other ref.Value) ref.Value

func (String) ConvertToNative

func (s String) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (String) ConvertToType

func (s String) ConvertToType(typeVal ref.Type) ref.Value

func (String) Equal

func (s String) Equal(other ref.Value) ref.Value

func (String) Match

func (s String) Match(pattern ref.Value) ref.Value

func (String) Size

func (s String) Size() ref.Value

func (String) Type

func (s String) Type() ref.Type

func (String) Value

func (s String) Value() interface{}

type Timestamp

type Timestamp struct {
	*tpb.Timestamp
}

Timestamp type implementation which supports add, compare, and subtract operations. Timestamps are also capable of participating in dynamic function dispatch to instance methods.

func (Timestamp) Add

func (t Timestamp) Add(other ref.Value) ref.Value

func (Timestamp) Compare

func (t Timestamp) Compare(other ref.Value) ref.Value

func (Timestamp) ConvertToNative

func (t Timestamp) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Timestamp) ConvertToType

func (t Timestamp) ConvertToType(typeVal ref.Type) ref.Value

func (Timestamp) Equal

func (t Timestamp) Equal(other ref.Value) ref.Value

func (Timestamp) Receive

func (t Timestamp) Receive(function string, overload string, args []ref.Value) ref.Value

func (Timestamp) Subtract

func (t Timestamp) Subtract(subtrahend ref.Value) ref.Value

func (Timestamp) Type

func (t Timestamp) Type() ref.Type

func (Timestamp) Value

func (t Timestamp) Value() interface{}

type TypeValue

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

TypeValue is an instance of a Value that describes a value's type.

func NewObjectTypeValue

func NewObjectTypeValue(name string) *TypeValue

NewObjectTypeValue returns a *TypeValue based on the input name, which is annotated with the traits relevant to all objects.

func NewTypeValue

func NewTypeValue(name string, traits ...int) *TypeValue

NewTypeValue returns *TypeValue which is both a ref.Type and ref.Value.

func (*TypeValue) ConvertToNative

func (t *TypeValue) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (*TypeValue) ConvertToType

func (t *TypeValue) ConvertToType(typeVal ref.Type) ref.Value

func (*TypeValue) Equal

func (t *TypeValue) Equal(other ref.Value) ref.Value

func (*TypeValue) HasTrait

func (t *TypeValue) HasTrait(trait int) bool

func (*TypeValue) String

func (t *TypeValue) String() string

func (*TypeValue) Type

func (t *TypeValue) Type() ref.Type

func (*TypeValue) TypeName

func (t *TypeValue) TypeName() string

func (*TypeValue) Value

func (t *TypeValue) Value() interface{}

type Uint

type Uint uint64

Uint type implementation which supports comparison and math operators.

func (Uint) Add

func (i Uint) Add(other ref.Value) ref.Value

func (Uint) Compare

func (i Uint) Compare(other ref.Value) ref.Value

func (Uint) ConvertToNative

func (i Uint) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Uint) ConvertToType

func (i Uint) ConvertToType(typeVal ref.Type) ref.Value

func (Uint) Divide

func (i Uint) Divide(other ref.Value) ref.Value

func (Uint) Equal

func (i Uint) Equal(other ref.Value) ref.Value

func (Uint) Modulo

func (i Uint) Modulo(other ref.Value) ref.Value

func (Uint) Multiply

func (i Uint) Multiply(other ref.Value) ref.Value

func (Uint) Subtract

func (i Uint) Subtract(subtrahend ref.Value) ref.Value

func (Uint) Type

func (i Uint) Type() ref.Type

func (Uint) Value

func (i Uint) Value() interface{}

type Unknown

type Unknown []int64

Unknown type implementation which collects expression ids which caused the current value to become unknown.

func (Unknown) ConvertToNative

func (u Unknown) ConvertToNative(typeDesc reflect.Type) (interface{}, error)

func (Unknown) ConvertToType

func (u Unknown) ConvertToType(typeVal ref.Type) ref.Value

func (Unknown) Equal

func (u Unknown) Equal(other ref.Value) ref.Value

func (Unknown) Type

func (u Unknown) Type() ref.Type

func (Unknown) Value

func (u Unknown) Value() interface{}

Directories

Path Synopsis
Package pb reflects over protocol buffer descriptors to generate objects that simplify type, enum, and field lookup.
Package pb reflects over protocol buffer descriptors to generate objects that simplify type, enum, and field lookup.
Package ref contains the reference interfaces used throughout the types components.
Package ref contains the reference interfaces used throughout the types components.
Package traits defines interfaces that a type may implement to participate in operator overloads and function dispatch.
Package traits defines interfaces that a type may implement to participate in operator overloads and function dispatch.

Jump to

Keyboard shortcuts

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