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

Function ExternFunctorSquare

test/externref/ExternrefTest.cpp:154–164  ·  view source on GitHub ↗

Host function to call a functor through an external reference.

Source from the content-addressed store, hash-verified

152
153// Host function to call a functor through an external reference.
154WasmEdge_Result ExternFunctorSquare(void *,
155 const WasmEdge_CallingFrameContext *,
156 const WasmEdge_Value *In,
157 WasmEdge_Value *Out) {
158 // Function type: {externref, i32} -> {i32}
159 void *Ptr = WasmEdge_ValueGetExternRef(In[0]);
160 SquareStruct &Obj = *reinterpret_cast<SquareStruct *>(Ptr);
161 uint32_t C = Obj(static_cast<uint32_t>(WasmEdge_ValueGetI32(In[1])));
162 Out[0] = WasmEdge_ValueGenI32(static_cast<int32_t>(C));
163 return WasmEdge_Result_Success;
164}
165
166// Host function to access a class through an external reference.
167WasmEdge_Result ExternClassAdd(void *, const WasmEdge_CallingFrameContext *,

Callers

nothing calls this directly

Calls 2

WasmEdge_ValueGetI32Function · 0.85

Tested by

no test coverage detected