generator

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package generator contains the generator implementation that manages backends. New backend must implement the backend.Backend interface and be registered into the Generator instance before using.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arguments

type Arguments struct {
	Out *LangSpec
	Req *plugin.Request
	Log backend.LogFunc
}

Arguments contains arguments for generator's Generate method.

type FileManager

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

FileManager manages in-memory files that used during the code generation process.

func NewFileManager

func NewFileManager(log backend.LogFunc) *FileManager

NewFileManager creates a new FileManager.

func (*FileManager) BuildResponse

func (fm *FileManager) BuildResponse() *plugin.Response

BuildResponse creates a plugin.Response containing all files that the FileManager manages. All insertion points will be removed after the response is built.

func (*FileManager) Feed

func (fm *FileManager) Feed(src string, files []*plugin.Generated) error

Feed adds files to the FileManager.

type Generator

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

Generator controls the code generation. The zero value of Generator is ready for use.

func (*Generator) AllBackend

func (g *Generator) AllBackend() []backend.Backend

AllBackend returns all registered backends.

func (*Generator) Generate

func (g *Generator) Generate(args *Arguments) (res *plugin.Response)

Generate generates codes for the target language and executes plugins specified.

func (*Generator) GetBackend

func (g *Generator) GetBackend(name string) backend.Backend

GetBackend returns a backend of the language.

func (*Generator) Name

func (g *Generator) Name() string

Name returns "thriftgo".

func (*Generator) Persist

func (g *Generator) Persist(res *plugin.Response) error

Persist writes generated files into the disk. Each files in the Contents slice must have a legal name.

func (*Generator) RegisterBackend

func (g *Generator) RegisterBackend(b backend.Backend) error

RegisterBackend adds a backend to the generator.

type LangSpec

type LangSpec struct {
	Language    string
	Options     []plugin.Option
	UsedPlugins []*plugin.Desc
}

LangSpec is the parameter to specify which language to generate codes for and what plugins should be used.

Directories

Path Synopsis
Package backend defines the Backend interface for generators.
Package backend defines the Backend interface for generators.
Package golang is the generator backend for golang.
Package golang is the generator backend for golang.
extension/unknown
Package unknown provides definitions that work with the thriftgo `keep_unknown_fields` option.
Package unknown provides definitions that work with the thriftgo `keep_unknown_fields` option.
templates
Package templates defines templates for generating golang codes.
Package templates defines templates for generating golang codes.

Jump to

Keyboard shortcuts

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