Host function to call a function through an external reference as a function pointer.
| 178 | // Host function to call a function through an external reference as a function |
| 179 | // pointer. |
| 180 | WasmEdge_Result ExternFuncMul(void *, const WasmEdge_CallingFrameContext *, |
| 181 | const WasmEdge_Value *In, WasmEdge_Value *Out) { |
| 182 | // Function type: {externref, i32, i32} -> {i32} |
| 183 | void *Ptr = WasmEdge_ValueGetExternRef(In[0]); |
| 184 | uint32_t (*Obj)(uint32_t, uint32_t) = |
| 185 | *reinterpret_cast<uint32_t (*)(uint32_t, uint32_t)>(Ptr); |
| 186 | uint32_t C = Obj(static_cast<uint32_t>(WasmEdge_ValueGetI32(In[1])), |
| 187 | static_cast<uint32_t>(WasmEdge_ValueGetI32(In[2]))); |
| 188 | Out[0] = WasmEdge_ValueGenI32(static_cast<int32_t>(C)); |
| 189 | return WasmEdge_Result_Success; |
| 190 | } |
| 191 | |
| 192 | // Host function to output std::string through std::ostream |
| 193 | WasmEdge_Result ExternSTLOStreamStr(void *, |
nothing calls this directly
no test coverage detected