Documentation ¶
Overview ¶
Package macro contains generic macro execution utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrStop = errors.New("macro exit")
ErrStop is special error to interrupt AST traversal.
Functions ¶
This section is empty.
Types ¶
type ASTInfo ¶
type ASTInfo struct { // Current file. File *ast.File // Current token set. FileSet *token.FileSet }
ASTInfo contains AST of Go source file.
func (ASTInfo) AddImports ¶
func (c ASTInfo) AddImports(newImports ...*ast.ImportSpec)
AddImports adds new imports to file. If import already exists AddImports does nothing.
type Context ¶
type Context struct { *astutil.Cursor Pre bool Delayed Delayed Report func(Report) // AST objects. ASTInfo // Type checker objects. TypeInfo // Parsed magic comments. Pragmas pragma.Pragmas }
Context is a macro context.
type Delayed ¶
type Delayed map[string]DelayedTypes
Delayed is mapping from macro name to DelayedTypes
func (Delayed) Add ¶
Add adds type names from package. If declaration have a magic comment, type name will be added.
func (Delayed) AddDecls ¶
AddDecls adds type names from declarations. If declaration have a magic comment, type name will be added.
func (Delayed) AddTypeName ¶
AddTypeName adds type name to list.
type DelayedTypes ¶
type DelayedTypes map[string]struct{}
DelayedTypes is a list of types will be changed by macros.
func (DelayedTypes) AddTypeName ¶
func (d DelayedTypes) AddTypeName(typeName *types.TypeName)
AddTypeName adds type name to list.
type HandlerFunc ¶
HandlerFunc is type adapter for Handler interface.
Directories ¶
Path | Synopsis |
---|---|
Package derive contains some utilities and helpers to build deriving macros.
|
Package derive contains some utilities and helpers to build deriving macros. |
Package internal contains unexported implementation details of gomacro.
|
Package internal contains unexported implementation details of gomacro. |
loader
Package loader contains Go source loading utilities.
|
Package loader contains Go source loading utilities. |
rewriter
Package rewriter contains Go source rewriting utilities.
|
Package rewriter contains Go source rewriting utilities. |
testutil
Package testutil contains testing utilities.
|
Package testutil contains testing utilities. |
macros
|
|
derive/cursor
Package cursor contains derive_binary macro.
|
Package cursor contains derive_binary macro. |
derive/deepcopy
Package deepcopy contains derive_copy macro.
|
Package deepcopy contains derive_copy macro. |
derive/zero
Package zero contains derive_zero macro.
|
Package zero contains derive_zero macro. |
Package pragma contains magic comment parser.
|
Package pragma contains magic comment parser. |
Package runner contains macro runner implementation.
|
Package runner contains macro runner implementation. |