for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
String newIntface = intMeth.getKey();
int newObjectId = getNewIntfaceObjectId(newIntface);
- //println("private final static int object" + newObjectId + "Id = " +
- // newObjectId + ";\t//" + newIntface);
Set<String> methodIds = intMeth.getValue();
print("private static Integer[] object" + newObjectId + "Permission = { ");
int i = 0;
println("retClsVal[retPos++] = null;");
}
}
- //println("Object[] retActualObj = rmiComm.getStructObjects(retCls, retClsVal);");
// Handle the actual returned struct
writeWaitForReturnValueJava(method, intDecl, "Object[] retActualObj = rmiComm.getStructObjects(retCls, retClsVal);");
if (isArray(retType)) { // An array
// Now, write the body of stub!
if (isCallbackMethod)
writeCallbackMethodBodyJavaStub(intDecl, methParams, methPrmTypes, method, callbackType);
- //else
writeStdMethodBodyJavaStub(intDecl, methParams, methPrmTypes, method, callbackType);
println("}\n");
}
private void writePropertiesJavaSkeleton(String intface, InterfaceDecl intDecl) {
println("private " + intface + " mainObj;");
- //println("private int objectId = 0;");
Integer objId = mapIntfaceObjId.get(intface);
println("private int objectId = " + objId + ";");
println("// Communications and synchronizations");
// Generate array of parameter objects
boolean isCallbackMethod = false;
- //String callbackType = null;
Set<String> callbackType = new HashSet<String>();
println("byte[] localMethodBytes = methodBytes;");
println("rmiComm.setGetMethodBytes();");
// Generate array of parameter objects
boolean isCallbackMethod = false;
- //String callbackType = null;
Set<String> callbackType = new HashSet<String>();
println("byte[] localMethodBytes = methodBytes;");
println("rmiComm.setGetMethodBytes();");
String paramType = returnGenericCallbackType(methPrmTypes.get(i));
if (callbackClasses.contains(paramType)) {
isCallbackMethod = true;
- //callbackType = paramType;
callbackType.add(paramType);
print("int[].class");
} else { // Generate normal classes if it's not a callback object
if (i != methParams.size() - 1)
print(", ");
}
- //println(" }, ");
// Generate generic class if it's a generic type.. null otherwise
print(" }, new Class<?>[] { ");
for (int i = 0; i < methParams.size(); i++) {
println("1;");
}
println("void* paramObjStruct" + i + "[] = { &structLen" + i + " };");
- //println("void* retStructLen" + i + " = NULL;");
println("rmiComm->remoteCall(objectId, methodIdStruct" + i +
", paramClsStruct" + i + ", paramObjStruct" + i +
", numParam" + i + ");\n");
println("retObj[retPos++] = &retParam" + i + ";");
}
}
- //println("rmiComm->getStructObjects(retCls, numRet, retObj);");
writeWaitForReturnValueCplus(method, intDecl, "rmiComm->getStructObjects(retCls, numRet, retObj);");
if (isArrayOrList(retType, retType)) { // An array or list
println("vector<" + simpleType + "> structRet(retLen);");
println("delete obj;");
println("}\n");
println("extern \"C\" void init" + newStubClass + "(void* t) {");
- //println(newStubClass + "* obj = (" + newStubClass + "*) t;");
- //println("obj->init();");
- //println("while(true);");
println("}\n");
}
}
println("using namespace std;"); println("");
// Add default constructor and destructor
- //println(newStubClass + "() { }"); println("");
writeConstructorCplusStub(newStubClass, callbackExist, callbackClasses, methods, intDecl);
writeCallbackConstructorCplusStub(newStubClass, callbackExist, callbackClasses, methods, intDecl);
writeDeconstructorCplusStub(newStubClass, callbackExist, callbackClasses);
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("int numStubs" + i + " = 0;");
println("vector<int> numStubIdArray" + i + ";");
}
}
// Generate array of parameter types
boolean isCallbackMethod = false;
- //String callbackType = null;
Set<String> callbackType = new HashSet<String>();
print("string paramCls[] = { ");
for (int i = 0; i < methParams.size(); i++) {
String paramType = returnGenericCallbackType(methPrmTypes.get(i));
if (callbackClasses.contains(paramType)) {
isCallbackMethod = true;
- //callbackType = paramType;
callbackType.add(paramType);
print("\"int*\"");
} else { // Generate normal classes if it's not a callback object
String prmType = returnGenericCallbackType(methPrmTypes.get(i));
if (callbackClasses.contains(prmType)) {
isCallbackMethod = true;
- //callbackType = prmType;
callbackType.add(prmType);
- //println("int numStubs" + i + " = 0;");
println("vector<int> numStubIdArray" + i + ";");
println("paramCls[pos] = \"int*\";");
println("paramObj[pos++] = &numStubIdArray" + i + ";");
println("delete obj;");
println("}\n");
println("extern \"C\" void init" + newSkelClass + "(void* t) {");
- //println(newSkelClass + "* obj = (" + newSkelClass + "*) t;");
- //println("obj->init();");
- //println("while(true);");
println("}\n");
}
public static void printUsage() {
System.out.println();
- System.out.println("Sentinel interface and stub compiler version 1.0");
+ System.out.println("Vigilia interface and stub compiler version 1.0");
System.out.println("Copyright (c) 2015-2016 University of California, Irvine - Programming Language Group.");
System.out.println("All rights reserved.");
System.out.println("Usage:");
// Basically the compiler needs to parse the policy (and requires) files for callback class first
private int getNewIntfaceObjectId(String newIntface) {
-// if (!mapNewIntfaceObjId.containsKey(newIntface)) {
-// throw new Error("IoTCompiler: Need to parse policy and requires files for callback class first! " +
-// "Please place the two files for callback class in front...\n");
-// return -1;
-// } else {
- int retObjId = mapNewIntfaceObjId.get(newIntface);
- return retObjId;
-// }
+ int retObjId = mapNewIntfaceObjId.get(newIntface);
+ return retObjId;
}
// Add the standard list first
importClasses.add("<vector>");
importClasses.add("<set>");
- //importClasses.add("\"IoTRMICall.hpp\"");
- //importClasses.add("\"IoTRMIObject.hpp\"");
importClasses.add("\"IoTRMIComm.hpp\"");
importClasses.add("\"IoTRMICommClient.hpp\"");
importClasses.add("\"IoTRMICommServer.hpp\"");