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

Method getEncodeDecodeCall

erpcgen/src/JavaGenerator.cpp:792–920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792data_map JavaGenerator::getEncodeDecodeCall(const string &name, DataType *t, StructType *structType,
793 bool inDataContainer, bool isStructMember, StructMember *structMember,
794 bool needTypeDeclaration, bool isFunctionParam)
795{
796 static uint8_t listArrayCounter; // Used for creating nested loops variable names
797 data_map templateData;
798 bool isReference = (isStructMember && structMember->isByref()) ||
799 (isFunctionParam && (structMember->getDirection() == param_direction_t::kOutDirection ||
800 structMember->getDirection() == param_direction_t::kInoutDirection));
801 templateData["type"] = getTypeInfo(t, isReference); // Type info about variable
802 templateData["inDataContainer"] = inDataContainer;
803 templateData["name"] = name; // Name of the variable
804 templateData["isStructMember"] = isStructMember; // If variable is part of struct
805 templateData["needTypeDeclaration"] = needTypeDeclaration; // Variable does not exist in the scope
806 templateData["isFunctionParam"] = isFunctionParam;
807 templateData["isReference"] = isReference;
808
809 switch (t->getDataType())
810 {
811 case DataType::data_type_t::kAliasType:
812 {
813 AliasType *aliasType = dynamic_cast<AliasType *>(t);
814 assert(aliasType);
815 templateData = getEncodeDecodeCall(name, aliasType->getElementType(), structType, inDataContainer, false,
816 structMember, true, false);
817 break;
818 }
819 case DataType::data_type_t::kArrayType:
820 {
821 ArrayType *arrayType = dynamic_cast<ArrayType *>(t);
822 assert(arrayType);
823 DataType *elementType = arrayType->getElementType()->getTrueDataType();
824
825 string arrayName = name;
826 templateData["decode"] = m_templateData["decodeArrayType"];
827 templateData["encode"] = m_templateData["encodeArrayType"];
828
829 templateData["initialization"] = getArrayInitialization(arrayType);
830
831 listArrayCounter++;
832 templateData["counter"] = format_string("genLoopVariable%d", listArrayCounter);
833 templateData["protoNext"] =
834 getEncodeDecodeCall(format_string("genValueVariable%d", listArrayCounter), elementType, structType,
835 true, false, structMember, true, false);
836 listArrayCounter--;
837
838 templateData["size"] = format_string("%d", arrayType->getElementCount());
839 templateData["isElementArrayType"] = elementType->isArray();
840 break;
841 }
842 case DataType::data_type_t::kBuiltinType:
843 {
844 templateData["decode"] = m_templateData["decodeBuiltinType"];
845 templateData["encode"] = m_templateData["encodeBuiltinType"];
846 break;
847 }
848 case DataType::data_type_t::kEnumType:
849 {

Callers

nothing calls this directly

Calls 12

format_stringFunction · 0.85
internal_errorClass · 0.85
isByrefMethod · 0.80
getTrueDataTypeMethod · 0.80
isArrayMethod · 0.80
hasLengthVariableMethod · 0.80
getSymbolMethod · 0.80
getDirectionMethod · 0.45
getDataTypeMethod · 0.45
getElementTypeMethod · 0.45
toStringMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected