From da6d0d112a9658557ea500805ba0dc2c4c51cde4 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Wed, 4 Apr 2018 09:29:57 -0700 Subject: [PATCH] Adding object Id specification for stub/skeleton used in multiple applications. --- iotjava/iotpolicy/IoTCompiler.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/iotjava/iotpolicy/IoTCompiler.java b/iotjava/iotpolicy/IoTCompiler.java index bdf6a41..79e838c 100644 --- a/iotjava/iotpolicy/IoTCompiler.java +++ b/iotjava/iotpolicy/IoTCompiler.java @@ -177,6 +177,17 @@ public class IoTCompiler { // Set object Id counter to 0 for each interface mapIntfaceObjId.put(origInt, countObjId++); } + + + /** + * setObjectId() updates the object Id. This option is useful + * when the stub/skeleton are also used in other apps, so that + * we can set a single object Id for the stub/skeleton. + */ + private void setObjectId(String intface, String objectId) { + + mapIntfaceObjId.put(intface, Integer.parseInt(objectId)); + } /** @@ -4516,6 +4527,9 @@ public class IoTCompiler { System.out.println("Options:"); System.out.println("\t-cont\t\tSpecify controller class name"); System.out.println("\t-drv\t\t\tSpecify driver class name"); + System.out.println("\t\t(place this option right after a pair of .pol and .req files)"); + System.out.println("\t-objid\t\t\tSpecify object Id for stub/skeleton used in multiple apps"); + System.out.println("\t\t(place this option right after -drv option)"); System.out.println("\t-cplus\t\t\tGenerate C++ stub files"); System.out.println("\t-java\t\t\tGenerate Java stub files\n"); System.out.println("\t\tNote: The options -cont and -drv have to be defined before -cplus and -java"); @@ -4655,7 +4669,7 @@ public class IoTCompiler { // Basically the compiler needs to parse the policy (and requires) files for callback class first private int getNewIntfaceObjectId(String newIntface) { - int retObjId = mapNewIntfaceObjId.get(newIntface); + int retObjId = mapNewIntfaceObjId.get(newIntface); return retObjId; } @@ -5348,7 +5362,6 @@ public class IoTCompiler { IoTCompiler comp = new IoTCompiler(); int i = 0; - //boolean driverDefined = false; boolean controllerDefined = false; do { if (!controllerDefined && args[i].equals("-cont")) { @@ -5365,11 +5378,18 @@ public class IoTCompiler { comp.setDataStructures(intface, pnPol, pnReq); comp.getMethodsForIntface(intface); i = i + 2; + // Driver name if (args[i].equals("-drv")) { comp.setDriverClass(intface, args[i+1]); i = i + 2; } else throw new Error("IoTCompiler: ERROR - driver class name is needed for the interface: " + intface + "\n"); + // Object ID (for a stub/skeleton pair that is also used in other applications) + if (args[i].equals("-objid")) { + comp.setObjectId(intface, args[i+1]); + i = i + 2; + } + // 1) Check if this is the last option before "-java" or "-cplus" // 2) Check if this is really the last option } while(!args[i].equals("-java") && -- 2.34.1