X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=iotjava%2Fiotpolicy%2FIoTCompiler.java;h=9d9ecdd948f576618dd68f7f71783950f2026c2c;hb=b7edf3322fe3f1470a19054bd9826933077f8e91;hp=ab19e6a313c69d1a29e29b124c07146dadcc8304;hpb=7b3e56c92613a88e1c54e65ba35d5dba9c41f2e8;p=iot2.git diff --git a/iotjava/iotpolicy/IoTCompiler.java b/iotjava/iotpolicy/IoTCompiler.java index ab19e6a..9d9ecdd 100644 --- a/iotjava/iotpolicy/IoTCompiler.java +++ b/iotjava/iotpolicy/IoTCompiler.java @@ -493,15 +493,17 @@ public class IoTCompiler { /** * HELPER: writeJavaInitCallbackPermission() writes the permission for callback */ - private void writeJavaInitCallbackPermission(String intface, InterfaceDecl intDecl) { + private void writeJavaInitCallbackPermission(String intface, InterfaceDecl intDecl, boolean callbackExist) { - String method = "___initCallBack()"; - int methodNumId = intDecl.getHelperMethodNumId(method); - Map> mapNewIntMethods = mapInt2NewInts.get(intface); - for (Map.Entry> intMeth : mapNewIntMethods.entrySet()) { - String newIntface = intMeth.getKey(); - int newObjectId = getNewIntfaceObjectId(newIntface); - println("set" + newObjectId + "Allowed.add(" + methodNumId + ");"); + if (callbackExist) { + String method = "___initCallBack()"; + int methodNumId = intDecl.getHelperMethodNumId(method); + Map> mapNewIntMethods = mapInt2NewInts.get(intface); + for (Map.Entry> intMeth : mapNewIntMethods.entrySet()) { + String newIntface = intMeth.getKey(); + int newObjectId = getNewIntfaceObjectId(newIntface); + println("set" + newObjectId + "Allowed.add(" + methodNumId + ");"); + } } } @@ -558,20 +560,20 @@ public class IoTCompiler { for (int i = 0; i < methParams.size(); i++) { String paramType = methPrmTypes.get(i); String param = methParams.get(i); - String simpleType = getSimpleType(paramType); + String simpleType = getGenericType(paramType); if (isEnumClass(simpleType)) { // Check if this is enum type if (isArray(param)) { // An array - println("int len" + i + " = " + param + ".length;"); - println("int paramEnum" + i + "[] = new int[len];"); + println("int len" + i + " = " + getSimpleIdentifier(param) + ".length;"); + println("int paramEnum" + i + "[] = new int[len" + i + "];"); println("for (int i = 0; i < len" + i + "; i++) {"); - println("paramEnum" + i + "[i] = " + param + "[i].ordinal();"); + println("paramEnum" + i + "[i] = " + getSimpleIdentifier(param) + "[i].ordinal();"); println("}"); } else if (isList(paramType)) { // A list - println("int len" + i + " = " + param + ".size();"); - println("int paramEnum" + i + "[] = new int[len];"); + println("int len" + i + " = " + getSimpleIdentifier(param) + ".size();"); + println("int paramEnum" + i + "[] = new int[len" + i + "];"); println("for (int i = 0; i < len" + i + "; i++) {"); - println("paramEnum" + i + "[i] = " + param + ".get(i).ordinal();"); + println("paramEnum" + i + "[i] = " + getSimpleIdentifier(param) + ".get(i).ordinal();"); println("}"); } else { // Just one element println("int paramEnum" + i + "[] = new int[1];"); @@ -588,10 +590,10 @@ public class IoTCompiler { private void checkAndWriteEnumRetTypeJavaStub(String retType) { // Strips off array "[]" for return type - String pureType = getSimpleArrayType(getSimpleType(retType)); + String pureType = getSimpleArrayType(getGenericType(retType)); // Take the inner type of generic if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) - pureType = getTypeOfGeneric(retType)[0]; + pureType = getGenericType(retType); if (isEnumClass(pureType)) { // Check if this is enum type // Enum decoder @@ -891,16 +893,16 @@ public class IoTCompiler { if (isStructClass(getGenericType(getSimpleArrayType(retType)))) { writeStructReturnJavaStub(getGenericType(getSimpleArrayType(retType)), retType); } else { - // Check if the return value NONPRIMITIVES - if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) { - String[] retGenValType = getTypeOfGeneric(retType); - println("Class retGenValType = " + retGenValType[0] + ".class;"); - println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, retGenValType, paramCls, paramObj);"); - println("return (" + retType + ")retObj;"); - } else if (getParamCategory(retType) == ParamCategory.ENUM) { // This is an enum type + if (getParamCategory(getGenericType(getSimpleArrayType(retType))) == ParamCategory.ENUM) { println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);"); checkAndWriteEnumRetTypeJavaStub(retType); + } else if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) { + // Check if the return value NONPRIMITIVES + String retGenValType = getGenericType(retType); + println("Class retGenValType = " + retGenValType + ".class;"); + println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, retGenValType, paramCls, paramObj);"); + println("return (" + retType + ")retObj;"); } else { println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);"); println("return (" + retType + ")retObj;"); @@ -1246,14 +1248,14 @@ public class IoTCompiler { /** * HELPER: writeConstructorJavaSkeleton() writes the constructor of the skeleton class */ - private void writeConstructorJavaSkeleton(String newSkelClass, String intface, InterfaceDecl intDecl, Collection methods) { + private void writeConstructorJavaSkeleton(String newSkelClass, String intface, InterfaceDecl intDecl, Collection methods, boolean callbackExist) { println("public " + newSkelClass + "(" + intface + " _mainObj, int _port) throws Exception {"); println("mainObj = _mainObj;"); println("rmiObj = new IoTRMIObject(_port);"); // Generate permission control initialization writeConstructorJavaPermission(intface); - writeJavaInitCallbackPermission(intface, intDecl); + writeJavaInitCallbackPermission(intface, intDecl, callbackExist); writeStructPermissionJavaSkeleton(methods, intDecl, intface); println("___waitRequestInvokeMethod();"); println("}\n"); @@ -1393,22 +1395,22 @@ public class IoTCompiler { for (int i = 0; i < methParams.size(); i++) { String paramType = methPrmTypes.get(i); String param = methParams.get(i); - String simpleType = getSimpleType(paramType); + String simpleType = getGenericType(paramType); if (isEnumClass(simpleType)) { // Check if this is enum type println("int paramInt" + i + "[] = (int[]) paramObj[" + i + "];"); println(simpleType + "[] enumVals = " + simpleType + ".values();"); if (isArray(param)) { // An array println("int len" + i + " = paramInt" + i + ".length;"); - println(simpleType + "[] paramEnum = new " + simpleType + "[len];"); + println(simpleType + "[] paramEnum" + i + " = new " + simpleType + "[len" + i + "];"); println("for (int i = 0; i < len" + i + "; i++) {"); - println("paramEnum[i] = enumVals[paramInt" + i + "[i]];"); + println("paramEnum" + i + "[i] = enumVals[paramInt" + i + "[i]];"); println("}"); } else if (isList(paramType)) { // A list println("int len" + i + " = paramInt" + i + ".length;"); - println("List<" + simpleType + "> paramEnum = new ArrayList<" + simpleType + ">();"); + println("List<" + simpleType + "> paramEnum" + i + " = new ArrayList<" + simpleType + ">();"); println("for (int i = 0; i < len" + i + "; i++) {"); - println("paramEnum.add(enumVals[paramInt" + i + "[i]]);"); + println("paramEnum" + i + ".add(enumVals[paramInt" + i + "[i]]);"); println("}"); } else { // Just one element println(simpleType + " paramEnum" + i + " = enumVals[paramInt" + i + "[0]];"); @@ -1424,10 +1426,10 @@ public class IoTCompiler { private void checkAndWriteEnumRetTypeJavaSkeleton(String retType, String methodId) { // Strips off array "[]" for return type - String pureType = getSimpleArrayType(getSimpleType(retType)); + String pureType = getSimpleArrayType(getGenericType(retType)); // Take the inner type of generic if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) - pureType = getTypeOfGeneric(retType)[0]; + pureType = getGenericType(retType); if (isEnumClass(pureType)) { // Check if this is enum type // Enum decoder @@ -1448,10 +1450,10 @@ public class IoTCompiler { private void checkAndWriteEnumRetConvJavaSkeleton(String retType) { // Strips off array "[]" for return type - String pureType = getSimpleArrayType(getSimpleType(retType)); + String pureType = getSimpleArrayType(getGenericType(retType)); // Take the inner type of generic if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) - pureType = getTypeOfGeneric(retType)[0]; + pureType = getGenericType(retType); if (isEnumClass(pureType)) { // Check if this is enum type if (isArray(retType)) { // An array @@ -1462,9 +1464,9 @@ public class IoTCompiler { println("}"); } else if (isList(retType)) { // A list println("int retLen = retEnum.size();"); - println("List<" + pureType + "> retEnumVal = new ArrayList<" + pureType + ">();"); + println("int[] retEnumVal = new int[retLen];"); println("for (int i = 0; i < retLen; i++) {"); - println("retEnumVal.add(retEnum[i].ordinal());"); + println("retEnumVal[i] = retEnum.get(i).ordinal();"); println("}"); } else { // Just one element println("int[] retEnumVal = new int[1];"); @@ -1656,9 +1658,9 @@ public class IoTCompiler { String retType = intDecl.getMethodType(method); if (retType.equals("void")) { print(intDecl.getMethodId(method) + "("); - } else if (isEnumClass(getSimpleArrayType(getSimpleType(retType)))) { // Enum type + } else if (isEnumClass(getSimpleArrayType(getGenericType(retType)))) { // Enum type checkAndWriteEnumRetTypeJavaSkeleton(retType, intDecl.getMethodId(method)); - } else if (isStructClass(getSimpleArrayType(getSimpleType(retType)))) { // Struct type + } else if (isStructClass(getSimpleArrayType(getGenericType(retType)))) { // Struct type print(retType + " retStruct = " + intDecl.getMethodId(method) + "("); } else { // We do have a return value print("Object retObj = " + intDecl.getMethodId(method) + "("); @@ -1667,9 +1669,9 @@ public class IoTCompiler { if (isCallbackMethod) { print(mapStubParam.get(i)); // Get the callback parameter - } else if (isEnumClass(getSimpleType(methPrmTypes.get(i)))) { // Enum class + } else if (isEnumClass(getGenericType(methPrmTypes.get(i)))) { // Enum class print(getEnumParam(methPrmTypes.get(i), methParams.get(i), i)); - } else if (isStructClass(getSimpleType(methPrmTypes.get(i)))) { + } else if (isStructClass(getGenericType(methPrmTypes.get(i)))) { print("paramStruct" + i); } else { String prmType = checkAndGetArray(methPrmTypes.get(i), methParams.get(i)); @@ -1683,11 +1685,11 @@ public class IoTCompiler { } println(");"); if (!retType.equals("void")) { - if (isEnumClass(getSimpleArrayType(getSimpleType(retType)))) { // Enum type + if (isEnumClass(getSimpleArrayType(getGenericType(retType)))) { // Enum type checkAndWriteEnumRetConvJavaSkeleton(retType); println("rmiObj.sendReturnObj(retObj);"); - } else if (isStructClass(getSimpleArrayType(getSimpleType(retType)))) { // Struct type - writeStructReturnJavaSkeleton(getSimpleArrayType(getSimpleType(retType)), retType); + } else if (isStructClass(getSimpleArrayType(getGenericType(retType)))) { // Struct type + writeStructReturnJavaSkeleton(getSimpleArrayType(getGenericType(retType)), retType); println("rmiObj.sendReturnObj(retCls, retObj);"); } else println("rmiObj.sendReturnObj(retObj);"); @@ -1778,8 +1780,9 @@ public class IoTCompiler { print("new Class[] { "); for (int i = 0; i < methParams.size(); i++) { String prmType = methPrmTypes.get(i); - if (getParamCategory(prmType) == ParamCategory.NONPRIMITIVES) - print(getTypeOfGeneric(prmType)[0] + ".class"); + if ((getParamCategory(prmType) == ParamCategory.NONPRIMITIVES) && + !isEnumClass(getGenericType(prmType))) + print(getGenericType(prmType) + ".class"); else print("null"); if (i != methParams.size() - 1) @@ -2124,7 +2127,7 @@ public class IoTCompiler { // Write properties writePropertiesJavaSkeleton(intface, callbackExist, intDecl); // Write constructor - writeConstructorJavaSkeleton(newSkelClass, intface, intDecl, methods); + writeConstructorJavaSkeleton(newSkelClass, intface, intDecl, methods, callbackExist); // Write methods writeMethodJavaSkeleton(methods, intDecl, callbackClasses, false); // Write method helper @@ -2552,9 +2555,6 @@ public class IoTCompiler { List methParams = intDecl.getMethodParams(method); List methPrmTypes = intDecl.getMethodParamTypes(method); - - //System.out.println("\n\nMethod return type: " + checkAndGetCplusType(intDecl.getMethodType(method)) + "\n\n"); - print(checkAndGetCplusType(intDecl.getMethodType(method)) + " " + intDecl.getMethodId(method) + "("); boolean isCallbackMethod = false; @@ -2631,11 +2631,8 @@ public class IoTCompiler { if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object print("\"int\""); } else { // Generate normal classes if it's not a callback object - //String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i)); - //String prmType = getSimpleType(getEnumType(paramTypeC)); String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i)); - String prmType = getEnumCplusClsType(paramTypeC); - print("\"" + prmType + "\""); + print("\"" + paramTypeC + "\""); } if (i != methParams.size() - 1) // Check if this is the last element print(", "); @@ -2683,14 +2680,13 @@ public class IoTCompiler { for (int i = 0; i < methParams.size(); i++) { String paramType = methPrmTypes.get(i); String param = methParams.get(i); - String simpleType = getSimpleType(paramType); - if (isEnumClass(simpleType)) { + if (isEnumClass(getGenericType(paramType))) { // Check if this is enum type if (isArrayOrList(paramType, param)) { // An array or vector - println("int len" + i + " = " + param + ".size();"); - println("vector paramEnum" + i + "(len);"); + println("int len" + i + " = " + getSimpleIdentifier(param) + ".size();"); + println("vector paramEnum" + i + "(len" + i + ");"); println("for (int i = 0; i < len" + i + "; i++) {"); - println("paramEnum" + i + "[i] = (int) " + param + "[i];"); + println("paramEnum" + i + "[i] = (int) " + getSimpleIdentifier(param) + "[i];"); println("}"); } else { // Just one element println("vector paramEnum" + i + "(1);"); @@ -2707,10 +2703,10 @@ public class IoTCompiler { private void checkAndWriteEnumRetTypeCplusStub(String retType) { // Strips off array "[]" for return type - String pureType = getSimpleArrayType(getSimpleType(retType)); + String pureType = getSimpleArrayType(getGenericType(retType)); // Take the inner type of generic if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) - pureType = getTypeOfGeneric(retType)[0]; + pureType = getGenericType(retType); if (isEnumClass(pureType)) { // Check if this is enum type println("vector retEnumInt;"); @@ -2955,8 +2951,6 @@ public class IoTCompiler { checkAndWriteStructSetupCplusStub(methParams, methPrmTypes, intDecl, method); println("int methodId = " + intDecl.getMethodNumId(method) + ";"); String retType = intDecl.getMethodType(method); - //String retTypeC = checkAndGetCplusType(retType); - //println("string retType = \"" + checkAndGetCplusArrayType(getStructType(getEnumType(retTypeC))) + "\";"); println("string retType = \"" + checkAndGetCplusRetClsType(getStructType(getEnumType(retType))) + "\";"); // Generate array of parameter types if (isStructPresent(methParams, methPrmTypes)) { @@ -2965,11 +2959,8 @@ public class IoTCompiler { println("int numParam = " + methParams.size() + ";"); print("string paramCls[] = { "); for (int i = 0; i < methParams.size(); i++) { - //String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i)); - //String prmType = getSimpleType(getEnumType(paramTypeC)); String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i)); - String prmType = getEnumCplusClsType(paramTypeC); - print("\"" + prmType + "\""); + print("\"" + paramTypeC + "\""); // Check if this is the last element (don't print a comma) if (i != methParams.size() - 1) { print(", "); @@ -2998,7 +2989,7 @@ public class IoTCompiler { writeStructReturnCplusStub(getGenericType(getSimpleArrayType(retType)), retType); } else { // Check if the return value NONPRIMITIVES - if (getParamCategory(retType) == ParamCategory.ENUM) { + if (isEnumClass(getSimpleArrayType(getGenericType(retType)))) { checkAndWriteEnumRetTypeCplusStub(retType); } else { //if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) @@ -3616,7 +3607,7 @@ public class IoTCompiler { for (int i = 0; i < methParams.size(); i++) { String paramType = methPrmTypes.get(i); String param = methParams.get(i); - String simpleType = getSimpleType(paramType); + String simpleType = getGenericType(paramType); if (isEnumClass(simpleType)) { // Check if this is enum type if (isArrayOrList(paramType, param)) { // An array @@ -3640,7 +3631,7 @@ public class IoTCompiler { private void checkAndWriteEnumRetTypeCplusSkeleton(String retType) { // Strips off array "[]" for return type - String pureType = getSimpleArrayType(getSimpleType(retType)); + String pureType = getSimpleArrayType(getGenericType(retType)); // Take the inner type of generic if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) pureType = getTypeOfGeneric(retType)[0]; @@ -3672,9 +3663,9 @@ public class IoTCompiler { String paramType = returnGenericCallbackType(methPrmTypes.get(i)); if (callbackClasses.contains(paramType)) print("stub" + i); - else if (isEnumClass(getSimpleType(paramType))) // Check if this is enum type + else if (isEnumClass(getGenericType(paramType))) // Check if this is enum type print("paramEnum" + i); - else if (isStructClass(getSimpleType(paramType))) // Struct type + else if (isStructClass(getGenericType(paramType))) // Struct type print("paramStruct" + i); else print(getSimpleIdentifier(methParams.get(i))); @@ -3704,23 +3695,23 @@ public class IoTCompiler { if (retType.equals("void")) { writeMethodInputParameters(methParams, methPrmTypes, callbackClasses, methodId); } else { // We do have a return value - if (isEnumClass(getSimpleArrayType(getSimpleType(retType)))) // Enum type + if (isEnumClass(getSimpleArrayType(getGenericType(retType)))) // Enum type print(checkAndGetCplusType(retType) + " retEnum = "); - else if (isStructClass(getSimpleArrayType(getSimpleType(retType)))) // Struct type + else if (isStructClass(getSimpleArrayType(getGenericType(retType)))) // Struct type print(checkAndGetCplusType(retType) + " retStruct = "); else print(checkAndGetCplusType(retType) + " retVal = "); writeMethodInputParameters(methParams, methPrmTypes, callbackClasses, methodId); checkAndWriteEnumRetTypeCplusSkeleton(retType); - if (isStructClass(getSimpleArrayType(getSimpleType(retType)))) // Struct type - writeStructReturnCplusSkeleton(getSimpleArrayType(getSimpleType(retType)), retType); - if (isEnumClass(getSimpleArrayType(getSimpleType(retType)))) // Enum type + if (isStructClass(getSimpleArrayType(getGenericType(retType)))) // Struct type + writeStructReturnCplusSkeleton(getSimpleArrayType(getGenericType(retType)), retType); + if (isEnumClass(getSimpleArrayType(getGenericType(retType)))) // Enum type println("void* retObj = &retEnumInt;"); else - if (!isStructClass(getSimpleArrayType(getSimpleType(retType)))) // Struct type + if (!isStructClass(getSimpleArrayType(getGenericType(retType)))) // Struct type println("void* retObj = &retVal;"); String retTypeC = checkAndGetCplusType(retType); - if (isStructClass(getSimpleArrayType(getSimpleType(retType)))) // Struct type + if (isStructClass(getSimpleArrayType(getGenericType(retType)))) // Struct type println("rmiObj->sendReturnObj(retObj, retCls, numRetObj);"); else println("rmiObj->sendReturnObj(retObj, \"" + checkAndGetCplusRetClsType(getEnumType(retType)) + "\");"); @@ -3745,11 +3736,8 @@ public class IoTCompiler { callbackType = paramType; print("\"int\""); } else { // Generate normal classes if it's not a callback object - //String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i)); - //String prmType = getSimpleType(getEnumType(paramTypeC)); String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i)); - String prmType = getEnumCplusClsType(paramTypeC); - print("\"" + prmType + "\""); + print("\"" + paramTypeC + "\""); } if (i != methParams.size() - 1) { print(", "); @@ -3763,10 +3751,12 @@ public class IoTCompiler { for (int i = 0; i < methParams.size(); i++) { String paramType = returnGenericCallbackType(methPrmTypes.get(i)); if (!callbackClasses.contains(paramType)) { - String methPrmType = checkAndGetCplusType(methPrmTypes.get(i)); - if (isEnumClass(getSimpleType(methPrmType))) { // Check if this is enum type + String methParamType = methPrmTypes.get(i); + if (isEnumClass(getSimpleArrayType(getGenericType(methParamType)))) { + // Check if this is enum type println("vector paramEnumInt" + i + ";"); } else { + String methPrmType = checkAndGetCplusType(methParamType); String methParamComplete = checkAndGetCplusArray(methPrmType, methParams.get(i)); println(methParamComplete + ";"); } @@ -3778,7 +3768,7 @@ public class IoTCompiler { String paramType = returnGenericCallbackType(methPrmTypes.get(i)); if (callbackClasses.contains(paramType)) print("&numStubs" + i); - else if (isEnumClass(getSimpleType(paramType))) // Check if this is enum type + else if (isEnumClass(getGenericType(paramType))) // Check if this is enum type print("¶mEnumInt" + i); else print("&" + getSimpleIdentifier(methParams.get(i))); @@ -3961,14 +3951,14 @@ public class IoTCompiler { } else { // Generate normal classes if it's not a callback object String paramTypeC = checkAndGetCplusType(methPrmTypes.get(i)); String prmTypeC = checkAndGetCplusArrayType(paramTypeC, methParams.get(i)); - if (isEnumClass(getSimpleType(paramTypeC))) { // Check if this is enum type + if (isEnumClass(getGenericType(paramTypeC))) { // Check if this is enum type println("vector paramEnumInt" + i + ";"); } else { String methParamComplete = checkAndGetCplusArray(paramTypeC, methParams.get(i)); println(methParamComplete + ";"); } println("paramCls[pos] = \"" + getEnumType(prmTypeC) + "\";"); - if (isEnumClass(getSimpleType(paramType))) // Check if this is enum type + if (isEnumClass(getGenericType(paramType))) // Check if this is enum type println("paramObj[pos++] = ¶mEnumInt" + i); else println("paramObj[pos++] = &" + getSimpleIdentifier(methParams.get(i)) + ";"); @@ -4561,9 +4551,12 @@ public class IoTCompiler { /** * This function converts Java to C++ type for compilation */ - private String convertType(String jType) { + private String convertType(String type) { - return mapPrimitives.get(jType); + if (mapPrimitives.containsKey(type)) + return mapPrimitives.get(type); + else + return type; } @@ -4816,7 +4809,7 @@ public class IoTCompiler { String pureType = getSimpleArrayType(type); // Take the inner type of generic if (getParamCategory(type) == ParamCategory.NONPRIMITIVES) - pureType = getTypeOfGeneric(type)[0]; + pureType = getGenericType(type); if (isEnumClass(pureType)) { String enumType = "int[]"; return enumType; @@ -4831,7 +4824,7 @@ public class IoTCompiler { String pureType = getSimpleArrayType(type); // Take the inner type of generic if (getParamCategory(type) == ParamCategory.NONPRIMITIVES) - pureType = getTypeOfGeneric(type)[0]; + pureType = getGenericType(type); if (isEnumClass(pureType)) { String enumType = "int*"; return enumType; @@ -4847,7 +4840,7 @@ public class IoTCompiler { String pureType = getSimpleArrayType(type); // Take the inner type of generic if (getParamCategory(type) == ParamCategory.NONPRIMITIVES) - pureType = getTypeOfGeneric(type)[0]; + pureType = getGenericType(type); if (isStructClass(pureType)) { String structType = "int"; return structType; @@ -5161,7 +5154,12 @@ public class IoTCompiler { // - Check and return C++ vector class, e.g. List A into vector private String checkAndGetCplusArgClsType(String paramType, String param) { - String paramTypeRet = null; + String paramTypeRet = getEnumCplusClsType(paramType); + if (!paramTypeRet.equals(paramType)) + // Just return if it is an enum type + // Type will still be the same if it's not an enum type + return paramTypeRet; + // Check for array declaration if (param.contains("[]")) { paramTypeRet = getSimpleArrayType(paramType) + "*";