X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iot2.git;a=blobdiff_plain;f=iotjava%2Fiotpolicy%2FIoTCompiler.java;h=e48df3571b7067050977bac980eb22640939c70c;hp=f2d8397ec03a917c84905e303605b0be7a7fc64a;hb=39d1438c65ec8184abb877639d2419b344b51662;hpb=ac75576ae0fffb9f1c277cca6ecd285548006137 diff --git a/iotjava/iotpolicy/IoTCompiler.java b/iotjava/iotpolicy/IoTCompiler.java index f2d8397..e48df35 100644 --- a/iotjava/iotpolicy/IoTCompiler.java +++ b/iotjava/iotpolicy/IoTCompiler.java @@ -491,10 +491,12 @@ public class IoTCompiler { /** - * 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> mapNewIntMethods = mapInt2NewInts.get(intface); for (Map.Entry> intMeth : mapNewIntMethods.entrySet()) { String newIntface = intMeth.getKey(); @@ -539,7 +541,6 @@ public class IoTCompiler { 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 };"); @@ -1216,13 +1217,14 @@ public class IoTCompiler { /** * 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"); } @@ -2092,7 +2094,7 @@ public class IoTCompiler { // 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 @@ -2513,7 +2515,7 @@ public class IoTCompiler { /** * HELPER: writeMethodCplusStub() writes the methods of the stub */ - private void writeMethodCplusStub(String intface, Collection methods, InterfaceDecl intDecl, Set callbackClasses) { + private void writeMethodCplusStub(Collection methods, InterfaceDecl intDecl, Set callbackClasses) { for (String method : methods) { @@ -2552,7 +2554,7 @@ public class IoTCompiler { // Write the init callback helper method if (isCallbackMethod) { writeInitCallbackCplusStub(callbackType, intDecl); - writeInitCallbackSendInfoCplusStub(intface, intDecl); + writeInitCallbackSendInfoCplusStub(intDecl); } } } @@ -3122,10 +3124,12 @@ public class IoTCompiler { /** - * 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> mapNewIntMethods = mapInt2NewInts.get(intface); for (Map.Entry> intMeth : mapNewIntMethods.entrySet()) { String newIntface = intMeth.getKey(); @@ -3138,7 +3142,7 @@ public class IoTCompiler { /** * 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() {"); @@ -3146,7 +3150,7 @@ public class IoTCompiler { 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;"); @@ -3196,7 +3200,7 @@ public class IoTCompiler { 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); @@ -3292,7 +3296,7 @@ public class IoTCompiler { 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); @@ -3368,12 +3372,13 @@ public class IoTCompiler { /** * 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"); } @@ -4150,7 +4155,7 @@ public class IoTCompiler { 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