From caf5e04927fffce8152e7bbd3655937826bfc2bc Mon Sep 17 00:00:00 2001 From: zach Date: Sat, 20 Apr 2024 06:44:18 -0700 Subject: [PATCH 1/5] cleanup: add newFunction --- src/Extism/HostFunction.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Extism/HostFunction.hs b/src/Extism/HostFunction.hs index d244e04..b330e68 100644 --- a/src/Extism/HostFunction.hs +++ b/src/Extism/HostFunction.hs @@ -233,3 +233,13 @@ hostFunction = hostFunctionWithNamespace' Nothing -- | 'Function' in the provided namespace that can be called from a 'Plugin' hostFunction' :: String -> String -> [ValType] -> [ValType] -> (CurrentPlugin -> a -> IO ()) -> a -> IO Function hostFunction' ns = hostFunctionWithNamespace' (Just ns) + +-- | 'newFunction "function_name" inputTypes outputTypes callback userData' creates a new +-- | 'Function' in the default namespace that can be called from a 'Plugin' +newFunction :: String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function +newFunction name params results x f = hostFunctionWithNamespace' Nothing name params results f x + +-- | 'newFunction' "namespace" "function_name" inputTypes outputTypes callback userData' creates a new +-- | 'Function' in the provided namespace that can be called from a 'Plugin' +newFunction' :: String -> String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function +newFunction' ns name params results x f = hostFunctionWithNamespace' (Just ns) name params results f x From 7a2cce4df9aae9c315490d68a036012c26fe430a Mon Sep 17 00:00:00 2001 From: zach Date: Mon, 22 Apr 2024 08:47:16 -0700 Subject: [PATCH 2/5] cleanup: export newFunction --- Example.hs | 2 +- src/Extism/HostFunction.hs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Example.hs b/Example.hs index e0e4d83..39da9df 100644 --- a/Example.hs +++ b/Example.hs @@ -18,7 +18,7 @@ hello currPlugin msg = do main = do setLogFile "stdout" LogError let m = manifest [wasmFile "wasm/code-functions.wasm"] - f <- hostFunction "hello_world" [ptr] [ptr] hello "Hello, again" + f <- newFunction "hello_world" [ptr] [ptr] "Hello, again" hello plugin <- unwrap <$> newPlugin m [f] True id <- pluginID plugin print id diff --git a/src/Extism/HostFunction.hs b/src/Extism/HostFunction.hs index b330e68..bb47439 100644 --- a/src/Extism/HostFunction.hs +++ b/src/Extism/HostFunction.hs @@ -29,6 +29,8 @@ module Extism.HostFunction fromF64, hostFunction, hostFunction', + newFunction, + newFunction', input, output, getParams, From 931dfd187e82f72a9a18ac7b042727fd357f12c2 Mon Sep 17 00:00:00 2001 From: zach Date: Mon, 22 Apr 2024 10:51:34 -0700 Subject: [PATCH 3/5] chore: use v1.2.1.0 --- extism.cabal | 2 +- manifest/extism-manifest.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extism.cabal b/extism.cabal index dbb9be4..6c9d322 100644 --- a/extism.cabal +++ b/extism.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: extism -version: 1.2.0.4 +version: 1.2.1.0 license: BSD-3-Clause maintainer: oss@extism.org author: Extism authors diff --git a/manifest/extism-manifest.cabal b/manifest/extism-manifest.cabal index b49c834..ebccad9 100644 --- a/manifest/extism-manifest.cabal +++ b/manifest/extism-manifest.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: extism-manifest -version: 1.2.0.4 +version: 1.2.1.0 license: BSD-3-Clause maintainer: oss@extism.org author: Extism authors From b09a6c792d1581bd2973330464c9d53b5b65a70f Mon Sep 17 00:00:00 2001 From: zach Date: Mon, 22 Apr 2024 11:16:59 -0700 Subject: [PATCH 4/5] doc: use newFunction --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6deea1..a38852e 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ hello currPlugin msg = do main = do setLogFile "stdout" LogError - f <- hostFunction "hello_world" [ptr] [ptr] hello "Hello, again" + f <- newFunction "hello_world" [ptr] [ptr] "Hello, again" hello plugin <- unwrap <$> newPlugin m [f] True id <- pluginID plugin print id From 76f47bae661e1181eb2932cf8e4043a7c308d27f Mon Sep 17 00:00:00 2001 From: zach Date: Mon, 22 Apr 2024 13:55:01 -0700 Subject: [PATCH 5/5] doc: update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fad5d30..b96dd7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for extism +## 1.2.1.0 -- 2024-04-22 + +* Added `newFunction` + ## 1.0.0.0 -- 2024-01-08 * Extism 1.0 compatible release