i++;
}
println(" };");
- println("private List<Integer> set" + newObjectId + "Allowed;");
+ println("private static List<Integer> set" + newObjectId + "Allowed;");
}
}
}
+ /**
+ * HELPER: writeJavaCallbackPermission() writes the permission for callback
+ */
+ private void writeJavaCallbackPermission(String intface, int methodNumId) {
+
+ Map<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
+ for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
+ String newIntface = intMeth.getKey();
+ int newObjectId = getNewIntfaceObjectId(newIntface);
+ println("set" + newObjectId + "Allowed.add(" + methodNumId + ");");
+ }
+ }
+
+
/**
* HELPER: writeInitCallbackJavaStub() writes callback initialization in stub
*/
println("thread.start();\n");
// Generate info sending part
String method = "___initCallBack()";
- println("int methodId = " + intDecl.getHelperMethodNumId(method) + ";");
+ int methodNumId = intDecl.getHelperMethodNumId(method);
+ println("int methodId = " + methodNumId + ";");
+ writeJavaCallbackPermission(intface, methodNumId);
println("Class<?> retType = void.class;");
println("Class<?>[] paramCls = new Class<?>[] { int.class, String.class, int.class };");
println("Object[] paramObj = new Object[] { ports[0], address, 0 };");
/**
* HELPER: writeMethodCplusStub() writes the methods of the stub
*/
- private void writeMethodCplusStub(Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
+ private void writeMethodCplusStub(String intface, Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
for (String method : methods) {
// Write the init callback helper method
if (isCallbackMethod) {
writeInitCallbackCplusStub(callbackType, intDecl);
- writeInitCallbackSendInfoCplusStub(intDecl);
+ writeInitCallbackSendInfoCplusStub(intface, intDecl);
}
}
}
//String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
//String prmType = getSimpleType(getEnumType(paramTypeC));
String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
- String prmType = getEnumType(paramTypeC);
+ String prmType = getEnumCplusClsType(paramTypeC);
print("\"" + prmType + "\"");
}
if (i != methParams.size() - 1) // Check if this is the last element
//String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
//String prmType = getSimpleType(getEnumType(paramTypeC));
String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
- String prmType = getEnumType(paramTypeC);
+ String prmType = getEnumCplusClsType(paramTypeC);
print("\"" + prmType + "\"");
// Check if this is the last element (don't print a comma)
if (i != methParams.size() - 1) {
String newIntface = intMeth.getKey();
int newObjectId = getNewIntfaceObjectId(newIntface);
println("const static int object" + newObjectId + "Id = " + newObjectId + ";\t//" + newIntface);
- println("const static set<int> set" + newObjectId + "Allowed;");
+ println("static set<int> set" + newObjectId + "Allowed;");
}
}
}
+ /**
+ * HELPER: writeCplusCallbackPermission() writes the permission for callback
+ */
+ private void writeCplusCallbackPermission(String intface, int methodNumId) {
+
+ Map<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
+ for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
+ String newIntface = intMeth.getKey();
+ int newObjectId = getNewIntfaceObjectId(newIntface);
+ println("set" + newObjectId + "Allowed.insert(" + methodNumId + ");");
+ }
+ }
+
+
/**
* HELPER: writeInitCallbackSendInfoCplusStub() writes the initialization (send info part) of callback
*/
- private void writeInitCallbackSendInfoCplusStub(InterfaceDecl intDecl) {
+ private void writeInitCallbackSendInfoCplusStub(String intface, InterfaceDecl intDecl) {
// Generate info sending part
println("void ___regCB() {");
println("int numParam = 3;");
String method = "___initCallBack()";
- println("int methodId = " + intDecl.getHelperMethodNumId(method) + ";");
+ int methodNumId = intDecl.getHelperMethodNumId(method);
+ println("int methodId = " + methodNumId + ";");
+ writeCplusCallbackPermission(intface, methodNumId);
println("string retType = \"void\";");
println("string paramCls[] = { \"int\", \"string\", \"int\" };");
println("int rev = 0;");
writeConstructorCplusStub(newStubClass, callbackExist, callbackClasses);
writeDeconstructorCplusStub(newStubClass, callbackExist, callbackClasses);
// Write methods
- writeMethodCplusStub(methods, intDecl, callbackClasses);
+ writeMethodCplusStub(intface, methods, intDecl, callbackClasses);
print("}"); println(";");
if (callbackExist)
writePermissionInitializationCplus(intface, newStubClass, intDecl);
writeConstructorCplusCallbackStub(newStubClass, callbackExist, callbackClasses);
writeDeconstructorCplusStub(newStubClass, callbackExist, callbackClasses);
// Write methods
- writeMethodCplusStub(methods, intDecl, callbackClasses);
+ writeMethodCplusStub(intface, methods, intDecl, callbackClasses);
println("};");
if (callbackExist)
writePermissionInitializationCplus(intface, newStubClass, intDecl);
for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
String newIntface = intMeth.getKey();
int newObjectId = getNewIntfaceObjectId(newIntface);
- print("const set<int> " + newSkelClass + "::set" + newObjectId + "Allowed {");
+ print("set<int> " + newSkelClass + "::set" + newObjectId + "Allowed {");
Set<String> methodIds = intMeth.getValue();
int i = 0;
for (String methodId : methodIds) {
//String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
//String prmType = getSimpleType(getEnumType(paramTypeC));
String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
- String prmType = getEnumType(paramTypeC);
+ String prmType = getEnumCplusClsType(paramTypeC);
print("\"" + prmType + "\"");
}
if (i != methParams.size() - 1) {
return type;
}
+ // Handle and return the correct enum declaration translate into int* for C
+ private String getEnumCplusClsType(String type) {
+
+ // Strips off array "[]" for return type
+ String pureType = getSimpleArrayType(type);
+ // Take the inner type of generic
+ if (getParamCategory(type) == ParamCategory.NONPRIMITIVES)
+ pureType = getTypeOfGeneric(type)[0];
+ if (isEnumClass(pureType)) {
+ String enumType = "int*";
+ return enumType;
+ } else
+ return type;
+ }
+
// Handle and return the correct struct declaration
private String getStructType(String type) {