55 const std::vector<Phasor::Value> &args);
80 explicit FFI(
const std::filesystem::path &pluginFolder,
VM *vm);
92 bool addPlugin(
const std::filesystem::path &pluginPath);
106 bool loadPlugin(
const std::filesystem::path &library,
VM *vm);
113 std::vector<std::string>
scanPlugins(
const std::filesystem::path &folder);
PhasorValue(* PhasorNativeFunction)(PhasorVM *vm, int argc, const PhasorValue *argv)
Signature for a native C function that can be registered with the Phasor VM.
struct PhasorVM PhasorVM
Phasor Virtual Machine pointer.
void unloadAll()
Unloads all currently loaded plugins and clears internal state.
std::vector< Plugin > plugins_
Loaded plugins.
std::filesystem::path pluginFolder_
Plugin search folder.
~FFI()
Destructor. Unloads all loaded plugins.
std::vector< std::string > scanPlugins(const std::filesystem::path &folder)
Scans a folder for plugin libraries.
Value native_add_plugin(const std::vector< Value > &args, VM *vm)
Native function to load a plugin at runtime.
bool loadPlugin(const std::filesystem::path &library, VM *vm)
Loads a single plugin from a library file.
bool addPlugin(const std::filesystem::path &pluginPath)
Adds a single plugin from the specified path.
VM * vm_
Pointer to the Phasor VM.
FFI(const std::filesystem::path &pluginFolder, VM *vm)
Constructs the FFI manager and loads plugins.
A value in the Phasor VM.
void(*)(const PhasorAPI *api, PhasorVM *vm) FFIFunction
The Phasor Programming Language and Runtime.
void register_native_c_func(PhasorVM *vm, const char *name, PhasorNativeFunction func)
The concrete implementation of the PhasorRegisterFunction API call.
Phasor::Value c_native_func_wrapper(PhasorNativeFunction c_func, Phasor::VM *vm, const std::vector< Phasor::Value > &args)
The "trampoline" that wraps a C function from a plugin.
Represents a loaded plugin.
void * handle
POSIX handle for the loaded library.
std::function< void()> shutdown
Optional shutdown callback.
std::string path
Path to the plugin file.
FFIFunction init
Plugin initialization function.
The collection of API functions that the Phasor host provides to the plugin.