Documentation ¶
Overview ¶
Package types implements functions and types to represent and work with Scriggo types.
Index ¶
- func AssignableTo(x, y reflect.Type) bool
- func ConvertibleTo(x, y reflect.Type) bool
- func Implements(x, y reflect.Type) bool
- type Types
- func (types *Types) ArrayOf(count int, elem reflect.Type) reflect.Type
- func (types *Types) ChanOf(dir reflect.ChanDir, t reflect.Type) reflect.Type
- func (types *Types) DefinedOf(name string, underlyingType reflect.Type) reflect.Type
- func (types *Types) FuncOf(in, out []reflect.Type, variadic bool) reflect.Type
- func (types *Types) MapOf(key, elem reflect.Type) reflect.Type
- func (types *Types) New(t reflect.Type) reflect.Value
- func (types *Types) PtrTo(t reflect.Type) reflect.Type
- func (types *Types) SliceOf(t reflect.Type) reflect.Type
- func (types *Types) StructOf(fields []reflect.StructField) reflect.Type
- func (types *Types) TypeOf(v reflect.Value) reflect.Type
- func (types *Types) Zero(t reflect.Type) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignableTo ¶
AssignableTo reports whether a value of type x is assignable to type y.
func ConvertibleTo ¶
ConvertibleTo reports whether a value of type x is convertible to type y.
func Implements ¶
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 (*Types) ArrayOf ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.