codegen

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func This

func This() string

This returns the string variable used by members to refer to themselves.

Types

type Function

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

Function represents a free function, not a method, for Go code to be generated.

func NewCommentedFunction

func NewCommentedFunction(pkg, name string,
	params, ret, block []jen.Code,
	comment jen.Code) *Function

NewCommentedFunction creates a new function with a comment.

func NewFunction

func NewFunction(pkg, name string,
	params, ret, block []jen.Code) *Function

NewFunction creates a new function without any comments.

func (Function) Call

func (m Function) Call(params ...jen.Code) jen.Code

Call generates the Go code required to call this function, with qualifier if required.

func (Function) Definition

func (m Function) Definition() jen.Code

Definition generates the Go code required to define and implement this function.

func (Function) Name

func (m Function) Name() string

Name returns the identifier of this function.

type FunctionSignature

type FunctionSignature struct {
	Name    string
	Params  []jen.Code
	Ret     []jen.Code
	Comment string
}

type Interface

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

func NewInterface

func NewInterface(pkg, name string,
	funcs []FunctionSignature,
	comment string) *Interface

func (Interface) Definition

func (i Interface) Definition() jen.Code

type Method

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

Method represents a method on a type, not a free function, for Go code to be generated.

func NewCommentedPointerMethod

func NewCommentedPointerMethod(pkg, name, structName string,
	params, ret, block []jen.Code,
	comment jen.Code) *Method

NewCommentedPointerMethod defines a commented method for the pointer to a type.

func NewCommentedValueMethod

func NewCommentedValueMethod(pkg, name, structName string,
	params, ret, block []jen.Code,
	comment jen.Code) *Method

NewCommentedValueMethod defines a commented method for the value of a type.

func NewPointerMethod

func NewPointerMethod(pkg, name, structName string,
	params, ret, block []jen.Code) *Method

NewPointerMethod defines a method for the pointer to a type. It is not commented.

func NewValueMethod

func NewValueMethod(pkg, name, structName string,
	params, ret, block []jen.Code) *Method

NewValueMethod defines a method for the value of a type. It is not commented.

func (Method) Call

func (m Method) Call(on string, params ...jen.Code) jen.Code

Call generates the Go code required to call this method, with qualifier if required.

func (Method) Definition

func (m Method) Definition() jen.Code

Definition generates the Go code required to define and implement this method.

func (Method) Name

func (m Method) Name() string

Name returns the identifier of this function.

type Struct

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

Struct defines a struct-based type, its functions, and its methods for Go code generation.

func NewStruct

func NewStruct(comment jen.Code,
	name string,
	methods []*Method,
	constructors []*Function,
	members []jen.Code) *Struct

NewStruct creates a new commented Struct type.

func (*Struct) Constructors

func (s *Struct) Constructors(name string) *Function

Constructors obtains the Go code to be generated for the function with a specific name. Panics if no such function exists.

func (*Struct) Definition

func (s *Struct) Definition() jen.Code

Definition generates the Go code required to define and implement this struct, its methods, and its functions.

func (*Struct) Method

func (s *Struct) Method(name string) *Method

Method obtains the Go code to be generated for the method with a specific name. Panics if no such method exists.

type Typedef

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

Typedef defines a non-struct-based type, its functions, and its methods for Go code generation.

func NewTypedef

func NewTypedef(comment jen.Code,
	name string,
	concreteType jen.Code,
	methods []*Method,
	constructors []*Function) *Typedef

NewTypedef creates a new commented Typedef.

func (*Typedef) Constructors

func (t *Typedef) Constructors(name string) *Function

Constructors obtains the Go code to be generated for the function with a specific name. Panics if no such function exists.

func (*Typedef) Definition

func (t *Typedef) Definition() jen.Code

Definition generates the Go code required to define and implement this type, its methods, and its functions.

func (*Typedef) Method

func (t *Typedef) Method(name string) *Method

Method obtains the Go code to be generated for the method with a specific name. Panics if no such method exists.

Jump to

Keyboard shortcuts

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