// 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));
+ }
/**
System.out.println("Options:");
System.out.println("\t-cont\t<controller-class>\tSpecify controller class name");
System.out.println("\t-drv\t<driver-class>\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<object-id>\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<directory>\t\tGenerate C++ stub files");
System.out.println("\t-java\t<directory>\t\tGenerate Java stub files\n");
System.out.println("\t\tNote: The options -cont and -drv have to be defined before -cplus and -java");
// 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;
}
IoTCompiler comp = new IoTCompiler();
int i = 0;
- //boolean driverDefined = false;
boolean controllerDefined = false;
do {
if (!controllerDefined && args[i].equals("-cont")) {
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") &&