Compare commits

...

7 Commits

Author SHA1 Message Date
Benjamin Eckel
b5db12e667 Merge branch 'main' into symlink-plugin-in-example-files 2023-03-16 09:54:02 -05:00
Benjamin Eckel
5b58cd2580 user_code not used 2023-01-23 14:08:49 -06:00
Benjamin Eckel
890760f06d include other languages 2023-01-19 15:33:16 -06:00
Benjamin Eckel
d29e9f8f93 add symlinks 2023-01-19 13:43:05 -06:00
Benjamin Eckel
52cc95bf5a go and python 2023-01-19 13:42:18 -06:00
Benjamin Eckel
4b5796b92b drop unix prefix 2023-01-19 13:33:12 -06:00
Benjamin Eckel
fee2f03651 docs: Symlink plugin in example files 2023-01-19 13:30:04 -06:00
15 changed files with 17 additions and 9 deletions

1
go/code-functions.wasm Symbolic link
View File

@@ -0,0 +1 @@
../wasm/code-functions.wasm

View File

@@ -46,7 +46,7 @@ func main() {
} else {
data = []byte("testing from go -> wasm shared memory...")
}
manifest := extism.Manifest{Wasm: []extism.Wasm{extism.WasmFile{Path: "../wasm/code-functions.wasm"}}}
manifest := extism.Manifest{Wasm: []extism.Wasm{extism.WasmFile{Path: "code-functions.wasm"}}}
f := extism.NewFunction("hello_world", []extism.ValType{extism.I64}, []extism.ValType{extism.I64}, C.hello_world, "Hello again!")
defer f.Free()
plugin, err := ctx.PluginFromManifest(manifest, []extism.Function{f}, true)

View File

@@ -8,7 +8,7 @@ unwrap (Left (ExtismError msg)) = do
error msg
main = do
let m = manifest [wasmFile "../wasm/code.wasm"]
let m = manifest [wasmFile "code.wasm"]
context <- Extism.newContext
plugin <- unwrap <$> Extism.pluginFromManifest context m False
res <- unwrap <$> Extism.call plugin "count_vowels" (Extism.toByteString "this is a test")

1
haskell/code.wasm Symbolic link
View File

@@ -0,0 +1 @@
../wasm/code.wasm

1
node/code-functions.wasm Symbolic link
View File

@@ -0,0 +1 @@
../wasm/code-functions.wasm

View File

@@ -24,7 +24,7 @@ let hello_world = new HostFunction(
let functions = [hello_world];
withContext(async function (context) {
let wasm = readFileSync("../wasm/code-functions.wasm");
let wasm = readFileSync("code-functions.wasm");
let p = context.plugin(wasm, true, functions);
if (!p.functionExists("count_vowels")) {
@@ -39,6 +39,6 @@ withContext(async function (context) {
// or, use a context like this:
// let ctx = new Context();
// let wasm = readFileSync("../wasm/code.wasm");
// let wasm = readFileSync("code-functions.wasm");
// let p = ctx.plugin(wasm);
// ... where the context can be passed around to various functions etc.

Binary file not shown.

1
php/example/code.wasm Symbolic link
View File

@@ -0,0 +1 @@
../../wasm/code.wasm

View File

@@ -3,16 +3,16 @@
require_once __DIR__ . '/vendor/autoload.php';
$ctx = new \Extism\Context();
$wasm = file_get_contents("../../wasm/code.wasm");
$wasm = file_get_contents("code.wasm");
$plugin = new \Extism\Plugin($ctx, $wasm);
$output = $plugin->call("count_vowels", "this is an example");
$json = json_decode(pack('C*', ...$output));
echo "Vowels counted = " . $json->{'count'} . PHP_EOL;
$wasm = file_get_contents("../../wasm/code.wasm");
$wasm = file_get_contents("code.wasm");
$ok = $plugin->update($wasm);
if ($ok) {
$id = $plugin->getId();
echo "updated plugin: $id";
}
}

1
python/code-functions.wasm Symbolic link
View File

@@ -0,0 +1 @@
../wasm/code-functions.wasm

1
python/code.wasm Symbolic link
View File

@@ -0,0 +1 @@
../wasm/code.wasm

1
ruby/code.wasm Symbolic link
View File

@@ -0,0 +1 @@
../wasm/code.wasm

View File

@@ -7,7 +7,7 @@ require "json"
# If you do you can create a context with `Extism#new`, example: `ctx = Extism.new`
Extism.with_context do |ctx|
manifest = {
:wasm => [{ :path => "../wasm/code.wasm" }],
:wasm => [{ :path => "code.wasm" }],
}
plugin = ctx.plugin(manifest)

View File

@@ -27,12 +27,13 @@ Gem::Specification.new do |spec|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
end
end
spec.files.reject! { |f| f.end_with?(".wasm") }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
# Uncomment to register a new dependency of your gem
spec.add_dependency "ffi", ">= 1.0.0"
spec.add_dependency "ffi", "~> 1.0"
# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html

Binary file not shown.