From 6e31aafa2c86bb913bf117cd73178cafadca2d99 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Thu, 1 Dec 2016 10:42:21 -0800 Subject: [PATCH] Fixing bugs: 1) Arrays.asList generates finaled List (need to feed it into an ArrayList constructor); 2) Generate setAllowed.insert() only when there is callback for C++ --- iotjava/iotpolicy/IoTCompiler.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/iotjava/iotpolicy/IoTCompiler.java b/iotjava/iotpolicy/IoTCompiler.java index 9d9ecdd..c28aeea 100644 --- a/iotjava/iotpolicy/IoTCompiler.java +++ b/iotjava/iotpolicy/IoTCompiler.java @@ -447,7 +447,7 @@ public class IoTCompiler { for (Map.Entry> intMeth : mapNewIntMethods.entrySet()) { String newIntface = intMeth.getKey(); int newObjectId = getNewIntfaceObjectId(newIntface); - println("set" + newObjectId + "Allowed = Arrays.asList(object" + newObjectId +"Permission);"); + println("set" + newObjectId + "Allowed = new ArrayList(Arrays.asList(object" + newObjectId +"Permission));"); } } @@ -3148,15 +3148,17 @@ public class IoTCompiler { /** * HELPER: writeCplusInitCallbackPermission() writes the permission for callback */ - private void writeCplusInitCallbackPermission(String intface, InterfaceDecl intDecl) { + private void writeCplusInitCallbackPermission(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.insert(" + 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.insert(" + methodNumId + ");"); + } } } @@ -3429,7 +3431,7 @@ public class IoTCompiler { println("bool _bResult = false;"); println("mainObj = _mainObj;"); println("rmiObj = new IoTRMIObject(_port, &_bResult);"); - writeCplusInitCallbackPermission(intface, intDecl); + writeCplusInitCallbackPermission(intface, intDecl, callbackExist); writeStructPermissionCplusSkeleton(methods, intDecl, intface); println("___waitRequestInvokeMethod();"); println("}\n"); -- 2.34.1