bridge

package module
v0.0.0-...-b14b5fa Latest Latest
Warning

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

Go to latest
Published: May 26, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NullType = iota
	UnresolvedType
	NamedType
	AliasType
	ReferenceType
	TupleType
	RecordType
	FunctionType
	ListType
	MapType
)

Variables

This section is empty.

Functions

func FindDecl

func FindDecl(parsedFile *ast.File, declName string) *ast.GenDecl

*

  • Finds a GenDecl node in a parsed file.

func LoadTemplate

func LoadTemplate(templatePath string) (*template.Template, error)

func PackagePathForFile

func PackagePathForFile(fullpath string) string

Given a full path to a file or folder, finds the full name of the package path in one of the GOPATH or GOROOT folders For example, if GOPATH contained the following folders: /home/user1/a /home/user1/b

and GOROOT was: /user/local/go

and given the input full path of:

/home/user1/a/src/github.com/theuser/repo

would return

github.com/theuser/repo

as the full package path as it exists in the src folder of one of the folders in GOPATH or GOROOT

func RenderTemplate

func RenderTemplate(writer io.Writer, templatePath string, context interface{}) error

Types

type AliasTypeData

type AliasTypeData struct {
	// Type this is an alias/typedef for
	Name       string
	TargetType *Type
}

type Field

type Field struct {
	Name string
	Type *Type
}

type FunctionTypeData

type FunctionTypeData struct {
	// Types of the input parameters
	InputTypes []*Type

	// Types of the output parameters
	OutputTypes []*Type

	// Types of possible exceptions that can be thrown (not supported in all languages)
	ExceptionTypes []*Type
}

func (*FunctionTypeData) NumExceptions

func (td *FunctionTypeData) NumExceptions() int

func (*FunctionTypeData) NumInputs

func (td *FunctionTypeData) NumInputs() int

func (*FunctionTypeData) NumOutputs

func (td *FunctionTypeData) NumOutputs() int

type Generator

type Generator interface {
	/**
	 * Emits the class that acts as a client for the service.
	 */
	EmitClientClass(writer io.Writer, serviceType *Type) error

	/**
	 * For a given service operation, emits a method which:
	 * 1. Has inputs the same as those of the underlying service operation,
	 * 2. creates a transport level request
	 * 3. Sends the transport level request
	 * 4. Gets a response from the transport level and returns it
	 */
	EmitServiceCallMethod(writer io.Writer, opName string, opType *FunctionTypeData, argPrefix string) error

	/**
	 * Emits the writer for a particular type.
	 */
	EmitTypeWriter(writer io.Writer, argType *Type) error

	/**
	 * Emits the reader for a particular type.
	 */
	EmitTypeReader(writer io.Writer, argType *Type) error
}

*

  • Responsible for generating the code for the client classes.

type ITypeLibrary

type ITypeLibrary interface {
	AddType(pkg string, name string, t *Type) (alt *Type)
	GetType(pkg string, name string) *Type
	AddGlobalType(name string) (alt *Type)
	GetGlobalType(name string) (alt *Type)

	// Package related API
	AddPackage(name string) (shortName string)
	ForEach(func(string, *Type, *bool))
	PackageByShortName(name string) string
	ShortNameForPackage(pkg string) string

	// Signature string creation
	Signature(t *Type) string
	TypeListSignature(types []*Type, argfmt string) string

	// General visitors
	// TODO: move this out of this fat interface
	TransitiveClosureFrom(startType *Type, filter func(t *Type) bool) ([]*Type, []string)
}

type ListTypeData

type ListTypeData struct {
	// The target type this is an array of
	TargetType *Type
}

type MapTypeData

type MapTypeData struct {
	// The target type this is an array of
	KeyType   *Type
	ValueType *Type
}

type NamedTypeData

type NamedTypeData struct {
	Name    string
	Package string
}

type ParsedFile

type ParsedFile struct {
	FullPath    string
	FileNode    *ast.File
	Package     string
	PackagePath string
	Imports     map[string]string
}

func NewParsedFile

func NewParsedFile(srcFile string) (out *ParsedFile, err error)

func (*ParsedFile) NodeToType

func (parsedFile *ParsedFile) NodeToType(node ast.Node, typeLibrary ITypeLibrary) *Type

*

  • Convert a node to a type.

func (*ParsedFile) ProcessNode

