Documentation
¶
Index ¶
- type FileGenerator
- type Generator
- func (g *Generator) AddFilters(filters []types.FilterMatcher)
- func (g *Generator) AddPostprocessors(ppMap map[string][]Postprocessor)
- func (g *Generator) AddProcessConverters(processors []typeconv.ConversionProcessor)
- func (g *Generator) ApplyPreprocessors(preprocs []types.Preprocessor)
- func (g *Generator) Filters() []types.FilterMatcher
- func (g *Generator) Logln(lvl logger.Level, v ...interface{})
- func (g *Generator) ModPath(n *gir.Namespace) string
- func (g *Generator) ProcessConverter(converter *typeconv.Converter)
- func (g *Generator) Repositories() gir.Repositories
- func (g *Generator) UseNamespace(namespace, version string) *NamespaceGenerator
- type NamespaceGenerator
- func (n *NamespaceGenerator) AddPostprocessors(pps []Postprocessor)
- func (n *NamespaceGenerator) CanGenerate(r *types.Resolved) bool
- func (n *NamespaceGenerator) FileWriter(info cmt.InfoFields) generators.FileWriter
- func (n *NamespaceGenerator) Generate() (map[string][]byte, error)
- func (n *NamespaceGenerator) Logln(lvl logger.Level, v ...interface{})
- func (n *NamespaceGenerator) MakeFile(filename string) *FileGenerator
- func (n *NamespaceGenerator) Namespace() *gir.NamespaceFindResult
- func (n *NamespaceGenerator) Pkgconfig() []string
- type Postprocessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileGenerator ¶
type FileGenerator struct { *NamespaceGenerator BuildTags []string // go:build lines, joined by AND (&&) // contains filtered or unexported fields }
FileGenerator is a file generator.
func NewFileGenerator ¶
func NewFileGenerator(n *NamespaceGenerator, name string, isRoot bool) *FileGenerator
NewFileGenerator creates a new empty FileGenerator instance.
func (*FileGenerator) CIncludes ¶
func (f *FileGenerator) CIncludes() []string
CIncludes returns this file's sorted C includes, including the repository's C includes.
func (*FileGenerator) Generate ¶
func (f *FileGenerator) Generate() ([]byte, error)
Generate generates the final file content, completed with gofmt.
func (*FileGenerator) Header ¶
func (f *FileGenerator) Header() *file.Header
Header returns the current file's header.
func (*FileGenerator) IsEmpty ¶
func (f *FileGenerator) IsEmpty() bool
IsEmpty returns true if the file is empty.
func (*FileGenerator) Logln ¶
func (f *FileGenerator) Logln(lvl logger.Level, v ...interface{})
func (*FileGenerator) Pen ¶
func (f *FileGenerator) Pen() *pen.Pen
Pen returns the current file's writing pen.
type Generator ¶
type Generator struct { Logger *log.Logger LogLevel logger.Level // contains filtered or unexported fields }
Generator is a big generator that manages multiple repositories.
func NewGenerator ¶
func NewGenerator(repos gir.Repositories, modPath types.ModulePathFunc) *Generator
NewGenerator creates a new generator with sane defaults.
func (*Generator) AddFilters ¶
func (g *Generator) AddFilters(filters []types.FilterMatcher)
AddFilters adds the given list of filters.
func (*Generator) AddPostprocessors ¶
func (g *Generator) AddPostprocessors(ppMap map[string][]Postprocessor)
AddPostprocessor registers the given postprocessors inside a map that has keys matching the namespace.
func (*Generator) AddProcessConverters ¶
func (g *Generator) AddProcessConverters(processors []typeconv.ConversionProcessor)
AddProcessConverters adds the given list of conversion processors.
func (*Generator) ApplyPreprocessors ¶
func (g *Generator) ApplyPreprocessors(preprocs []types.Preprocessor)
AddPreprocessors applies the given list of preprocessors.
func (*Generator) Filters ¶
func (g *Generator) Filters() []types.FilterMatcher
Filters returns the generator's list of type filters.
func (*Generator) ModPath ¶
ModPath creates an import path from the user's ModulePathFunc given into the constructor.
func (*Generator) ProcessConverter ¶
ProcessConverter satisfies the typeconv.ConversionProcessor interface.
func (*Generator) Repositories ¶
func (g *Generator) Repositories() gir.Repositories
Repositories returns the generator's repositories.
func (*Generator) UseNamespace ¶
func (g *Generator) UseNamespace(namespace, version string) *NamespaceGenerator
UseNamespace creates a new namespace generator using the given namespace.
type NamespaceGenerator ¶
type NamespaceGenerator struct { *Generator PkgPath string PkgName string PkgVersion string Files map[string]*FileGenerator // contains filtered or unexported fields }
NamespaceGenerator manages generation of a namespace. A namespace contains various files, which are created using the FileWriter method.
func NewNamespaceGenerator ¶
func NewNamespaceGenerator(g *Generator, n *gir.NamespaceFindResult) *NamespaceGenerator
NewNamespaceGenerator creates a new NamespaceGenerator from the given generator and namespace.
func (*NamespaceGenerator) AddPostprocessors ¶
func (n *NamespaceGenerator) AddPostprocessors(pps []Postprocessor)
AddPostprocessors adds the given list of postprocessors.
func (*NamespaceGenerator) CanGenerate ¶
func (n *NamespaceGenerator) CanGenerate(r *types.Resolved) bool
CanGenerate checks if a type can be generated or not.
func (*NamespaceGenerator) FileWriter ¶
func (n *NamespaceGenerator) FileWriter(info cmt.InfoFields) generators.FileWriter
FileWriter returns the respective file writer from the given InfoFields.
func (*NamespaceGenerator) Generate ¶
func (n *NamespaceGenerator) Generate() (map[string][]byte, error)
Generate generates everything in the current namespace into files. The returned map maps the filename to the raw file content.
func (*NamespaceGenerator) Logln ¶
func (n *NamespaceGenerator) Logln(lvl logger.Level, v ...interface{})
func (*NamespaceGenerator) MakeFile ¶
func (n *NamespaceGenerator) MakeFile(filename string) *FileGenerator
MakeFile makes a new FileGenerator for the given filename or returns an existing one.
func (*NamespaceGenerator) Namespace ¶
func (n *NamespaceGenerator) Namespace() *gir.NamespaceFindResult
Namespace returns the generator's namespace that includes the repository it's in.
func (*NamespaceGenerator) Pkgconfig ¶
func (n *NamespaceGenerator) Pkgconfig() []string
Pkgconfig returns the current repository's pkg-config names.
type Postprocessor ¶
type Postprocessor func(n *NamespaceGenerator) error
Postprocessor describes a processor function that modifies a namespace. It is called right before files are finalized within the namespace generator.
Directories
¶
Path | Synopsis |
---|---|
Package cmt provides functions that parse and render GIR comments into nice and conventional Go comments.
|
Package cmt provides functions that parse and render GIR comments into nice and conventional Go comments. |
Package file provides per-file state helpers, such as for tracking imports.
|
Package file provides per-file state helpers, such as for tracking imports. |
callable
Package callable provides a generic callable generator.
|
Package callable provides a generic callable generator. |
iface
Package iface provides an interface generator.
|
Package iface provides an interface generator. |
Package gotmpl provides abstractions around text/template to better generate Go files.
|
Package gotmpl provides abstractions around text/template to better generate Go files. |
Package logger provides abstractions over girgen's logging.
|
Package logger provides abstractions over girgen's logging. |
Package strcases provides helper functions to convert between string cases, such as Pascal Case, snake_case and Go's Mixed Caps, along with various special cases.
|
Package strcases provides helper functions to convert between string cases, such as Pascal Case, snake_case and Go's Mixed Caps, along with various special cases. |
typeconv
Package typeconv provides conversions between C and Go types.
|
Package typeconv provides conversions between C and Go types. |