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

Method getFunctionPrototype

erpcgen/src/CGenerator.cpp:2014–2180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2012}
2013
2014string CGenerator::getFunctionPrototype(Group *group, FunctionBase *fn, const std::string &interfaceName,
2015 const string &name, bool insideInterfaceCall)
2016{
2017 DataType *dataTypeReturn = fn->getReturnType();
2018 string proto = getExtraPointerInReturn(dataTypeReturn);
2019 string ifaceVar = interfaceName;
2020 if (proto == "*")
2021 {
2022 proto += " ";
2023 }
2024
2025 if (ifaceVar != "")
2026 {
2027 ifaceVar += "::";
2028 }
2029
2030 FunctionType *funType = dynamic_cast<FunctionType *>(fn);
2031 if (name.empty())
2032 {
2033 Symbol *symbol = dynamic_cast<Symbol *>(fn);
2034 assert(symbol);
2035 string functionName = getOutputName(symbol);
2036 if (funType) /* Need add '(*name)' for function type definition. */
2037 {
2038 proto += "(" + ifaceVar + "*" + functionName + ")";
2039 }
2040 else /* Use function name only. */
2041 {
2042 proto += ifaceVar + functionName;
2043 }
2044 }
2045 else
2046 {
2047 proto += ifaceVar + name;
2048 }
2049
2050 proto += "(";
2051
2052 auto params = fn->getParameters().getMembers();
2053 // add interface id and function id parameters for common callbacks shim code function
2054 if (!name.empty())
2055 {
2056 proto += "ClientManager *m_clientManager, uint32_t serviceID, uint32_t functionID";
2057 if (params.size() > 0)
2058 {
2059 proto += ", ";
2060 }
2061 }
2062
2063 if (params.size())
2064 {
2065 unsigned int n = 0;
2066 for (auto it : params)
2067 {
2068 bool isLast = (n == params.size() - 1);
2069 string paramSignature = getOutputName(it);
2070 DataType *dataType = it->getDataType();
2071 DataType *trueDataType = dataType->getTrueDataType();

Callers

nothing calls this directly

Calls 15

syntax_errorClass · 0.85
format_stringFunction · 0.85
getReturnTypeMethod · 0.80
getTrueDataTypeMethod · 0.80
isBuiltinMethod · 0.80
isEnumMethod · 0.80
isFunctionMethod · 0.80
hasProgramSymbolMethod · 0.80
getProgramSymbolMethod · 0.80
isStructMethod · 0.80
isArrayMethod · 0.80
isUnionMethod · 0.80

Tested by

no test coverage detected