Host function to call a functor through an external reference.
| 152 | |
| 153 | // Host function to call a functor through an external reference. |
| 154 | WasmEdge_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. |
| 167 | WasmEdge_Result ExternClassAdd(void *, const WasmEdge_CallingFrameContext *, |
nothing calls this directly
no test coverage detected