Documentation
¶
Overview ¶
package types implements functions and types to represent and work with Scriggo types.
Index ¶
- type ScriggoType
- type Types
- func (types *Types) ArrayOf(count int, elem reflect.Type) reflect.Type
- func (types *Types) AssignableTo(x, u reflect.Type) bool
- func (types *Types) ChanOf(dir reflect.ChanDir, t reflect.Type) reflect.Type
- func (types *Types) ConvertibleTo(x, u reflect.Type) bool
- 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) Implements(x, u reflect.Type) bool
- func (types *Types) MapOf(key, elem reflect.Type) reflect.Type
- func (types *Types) New(typ 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) Zero(t reflect.Type) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ScriggoType ¶
type ScriggoType interface {
reflect.Type
// Underlying returns the reflect implementation of the reflect.Type, so
// it's safe to pass the returned value to the functions of the reflect
// package.
Underlying() reflect.Type
}
A ScriggoType represents a type compiled by Scriggo from a type definition or a composite type literal with at least one element with a Scriggo type.
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) AssignableTo ¶
AssignableTo is equivalent to reflect's AssignableTo.
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) ConvertibleTo ¶
ConvertibleTo is equivalent to reflect's ConvertibleTo.
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) Implements ¶
Implements behaves like x.Implements(u) except when one of x or u is a Scriggo 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 typ is a Scriggo type; in such case it returns an instance of the underlying 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.