diff --git a/src/main/java/org/extism/sdk/LibExtism.java b/src/main/java/org/extism/sdk/LibExtism.java index 85dda02..5fd96dc 100644 --- a/src/main/java/org/extism/sdk/LibExtism.java +++ b/src/main/java/org/extism/sdk/LibExtism.java @@ -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` @@ -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 @@ -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. @@ -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