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

Method setUnionMembersTemplateData

erpcgen/src/CGenerator.cpp:1267–1296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1265}
1266
1267void CGenerator::setUnionMembersTemplateData(UnionType *unionType, data_map &unionInfo)
1268{
1269 data_list unionCasesList;
1270 for (auto unionCase : unionType->getUniqueCases())
1271 {
1272 if (!unionCase->caseMemberIsVoid())
1273 {
1274 data_list unionCaseList;
1275 for (auto memberName : unionCase->getMemberDeclarationNames())
1276 {
1277 data_map unionMemberMap;
1278 StructMember *unionMember = unionCase->getUnionMemberDeclaration(memberName);
1279 string unionMemberName = getOutputName(unionMember);
1280 DataType *unionMemberType = unionMember->getDataType()->getTrueDataType();
1281
1282 // Check if member is byRef type. Add "*" for type and allocate space for data on server side.
1283 if (unionMember->isByref() && (unionMemberType->isStruct() || unionMemberType->isUnion() ||
1284 unionMemberType->isScalar() || unionMemberType->isEnum()))
1285 {
1286 unionMemberName = "*" + unionMemberName;
1287 }
1288
1289 unionMemberMap["typenameName"] = getTypenameName(unionMember->getDataType(), unionMemberName);
1290 unionCaseList.push_back(unionMemberMap);
1291 }
1292 unionCasesList.push_back(unionCaseList);
1293 }
1294 }
1295 unionInfo["unionCases"] = unionCasesList;
1296}
1297
1298string CGenerator::getUnionMembersData(UnionType *unionType, string indent)
1299{

Callers

nothing calls this directly

Calls 12

getUniqueCasesMethod · 0.80
caseMemberIsVoidMethod · 0.80
getTrueDataTypeMethod · 0.80
isByrefMethod · 0.80
isStructMethod · 0.80
isUnionMethod · 0.80
isEnumMethod · 0.80
push_backMethod · 0.80
getDataTypeMethod · 0.45
isScalarMethod · 0.45

Tested by

no test coverage detected