Phasor 2.2.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
Phasor::FFI Class Reference

Manages loading, registering, and unloading native FFI plugins. More...

#include <ffi.hpp>

Collaboration diagram for Phasor::FFI:
[legend]

Public Member Functions

 FFI (const std::filesystem::path &pluginFolder, VM *vm)
 Constructs the FFI manager and loads plugins.
 ~FFI ()
 Destructor. Unloads all loaded plugins.
bool addPlugin (const std::filesystem::path &pluginPath)
 Adds a single plugin from the specified path.
Value native_add_plugin (const std::vector< Value > &args, VM *vm)
 Native function to load a plugin at runtime.

Private Member Functions

bool loadPlugin (const std::filesystem::path &library, VM *vm)
 Loads a single plugin from a library file.
std::vector< std::string > scanPlugins (const std::filesystem::path &folder)
 Scans a folder for plugin libraries.
void unloadAll ()
 Unloads all currently loaded plugins and clears internal state.

Private Attributes

std::vector< Pluginplugins_
 Loaded plugins.
std::filesystem::path pluginFolder_
 Plugin search folder.
VMvm_
 Pointer to the Phasor VM.

Detailed Description

Manages loading, registering, and unloading native FFI plugins.

This class scans a folder for plugins, loads them, registers their functions with the VM, and handles cleanup when destroyed.

Definition at line 47 of file ffi.hpp.

Constructor & Destructor Documentation

◆ FFI()

Phasor::FFI::FFI ( const std::filesystem::path & pluginFolder,
VM * vm )
explicit

Constructs the FFI manager and loads plugins.

Parameters
pluginFolderPath to the folder containing plugins.
vmPointer to the Phasor VM instance to register plugin functions with.

Definition at line 290 of file ffi.cpp.

Here is the call graph for this function:

◆ ~FFI()

Phasor::FFI::~FFI ( )

Destructor. Unloads all loaded plugins.

Definition at line 307 of file ffi.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addPlugin()

bool Phasor::FFI::addPlugin ( const std::filesystem::path & pluginPath)

Adds a single plugin from the specified path.

Parameters
pluginPathPath to the plugin file.
Returns
True if the plugin was added successfully, false otherwise.

Definition at line 211 of file ffi.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadPlugin()

bool Phasor::FFI::loadPlugin ( const std::filesystem::path & library,
VM * vm )
private

Loads a single plugin from a library file.

Loads a plugin, finds its entry point, and initializes it.

Parameters
libraryPath to the shared library file.
vmPointer to the VM to register plugin functions with.
Returns
True if the plugin loaded successfully, false otherwise.

Definition at line 167 of file ffi.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ native_add_plugin()

Value Phasor::FFI::native_add_plugin ( const std::vector< Value > & args,
VM * vm )

Native function to load a plugin at runtime.

Definition at line 312 of file ffi.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scanPlugins()

std::vector< std::string > Phasor::FFI::scanPlugins ( const std::filesystem::path & folder)
private

Scans a folder for plugin libraries.

Scans configured plugin directories for shared libraries.

Parameters
folderPath to the folder to scan.
Returns
A vector of plugin file paths.

Definition at line 219 of file ffi.cpp.

Here is the caller graph for this function:

◆ unloadAll()

void Phasor::FFI::unloadAll ( )
private

Unloads all currently loaded plugins and clears internal state.

Unloads all currently loaded plugins.

Definition at line 277 of file ffi.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ pluginFolder_

std::filesystem::path Phasor::FFI::pluginFolder_
private

Plugin search folder.

Definition at line 96 of file ffi.hpp.

◆ plugins_

std::vector<Plugin> Phasor::FFI::plugins_
private

Loaded plugins.

Definition at line 95 of file ffi.hpp.

◆ vm_

VM* Phasor::FFI::vm_
private

Pointer to the Phasor VM.

Definition at line 97 of file ffi.hpp.


The documentation for this class was generated from the following files: