MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / getEncodeDecodeBuiltin

Method getEncodeDecodeBuiltin

erpcgen/src/CGenerator.cpp:2349–2401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2347}
2348
2349void CGenerator::getEncodeDecodeBuiltin(Group *group, BuiltinType *t, data_map &templateData, StructType *structType,
2350 StructMember *structMember, bool isFunctionParam)
2351{
2352 templateData["decode"] = m_templateData["decodeBuiltinType"];
2353 templateData["encode"] = m_templateData["encodeBuiltinType"];
2354
2355 if (t->isString())
2356 {
2357 templateData["checkStringNull"] = false;
2358 templateData["withoutAlloc"] =
2359 ((structMember->getDirection() == param_direction_t::kInoutDirection) ||
2360 (structType && group->getSymbolDirections(structType).count(param_direction_t::kInoutDirection))) ?
2361 true :
2362 false;
2363 if (!isFunctionParam)
2364 {
2365 templateData["stringAllocSize"] = getOutputName(structMember) + "_len";
2366 templateData["stringLocalName"] = getOutputName(structMember);
2367 }
2368 else
2369 {
2370 if (!structType)
2371 {
2372 templateData["stringAllocSize"] = "return_len";
2373 templateData["stringLocalName"] = "return";
2374 }
2375 else
2376 {
2377 templateData["checkStringNull"] = true;
2378 templateData["stringLocalName"] = getOutputName(structMember);
2379 templateData["stringAllocSize"] = getAnnStringValue(structMember, MAX_LENGTH_ANNOTATION);
2380 if ((structMember->getDirection() == param_direction_t::kInoutDirection) ||
2381 (structMember->getDirection() == param_direction_t::kOutDirection))
2382 {
2383 templateData["withoutAlloc"] = true;
2384 }
2385
2386 if (templateData["stringAllocSize"]->getvalue() == "")
2387 {
2388 templateData["stringAllocSize"] = templateData["stringLocalName"]->getvalue() + "_len";
2389 }
2390 }
2391 }
2392 templateData["freeingCall"] = m_templateData["freeData"];
2393 // needDealloc(templateData, t, structType, nullptr);
2394 templateData["builtinType"] = "kStringType";
2395 templateData["builtinTypeName"] = t->isUString() ? "unsigned char*" : "char*";
2396 }
2397 else
2398 {
2399 templateData["builtinType"] = "kNumberType";
2400 }
2401}
2402
2403data_map CGenerator::getEncodeDecodeCall(const string &name, Group *group, DataType *t, StructType *structType,
2404 bool inDataContainer, StructMember *structMember, bool &needTempVariableI32,

Callers

nothing calls this directly

Calls 5

getSymbolDirectionsMethod · 0.80
getvalueMethod · 0.80
isStringMethod · 0.45
getDirectionMethod · 0.45
isUStringMethod · 0.45

Tested by

no test coverage detected