Skip to content

Commit f17470b

Browse files
authored
code cleanup, prepare release (#24)
* cleanup: add newFunction * cleanup: export newFunction * chore: use v1.2.1.0 * doc: use newFunction * doc: update changelog
1 parent 82e3ffe commit f17470b

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Revision history for extism
22

3+
## 1.2.1.0 -- 2024-04-22
4+
5+
* Added `newFunction`
6+
37
## 1.0.0.0 -- 2024-01-08
48

59
* Extism 1.0 compatible release

Diff for: Example.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ hello currPlugin msg = do
1818
main = do
1919
setLogFile "stdout" LogError
2020
let m = manifest [wasmFile "wasm/code-functions.wasm"]
21-
f <- hostFunction "hello_world" [ptr] [ptr] hello "Hello, again"
21+
f <- newFunction "hello_world" [ptr] [ptr] "Hello, again" hello
2222
plugin <- unwrap <$> newPlugin m [f] True
2323
id <- pluginID plugin
2424
print id

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ hello currPlugin msg = do
118118

119119
main = do
120120
setLogFile "stdout" LogError
121-
f <- hostFunction "hello_world" [ptr] [ptr] hello "Hello, again"
121+
f <- newFunction "hello_world" [ptr] [ptr] "Hello, again" hello
122122
plugin <- unwrap <$> newPlugin m [f] True
123123
id <- pluginID plugin
124124
print id

Diff for: extism.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: extism
3-
version: 1.2.0.4
3+
version: 1.2.1.0
44
license: BSD-3-Clause
55
maintainer: [email protected]
66
author: Extism authors

Diff for: manifest/extism-manifest.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: extism-manifest
3-
version: 1.2.0.4
3+
version: 1.2.1.0
44
license: BSD-3-Clause
55
maintainer: [email protected]
66
author: Extism authors

Diff for: src/Extism/HostFunction.hs

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ module Extism.HostFunction
2929
fromF64,
3030
hostFunction,
3131
hostFunction',
32+
newFunction,
33+
newFunction',
3234
input,
3335
output,
3436
getParams,
@@ -233,3 +235,13 @@ hostFunction = hostFunctionWithNamespace' Nothing
233235
-- | 'Function' in the provided namespace that can be called from a 'Plugin'
234236
hostFunction' :: String -> String -> [ValType] -> [ValType] -> (CurrentPlugin -> a -> IO ()) -> a -> IO Function
235237
hostFunction' ns = hostFunctionWithNamespace' (Just ns)
238+
239+
-- | 'newFunction "function_name" inputTypes outputTypes callback userData' creates a new
240+
-- | 'Function' in the default namespace that can be called from a 'Plugin'
241+
newFunction :: String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function
242+
newFunction name params results x f = hostFunctionWithNamespace' Nothing name params results f x
243+
244+
-- | 'newFunction' "namespace" "function_name" inputTypes outputTypes callback userData' creates a new
245+
-- | 'Function' in the provided namespace that can be called from a 'Plugin'
246+
newFunction' :: String -> String -> [ValType] -> [ValType] -> a -> (CurrentPlugin -> a -> IO ()) -> IO Function
247+
newFunction' ns name params results x f = hostFunctionWithNamespace' (Just ns) name params results f x

0 commit comments

Comments
 (0)