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

Method handleParam

erpcgen/src/SymbolScanner.cpp:1289–1419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1287}
1288
1289AstNode *SymbolScanner::handleParam(AstNode *node, top_down)
1290{
1291 assert_throw_internal((m_currentStruct), "parameter not in function");
1292
1293 /* Is this param for callback function? */
1294 StructMember *callbackParam = nullptr;
1295 Function *fun = nullptr;
1296 FunctionType *funType = nullptr;
1297 bool isFunctionType = m_currentInterface->getFunctions().empty();
1298 if (!isFunctionType)
1299 {
1300 fun = m_currentInterface->getFunctions().back();
1301 for (FunctionType *funType : m_currentInterface->getFunctionTypes())
1302 {
1303 FunctionType::c_function_list_t &callbacks = funType->getCallbackFuns();
1304 if (find(callbacks.begin(), callbacks.end(), fun) != callbacks.end())
1305 {
1306 if (fun->getParameters().getMembers().size() > funType->getParameters().getMembers().size())
1307 {
1308 throw syntax_error(
1309 format_string("line %d: Function definition contains more parameters than "
1310 "function type definition from %d.\n",
1311 fun->getFirstLine(), funType->getFirstLine()));
1312 }
1313 else
1314 {
1315 callbackParam = funType->getParameters().getMembers()[fun->getParameters().getMembers().size()];
1316 }
1317 break;
1318 }
1319 }
1320 }
1321
1322 AstNode *ident = (*node)[0];
1323 StructMember *param;
1324 if (callbackParam) /* Callback parameters. */
1325 {
1326 string name;
1327 if (ident) /* Get name from callback definition. */
1328 {
1329 const Token &tok = ident->getToken();
1330 name = tok.getStringValue();
1331 }
1332 else /* Get name from function type definition. */
1333 {
1334 name = callbackParam->getName();
1335 }
1336 if (name.compare("") == 0)
1337 {
1338 assert(funType);
1339 assert(fun);
1340 throw semantic_error(
1341 format_string("Missing function param name. That has to be defined in function definition %d or "
1342 "function type definition %d.\n",
1343 fun->getFirstLine(), funType->getFirstLine()));
1344 }
1345 param = createCallbackParam(callbackParam, name);
1346 }

Callers

nothing calls this directly

Calls 14

assert_throw_internalFunction · 0.85
syntax_errorClass · 0.85
format_stringFunction · 0.85
semantic_errorClass · 0.85
getTokenMethod · 0.80
getChildMethod · 0.80
getSymbolsOfTypeMethod · 0.80
addMemberMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected