mirror of
https://github.com/navidrome/navidrome.git
synced 2026-02-02 06:24:14 +00:00
- Implemented hostgen tool to generate wrappers from annotated Go interfaces. - Added command-line flags for input/output directories and package name. - Introduced parsing and code generation logic for host services. - Created test data for various service interfaces and expected generated code. - Added documentation for host services and annotations for code generation. - Implemented SubsonicAPI service with corresponding generated code.
38 lines
985 B
Go
38 lines
985 B
Go
// Code generated by hostgen. DO NOT EDIT.
|
|
|
|
package testpkg
|
|
|
|
import (
|
|
"context"
|
|
|
|
extism "github.com/extism/go-sdk"
|
|
)
|
|
|
|
// RegisterCounterHostFunctions registers Counter service host functions.
|
|
// The returned host functions should be added to the plugin's configuration.
|
|
func RegisterCounterHostFunctions(service CounterService) []extism.HostFunction {
|
|
return []extism.HostFunction{
|
|
newCounterCountHostFunction(service),
|
|
}
|
|
}
|
|
|
|
func newCounterCountHostFunction(service CounterService) extism.HostFunction {
|
|
return extism.NewHostFunctionWithStack(
|
|
"counter_count",
|
|
func(ctx context.Context, p *extism.CurrentPlugin, stack []uint64) {
|
|
// Read parameters from stack
|
|
name, err := p.ReadString(stack[0])
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
// Call the service method
|
|
value := service.Count(ctx, name)
|
|
// Write return values to stack
|
|
stack[0] = extism.EncodeI32(value)
|
|
},
|
|
[]extism.ValueType{extism.ValueTypePTR},
|
|
[]extism.ValueType{extism.ValueTypeI32},
|
|
)
|
|
}
|