| 2804 | } |
| 2805 | |
| 2806 | WASMEDGE_CAPI_EXPORT WasmEdge_Result WasmEdge_TableInstanceSetData( |
| 2807 | WasmEdge_TableInstanceContext *Cxt, WasmEdge_Value Data, |
| 2808 | const uint64_t Offset) noexcept { |
| 2809 | return wrap( |
| 2810 | [&]() -> WasmEdge::Expect<void> { |
| 2811 | // Comparison of the value types needs the module instance to retrieve |
| 2812 | // the function type index after applying the typed function reference |
| 2813 | // proposal. It's impossible to do this without refactoring. Therefore |
| 2814 | // simply match the FuncRef and ExternRef here. |
| 2815 | WasmEdge::ValType ExpType = |
| 2816 | fromTabCxt(Cxt)->getTableType().getRefType(); |
| 2817 | WasmEdge::ValType GotType = genValType(Data.Type); |
| 2818 | if (!GotType.isRefType() || |
| 2819 | ExpType.isFuncRefType() != GotType.isFuncRefType()) { |
| 2820 | spdlog::error(WasmEdge::ErrCode::Value::RefTypeMismatch); |
| 2821 | spdlog::error(WasmEdge::ErrInfo::InfoMismatch(ExpType, GotType)); |
| 2822 | return Unexpect(WasmEdge::ErrCode::Value::RefTypeMismatch); |
| 2823 | } |
| 2824 | auto Val = WasmEdge::ValVariant( |
| 2825 | to_WasmEdge_128_t<WasmEdge::uint128_t>(Data.Value)) |
| 2826 | .get<WasmEdge::RefVariant>(); |
| 2827 | if (!ExpType.isNullableRefType() && Val.isNull()) { |
| 2828 | // If this table is not a nullable ref type, the data should not be |
| 2829 | // null. |
| 2830 | spdlog::error(WasmEdge::ErrCode::Value::NonNullRequired); |
| 2831 | return Unexpect(WasmEdge::ErrCode::Value::NonNullRequired); |
| 2832 | } |
| 2833 | return fromTabCxt(Cxt)->setRefAddr(Offset, Val); |
| 2834 | }, |
| 2835 | EmptyThen, Cxt); |
| 2836 | } |
| 2837 | |
| 2838 | WASMEDGE_CAPI_EXPORT uint64_t WasmEdge_TableInstanceGetSize( |
| 2839 | const WasmEdge_TableInstanceContext *Cxt) noexcept { |
nothing calls this directly
no test coverage detected