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

Function ExternClassAdd

test/externref/ExternrefTest.cpp:167–176  ·  view source on GitHub ↗

Host function to access a class through an external reference.

Source from the content-addressed store, hash-verified

165
166// Host function to access a class through an external reference.
167WasmEdge_Result ExternClassAdd(void *, const WasmEdge_CallingFrameContext *,
168 const WasmEdge_Value *In, WasmEdge_Value *Out) {
169 // Function type: {externref, i32, i32} -> {i32}
170 void *Ptr = WasmEdge_ValueGetExternRef(In[0]);
171 AddClass &Obj = *reinterpret_cast<AddClass *>(Ptr);
172 uint32_t C = Obj.add(static_cast<uint32_t>(WasmEdge_ValueGetI32(In[1])),
173 static_cast<uint32_t>(WasmEdge_ValueGetI32(In[2])));
174 Out[0] = WasmEdge_ValueGenI32(static_cast<int32_t>(C));
175 return WasmEdge_Result_Success;
176}
177
178// Host function to call a function through an external reference as a function
179// pointer.

Callers

nothing calls this directly

Calls 3

WasmEdge_ValueGetI32Function · 0.85
addMethod · 0.45

Tested by

no test coverage detected