}
+ /**
+ * HELPER: writeStructPermissionJavaSkeleton() writes permission for struct helper
+ */
+ private void writeStructPermissionJavaSkeleton(Collection<String> methods, InterfaceDecl intDecl, String intface) {
+
+ // Use this set to handle two same methodIds
+ for (String method : methods) {
+ List<String> methParams = intDecl.getMethodParams(method);
+ List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+ // Check for params with structs
+ for (int i = 0; i < methParams.size(); i++) {
+ String paramType = methPrmTypes.get(i);
+ String param = methParams.get(i);
+ String simpleType = getSimpleType(paramType);
+ if (isStructClass(simpleType)) {
+ int methodNumId = intDecl.getMethodNumId(method);
+ // Iterate over interfaces to give permissions to
+ 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: writeConstructorJavaSkeleton() writes the constructor of the skeleton class
*/
- private void writeConstructorJavaSkeleton(String newSkelClass, String intface, InterfaceDecl intDecl) {
+ private void writeConstructorJavaSkeleton(String newSkelClass, String intface, InterfaceDecl intDecl, Collection<String> methods) {
println("public " + newSkelClass + "(" + intface + " _mainObj, int _port) throws Exception {");
println("mainObj = _mainObj;");
// Generate permission control initialization
writeConstructorJavaPermission(intface);
writeJavaInitCallbackPermission(intface, intDecl);
+ writeStructPermissionJavaSkeleton(methods, intDecl, intface);
println("___waitRequestInvokeMethod();");
println("}\n");
}
// Write properties
writePropertiesJavaSkeleton(intface, callbackExist, intDecl);
// Write constructor
- writeConstructorJavaSkeleton(newSkelClass, intface, intDecl);
+ writeConstructorJavaSkeleton(newSkelClass, intface, intDecl, methods);
// Write methods
writeMethodJavaSkeleton(methods, intDecl, callbackClasses, false);
// Write method helper
/**
* HELPER: writeConstructorJavaCallbackSkeleton() writes the constructor of the skeleton class
*/
- private void writeConstructorJavaCallbackSkeleton(String newSkelClass, String intface) {
+ private void writeConstructorJavaCallbackSkeleton(String newSkelClass, String intface, InterfaceDecl intDecl, Collection<String> methods) {
println("public " + newSkelClass + "(" + intface + " _mainObj, int _objectId) throws Exception {");
println("mainObj = _mainObj;");
println("objectId = _objectId;");
+ writeStructPermissionJavaSkeleton(methods, intDecl, intface);
println("}\n");
}
// Write properties
writePropertiesJavaCallbackSkeleton(intface, callbackExist);
// Write constructor
- writeConstructorJavaCallbackSkeleton(newSkelClass, intface);
+ writeConstructorJavaCallbackSkeleton(newSkelClass, intface, intDecl, methods);
// Write methods
writeMethodJavaSkeleton(methods, intDecl, callbackClasses, true);
// Write method helper
}
+ /**
+ * HELPER: writeStructPermissionCplusSkeleton() writes permission for struct helper
+ */
+ private void writeStructPermissionCplusSkeleton(Collection<String> methods, InterfaceDecl intDecl, String intface) {
+
+ // Use this set to handle two same methodIds
+ for (String method : methods) {
+ List<String> methParams = intDecl.getMethodParams(method);
+ List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+ // Check for params with structs
+ for (int i = 0; i < methParams.size(); i++) {
+ String paramType = methPrmTypes.get(i);
+ String param = methParams.get(i);
+ String simpleType = getSimpleType(paramType);
+ if (isStructClass(simpleType)) {
+ int methodNumId = intDecl.getMethodNumId(method);
+ // Iterate over interfaces to give permissions to
+ 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: writeConstructorCplusSkeleton() writes the constructor of the skeleton class
*/
- private void writeConstructorCplusSkeleton(String newSkelClass, String intface, boolean callbackExist, InterfaceDecl intDecl) {
+ private void writeConstructorCplusSkeleton(String newSkelClass, String intface, boolean callbackExist, InterfaceDecl intDecl, Collection<String> methods) {
println(newSkelClass + "(" + intface + " *_mainObj, int _port) {");
println("bool _bResult = false;");
println("mainObj = _mainObj;");
println("rmiObj = new IoTRMIObject(_port, &_bResult);");
writeCplusInitCallbackPermission(intface, intDecl);
+ writeStructPermissionCplusSkeleton(methods, intDecl, intface);
println("___waitRequestInvokeMethod();");
println("}\n");
}
writePropertiesCplusSkeleton(intface, callbackExist, callbackClasses);
println("public:\n");
// Write constructor
- writeConstructorCplusSkeleton(newSkelClass, intface, callbackExist, intDecl);
+ writeConstructorCplusSkeleton(newSkelClass, intface, callbackExist, intDecl, methods);
// Write deconstructor
writeDeconstructorCplusSkeleton(newSkelClass, callbackExist, callbackClasses);
// Write methods
/**
* HELPER: writeConstructorCplusCallbackSkeleton() writes the constructor of the skeleton class
*/
- private void writeConstructorCplusCallbackSkeleton(String newSkelClass, String intface, boolean callbackExist) {
+ private void writeConstructorCplusCallbackSkeleton(String newSkelClass, String intface, boolean callbackExist, InterfaceDecl intDecl, Collection<String> methods) {
println(newSkelClass + "(" + intface + " *_mainObj, int _objectId) {");
println("mainObj = _mainObj;");
println("objectId = _objectId;");
+ writeStructPermissionCplusSkeleton(methods, intDecl, intface);
println("}\n");
}
writePropertiesCplusCallbackSkeleton(intface, callbackExist, callbackClasses);
println("public:\n");
// Write constructor
- writeConstructorCplusCallbackSkeleton(newSkelClass, intface, callbackExist);
+ writeConstructorCplusCallbackSkeleton(newSkelClass, intface, callbackExist, intDecl, methods);
// Write deconstructor
writeDeconstructorCplusCallbackSkeleton(newSkelClass, callbackExist, callbackClasses);
// Write methods