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

Method generate

erpcgen/src/CGenerator.cpp:477–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477void CGenerator::generate()
478{
479 Program *program = nullptr;
480 bool generateAllocErrorChecks = true;
481 bool generateInfraErrorChecks = true;
482 if (m_def->hasProgramSymbol())
483 {
484 program = m_def->getProgramSymbol();
485 generateAllocErrorChecks = (findAnnotation(program, NO_ALLOC_ERRORS_ANNOTATION) == nullptr);
486 generateInfraErrorChecks = (findAnnotation(program, NO_INFRA_ERRORS_ANNOTATION) == nullptr);
487 }
488 /* Generate file with shim code version. */
489 m_templateData["versionGuardMacro"] =
490 generateIncludeGuardName(format_string("erpc_generated_shim_code_crc_%d", m_idlCrc16));
491
492 m_templateData["generateInfraErrorChecks"] = generateInfraErrorChecks;
493 m_templateData["generateAllocErrorChecks"] = generateAllocErrorChecks;
494 m_templateData["generateErrorChecks"] = generateInfraErrorChecks || generateAllocErrorChecks;
495
496 data_list empty;
497 m_templateData["enums"] = empty;
498 m_templateData["aliases"] = empty;
499 m_templateData["structs"] = empty;
500 m_templateData["unions"] = empty;
501 m_templateData["consts"] = empty;
502
503 m_templateData["nonExternalStructUnion"] = false;
504
505 // Keil need extra pragma option when unions are used.
506 m_templateData["usedUnionType"] = false;
507
508 /* Set directions constants*/
509 m_templateData["InDirection"] = getDirection(param_direction_t::kInDirection);
510 m_templateData["OutDirection"] = getDirection(param_direction_t::kOutDirection);
511 m_templateData["InoutDirection"] = getDirection(param_direction_t::kInoutDirection);
512 m_templateData["ReturnDirection"] = getDirection(param_direction_t::kReturn);
513
514 parseSubtemplates();
515
516 /* Generate file containing crc of IDL files. */
517 if (m_def->hasProgramSymbol() && findAnnotation(program, CRC_ANNOTATION) != nullptr)
518 {
519 generateCrcFile();
520 }
521
522 // check if structure/function parameters annotations are valid.
523 for (Symbol *symbol : getDataTypesFromSymbolScope(m_globals, DataType::data_type_t::kStructType))
524 {
525 StructType *structType = dynamic_cast<StructType *>(symbol);
526 assert(structType);
527 scanStructForAnnotations(structType, false);
528 }
529
530 for (Symbol *symbol : m_globals->getSymbolsOfType(Symbol::symbol_type_t::kInterfaceSymbol))
531 {
532 Interface *interface = dynamic_cast<Interface *>(symbol);
533 assert(interface);
534 for (Function *function : interface->getFunctions())

Callers 1

runMethod · 0.45

Calls 7

format_stringFunction · 0.85
hasProgramSymbolMethod · 0.80
getProgramSymbolMethod · 0.80
getSymbolsOfTypeMethod · 0.80
push_backMethod · 0.80
setTemplateMethod · 0.80
getNameMethod · 0.45

Tested by

no test coverage detected