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

Method serializeSection

lib/loader/serialize/serial_section.cpp:10–26  ·  view source on GitHub ↗

Serialize custom section. See "include/loader/serialize.h".

Source from the content-addressed store, hash-verified

8
9// Serialize custom section. See "include/loader/serialize.h".
10Expect<void>
11Serializer::serializeSection(const AST::CustomSection &Sec,
12 std::vector<uint8_t> &OutVec) const noexcept {
13 // Custom section: 0x00 + size:u32 + name:vec(byte) + content:byte*.
14 // Section ID.
15 OutVec.push_back(0x00U);
16 auto OrgSize = OutVec.size();
17 // Name: vec(byte).
18 serializeU32(static_cast<uint32_t>(Sec.getName().size()), OutVec);
19 OutVec.insert(OutVec.end(), Sec.getName().begin(), Sec.getName().end());
20 // Content: byte*.
21 OutVec.insert(OutVec.end(), Sec.getContent().begin(), Sec.getContent().end());
22 // Backward insert the section size.
23 serializeU32(static_cast<uint32_t>(OutVec.size() - OrgSize), OutVec,
24 std::next(OutVec.begin(), static_cast<ptrdiff_t>(OrgSize)));
25 return {};
26}
27
28// Serialize type section. See "include/loader/serialize.h".
29Expect<void>

Callers 6

TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80

Calls 11

insertMethod · 0.80
getRecursiveInfoMethod · 0.80
hasProposalMethod · 0.80
EXPECTED_TRYFunction · 0.50
errorFunction · 0.50
sizeMethod · 0.45
getNameMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
getContentMethod · 0.45
has_valueMethod · 0.45

Tested by 6

TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64