Documentation ¶
Index ¶
- Variables
- func FindServices(pkgs []*packages.Package, systemPaths *config.SystemPaths, ...) error
- func GenerateConstants(goData []byte) (string, error)
- func LoadPackages(buildFlags []string, patterns ...string) (pkgs []*packages.Package, err error)
- func ResolvePatterns(buildFlags []string, patterns ...string) (paths []string, err error)
- func ResolveSystemPaths(buildFlags []string) (paths *config.SystemPaths, err error)
- type ErrorReport
- func (report *ErrorReport) Debugf(format string, a ...any)
- func (report *ErrorReport) Error() string
- func (report *ErrorReport) Errorf(format string, a ...any)
- func (report *ErrorReport) Errors() []string
- func (report *ErrorReport) HasErrors() bool
- func (report *ErrorReport) HasWarnings() bool
- func (report *ErrorReport) Infof(format string, a ...any)
- func (report *ErrorReport) Statusf(format string, a ...any)
- func (report *ErrorReport) Warningf(format string, a ...any)
- func (report *ErrorReport) Warnings() []string
- type Generator
Constants ¶
This section is empty.
Variables ¶
var ErrBadApplicationPackage = errors.New("package " + config.WailsAppPkgPath + ": function NewService has wrong signature: is the Wails v3 module properly installed?")
ErrBadApplicationPackage indicates that the Wails application package has invalid content.
var ErrNoApplicationPackage = errors.New("Wails application package not found at canonical import path ('" + config.WailsAppPkgPath + "'): is the Wails v3 module properly installed?")
ErrNoApplicationPackage indicates that the canonical path for the Wails application package did not match any actual package.
var ErrNoContextPackage = errors.New("standard context package not found at canonical import path ('context'): is the Wails v3 module properly installed?")
ErrNoContextPackage indicates that the canonical path for the standard context package did not match any actual package.
var ErrNoPackages = errors.New("the given patterns matched no packages")
ErrNoPackages is returned by Generator.Generate when LoadPackages returns no error and no packages.
Functions ¶
func FindServices ¶
func FindServices(pkgs []*packages.Package, systemPaths *config.SystemPaths, logger config.Logger, yield func(*types.TypeName) bool) error
FindServices scans the given packages for invocations of the NewService function from the Wails application package.
Whenever one is found and the type of its unique argument is a valid service type, the corresponding named type object is passed to yield.
Results are deduplicated, i.e. yield is called at most once per object.
If yield returns false, FindBoundTypes returns immediately.
func GenerateConstants ¶
func LoadPackages ¶
LoadPackages loads the packages specified by the given patterns and their whole dependency tree. It returns a slice containing all packages that match the given patterns and all of their direct and indirect dependencies.
The returned slice is in post-order w.r.t. the dependency relation, i.e. if package A depends on package B, then package B precedes package A.
All returned package instances include syntax trees and full type information.
Syntax is loaded in the context of a global token.FileSet, which is available through the field packages.Package.Fset on each returned package. Therefore, source positions are canonical across all loaded packages.
func ResolvePatterns ¶
ResolvePatterns returns a slice containing all package paths that match the given patterns, according to the underlying build tool and within the context of the current working directory.
func ResolveSystemPaths ¶
func ResolveSystemPaths(buildFlags []string) (paths *config.SystemPaths, err error)
ResolveSystemPaths resolves paths for the Wails system
Types ¶
type ErrorReport ¶
type ErrorReport struct {
// contains filtered or unexported fields
}
ErrorReport accumulates and logs error and warning messages, with deduplication.
It implements the error interface; the Error method returns a report counting messages emitted so far.
It also implements the interface config.Logger for convenience.
func NewErrorReport ¶
func NewErrorReport(logger config.Logger) *ErrorReport
NewError report initialises an ErrorReport instance with the provided Logger implementation.
If logger is nil, messages will be accumulated but not logged.
func (*ErrorReport) Debugf ¶
func (report *ErrorReport) Debugf(format string, a ...any)
Debugf forwards the given informational message to the logger instance provided during initialisation.
This method is here just for convenience and performs no deduplication.
func (*ErrorReport) Error ¶
func (report *ErrorReport) Error() string
Error returns a string reporting the number of errors and warnings emitted so far.
func (*ErrorReport) Errorf ¶
func (report *ErrorReport) Errorf(format string, a ...any)
Errorf formats an error message and adds it to the report. If not already present, the message is forwarded to the logger instance provided during initialisation.
func (*ErrorReport) Errors ¶
func (report *ErrorReport) Errors() []string
Errors returns the list of error messages that have been added to the report. The order is randomised.
func (*ErrorReport) HasErrors ¶
func (report *ErrorReport) HasErrors() bool
HasErrors returns true if at least one error has been added to the report.
func (*ErrorReport) HasWarnings ¶
func (report *ErrorReport) HasWarnings() bool
HasWarnings returns true if at least one warning has been added to the report.
func (*ErrorReport) Infof ¶
func (report *ErrorReport) Infof(format string, a ...any)
Infof forwards the given informational message to the logger instance provided during initialisation.
This method is here just for convenience and performs no deduplication.
func (*ErrorReport) Statusf ¶
func (report *ErrorReport) Statusf(format string, a ...any)
Statusf forwards the given status message to the logger instance provided during initialisation.
This method is here just for convenience and performs no deduplication.
func (*ErrorReport) Warningf ¶
func (report *ErrorReport) Warningf(format string, a ...any)
Warningf formats an error message and adds it to the report. If not already present, the message is forwarded to the logger instance provided during initialisation.
func (*ErrorReport) Warnings ¶
func (report *ErrorReport) Warnings() []string
Warnings returns the list of warning messages that have been added to the report. The order is randomised.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator wraps all bookkeeping data structures that are needed to generate bindings for a set of packages.
func NewGenerator ¶
func NewGenerator(options *flags.GenerateBindingsOptions, creator config.FileCreator, logger config.Logger) *Generator
NewGenerator configures a new generator instance. The options argument must not be nil. If creator is nil, no output file will be created. If logger is not nil, it is used to report messages interactively.
func (*Generator) Generate ¶
Generate runs the binding generation process for the packages specified by the given patterns.
Concurrent or repeated calls to Generate with the same receiver are not allowed.
The stats result field is never nil.
The error result field is nil in case of complete success (no warning). Otherwise, it may either report errors that occured while loading the initial set of packages, or errors returned by the static analyser, or be an ErrorReport instance.
If error is an ErrorReport, it may have accumulated no errors, just warnings. When this is the case, all bindings have been generated successfully.
Parsing/type-checking errors or errors encountered while writing individual files will be printed directly to the config.Logger instance provided during initialisation.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
_reference
This example explores exhaustively the behaviour of encoding/json when handling types that implement marshaler interfaces.
|
This example explores exhaustively the behaviour of encoding/json when handling types that implement marshaler interfaces. |
testcases
|
|