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

Function ExternSTLMapInsert

test/externref/ExternrefTest.cpp:219–230  ·  view source on GitHub ↗

Host function to insert {key, val} into std::map .

Source from the content-addressed store, hash-verified

217
218// Host function to insert {key, val} into std::map<std::string, std::string>.
219WasmEdge_Result ExternSTLMapInsert(void *, const WasmEdge_CallingFrameContext *,
220 const WasmEdge_Value *In, WasmEdge_Value *) {
221 // Function type: {externref, externref, externref} -> {}
222 void *Ptr0 = WasmEdge_ValueGetExternRef(In[0]);
223 void *Ptr1 = WasmEdge_ValueGetExternRef(In[1]);
224 void *Ptr2 = WasmEdge_ValueGetExternRef(In[2]);
225 auto &Map = *reinterpret_cast<std::map<std::string, std::string> *>(Ptr0);
226 auto &Key = *reinterpret_cast<std::string *>(Ptr1);
227 auto &Val = *reinterpret_cast<std::string *>(Ptr2);
228 Map[Key] = Val;
229 return WasmEdge_Result_Success;
230}
231
232// Host function to erase std::map<std::string, std::string> by key.
233WasmEdge_Result ExternSTLMapErase(void *, const WasmEdge_CallingFrameContext *,

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected