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

Function ExternSTLVectorPush

test/externref/ExternrefTest.cpp:265–274  ·  view source on GitHub ↗

Host function to push a value into std::vector .

Source from the content-addressed store, hash-verified

263
264// Host function to push a value into std::vector<uint32_t>.
265WasmEdge_Result ExternSTLVectorPush(void *,
266 const WasmEdge_CallingFrameContext *,
267 const WasmEdge_Value *In,
268 WasmEdge_Value *) {
269 // Function type: {externref, i32} -> {}
270 void *Ptr = WasmEdge_ValueGetExternRef(In[0]);
271 auto &Vec = *reinterpret_cast<std::vector<uint32_t> *>(Ptr);
272 Vec.push_back(static_cast<uint32_t>(WasmEdge_ValueGetI32(In[1])));
273 return WasmEdge_Result_Success;
274}
275
276// Host function to sum values in a slice of std::vector<uint32_t>.
277WasmEdge_Result ExternSTLVectorSum(void *, const WasmEdge_CallingFrameContext *,

Callers

nothing calls this directly

Calls 2

WasmEdge_ValueGetI32Function · 0.85

Tested by

no test coverage detected