Documentation
¶
Overview ¶
Package plugin provides plugin system for Nxlang Plugins are Go-based extensions that can be loaded into the Nxlang VM
Index ¶
- func Call(pluginName, funcName string, args ...types.Object) (types.Object, error)
- func Load(pluginPath string) error
- type NxPlugin
- type PluginFunction
- type PluginInfo
- type PluginLoader
- func (pl *PluginLoader) GetFunction(pluginName, funcName string) (func(args ...types.Object) types.Object, error)
- func (pl *PluginLoader) ListPlugins() []PluginInfo
- func (pl *PluginLoader) LoadPlugin(pluginPath string) error
- func (pl *PluginLoader) LoadPluginFromDir(dirPath string) error
- func (pl *PluginLoader) UnloadPlugin(pluginPathOrName string) error
- type PluginWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type NxPlugin ¶
type NxPlugin interface {
// Info returns plugin metadata
Info() PluginInfo
// Initialize is called when the plugin is loaded
Initialize() error
// GetFunctions returns all functions exported by this plugin
GetFunctions() []PluginFunction
// Cleanup is called when the plugin is unloaded
Cleanup() error
}
NxPlugin is the interface that all Nxlang plugins must implement
type PluginFunction ¶
type PluginFunction struct {
Name string // Function name as seen in Nxlang
Fn func(args ...types.Object) types.Object // The actual function
}
PluginFunction represents a function exported by a plugin
type PluginInfo ¶
type PluginInfo struct {
Name string // Plugin name
Version string // Plugin version
Description string // Plugin description
Author string // Plugin author
}
PluginInfo contains metadata about a plugin
type PluginLoader ¶
type PluginLoader struct {
// contains filtered or unexported fields
}
PluginLoader handles loading and managing plugins
func GetGlobalLoader ¶
func GetGlobalLoader() *PluginLoader
GetGlobalLoader returns the global plugin loader
func NewPluginLoader ¶
func NewPluginLoader() *PluginLoader
NewPluginLoader creates a new plugin loader
func (*PluginLoader) GetFunction ¶
func (pl *PluginLoader) GetFunction(pluginName, funcName string) (func(args ...types.Object) types.Object, error)
GetFunction returns a function from a loaded plugin
func (*PluginLoader) ListPlugins ¶
func (pl *PluginLoader) ListPlugins() []PluginInfo
ListPlugins returns information about all loaded plugins
func (*PluginLoader) LoadPlugin ¶
func (pl *PluginLoader) LoadPlugin(pluginPath string) error
LoadPlugin loads a plugin from a .nxp file (Nxlang plugin) The plugin file should be a Go plugin (.so on Linux, .dylib on macOS, .dll on Windows)
func (*PluginLoader) LoadPluginFromDir ¶
func (pl *PluginLoader) LoadPluginFromDir(dirPath string) error
LoadPluginFromDir loads all plugins from a directory
func (*PluginLoader) UnloadPlugin ¶
func (pl *PluginLoader) UnloadPlugin(pluginPathOrName string) error
UnloadPlugin unloads a plugin
type PluginWrapper ¶
type PluginWrapper struct {
// contains filtered or unexported fields
}
PluginWrapper wraps a loaded Go plugin
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pluginhelper provides helper functions for creating Nxlang plugins Plugin developers can use this package to simplify plugin development
|
Package pluginhelper provides helper functions for creating Nxlang plugins Plugin developers can use this package to simplify plugin development |