mirror of
https://github.com/mii443/wasmer.git
synced 2025-09-03 16:09:20 +00:00
Merge #1736
1736: feat(c-api): Implement `wasm_global_type` r=Hywan a=jubianchi
This patch adds a `wasm_globaltype_t::new` constructor for use by the
new `wasm_global_type` function and the existing
`wasm_globaltype_new_inner` function.
Note: `wasm_global_type` is defined here:
193d7c8ce1/lib/c-api/tests/wasm_c_api/wasm-c-api/include/wasm.h (L436)
# Review
- [x] Add a short description of the the change to the CHANGELOG.md file
Co-authored-by: jubianchi <julien@wasmer.io>
This commit is contained in:
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- [#1736](https://github.com/wasmerio/wasmer/pull/1736) Implement `wasm_global_type` in the Wasm C API.
|
||||||
- [#1699](https://github.com/wasmerio/wasmer/pull/1699) Update `wasm.h` to its latest version.
|
- [#1699](https://github.com/wasmerio/wasmer/pull/1699) Update `wasm.h` to its latest version.
|
||||||
- [#1685](https://github.com/wasmerio/wasmer/pull/1685) Implement `wasm_exporttype_delete` in the Wasm C API.
|
- [#1685](https://github.com/wasmerio/wasmer/pull/1685) Implement `wasm_exporttype_delete` in the Wasm C API.
|
||||||
- [#1725](https://github.com/wasmerio/wasmer/pull/1725) Implement `wasm_func_type` in the Wasm C API.
|
- [#1725](https://github.com/wasmerio/wasmer/pull/1725) Implement `wasm_func_type` in the Wasm C API.
|
||||||
|
5
lib/c-api/src/wasm_c_api/externals/global.rs
vendored
5
lib/c-api/src/wasm_c_api/externals/global.rs
vendored
@ -59,3 +59,8 @@ pub unsafe extern "C" fn wasm_global_same(
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
wasm_global1.inner.same(&wasm_global2.inner)
|
wasm_global1.inner.same(&wasm_global2.inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn wasm_global_type(wasm_global: &wasm_global_t) -> Box<wasm_globaltype_t> {
|
||||||
|
Box::new(wasm_globaltype_t::new(wasm_global.inner.ty().clone()))
|
||||||
|
}
|
||||||
|
@ -20,6 +20,14 @@ impl wasm_globaltype_t {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn new(global_type: GlobalType) -> Self {
|
||||||
|
Self {
|
||||||
|
extern_: wasm_externtype_t {
|
||||||
|
inner: ExternType::Global(global_type),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wasm_declare_vec!(globaltype);
|
wasm_declare_vec!(globaltype);
|
||||||
@ -42,11 +50,10 @@ unsafe fn wasm_globaltype_new_inner(
|
|||||||
mutability: wasm_mutability_t,
|
mutability: wasm_mutability_t,
|
||||||
) -> Option<Box<wasm_globaltype_t>> {
|
) -> Option<Box<wasm_globaltype_t>> {
|
||||||
let me: wasm_mutability_enum = mutability.try_into().ok()?;
|
let me: wasm_mutability_enum = mutability.try_into().ok()?;
|
||||||
let gd = Box::new(wasm_globaltype_t {
|
let gd = Box::new(wasm_globaltype_t::new(GlobalType::new(
|
||||||
extern_: wasm_externtype_t {
|
(*valtype).into(),
|
||||||
inner: ExternType::Global(GlobalType::new((*valtype).into(), me.into())),
|
me.into(),
|
||||||
},
|
)));
|
||||||
});
|
|
||||||
wasm_valtype_delete(Some(valtype));
|
wasm_valtype_delete(Some(valtype));
|
||||||
|
|
||||||
Some(gd)
|
Some(gd)
|
||||||
|
Reference in New Issue
Block a user