Commit Graph

11 Commits

Author SHA1 Message Date
Benjamin Eckel
1024bb6d12 Implement Elixir / Erlang Host SDK 2022-10-19 14:12:56 -05:00
Benjamin Eckel
85b3aece6f Add version to Host SDK and all clients 2022-10-17 09:25:22 -05:00
zach
87be73570d Add ExtismContext to SDK + better errors for failed register/update (#19)
- Adds `ExtismContext` instead of global `PLUGINS` registry
- Adds `extism_context_new`, `extism_context_free` and
`extism_context_reset`
- Requires updating nearly every SDK function to add context parameter
- Renames some SDK functions to follow better naming conventions
   - `extism_plugin_register` -> `extism_plugin_new`
   - `extism_output_get` -> `extism_plugin_output_data`
   - `extism_output_length` -> `extism_plugin_output_length`
   - `extism_call` -> `extism_plugin_call`
- Updates `extism_error` to return the context error when -1 issued for
the plug-in ID
- Adds `extism_plugin_free` to remove an existing plugin
- Updates SDKs to include these functions
- Updates SDK examples and comments

Co-authored-by: Steve Manuel <steve@dylib.so>
2022-09-20 14:53:15 -06:00
zach
4a49408045 fix: handle large allocations (missing commits) (#14) 2022-09-13 00:17:05 -06:00
zach
8bc608d1e9 feat: access input/output buffers directly (#11)
This PR updates `extism_output_get` to return an actual pointer to the
output value (`const uint8_t* extism_output_get(PluginIndex plugin)`
instead of `void extism_output_get(PluginIndex plugin, uint8_t *buffer,
uint64_t length)`), this pointer will only be valid until the next call,
but it makes it possible to access the output data without copying.

The input buffer is also not copied and the same issue applies: 
the input buffer must not change during `call`.

Co-authored-by: Steve Manuel <steve@dylib.so>
2022-09-12 09:34:50 -06:00
zach
7b27d4f883 feat: add extism_plugin_update (#6)
This gives host the ability to re-use plugin descriptors instead of
loading a new plugin each time. The plugin memory and everything is
reset, so no state is shared with the newly loaded plugin.

Co-authored-by: Steve Manuel <steve@dylib.so>
2022-09-09 00:39:57 -06:00
Benjamin Eckel
ffa01403a3 feat(ruby-sdk): create Extism module / namespace (#5)
I noticed when calling set_log_file that it's on the top-level namespace.
And so is the rest of the gem. It's not a good idea to do this as it
pollutes the user's application. Best practice is to wrap all code in a
module which by convention is the gem name.

I was also getting `Uninitialized constant FFI:NIL` and in the
set_log_file method and I could not tell why it was needed. I changed it
to a regular ruby nil. If it's needed for some reason I'll change it
back or move to another PR.
2022-09-04 17:05:10 -06:00
Benjamin Eckel
bf2509c1e7 Safe access to nilable error
There appears to be a situation in which this err can be nil
2022-09-04 12:36:30 -05:00
zach
afe66b0b1c fix: typos 2022-08-26 06:36:52 -07:00
zach
64856207d0 refactor: port over missing changes 2022-08-25 20:26:36 -07:00
Steve Manuel
e27fae9193 v0.0.1 alpha
Co-authored-by: Zach Shipko <zach@dylib.so>
2022-08-25 14:36:47 -06:00