plugin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package plugin provides plugin system for Nxlang Plugins are Go-based extensions that can be loaded into the Nxlang VM

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(pluginName, funcName string, args ...types.Object) (types.Object, error)

Call calls a function from a loaded plugin

func Load

func Load(pluginPath string) error

Load loads a plugin using the global loader

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

Jump to

Keyboard shortcuts

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