1685: feat(c-api) Implement `wasm_exporttype_delete` r=Hywan a=Hywan
This PR implements the destructor for `wasm_exporttype_t`.
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
When building a `wasm_memorytype_t` with `wasm_memorytype_new`, we
pass a `wasm_limits_t`, where `min` and `max` represent `Pages`. This
semantics is set by `wasm_memorytype_new` itself where `min` and `max`
from `wasm_limits_t` are used to compute `Pages`, which are then passed
to `MemoryType`.
Then, in `wasm_memorytype_limits`, we expect to get the same
`wasm_limits_t` given to `wasm_memorytype_new`. But it's not!
The same `MemoryType` is read, good. The `minimum` and `maximum`
fields are `Pages`, good. Then, we compute the `min` and `max` values
for the resulting `wasm_limits_t`, which receive `Page.bytes().0`, not
good! We don't want the number of bytes, but the number of pages.
This patch fixes that.
`wasm_exporttype_t` has 2 fields: `name` and `extern_type`. Both are
of kind `NonNull`. When `wasm_exporttype_t` is dropped, nor `name` nor
`extern_type` are going to be dropped.
To avoid leaking data, this patch adds a new field: `owns_fields`:
* When `wasm_exporttype_t` is built from `wasm_exportype_new`, this
field is set to `false` because `name` and `extern_type` are
received by pointer, and its the responsibility of the caller to
free them,
* When `wasm_exporttype_t` is built from the `From<&ExportType>`
implementation, _we_ create `name` and `extern_type` to then leak
them. In this case, it is safe to reconstruct proper `Box`es to
finally drop them.
`wasm_store_t` is now a proper struct (rather than an opaque type) of
kind:
```rs
struct wasm_store_t {
inner: Store
}
```
The rest of the patch updates the code accordingly.
This feature is no longer necessary. The `build.rs` no longer uses
it. The overhead of including the deprecated symbol inside the dylib
is acceptable. It simplifies the overall build system.