| 790 | } |
| 791 | |
| 792 | data_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 | { |
nothing calls this directly
no test coverage detected