extism 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/extism/version.rb +1 -1
- data/lib/extism.rb +23 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b540fbbf71c7df6e1830473a374de243616af3fbed809b54e65d54b97521ca4
|
4
|
+
data.tar.gz: 9c37464eb99dd16e7481e6ad1b1a46385b2b8c33861041ede0d055cbdaab2317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 541a4167c2985a8adecb5565d6c4fca794c87de64ccd10bbde410f22c752e9eaaf16686306ec280e9755deeafa47866b6bf26a098cb54199c6185ed6321fadfc
|
7
|
+
data.tar.gz: f3711e03292689c31547d22bc099ec356e07fa7876698c8d00cc5d0ab4b54f0f76377bca5d34789e76766978b9bd620721d11639143fde06572ef07ec07b086f
|
data/Gemfile
CHANGED
data/lib/extism/version.rb
CHANGED
data/lib/extism.rb
CHANGED
@@ -115,6 +115,18 @@ module Extism
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
# A CancelHandle can be used to cancel a running plugin from another thread
|
119
|
+
class CancelHandle
|
120
|
+
def initialize(handle)
|
121
|
+
@handle = handle
|
122
|
+
end
|
123
|
+
|
124
|
+
# Cancel the plugin used to generate the handle
|
125
|
+
def cancel
|
126
|
+
return C.extism_plugin_cancel(@handle)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
118
130
|
# A Plugin represents an instance of your WASM program from the given manifest.
|
119
131
|
class Plugin
|
120
132
|
# Intialize a plugin
|
@@ -131,7 +143,7 @@ module Extism
|
|
131
143
|
end
|
132
144
|
code = FFI::MemoryPointer.new(:char, wasm.bytesize)
|
133
145
|
code.put_bytes(0, wasm)
|
134
|
-
@plugin = C.extism_plugin_new(context.pointer, code, wasm.bytesize, wasi)
|
146
|
+
@plugin = C.extism_plugin_new(context.pointer, code, wasm.bytesize, nil, 0, wasi)
|
135
147
|
if @plugin < 0
|
136
148
|
err = C.extism_error(@context.pointer, -1)
|
137
149
|
if err&.empty?
|
@@ -161,7 +173,7 @@ module Extism
|
|
161
173
|
end
|
162
174
|
code = FFI::MemoryPointer.new(:char, wasm.bytesize)
|
163
175
|
code.put_bytes(0, wasm)
|
164
|
-
ok = C.extism_plugin_update(@context.pointer, @plugin, code, wasm.bytesize, wasi)
|
176
|
+
ok = C.extism_plugin_update(@context.pointer, @plugin, code, wasm.bytesize, nil, 0, wasi)
|
165
177
|
if !ok
|
166
178
|
err = C.extism_error(@context.pointer, @plugin)
|
167
179
|
if err&.empty?
|
@@ -219,6 +231,11 @@ module Extism
|
|
219
231
|
C.extism_plugin_free(@context.pointer, @plugin)
|
220
232
|
@plugin = -1
|
221
233
|
end
|
234
|
+
|
235
|
+
# Get a CancelHandle for a plugin
|
236
|
+
def cancel_handle
|
237
|
+
return CancelHandle.new(C.extism_plugin_cancel_handle(@context.pointer, @plugin))
|
238
|
+
end
|
222
239
|
end
|
223
240
|
|
224
241
|
private
|
@@ -230,8 +247,8 @@ module Extism
|
|
230
247
|
ffi_lib "extism"
|
231
248
|
attach_function :extism_context_new, [], :pointer
|
232
249
|
attach_function :extism_context_free, [:pointer], :void
|
233
|
-
attach_function :extism_plugin_new, [:pointer, :pointer, :uint64, :bool], :int32
|
234
|
-
attach_function :extism_plugin_update, [:pointer, :int32, :pointer, :uint64, :bool], :bool
|
250
|
+
attach_function :extism_plugin_new, [:pointer, :pointer, :uint64, :pointer, :uint64, :bool], :int32
|
251
|
+
attach_function :extism_plugin_update, [:pointer, :int32, :pointer, :uint64, :pointer, :uint64, :bool], :bool
|
235
252
|
attach_function :extism_error, [:pointer, :int32], :string
|
236
253
|
attach_function :extism_plugin_call, [:pointer, :int32, :string, :pointer, :uint64], :int32
|
237
254
|
attach_function :extism_plugin_function_exists, [:pointer, :int32, :string], :bool
|
@@ -241,5 +258,7 @@ module Extism
|
|
241
258
|
attach_function :extism_plugin_free, [:pointer, :int32], :void
|
242
259
|
attach_function :extism_context_reset, [:pointer], :void
|
243
260
|
attach_function :extism_version, [], :string
|
261
|
+
attach_function :extism_plugin_cancel_handle, [:pointer, :int32], :pointer
|
262
|
+
attach_function :extism_plugin_cancel, [:pointer], :bool
|
244
263
|
end
|
245
264
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|