types

package
v0.56.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package types implements functions and types to represent and work with Scriggo types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignableTo

func AssignableTo(x, y reflect.Type) bool

AssignableTo reports whether a value of type x is assignable to type y.

func ConvertibleTo

func ConvertibleTo(x, y reflect.Type) bool

ConvertibleTo reports whether a value of type x is convertible to type y.

func Implements

func Implements(x, y reflect.Type) bool

Implements reports whether x implements the interface type y.

Types

type Types

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

Types allows to create and manage types and values, as the reflect package does, for a specific compilation and for both the types compiled by Scriggo and by gc.

func NewTypes

func NewTypes() *Types

NewTypes returns a new instance of Types.

func (*Types) ArrayOf

func (types *Types) ArrayOf(count int, elem reflect.Type) reflect.Type

ArrayOf is equivalent to reflect.ArrayOf except when elem is a Scriggo type; in such case a new Scriggo array type is created and returned as reflect.Type.

func (*Types) ChanOf

func (types *Types) ChanOf(dir reflect.ChanDir, t reflect.Type) reflect.Type

ChanOf behaves like reflect.ChanOf except when t is a Scriggo type; in such case a new Scriggo channel type is created and returned as reflect.Type.

func (*Types) DefinedOf

func (types *Types) DefinedOf(name string, underlyingType reflect.Type) reflect.Type

DefinedOf returns the defined type with the given name and underlying type. For example, if n is "Int" and k represents int, DefinedOf(n, k) represents the type Int declared with 'type Int int'.

func (*Types) FuncOf

func (types *Types) FuncOf(in, out []reflect.Type, variadic bool) reflect.Type

FuncOf behaves like reflect.FuncOf except when at least one of the parameters is a Scriggo type; in such case a new Scriggo function type is created and returned as reflect.Type.

func (*Types) MapOf

func (types *Types) MapOf(key, elem reflect.Type) reflect.Type

MapOf behaves like reflect.MapOf except when at least one of the map key or the map element is a Scriggo type; in such case a new Scriggo map type is created and returned as reflect.Type.

func (*Types) New

func (types *Types) New(t reflect.Type) reflect.Value

New behaves like reflect.New except when t is a Scriggo type; in such case it returns an instance of the Go type created with a reflect.New call.

func (*Types) PtrTo

func (types *Types) PtrTo(t reflect.Type) reflect.Type

PtrTo behaves like reflect.PtrTo except when it is a Scriggo type; in such case a new Scriggo pointer type is created and returned as reflect.Type.

func (*Types) SliceOf

func (types *Types) SliceOf(t reflect.Type) reflect.Type

SliceOf behaves like reflect.SliceOf except when elem is a Scriggo type; in such case a new Scriggo slice type is created and returned as reflect.Type.

func (*Types) StructOf

func (types *Types) StructOf(fields []reflect.StructField) reflect.Type

StructOf behaves like reflect.StructOf except when at least one of the fields has a Scriggo type; in such case a new Scriggo struct type is created and returned as reflect.Type.

func (*Types) TypeOf

func (types *Types) TypeOf(v reflect.Value) reflect.Type

TypeOf returns the type of v.

func (*Types) Zero

func (types *Types) Zero(t reflect.Type) reflect.Value

Zero is equivalent to reflect.Zero. If t is a Scriggo type it returns the zero of the underlying type.

Jump to

Keyboard shortcuts

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