MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / ExternFuncMul

Function ExternFuncMul

test/externref/ExternrefTest.cpp:180–190  ·  view source on GitHub ↗

Host function to call a function through an external reference as a function pointer.

Source from the content-addressed store, hash-verified

178// Host function to call a function through an external reference as a function
179// pointer.
180WasmEdge_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
193WasmEdge_Result ExternSTLOStreamStr(void *,

Callers

nothing calls this directly

Calls 2

WasmEdge_ValueGetI32Function · 0.85

Tested by

no test coverage detected