Skip to content

Expose Engine::clone to c-api#8907

Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom
CGamesPlay:main
Jul 8, 2024
Merged

Expose Engine::clone to c-api#8907
alexcrichton merged 1 commit intobytecodealliance:mainfrom
CGamesPlay:main

Conversation

@CGamesPlay
Copy link
Copy Markdown
Contributor

This creates an API to allow cloning references to wasm_engine_t in the C API. This is simple in the Rust API which implements Clone, however it is not exposed to the C API.

Use case: in tree-sitter's wasm support, we create a store object and want to instantiate modules into it over the course of the object's lifetime. This requires a handle to the underlying engine, which means our store must be kept alongside a reference to the engine (since tree-sitter is a library, it doesn't want to assume a global wasm engine). This currently requires transferring ownership of the engine to the tree sitter store container, which means we can't reuse engine objects between multiple stores.

This pertains to tree-sitter/tree-sitter#3454.

@CGamesPlay CGamesPlay requested a review from a team as a code owner July 7, 2024 02:24
@CGamesPlay CGamesPlay requested review from fitzgen and removed request for a team July 7, 2024 02:24
@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Jul 7, 2024

```
cargo build --release wasmtime-c-api
cargo build --release -p wasmtime-c-api
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We'll need to update this documentation further nowadays because some headers are generated as part of the build now so CMake is primarily needed to get the headers right.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton alexcrichton added this pull request to the merge queue Jul 8, 2024
Merged via the queue into bytecodealliance:main with commit 9e22c4e Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:c-api Issues pertaining to the C API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants