Skip to content

Commit

Permalink
Merge #589
Browse files Browse the repository at this point in the history
589: wasmer-c-api-changes: making `wasmer_byte_array` fields `public` r=bjfish a=YaronWittenstein

I've added this PR since I've tests that need access to `wasmer_byte_array` field.
Here is an example:
https://github.com/spacemeshos/svm/blob/52f04b52cc9a5227030f3dd3499e04c6cbe143d9/crates/svm-wasmer-c-api/tests/c_api.rs#L96

```rust
unsafe fn cast_wasmer_byte_array_to_string(wasmer_bytes: &wasmer_byte_array) -> String {
    let slice: &[u8] =
        std::slice::from_raw_parts(wasmer_bytes.bytes, wasmer_bytes.bytes_len as usize);

    if let Ok(s) = std::str::from_utf8(slice) {
        s.to_string()
    } else {
        panic!("error converting `wasmer_byte_array` to string")
    }
}
```

@syrusakbary @bjfish @Hywan 

Co-authored-by: Yaron Wittenstein <[email protected]>
Co-authored-by: Brandon Fish <[email protected]>
  • Loading branch information
3 people committed Aug 1, 2019
2 parents d117a46 + d9e1609 commit f8fa06e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/runtime-c-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ pub struct wasmer_limit_option_t {

#[repr(C)]
pub struct wasmer_byte_array {
bytes: *const u8,
bytes_len: u32,
pub bytes: *const u8,
pub bytes_len: u32,
}

0 comments on commit f8fa06e

Please sign in to comment.