Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add CompiledPlugin #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/main/java/org/extism/sdk/LibExtism.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ Pointer extism_function_new(String name,
* @return pointer to the plugin, or null in case of error
*/
Pointer extism_plugin_new(byte[] wasm, long wasmSize, Pointer[] functions, int nFunctions, boolean withWASI, Pointer[] errmsg);
Pointer extism_plugin_new(Pointer compiledPluginPointer, Pointer[] errmsg);
Pointer extism_plugin_new_with_fuel_limit(byte[] wasm, long wasmSize, Pointer[] functions, int nFunctions, boolean withWASI, long fuelLimit, Pointer[] errmsg);

/**
* Create a new compiled plugin.
*/
Pointer extism_compiled_plugin_new(byte[] wasm, long wasmSize, Pointer[] functions, int nFunctions, boolean withWASI, Pointer[] errmsg);


/**
* Free error message from `extism_plugin_new`
Expand All @@ -135,7 +141,7 @@ Pointer extism_function_new(String name,


/**
* Calls a function from the @{@link Plugin} at the given {@code pluginIndex}.
* Calls a function from a @{@link Plugin}.
*
* @param pluginPointer
* @param function_name is the function to call
Expand All @@ -145,6 +151,19 @@ Pointer extism_function_new(String name,
*/
int extism_plugin_call(Pointer pluginPointer, String function_name, byte[] data, int dataLength);


/**
* Calls a function from a @{@link Plugin} with the given host context.
*
* @param pluginPointer
* @param function_name is the function to call
* @param data is the data input data
* @param dataLength is the data input data length
* @param hostContext is the host context value
* @return the result code of the plugin call. non-zero in case of error, {@literal 0} otherwise.
*/
int extism_plugin_call_with_host_context(Pointer pluginPointer, String function_name, byte[] data, int dataLength, Pointer hostContext);

/**
* Returns
* @return the length of the output data in bytes.
Expand All @@ -158,10 +177,15 @@ Pointer extism_function_new(String name,
Pointer extism_plugin_output_data(Pointer pluginPointer);

/**
* Remove a plugin from the
* Free a plugin
*/
void extism_plugin_free(Pointer pluginPointer);

/**
* Free a compiled plugin
*/
void extism_compiled_plugin_free(Pointer compiledPluginPointer);

/**
* Update plugin config values, this
* @param json
Expand Down
Loading