Moving permission setting from stub to skeleton (mistakenly put stuff in stub and...
authorrtrimana <rtrimana@uci.edu>
Tue, 29 Nov 2016 21:30:01 +0000 (13:30 -0800)
committerrtrimana <rtrimana@uci.edu>
Tue, 29 Nov 2016 21:30:01 +0000 (13:30 -0800)
iotjava/iotpolicy/IoTCompiler.java

index f2d8397..e48df35 100644 (file)
@@ -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<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
                for (Map.Entry<String,Set<String>> 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<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
+       private void writeMethodCplusStub(Collection<String> methods, InterfaceDecl intDecl, Set<String> 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<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
                for (Map.Entry<String,Set<String>> 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