Hyperon C
Loading...
Searching...
No Matches
Module Interface

Interfaces for module loading, defining module formats, and package management. More...

Classes

struct  metta_mod_ref_t
 MettaMod C API wrapper. More...
struct  module_loader_t
 A C representation of the Rust [ModuleLoader] interface. User can provide [ModuleLoader] methods implemented in C. More...
struct  module_id_t
 Identifies a loaded module inside a specific metta_t MeTTa runner. More...
struct  module_descriptor_t
 Identifies the properties on a specific module, including its name and version. More...
struct  fs_module_format_t
 A table of functions to load MeTTa modules from an arbitrary format. More...

Functions

void run_context_init_self_module (struct run_context_t *run_context, struct space_t *space, const char *resource_dir_path)
 Called within a module loader function to initialize the new module.
struct module_id_t run_context_load_module (struct run_context_t *run_context, const char *name)
 Resolves a module name in the context of a running module, and loads that module if it's not already loaded.
void run_context_import_dependency (struct run_context_t *run_context, struct module_id_t mod_id)
 Imports a dependency module into the currently running module. This is "import *" behavior.
struct tokenizer_t metta_mod_ref_tokenizer (const struct metta_mod_ref_t *mod_ref)
 Returns tokenizer of the MeTTa module.
struct module_descriptor_t module_descriptor_new (const char *name)
 Creates a new module_descriptor_t with the specified name.
struct module_descriptor_t module_descriptor_clone (const struct module_descriptor_t *descriptor)
 Creates a new module_descriptor_t that is a clone of the argument passed.
void module_descriptor_free (struct module_descriptor_t descriptor)
 Frees a module_descriptor_t.
bool module_id_is_valid (const struct module_id_t *mod_id)
 Returns true is a module_id_t is valid, otherwise returns false

Detailed Description

Interfaces for module loading, defining module formats, and package management.

This interface includes structures and functions to define module formats and loader functions, as well as the API for accessing the MeTTa package manager

Function Documentation

◆ metta_mod_ref_tokenizer()

struct tokenizer_t metta_mod_ref_tokenizer ( const struct metta_mod_ref_t * mod_ref)

Returns tokenizer of the MeTTa module.

Parameters
[in]mod_refA pointer to the metta_mod_ref_t
Returns
tokenizer_t instance

◆ module_descriptor_clone()

struct module_descriptor_t module_descriptor_clone ( const struct module_descriptor_t * descriptor)

Creates a new module_descriptor_t that is a clone of the argument passed.

Parameters
[in]descriptorThe module_descriptor_t to clone
Returns
The new module_descriptor_t
Note
The returned module_descriptor_t must be freed with module_descriptor_free()

◆ module_descriptor_free()

void module_descriptor_free ( struct module_descriptor_t descriptor)

Frees a module_descriptor_t.

Parameters
[in]descriptorThe module_descriptor_t to free

◆ module_descriptor_new()

struct module_descriptor_t module_descriptor_new ( const char * name)

Creates a new module_descriptor_t with the specified name.

Parameters
[in]nameA C-style string containing the name of the module
Returns
The new module_descriptor_t
Note
The returned module_descriptor_t must be freed with module_descriptor_free()

◆ module_id_is_valid()

bool module_id_is_valid ( const struct module_id_t * mod_id)

Returns true is a module_id_t is valid, otherwise returns false

Parameters
[in]mod_idA pointer to the module_id_t to test for validity
Returns
true if the module_id_t is valid, otherwise returns false

◆ run_context_import_dependency()

void run_context_import_dependency ( struct run_context_t * run_context,
struct module_id_t mod_id )

Imports a dependency module into the currently running module. This is "import *" behavior.

Parameters
[in]run_contextA pointer to the run_context_t to access the runner API
[in]mod_idThe loaded module_id_t of the module to import

◆ run_context_init_self_module()

void run_context_init_self_module ( struct run_context_t * run_context,
struct space_t * space,
const char * resource_dir_path )

Called within a module loader function to initialize the new module.

Parameters
[in]run_contextA pointer to the run_context_t to access the runner API
[in]spaceA pointer to a handle for the new module's space
[in]resource_dir_pathA C-style string specifying a file system path to use as the module's resource directory. Passing NULL means the module does not have a resource directory
Note
this function must be called exactly once within a module loader function

◆ run_context_load_module()

struct module_id_t run_context_load_module ( struct run_context_t * run_context,
const char * name )

Resolves a module name in the context of a running module, and loads that module if it's not already loaded.

Parameters
[in]run_contextA pointer to the run_context_t to access the runner API
[in]nameA C-style string containing the module name
Returns
The module_id_t for the loaded module, or invalid if there was an error