definitions

package
v0.0.0-...-d73cd42 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2014 License: BSD-2-Clause Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Builtin types (int, int8, string, bool, etc)
	Builtin = TypeCategory(iota + 1)

	// Simple types. eg: `type myInt int`
	Simple

	// Slice types. eg: `type mySlice []int`
	Slice

	// Map types. eg: `type myMap map[keyType]valueType`
	Map

	// Struct types. eg: `type myStruct struct{}`
	Struct
)

Variables

View Source
var (
	ServerProcedure = ProcedureType("string")
	ClientProcedure = ProcedureType("client")
)

ProcedureType's

View Source
var (
	TypeInt      = &Type{Name: "int", Category: Builtin}
	TypeInt8     = &Type{Name: "int8", Category: Builtin}
	TypeInt16    = &Type{Name: "int16", Category: Builtin}
	TypeInt32    = &Type{Name: "int32", Category: Builtin}
	TypeInt64    = &Type{Name: "int64", Category: Builtin}
	TypeUint     = &Type{Name: "uint", Category: Builtin}
	TypeUint8    = &Type{Name: "uint8", Category: Builtin}
	TypeUint16   = &Type{Name: "uint16", Category: Builtin}
	TypeUint32   = &Type{Name: "uint32", Category: Builtin}
	TypeUint64   = &Type{Name: "uint64", Category: Builtin}
	TypeString   = &Type{Name: "string", Category: Builtin}
	TypeBool     = &Type{Name: "bool", Category: Builtin}
	BuiltinTypes = map[string]*Type{
		TypeInt.Name:    TypeInt,
		TypeInt8.Name:   TypeInt8,
		TypeInt16.Name:  TypeInt16,
		TypeInt32.Name:  TypeInt32,
		TypeInt64.Name:  TypeInt64,
		TypeUint.Name:   TypeUint,
		TypeUint8.Name:  TypeUint8,
		TypeUint16.Name: TypeUint16,
		TypeUint32.Name: TypeUint32,
		TypeUint64.Name: TypeUint64,
		TypeString.Name: TypeString,
		TypeBool.Name:   TypeBool,
	}
)

Builtin types

Functions

This section is empty.

Types

type Param

type Param struct {
	Name string
	Type *Type
}

Param defines an argument or return parameter

func (*Param) CapitalizedName

func (p *Param) CapitalizedName() string

CapitalizedName returns the name for this param, capitalized

func (*Param) GoTypeName

func (p *Param) GoTypeName() string

GoTypeName returns the type

func (*Param) IsNumber

func (p *Param) IsNumber() bool

TODO: move method to (t *Type) IsNumber returns true when the type is numeric

func (*Param) JsTypeName

func (p *Param) JsTypeName() string

TODO: move method to (t *Type) JsTypeName returns the Js TypeName for the Type

func (Param) NumberMax

func (p Param) NumberMax() (uint64, error)

TODO: move method to (t *Type) NumberMax returns the maximal numeric value for the given type or an error when the type is not a number

func (Param) NumberMin

func (p Param) NumberMin() (int64, error)

TODO: move method to (t *Type) NumberMin returns the minimal numeric value for the given type or an error when the type is not a number

type Params

type Params []*Param

Params is a list of parameters

func (Params) GoParameterList

func (ps Params) GoParameterList() string

GoParameterList returns the params as go ParameterList (http://golang.org/ref/spec#ParameterList)

func (Params) JsParameterList

func (ps Params) JsParameterList() string

JsParameterList returns a comma seperated string of arguments (name only)

type Procedure

type Procedure struct {
	Type   ProcedureType
	Oneway bool
	Name   string
	Args   Params
	Rets   Params
	Source Source
}

Procedure defines a remote method/function

func (*Procedure) CapitalizedName

func (p *Procedure) CapitalizedName() string

CapitalizedName returns the name, capitalized. Used by ango-service.tmpl.go

func (*Procedure) GoArgs

func (p *Procedure) GoArgs() string

GoArgs returns the go function definition argument ParameterList Used by ango-service.tmpl.go

func (*Procedure) GoCallArgs

func (p *Procedure) GoCallArgs() string

GoCallArgs returns the procedure call argument values Used by ango-service.tmpl.go

func (*Procedure) GoCallRets

func (p *Procedure) GoCallRets() string

GoCallRets returns the procedure call return values Used by ango-service.tmpl.go

func (*Procedure) GoRets

func (p *Procedure) GoRets() string

GoRets returns the go function definition return ParameterList Used by ango-service.tmpl.go

func (*Procedure) JsArgs

func (p *Procedure) JsArgs() string

JsArgs returns the js arguments Used by ango-service.tmpl.js

func (*Procedure) JsCallArgs

func (p *Procedure) JsCallArgs() string

JsCallArgs returns the procedure call argument values Used by ango-service.tmpl.js

type ProcedureType

type ProcedureType string

ProcedureType indicates wether a procedure is server- or client-side

type Service

type Service struct {
	// Name is the name given to the service
	Name string

	// Types defined on the service
	Types map[string]*Type

	// ServiceProceduers holds all server-side procedures, by their name
	ServerProcedures map[string]*Procedure

	// ClientProcedures holds all client-side procedures, by their name
	ClientProcedures map[string]*Procedure
}

Service holds information about a ango service

func NewService

func NewService() *Service

NewService creates a new service instance and sets up maps and defaults

func (*Service) CapitalizedName

func (s *Service) CapitalizedName() string

CapitalizedName returns the service name, capitalized. Used by ango-service.tmpl.go

func (*Service) JsClientProceduresStringAry

func (s *Service) JsClientProceduresStringAry() string

JsClientProceduresStringAry returns a comma seperated list of js strings Used by ango-service.tmpl.js

func (*Service) LookupType

func (s *Service) LookupType(name string) *Type

LookupType searches for a type in the service.Types map or BuiltinTypes map. When a type is builtin and is not in service.Types yet, it is added. When a type cannot be found, nil is returned.

type Source

type Source struct {
	Linenumber int
}

Source contains information about where a given definition was declared.

type StructField

type StructField struct {
	Name string
	Type *Type
}

StructField defines a single field in a struct

type Type

type Type struct {
	// Name is the identifier of the type
	Name string

	// Category indicates the Type's category (builtin, simple, slice, map, struct)
	Category TypeCategory

	// SimpleType defines the type for the type that this type maps to
	SimpleType *Type

	// SliceElementType defines the type for the slice elements
	SliceElementType *Type

	// MapKeyType and MapValueType define the key and value types for the map
	MapKeyType   *Type
	MapValueType *Type

	// StructFields holds the struct field definitions, only used when Category is Struct.
	StructFields []StructField
}

Type is the type of a parameter It's value should be a valid go TypeName (http://golang.org/ref/spec#TypeName)

func (*Type) CapitalizedName

func (t *Type) CapitalizedName() string

CapitalizedName returns the name, capitalized

func (*Type) GoIsBuiltin

func (t *Type) GoIsBuiltin() bool

GoIsBuiltin returns true when the type is a Go builtin type

func (*Type) GoName

func (t *Type) GoName() string

GoName returns the Go identifier for this type. The Go identifier is capitalized when the type is not a builtin Go type.

func (*Type) GoTypeDefinition

func (t *Type) GoTypeDefinition() string

type TypeCategory

type TypeCategory int

TypeCategory is the category to which a type belongs. The different categories are defined as constants.

Jump to

Keyboard shortcuts

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