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

Method findChildDataType

erpcgen/src/CGenerator.cpp:220–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220DataType *CGenerator::findChildDataType(set<DataType *> &dataTypes, DataType *dataType)
221{
222 // Detecting loops from forward declarations.
223 // Insert data type into set
224 if (!(dataType->isBinary() || dataType->isList()))
225 {
226 if (!dataTypes.insert(dataType).second)
227 {
228 return dataType;
229 }
230 }
231
232 switch (dataType->getDataType())
233 {
234 case DataType::data_type_t::kAliasType:
235 {
236 AliasType *aliasType = dynamic_cast<AliasType *>(dataType);
237 assert(aliasType);
238 aliasType->setElementType(findChildDataType(dataTypes, aliasType->getElementType()));
239 break;
240 }
241 case DataType::data_type_t::kArrayType:
242 {
243 ArrayType *arrayType = dynamic_cast<ArrayType *>(dataType);
244 assert(arrayType);
245 arrayType->setElementType(findChildDataType(dataTypes, arrayType->getElementType()));
246 break;
247 }
248 case DataType::data_type_t::kBuiltinType:
249 {
250 if (dataType->isBinary())
251 {
252 // check if binary data type was replaced with structure wrapper
253 dataType = dynamic_cast<DataType *>(m_globals->getSymbol("binary_t"));
254 if (!dataType)
255 {
256 // Replace binary with list<uint8>
257 BuiltinType *builtinType = dynamic_cast<BuiltinType *>(m_globals->getSymbol("uint8"));
258 assert(builtinType);
259 ListType *listType = new ListType(builtinType);
260 BuiltinType *replacedBuiltinType = dynamic_cast<BuiltinType *>(m_globals->getSymbol("binary"));
261 assert(replacedBuiltinType);
262
263 StructType *newStruct = new StructType("binary_t");
264 StructMember *elements = new StructMember("data", listType);
265 elements->setContainList(true);
266 elements->setContainString(false);
267 newStruct->addMember(elements);
268 newStruct->getScope().setParent(m_globals);
269
270 m_globals->replaceSymbol(replacedBuiltinType, newStruct);
271 m_listBinaryTypes.insert(m_listBinaryTypes.begin(), listType);
272
273 dataType = dynamic_cast<DataType *>(m_globals->getSymbol("binary_t"));
274 assert(dataType);
275 }
276 }
277 dataTypes.insert(dataType);

Callers

nothing calls this directly

Calls 15

format_stringFunction · 0.85
getSymbolMethod · 0.80
setContainListMethod · 0.80
setContainStringMethod · 0.80
addMemberMethod · 0.80
replaceSymbolMethod · 0.80
getReturnTypeMethod · 0.80
hasLengthVariableMethod · 0.80
isStructMethod · 0.80
getTrueDataTypeMethod · 0.80

Tested by

no test coverage detected