Skip to content

Commit

Permalink
Merge pull request #59 from extism/document-raw-host-interface
Browse files Browse the repository at this point in the history
Document raw import interface
  • Loading branch information
bhelx authored Jul 17, 2024
2 parents 6a3c50a + 294b46d commit e70b0d6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ extern "ExtismHost" {
}
```

> **Note**: Under the hood this macro turns this into an interface that passes a pointer as an argument
> and a pointer as a return. If you want to pass raw, dereferenced wasm values see the raw interface documentation below.
To declare a host function in a specific namespace, pass the module name to the `host_fn` macro:

```rust
Expand Down Expand Up @@ -335,6 +338,19 @@ python3 app.py
# => An argument to send to Python!
```

## Raw Import Interface

Like exports, with imports we do some magic to turn the parameters and returns into pointers for you.
In some rare situations, you might wish to pass raw wasm values to the host (not pointers).
If you do, you need to drop down into a raw interface.
E.g, imagine an interface that sums two i64s

```rust
extern "C" {
fn sum(a: i64, b: i64) -> i64;
}
```

### Reach Out!

Have a question or just want to drop in and say hi? [Hop on the Discord](https://extism.org/discord)!
Binary file added count_vowels.wasm
Binary file not shown.
Binary file modified test/code.wasm
Binary file not shown.
Binary file modified test/host_function.wasm
Binary file not shown.
Binary file modified test/http.wasm
Binary file not shown.

0 comments on commit e70b0d6

Please sign in to comment.