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

Method allocateCall

erpcgen/src/CGenerator.cpp:3115–3175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3113}
3114
3115data_map CGenerator::allocateCall(const string &name, Symbol *symbol)
3116{
3117 StructMember *structMember = dynamic_cast<StructMember *>(symbol);
3118 DataType *dataType;
3119 data_map alloc;
3120 if (structMember)
3121 {
3122 dataType = structMember->getDataType();
3123 }
3124 else
3125 {
3126 dataType = dynamic_cast<DataType *>(symbol);
3127 assert(dataType);
3128 }
3129 DataType *trueDataType = dataType->getTrueDataType();
3130 string size;
3131 string chSize;
3132 if ((trueDataType->isList() || trueDataType->isString()) && structMember)
3133 {
3134 size = getAnnStringValue(structMember, MAX_LENGTH_ANNOTATION);
3135 if (size != "")
3136 {
3137 if (dataType->isString())
3138 {
3139 chSize = size;
3140 size = "(" + size + " + 1)";
3141 }
3142 size += " * ";
3143 }
3144 }
3145 if (dataType->isList())
3146 {
3147 ListType *listType = dynamic_cast<ListType *>(dataType);
3148 assert(listType);
3149 dataType = listType->getElementType();
3150 if (size == "")
3151 {
3152 size = listType->getLengthVariableName() + " * ";
3153 }
3154 }
3155 string typeValue;
3156 string typePointerValue;
3157 if (!dataType->isString())
3158 {
3159 typeValue = getTypenameName(dataType, "");
3160 typePointerValue = getTypenameName(dataType, "*");
3161 }
3162 else
3163 {
3164 typeValue = "char";
3165 typePointerValue = dataType->isUString() ? "unsigned char*" : "char *";
3166 }
3167
3168 alloc["name"] = name.c_str();
3169 alloc["typePointerValue"] = typePointerValue.c_str();
3170 alloc["size"] = size.c_str();
3171 alloc["chSize"] = chSize.c_str();
3172 alloc["typeValue"] = typeValue.c_str();

Callers

nothing calls this directly

Calls 6

getTrueDataTypeMethod · 0.80
getDataTypeMethod · 0.45
isListMethod · 0.45
isStringMethod · 0.45
getElementTypeMethod · 0.45
isUStringMethod · 0.45

Tested by

no test coverage detected