func (parsedFile *ParsedFile) ProcessNode(typeLibrary ITypeLibrary) error

*

  • Parses a file and returns a map of types indexed by name.

type RecordTypeData

type RecordTypeData struct {
	NamedTypeData

	// Type of each member in the struct
	Bases  []*Type
	Fields []*Field
}

func (*RecordTypeData) NumBases

func (td *RecordTypeData) NumBases() int

func (*RecordTypeData) NumFields

func (td *RecordTypeData) NumFields() int

type ReferenceTypeData

type ReferenceTypeData struct {
	// The target type this is a reference to
	TargetType *Type
}

type TupleTypeData

type TupleTypeData struct {
	SubTypes []*Type
}

type Type

type Type struct {
	// One of the above type classes
	TypeClass int

	TypeData interface{}
}

func NewType

func NewType(typeCls int, data interface{}) *Type

func (*Type) AsAliasType

func (t *Type) AsAliasType() *AliasTypeData

func (*Type) AsFunctionType

func (t *Type) AsFunctionType() *FunctionTypeData

func (*Type) AsListType

func (t *Type) AsListType() *ListTypeData

func (*Type) AsMapType

func (t *Type) AsMapType() *MapTypeData

func (*Type) AsNamedType

func (t *Type) AsNamedType() *NamedTypeData

func (*Type) AsRecordType

func (t *Type) AsRecordType() *RecordTypeData

func (*Type) AsReferenceType

func (t *Type) AsReferenceType() *ReferenceTypeData

func (*Type) AsTupleType

func (t *Type) AsTupleType() *TupleTypeData

func (*Type) IsAliasType

func (t *Type) IsAliasType() bool

func (*Type) IsFunctionType

func (t *Type) IsFunctionType() bool

func (*Type) IsListType

func (t *Type) IsListType() bool

func (*Type) IsMapType

func (t *Type) IsMapType() bool

func (*Type) IsNamedType

func (t *Type) IsNamedType() bool

func (*Type) IsNullType

func (t *Type) IsNullType() bool

func (*Type) IsRecordType

func (t *Type) IsRecordType() bool

func (*Type) IsReferenceType

func (t *Type) IsReferenceType() bool

func (*Type) IsTupleType

func (t *Type) IsTupleType() bool

func (*Type) IsUnresolvedType

func (t *Type) IsUnresolvedType() bool

func (*Type) IsValueType

func (t *Type) IsValueType() bool

*

  • Tells if the value will be passed by value or by reference.

func (*Type) LeafType

func (t *Type) LeafType() *NamedTypeData

func (*Type) String

func (t *Type) String() string

func (*Type) TypeClassString

func (t *Type) TypeClassString() string

type TypeLibrary

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

func NewTypeLibrary

func NewTypeLibrary() *TypeLibrary

func (*TypeLibrary) AddGlobalType

func (tl *TypeLibrary) AddGlobalType(name string) (alt *Type)

func (*TypeLibrary) AddPackage

func (tl *TypeLibrary) AddPackage(pkg string) (shortName string)

func (*TypeLibrary) AddType

func (tl *TypeLibrary) AddType(pkg string, name string, t *Type) (alt *Type)

*

  • Adds a type to the type system. If the type already exists then
  • the existing one is returned otherwise a new type is added and returned.
  • Also the type's ID will be set.

func (*TypeLibrary) ForEach

func (tl *TypeLibrary) ForEach(mapFunc func(string, *Type, *bool))

*

  • Returns all the types as a list.

func (*TypeLibrary) GetGlobalType

func (tl *TypeLibrary) GetGlobalType(name string) (alt *Type)

func (*TypeLibrary) GetType

func (tl *TypeLibrary) GetType(pkg string, name string) *Type

func (*TypeLibrary) PackageByShortName

func (tl *TypeLibrary) PackageByShortName(name string) string

func (*TypeLibrary) ShortNameForPackage

func (tl *TypeLibrary) ShortNameForPackage(pkg string) string

func (*TypeLibrary) Signature

func (tl *TypeLibrary) Signature(t *Type) string

func (*TypeLibrary) TransitiveClosureFrom

func (tl *TypeLibrary) TransitiveClosureFrom(startType *Type, filter func(t *Type) bool) ([]*Type, []string)

func (*TypeLibrary) TypeListSignature

func (tl *TypeLibrary) TypeListSignature(types []*Type, argfmt string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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