+ return mapStubParam;
+ }
+
+
+ /**
+ * HELPER: checkAndWriteEnumTypeJavaSkeleton() writes the enum type (convert from enum to int)
+ */
+ private void checkAndWriteEnumTypeJavaSkeleton(List<String> methParams, List<String> methPrmTypes, boolean isStructMethod) {
+
+ String offsetPfx = "";
+ if (isStructMethod)
+ offsetPfx = "offset";
+ // Iterate and find enum declarations
+ boolean printed = false;
+ for (int i = 0; i < methParams.size(); i++) {
+ String paramType = methPrmTypes.get(i);
+ String param = methParams.get(i);
+ String simpleType = getGenericType(paramType);
+ if (isEnumClass(simpleType)) {
+ // Check if this is enum type
+ println("int paramInt" + i + "[] = (int[]) paramObj[" + offsetPfx + i + "];");
+ if (!printed) {
+ println(simpleType + "[] enumVals = " + simpleType + ".values();");
+ printed = true;
+ }
+ if (isArray(param)) { // An array
+ println("int len" + i + " = paramInt" + i + ".length;");
+ println(simpleType + "[] paramEnum" + i + " = new " + simpleType + "[len" + i + "];");
+ println("for (int i = 0; i < len" + i + "; i++) {");
+ println("paramEnum" + i + "[i] = enumVals[paramInt" + i + "[i]];");
+ println("}");
+ } else if (isList(paramType)) { // A list
+ println("int len" + i + " = paramInt" + i + ".length;");
+ println("List<" + simpleType + "> paramEnum" + i + " = new ArrayList<" + simpleType + ">();");
+ println("for (int i = 0; i < len" + i + "; i++) {");
+ println("paramEnum" + i + ".add(enumVals[paramInt" + i + "[i]]);");
+ println("}");
+ } else { // Just one element
+ println(simpleType + " paramEnum" + i + " = enumVals[paramInt" + i + "[0]];");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: checkAndWriteEnumRetTypeJavaSkeleton() writes the enum return type (convert from enum to int)
+ */
+ private void checkAndWriteEnumRetTypeJavaSkeleton(String retType, String methodId) {
+
+ // Strips off array "[]" for return type
+ String pureType = getSimpleArrayType(getGenericType(retType));
+ // Take the inner type of generic
+ if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES)
+ pureType = getGenericType(retType);
+ if (isEnumClass(pureType)) {
+ // Check if this is enum type
+ // Enum decoder
+ if (isArray(retType)) { // An array
+ print(pureType + "[] retEnum = " + methodId + "(");
+ } else if (isList(retType)) { // A list
+ print("List<" + pureType + "> retEnum = " + methodId + "(");
+ } else { // Just one element
+ print(pureType + " retEnum = " + methodId + "(");
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: checkAndWriteEnumRetConvJavaSkeleton() writes the enum return type (convert from enum to int)
+ */
+ private void checkAndWriteEnumRetConvJavaSkeleton(String retType) {
+
+ // Strips off array "[]" for return type
+ String pureType = getSimpleArrayType(getGenericType(retType));
+ // Take the inner type of generic
+ if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES)
+ pureType = getGenericType(retType);
+ if (isEnumClass(pureType)) {
+ // Check if this is enum type
+ if (isArray(retType)) { // An array
+ println("int retLen = retEnum.length;");
+ println("int[] retEnumVal = new int[retLen];");
+ println("for (int i = 0; i < retLen; i++) {");
+ println("retEnumVal[i] = retEnum[i].ordinal();");
+ println("}");
+ } else if (isList(retType)) { // A list
+ println("int retLen = retEnum.size();");
+ println("int[] retEnumVal = new int[retLen];");
+ println("for (int i = 0; i < retLen; i++) {");
+ println("retEnumVal[i] = retEnum.get(i).ordinal();");
+ println("}");
+ } else { // Just one element
+ println("int[] retEnumVal = new int[1];");
+ println("retEnumVal[0] = retEnum.ordinal();");
+ }
+ println("Object retObj = retEnumVal;");
+ }
+ }
+
+
+ /**
+ * HELPER: writeLengthStructParamClassSkeleton() writes lengths of params
+ */
+ private void writeLengthStructParamClassSkeleton(List<String> methParams, List<String> methPrmTypes,
+ String method, InterfaceDecl intDecl) {
+
+ // Iterate and find struct declarations - count number of params
+ 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 members = getNumOfMembers(simpleType);
+ print(Integer.toString(members) + "*");
+ int methodNumId = intDecl.getMethodNumId(method);
+ print("struct" + methodNumId + "Size" + i);
+ } else
+ print("1");
+ if (i != methParams.size() - 1) {
+ print("+");
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: writeStructMembersJavaSkeleton() writes member parameters of struct
+ */
+ private void writeStructMembersJavaSkeleton(String simpleType, String paramType,
+ String param, String method, InterfaceDecl intDecl, int iVar) {
+
+ // Get the struct declaration for this struct and generate initialization code
+ StructDecl structDecl = getStructDecl(simpleType);
+ List<String> memTypes = structDecl.getMemberTypes(simpleType);
+ List<String> members = structDecl.getMembers(simpleType);
+ if (isArrayOrList(paramType, param)) { // An array or list
+ int methodNumId = intDecl.getMethodNumId(method);
+ String counter = "struct" + methodNumId + "Size" + iVar;
+ println("for(int i = 0; i < " + counter + "; i++) {");
+ }
+ if (isArrayOrList(paramType, param)) { // An array or list
+ for (int i = 0; i < members.size(); i++) {
+ String prmType = checkAndGetArray(memTypes.get(i), members.get(i));
+ println("paramCls[pos] = " + getSimpleType(getEnumType(prmType)) + ".class;");
+ println("paramClsGen[pos++] = null;");
+ }
+ println("}");
+ } else { // Just one struct element
+ for (int i = 0; i < members.size(); i++) {
+ String prmType = checkAndGetArray(memTypes.get(i), members.get(i));
+ println("paramCls[pos] = " + getSimpleType(getEnumType(prmType)) + ".class;");
+ println("paramClsGen[pos++] = null;");
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: writeStructMembersInitJavaSkeleton() writes member parameters initialization of struct
+ */
+ private void writeStructMembersInitJavaSkeleton(InterfaceDecl intDecl, List<String> methParams,
+ List<String> methPrmTypes, String method) {
+
+ println("int objPos = 0;");
+ 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);
+ String counter = "struct" + methodNumId + "Size" + i;
+ // Declaration
+ if (isArray(param)) { // An array
+ println(simpleType + "[] paramStruct" + i + " = new " + simpleType + "[" + counter + "];");
+ println("for(int i = 0; i < " + counter + "; i++) {");
+ println("paramStruct" + i + "[i] = new " + simpleType + "();");
+ println("}");
+ } else if (isList(paramType)) { // A list
+ println("List<" + simpleType + "> paramStruct" + i + " = new ArrayList<" + simpleType + ">();");
+ } else
+ println(simpleType + " paramStruct" + i + " = new " + simpleType + "();");
+ // Initialize members
+ StructDecl structDecl = getStructDecl(simpleType);
+ List<String> members = structDecl.getMembers(simpleType);
+ List<String> memTypes = structDecl.getMemberTypes(simpleType);
+ if (isArrayOrList(paramType, param)) { // An array or list
+ println("for(int i = 0; i < " + counter + "; i++) {");
+ }
+ if (isArray(param)) { // An array
+ for (int j = 0; j < members.size(); j++) {
+ String prmType = checkAndGetArray(memTypes.get(j), members.get(j));
+ print("paramStruct" + i + "[i]." + getSimpleIdentifier(members.get(j)));
+ println(" = (" + getSimpleType(getEnumType(prmType)) + ") paramObj[objPos++];");
+ }
+ println("}");
+ } else if (isList(paramType)) { // A list
+ println(simpleType + " paramStructMem = new " + simpleType + "();");
+ for (int j = 0; j < members.size(); j++) {
+ String prmType = checkAndGetArray(memTypes.get(j), members.get(j));
+ print("paramStructMem." + getSimpleIdentifier(members.get(j)));
+ println(" = (" + getSimpleType(getEnumType(prmType)) + ") paramObj[objPos++];");
+ }
+ println("paramStruct" + i + ".add(paramStructMem);");
+ println("}");
+ } else { // Just one struct element
+ for (int j = 0; j < members.size(); j++) {
+ String prmType = checkAndGetArray(memTypes.get(j), members.get(j));
+ print("paramStruct" + i + "." + getSimpleIdentifier(members.get(j)));
+ println(" = (" + getSimpleType(getEnumType(prmType)) + ") paramObj[objPos++];");
+ }
+ }
+ } else {
+ // Take offsets of parameters
+ println("int offset" + i +" = objPos++;");
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: writeStructReturnJavaSkeleton() writes struct for return statement
+ */
+ private void writeStructReturnJavaSkeleton(String simpleType, String retType) {
+
+ // Minimum retLen is 1 if this is a single struct object
+ if (isArray(retType))
+ println("int retLen = retStruct.length;");
+ else if (isList(retType))
+ println("int retLen = retStruct.size();");
+ else // Just single struct object
+ println("int retLen = 1;");
+ println("Object retLenObj = retLen;");
+ println("rmiObj.sendReturnObj(retLenObj);");
+ int numMem = getNumOfMembers(simpleType);
+ println("Class<?>[] retCls = new Class<?>[" + numMem + "*retLen];");
+ println("Object[] retObj = new Object[" + numMem + "*retLen];");
+ println("int retPos = 0;");
+ // Get the struct declaration for this struct and generate initialization code
+ StructDecl structDecl = getStructDecl(simpleType);
+ List<String> memTypes = structDecl.getMemberTypes(simpleType);
+ List<String> members = structDecl.getMembers(simpleType);
+ if (isArray(retType)) { // An array or list
+ println("for(int i = 0; i < retLen; i++) {");
+ for (int i = 0; i < members.size(); i++) {
+ String prmType = checkAndGetArray(memTypes.get(i), members.get(i));
+ println("retCls[retPos] = " + getSimpleType(getEnumType(prmType)) + ".class;");
+ print("retObj[retPos++] = retStruct[i].");
+ print(getEnumParam(memTypes.get(i), getSimpleIdentifier(members.get(i)), i));
+ println(";");
+ }
+ println("}");
+ } else if (isList(retType)) { // An array or list
+ println("for(int i = 0; i < retLen; i++) {");
+ for (int i = 0; i < members.size(); i++) {
+ String prmType = checkAndGetArray(memTypes.get(i), members.get(i));
+ println("retCls[retPos] = " + getSimpleType(getEnumType(prmType)) + ".class;");
+ print("retObj[retPos++] = retStruct.get(i).");
+ print(getEnumParam(memTypes.get(i), getSimpleIdentifier(members.get(i)), i));
+ println(";");
+ }
+ println("}");
+ } else { // Just one struct element
+ for (int i = 0; i < members.size(); i++) {
+ String prmType = checkAndGetArray(memTypes.get(i), members.get(i));
+ println("retCls[retPos] = " + getSimpleType(getEnumType(prmType)) + ".class;");
+ print("retObj[retPos++] = retStruct.");
+ print(getEnumParam(memTypes.get(i), getSimpleIdentifier(members.get(i)), i));
+ println(";");
+ }
+ }
+
+ }
+
+
+ /**
+ * HELPER: writeMethodHelperReturnJavaSkeleton() writes return statement part in skeleton
+ */
+ private void writeMethodHelperReturnJavaSkeleton(InterfaceDecl intDecl, List<String> methParams,
+ List<String> methPrmTypes, String method, boolean isCallbackMethod, String callbackType,
+ boolean isStructMethod) {
+
+ checkAndWriteEnumTypeJavaSkeleton(methParams, methPrmTypes, isStructMethod);
+ Map<Integer,String> mapStubParam = null;
+ if (isCallbackMethod) {
+ println("try {");
+ mapStubParam = writeCallbackJavaStubGeneration(methParams, methPrmTypes, callbackType, isStructMethod);
+ }
+ // Check if this is "void"
+ String retType = intDecl.getMethodType(method);
+ if (retType.equals("void")) {
+ print(intDecl.getMethodId(method) + "(");
+ } else if (isEnumClass(getSimpleArrayType(getGenericType(retType)))) { // Enum type
+ checkAndWriteEnumRetTypeJavaSkeleton(retType, intDecl.getMethodId(method));
+ } else if (isStructClass(getSimpleArrayType(getGenericType(retType)))) { // Struct type
+ print(retType + " retStruct = " + intDecl.getMethodId(method) + "(");
+ } else { // We do have a return value
+ print("Object retObj = " + intDecl.getMethodId(method) + "(");
+ }
+ for (int i = 0; i < methParams.size(); i++) {
+
+ String paramType = methPrmTypes.get(i);
+ if (isCallbackMethod && checkCallbackType(paramType, callbackType)) {
+ print(mapStubParam.get(i)); // Get the callback parameter
+ } else if (isEnumClass(getGenericType(paramType))) { // Enum class
+ print(getEnumParam(paramType, methParams.get(i), i));
+ } else if (isStructClass(getGenericType(paramType))) {
+ print("paramStruct" + i);
+ } else {
+ String prmType = checkAndGetArray(paramType, methParams.get(i));
+ if (isStructMethod)
+ print("(" + prmType + ") paramObj[offset" + i + "]");
+ else
+ print("(" + prmType + ") paramObj[" + i + "]");
+ }
+ if (i != methParams.size() - 1)
+ print(", ");
+ }
+ println(");");
+ if (!retType.equals("void")) {
+ if (isEnumClass(getSimpleArrayType(getGenericType(retType)))) { // Enum type
+ checkAndWriteEnumRetConvJavaSkeleton(retType);
+ println("rmiObj.sendReturnObj(retObj);");
+ } else if (isStructClass(getSimpleArrayType(getGenericType(retType)))) { // Struct type
+ writeStructReturnJavaSkeleton(getSimpleArrayType(getGenericType(retType)), retType);
+ println("rmiObj.sendReturnObj(retCls, retObj);");
+ } else
+ println("rmiObj.sendReturnObj(retObj);");
+ }
+ if (isCallbackMethod) { // Catch exception if this is callback
+ print("}");
+ println(" catch(Exception ex) {");
+ println("ex.printStackTrace();");
+ println("throw new Error(\"Exception from callback object instantiation!\");");
+ println("}");
+ }
+ }
+
+
+ /**
+ * HELPER: writeMethodHelperStructJavaSkeleton() writes the struct in skeleton
+ */
+ private void writeMethodHelperStructJavaSkeleton(InterfaceDecl intDecl, List<String> methParams,
+ List<String> methPrmTypes, String method, Set<String> callbackClasses) {
+
+ // Generate array of parameter objects
+ boolean isCallbackMethod = false;
+ String callbackType = null;
+ print("int paramLen = ");
+ writeLengthStructParamClassSkeleton(methParams, methPrmTypes, method, intDecl);
+ println(";");
+ println("Class<?>[] paramCls = new Class<?>[paramLen];");
+ println("Class<?>[] paramClsGen = new Class<?>[paramLen];");
+ println("int pos = 0;");
+ // Iterate again over the parameters
+ 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)) {
+ writeStructMembersJavaSkeleton(simpleType, paramType, param, method, intDecl, i);
+ } else {
+ String prmType = returnGenericCallbackType(methPrmTypes.get(i));
+ if (callbackClasses.contains(prmType)) {
+ isCallbackMethod = true;
+ callbackType = prmType;
+ println("paramCls[pos] = int.class;");
+ println("paramClsGen[pos++] = null;");
+ } else { // Generate normal classes if it's not a callback object
+ String paramTypeOth = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
+ println("paramCls[pos] = " + getSimpleType(getEnumType(paramTypeOth)) + ".class;");
+ print("paramClsGen[pos++] = ");
+ String prmTypeOth = methPrmTypes.get(i);
+ if (getParamCategory(prmTypeOth) == ParamCategory.NONPRIMITIVES)
+ println(getTypeOfGeneric(prmType)[0] + ".class;");
+ else
+ println("null;");
+ }
+ }
+ }
+ println("Object[] paramObj = rmiObj.getMethodParams(paramCls, paramClsGen);");
+ writeStructMembersInitJavaSkeleton(intDecl, methParams, methPrmTypes, method);
+ // Write the return value part
+ writeMethodHelperReturnJavaSkeleton(intDecl, methParams, methPrmTypes, method, isCallbackMethod, callbackType, true);
+ }
+
+
+ /**
+ * HELPER: writeStdMethodHelperBodyJavaSkeleton() writes the standard method body helper in the skeleton class
+ */
+ private void writeStdMethodHelperBodyJavaSkeleton(InterfaceDecl intDecl, List<String> methParams,
+ List<String> methPrmTypes, String method, Set<String> callbackClasses) {
+
+ // Generate array of parameter objects
+ boolean isCallbackMethod = false;
+ String callbackType = null;
+ print("Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { ");
+ for (int i = 0; i < methParams.size(); i++) {
+
+ String paramType = returnGenericCallbackType(methPrmTypes.get(i));
+ if (callbackClasses.contains(paramType)) {
+ isCallbackMethod = true;
+ callbackType = paramType;
+ print("int.class");
+ } else { // Generate normal classes if it's not a callback object
+ String prmType = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
+ print(getSimpleType(getEnumType(prmType)) + ".class");
+ }
+ if (i != methParams.size() - 1)
+ print(", ");
+ }
+ println(" }, ");
+ // Generate generic class if it's a generic type.. null otherwise
+ print("new Class<?>[] { ");
+ for (int i = 0; i < methParams.size(); i++) {
+ String prmType = methPrmTypes.get(i);
+ if ((getParamCategory(prmType) == ParamCategory.NONPRIMITIVES) &&
+ !isEnumClass(getGenericType(prmType)) &&
+ !callbackClasses.contains(getGenericType(prmType)))
+ print(getGenericType(prmType) + ".class");
+ else
+ print("null");
+ if (i != methParams.size() - 1)
+ print(", ");
+ }
+ println(" });");
+ // Write the return value part
+ writeMethodHelperReturnJavaSkeleton(intDecl, methParams, methPrmTypes, method, isCallbackMethod, callbackType, false);
+ }
+
+
+ /**
+ * HELPER: writeMethodHelperJavaSkeleton() writes the method helper of the skeleton class
+ */
+ private void writeMethodHelperJavaSkeleton(Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
+
+ // 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("public void ___");
+ 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);
+ }
+ }
+ // Check if this is "void"
+ if (retType.equals("void"))
+ println(") {");
+ else
+ println(") throws IOException {");
+ writeMethodHelperStructJavaSkeleton(intDecl, methParams, methPrmTypes, method, callbackClasses);
+ println("}\n");
+ } else {
+ String methodId = intDecl.getMethodId(method);
+ print("public 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);
+ if (retType.equals("void"))
+ println(helperMethod + "() {");
+ else
+ println(helperMethod + "() throws IOException {");
+ // Now, write the helper body of skeleton!
+ writeStdMethodHelperBodyJavaSkeleton(intDecl, methParams, methPrmTypes, method, callbackClasses);
+ println("}\n");
+ }
+ }
+ // Write method helper for structs
+ writeMethodHelperStructSetupJavaSkeleton(methods, intDecl);
+ }
+
+
+ /**
+ * HELPER: writeMethodHelperStructSetupJavaSkeleton() writes the method helper of struct setup in skeleton class
+ */
+ private void writeMethodHelperStructSetupJavaSkeleton(Collection<String> methods,
+ InterfaceDecl intDecl) {
+
+ // 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("public int ___");
+ String helperMethod = methodNumId + "struct" + i;
+ println(helperMethod + "() {");
+ // Now, write the helper body of skeleton!
+ println("Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, new Class<?>[] { null });");
+ println("return (int) paramObj[0];");
+ println("}\n");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: writeMethodHelperStructSetupJavaCallbackSkeleton() writes the method helper of struct setup in callback skeleton class
+ */
+ private void writeMethodHelperStructSetupJavaCallbackSkeleton(Collection<String> methods,
+ InterfaceDecl intDecl) {
+
+ // 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("public int ___");
+ String helperMethod = methodNumId + "struct" + i;
+ println(helperMethod + "(IoTRMIObject rmiObj) {");
+ // Now, write the helper body of skeleton!
+ println("Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, new Class<?>[] { null });");
+ println("return (int) paramObj[0];");
+ println("}\n");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: writeCountVarStructSkeleton() writes counter variable of struct for skeleton
+ */
+ private void writeCountVarStructSkeleton(Collection<String> methods, InterfaceDecl intDecl) {
+
+ // 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);
+ println("int struct" + methodNumId + "Size" + i + " = 0;");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * HELPER: writeInputCountVarStructSkeleton() writes input counter variable of struct for skeleton
+ */
+ private boolean writeInputCountVarStructSkeleton(String method, InterfaceDecl intDecl) {
+
+ List<String> methParams = intDecl.getMethodParams(method);
+ List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+ boolean structExist = false;
+ boolean begin = true;
+ // 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)) {
+ structExist = true;
+ if (!begin)
+ print(", ");
+ else
+ begin = false;
+ int methodNumId = intDecl.getMethodNumId(method);
+ print("struct" + methodNumId + "Size" + i);
+ }
+ }
+ return structExist;