Testing complex callbacks invocation; fixing subtle bugs
[iot2.git] / iotjava / iotpolicy / IoTCompiler.java
index 9eafffbef295bb01b287b4d6075600f2863f0d92..8242bfc0d99fa2094705b960d2935e3fb09f1749 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(", ");
                }