/**
- * HELPER: writeJavaCallbackPermission() writes the permission for callback
+ * HELPER: writeJavaInitCallbackPermission() writes the permission for callback
*/
- private void writeJavaCallbackPermission(String intface, int methodNumId) {
+ private void writeJavaInitCallbackPermission(String intface, InterfaceDecl intDecl) {
+ String method = "___initCallBack()";
+ int methodNumId = intDecl.getHelperMethodNumId(method);
Map<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
String newIntface = intMeth.getKey();
String method = "___initCallBack()";
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: writeConstructorJavaSkeleton() writes the constructor of the skeleton class
*/
- private void writeConstructorJavaSkeleton(String newSkelClass, String intface) {
+ private void writeConstructorJavaSkeleton(String newSkelClass, String intface, InterfaceDecl intDecl) {
println("public " + newSkelClass + "(" + intface + " _mainObj, int _port) throws Exception {");
println("mainObj = _mainObj;");
println("rmiObj = new IoTRMIObject(_port);");
// Generate permission control initialization
writeConstructorJavaPermission(intface);
+ writeJavaInitCallbackPermission(intface, intDecl);
println("___waitRequestInvokeMethod();");
println("}\n");
}
// Write properties
writePropertiesJavaSkeleton(intface, callbackExist, intDecl);
// Write constructor
- writeConstructorJavaSkeleton(newSkelClass, intface);
+ writeConstructorJavaSkeleton(newSkelClass, intface, intDecl);
// Write methods
writeMethodJavaSkeleton(methods, intDecl, callbackClasses, false);
// Write method helper
/**
* HELPER: writeMethodCplusStub() writes the methods of the stub
*/
- private void writeMethodCplusStub(String intface, Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
+ private void writeMethodCplusStub(Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
for (String method : methods) {
// Write the init callback helper method
if (isCallbackMethod) {
writeInitCallbackCplusStub(callbackType, intDecl);
- writeInitCallbackSendInfoCplusStub(intface, intDecl);
+ writeInitCallbackSendInfoCplusStub(intDecl);
}
}
}
/**
- * HELPER: writeCplusCallbackPermission() writes the permission for callback
+ * HELPER: writeCplusInitCallbackPermission() writes the permission for callback
*/
- private void writeCplusCallbackPermission(String intface, int methodNumId) {
+ private void writeCplusInitCallbackPermission(String intface, InterfaceDecl intDecl) {
+ String method = "___initCallBack()";
+ int methodNumId = intDecl.getHelperMethodNumId(method);
Map<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
String newIntface = intMeth.getKey();
/**
* HELPER: writeInitCallbackSendInfoCplusStub() writes the initialization (send info part) of callback
*/
- private void writeInitCallbackSendInfoCplusStub(String intface, InterfaceDecl intDecl) {
+ private void writeInitCallbackSendInfoCplusStub(InterfaceDecl intDecl) {
// Generate info sending part
println("void ___regCB() {");
String method = "___initCallBack()";
int methodNumId = intDecl.getHelperMethodNumId(method);
println("int methodId = " + methodNumId + ";");
- writeCplusCallbackPermission(intface, 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(intface, methods, intDecl, callbackClasses);
+ writeMethodCplusStub(methods, intDecl, callbackClasses);
print("}"); println(";");
if (callbackExist)
writePermissionInitializationCplus(intface, newStubClass, intDecl);
writeConstructorCplusCallbackStub(newStubClass, callbackExist, callbackClasses);
writeDeconstructorCplusStub(newStubClass, callbackExist, callbackClasses);
// Write methods
- writeMethodCplusStub(intface, methods, intDecl, callbackClasses);
+ writeMethodCplusStub(methods, intDecl, callbackClasses);
println("};");
if (callbackExist)
writePermissionInitializationCplus(intface, newStubClass, intDecl);
/**
* HELPER: writeConstructorCplusSkeleton() writes the constructor of the skeleton class
*/
- private void writeConstructorCplusSkeleton(String newSkelClass, String intface, boolean callbackExist) {
+ private void writeConstructorCplusSkeleton(String newSkelClass, String intface, boolean callbackExist, InterfaceDecl intDecl) {
println(newSkelClass + "(" + intface + " *_mainObj, int _port) {");
println("bool _bResult = false;");
println("mainObj = _mainObj;");
println("rmiObj = new IoTRMIObject(_port, &_bResult);");
+ writeCplusInitCallbackPermission(intface, intDecl);
println("___waitRequestInvokeMethod();");
println("}\n");
}
writePropertiesCplusSkeleton(intface, callbackExist, callbackClasses);
println("public:\n");
// Write constructor
- writeConstructorCplusSkeleton(newSkelClass, intface, callbackExist);
+ writeConstructorCplusSkeleton(newSkelClass, intface, callbackExist, intDecl);
// Write deconstructor
writeDeconstructorCplusSkeleton(newSkelClass, callbackExist, callbackClasses);
// Write methods