Integrating enum and struct in one method call; fixing minor bugs
[iot2.git] / iotjava / iotpolicy / IoTCompiler.java
index 9eafffbef295bb01b287b4d6075600f2863f0d92..5c3ab9226913c2a771b8cea644078b4ff9d5911d 100644 (file)
@@ -1363,7 +1363,6 @@ public class IoTCompiler {
                for (int i = 0; i < methParams.size(); i++) {
                        String paramType = methPrmTypes.get(i);
                        String param = methParams.get(i);
-                       //if (callbackType.equals(paramType)) {
                        if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
                                println("try {");
                                String exchParamType = checkAndGetParamClass(getGenericType(paramType));
@@ -1674,8 +1673,9 @@ public class IoTCompiler {
 
                checkAndWriteEnumTypeJavaSkeleton(methParams, methPrmTypes);
                Map<Integer,String> mapStubParam = null;
-               if (isCallbackMethod)
+               if (isCallbackMethod) {
                        mapStubParam = writeCallbackJavaStubGeneration(methParams, methPrmTypes, callbackType);
+               }
                // Check if this is "void"
                String retType = intDecl.getMethodType(method);
                if (retType.equals("void")) {
@@ -1689,14 +1689,15 @@ public class IoTCompiler {
                }
                for (int i = 0; i < methParams.size(); i++) {
 
-                       if (isCallbackMethod) {
+                       String paramType = methPrmTypes.get(i);
+                       if (isCallbackMethod && checkCallbackType(paramType, callbackType)) {
                                print(mapStubParam.get(i));     // Get the callback parameter
-                       } else if (isEnumClass(getGenericType(methPrmTypes.get(i)))) { // Enum class
-                               print(getEnumParam(methPrmTypes.get(i), methParams.get(i), i));
-                       } else if (isStructClass(getGenericType(methPrmTypes.get(i)))) {
+                       } else if (isEnumClass(getGenericType(paramType))) { // Enum class
+                               print(getEnumParam(paramType, methParams.get(i), i));
+                       } else if (isStructClass(getGenericType(paramType))) {
                                print("paramStruct" + i);
                        } else {
-                               String prmType = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
+                               String prmType = checkAndGetArray(paramType, methParams.get(i));
                                if (isStructMethod)
                                        print("(" + prmType + ") paramObj[offset" + i + "]");
                                else
@@ -2676,7 +2677,7 @@ public class IoTCompiler {
                        if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
                                print("&___paramCB");
                        } else
-                               print(getSimpleIdentifier(methParams.get(i)));
+                               print("&" + getSimpleIdentifier(methParams.get(i)));
                        if (i != methParams.size() - 1)
                                print(", ");
                }
@@ -2973,6 +2974,7 @@ public class IoTCompiler {
                println("int methodId = " + intDecl.getMethodNumId(method) + ";");
                String retType = intDecl.getMethodType(method);
                println("string retType = \"" + checkAndGetCplusRetClsType(getStructType(getEnumType(retType))) + "\";");
+               checkAndWriteEnumTypeCplusStub(methParams, methPrmTypes);
                // Generate array of parameter types
                if (isStructPresent(methParams, methPrmTypes)) {
                        writeStructParamClassCplusStub(methParams, methPrmTypes);
@@ -2993,7 +2995,6 @@ public class IoTCompiler {
                                }
                        }
                        println(" };");
-                       checkAndWriteEnumTypeCplusStub(methParams, methPrmTypes);
                        // Generate array of parameter objects
                        print("void* paramObj[] = { ");
                        for (int i = 0; i < methParams.size(); i++) {
@@ -3996,7 +3997,7 @@ public class IoTCompiler {
                                        String prmTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
                                        println("paramCls[pos] = \"" + prmTypeC + "\";");
                                        if (isEnumClass(getGenericType(paramType)))     // Check if this is enum type
-                                               println("paramObj[pos++] = &paramEnumInt" + i);
+                                               println("paramObj[pos++] = &paramEnumInt" + i + ";");
                                        else
                                                println("paramObj[pos++] = &" + getSimpleIdentifier(methParams.get(i)) + ";");
                                }