+ println(", " + newSkelClass + "* skel);");
+ } else {
+ String methodId = intDecl.getMethodId(method);
+ print("void ___");
+ String helperMethod = methodId;
+ if (uniqueMethodIds.contains(methodId))
+ helperMethod = helperMethod + intDecl.getMethodNumId(method);
+ else
+ uniqueMethodIds.add(methodId);
+ // Check if this is "void"
+ String retType = intDecl.getMethodType(method);
+ println(helperMethod + "(" + newSkelClass + "* skel);");
+ }
+ }
+ // Write method helper for structs
+ writeMethodHelperStructDeclSetupCplusSkeleton(methods, intDecl, newSkelClass);
+ }
+
+
+ /**
+ * HELPER: writeMethodHelperStructDeclSetupCplusSkeleton() writes the struct method helper declaration in skeleton class
+ */
+ private void writeMethodHelperStructDeclSetupCplusSkeleton(Collection<String> methods,
+ InterfaceDecl intDecl, String newSkelClass) {
+
+ // 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 = getGenericType(paramType);
+ if (isStructClass(simpleType)) {
+ int methodNumId = intDecl.getMethodNumId(method);
+ print("int ___");
+ String helperMethod = methodNumId + "struct" + i;
+ println(helperMethod + "(" + newSkelClass + "* skel);");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: writeMethodBytesCopy() writes the methodBytes copy part in C++ skeleton
+ */
+ private void writeMethodBytesCopy() {
+
+ println("char* localMethodBytes = new char[methodLen];");
+ println("memcpy(localMethodBytes, skel->methodBytes, methodLen);");
+ println("didGetMethodBytes.exchange(true);");
+ }
+
+
+ /**
+ * HELPER: writeMethodHelperCplusSkeleton() writes the method helper of the skeleton class
+ */
+ private void writeMethodHelperCplusSkeleton(Collection<String> methods, InterfaceDecl intDecl,
+ Set<String> callbackClasses, String newSkelClass) {
+
+ // Use this set to handle two same methodIds
+ Set<String> uniqueMethodIds = new HashSet<String>();
+ for (String method : methods) {
+
+ List<String> methParams = intDecl.getMethodParams(method);
+ List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+ if (isStructPresent(methParams, methPrmTypes)) { // Treat struct differently
+ String methodId = intDecl.getMethodId(method);
+ print("void " + newSkelClass + "::___");
+ String helperMethod = methodId;
+ if (uniqueMethodIds.contains(methodId))
+ helperMethod = helperMethod + intDecl.getMethodNumId(method);
+ else
+ uniqueMethodIds.add(methodId);
+ String retType = intDecl.getMethodType(method);
+ print(helperMethod + "(");
+ boolean begin = true;
+ for (int i = 0; i < methParams.size(); i++) { // Print size variables
+ String paramType = methPrmTypes.get(i);
+ String param = methParams.get(i);
+ String simpleType = getGenericType(paramType);
+ if (isStructClass(simpleType)) {
+ if (!begin) // Generate comma for not the beginning variable
+ print(", ");
+ else
+ begin = false;
+ int methodNumId = intDecl.getMethodNumId(method);
+ print("int struct" + methodNumId + "Size" + i);
+ }
+ }
+ println(", " + newSkelClass + "* skel) {");
+ writeMethodBytesCopy();