Fixing a bug in C++ socket server-client: message length was represented just in...
authorrtrimana <rtrimana@uci.edu>
Fri, 9 Dec 2016 17:40:46 +0000 (09:40 -0800)
committerrtrimana <rtrimana@uci.edu>
Fri, 9 Dec 2016 17:40:46 +0000 (09:40 -0800)
config/iotpolicy/testclasspolicy_advanced.pol
iotjava/iotpolicy/IoTCompiler.java
iotjava/iotrmi/C++/IoTRMICall.hpp
iotjava/iotrmi/C++/IoTRMIObject.hpp
iotjava/iotrmi/C++/IoTSocket.hpp
iotjava/iotrmi/C++/basics/TestClass.hpp
iotjava/iotrmi/C++/basics/TestClassAdvanced_Stub.cpp
iotjava/iotrmi/Java/basics/TestClass.java
iotjava/iotrmi/Java/basics/TestClassAdvanced_Stub.java

index 9867b23..b7899df 100644 (file)
@@ -5,11 +5,14 @@ public interface TestClassInterface {
        public List<Enum> handleEnumList(List<Enum> en);
        public Enum handleEnumComplex(Enum en, int i, char c);
        public Enum[] handleEnumComplex2(Enum en[], int in, char c);
+       public Enum[] handleEnumTwo(Enum en1[], Enum en2[]);
 
        public Struct handleStruct(Struct str);
        public Struct[] handleStructArray(Struct str[]);
        public List<Struct> handleStructList(List<Struct> str);
        public Struct handleStructComplex(int in, char c, Struct str);
+       public List<Struct> handleStructTwo(List<Struct> str1, List<Struct> str2);
+       public List<Struct> handleStructThree(List<Struct> str1, List<Struct> str2, List<Struct> str3);
        public List<Struct> handleStructComplex2(int in, char c, Struct str[]);
 
        public Enum[] handleEnumStruct(Enum en[], List<Struct> str, char c);
@@ -21,7 +24,10 @@ public interface TestClassInterface {
        public int callBack();
        public Enum[] handleCallbackEnum(Enum en[], char c, List<CallBackInterface> _cb);
 
+
        public Enum[] handleAll(Enum en[], List<Struct> str, char c, List<CallBackInterface> _cb);
+       public Enum[] handleAllTwo(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2, char c, List<CallBackInterface> _cb1, List<CallBackInterface> _cb2);
+       public Enum[] handleEnumThree(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2);
 
        capability EnumsStructs {
                description = "All the set methods";
@@ -31,16 +37,21 @@ public interface TestClassInterface {
                method = "handleEnumList(List<Enum> en)";
                method = "handleEnumComplex(Enum en, int i, char c)";
                method = "handleEnumComplex2(Enum en[], int in, char c)";
+               method = "handleEnumTwo(Enum en1[], Enum en2[])";
+               method = "handleEnumThree(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2)";
 
                method = "handleStruct(Struct str)";
                method = "handleStructArray(Struct str[])";
                method = "handleStructList(List<Struct> str)";
                method = "handleStructComplex(int in, char c, Struct str)";
                method = "handleStructComplex2(int in, char c, Struct str[])";
+               method = "handleStructTwo(List<Struct> str1, List<Struct> str2)";
+               method = "handleStructThree(List<Struct> str1, List<Struct> str2, List<Struct> str3)";
 
                method = "handleEnumStruct(Enum en[], List<Struct> str, char c)";
                method = "handleCallbackEnum(Enum en[], char c, List<CallBackInterface> _cb)";
                method = "handleAll(Enum en[], List<Struct> str, char c, List<CallBackInterface> _cb)";
+               method = "handleAllTwo(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2, char c, List<CallBackInterface> _cb1, List<CallBackInterface> _cb2)";
        }
 
        capability Callbacks {
index 1bd90c6..3187637 100644 (file)
@@ -943,66 +943,6 @@ public class IoTCompiler {
        }
 
 
-       /*private void writeStdMethodBodyJavaStub(InterfaceDecl intDecl, List<String> methParams,
-                       List<String> methPrmTypes, String method) {
-
-               checkAndWriteStructSetupJavaStub(methParams, methPrmTypes, intDecl, method);
-               println("int methodId = " + intDecl.getMethodNumId(method) + ";");
-               String retType = intDecl.getMethodType(method);
-               println("Class<?> retType = " + getSimpleType(getStructType(getEnumType(retType))) + ".class;");
-               checkAndWriteEnumTypeJavaStub(methParams, methPrmTypes);
-               // Generate array of parameter types
-               if (isStructPresent(methParams, methPrmTypes)) {
-                       writeStructParamClassJavaStub(methParams, methPrmTypes);
-               } else {
-                       print("Class<?>[] paramCls = new Class<?>[] { ");
-                       for (int i = 0; i < methParams.size(); i++) {
-                               String paramType = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
-                               print(getSimpleType(getEnumType(paramType)) + ".class");
-                               // Check if this is the last element (don't print a comma)
-                               if (i != methParams.size() - 1) {
-                                       print(", ");
-                               }
-                       }
-                       println(" };");
-                       // Generate array of parameter objects
-                       print("Object[] paramObj = new Object[] { ");
-                       for (int i = 0; i < methParams.size(); i++) {
-                               print(getEnumParam(methPrmTypes.get(i), getSimpleIdentifier(methParams.get(i)), i));
-                               // Check if this is the last element (don't print a comma)
-                               if (i != methParams.size() - 1) {
-                                       print(", ");
-                               }
-                       }
-                       println(" };");
-               }
-               // Check if this is "void"
-               if (retType.equals("void")) {
-                       println("rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);");
-               } else { // We do have a return value
-                       // Generate array of parameter types
-                       if (isStructClass(getGenericType(getSimpleArrayType(retType)))) {
-                               writeStructReturnJavaStub(getGenericType(getSimpleArrayType(retType)), retType);
-                       } else {
-                               // This is an enum type
-                               if (getParamCategory(getGenericType(getSimpleArrayType(retType))) == ParamCategory.ENUM) {
-                                       println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);");
-                                       checkAndWriteEnumRetTypeJavaStub(retType);
-                               } else if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES) {
-                               // Check if the return value NONPRIMITIVES
-                                       String retGenValType = getGenericType(retType);
-                                       println("Class<?> retGenValType = " + retGenValType + ".class;");
-                                       println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, retGenValType, paramCls, paramObj);");
-                                       println("return (" + retType + ")retObj;");
-                               } else {
-                                       println("Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);");
-                                       println("return (" + retType + ")retObj;");
-                               }
-                       }
-               }
-       }*/
-
-
        /**
         * HELPER: returnGenericCallbackType() returns the callback type
         */
@@ -1483,7 +1423,6 @@ public class IoTCompiler {
                        String paramType = methPrmTypes.get(i);
                        String param = methParams.get(i);
                        if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
-                               println("try {");
                                String exchParamType = checkAndGetParamClass(getGenericType(paramType));
                                // Print array if this is array or list if this is a list of callback objects
                                if (isArray(param)) {
@@ -1521,17 +1460,24 @@ public class IoTCompiler {
        /**
         * HELPER: checkAndWriteEnumTypeJavaSkeleton() writes the enum type (convert from enum to int)
         */
-       private void checkAndWriteEnumTypeJavaSkeleton(List<String> methParams, List<String> methPrmTypes) {
+       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[" + i + "];");
-                               println(simpleType + "[] enumVals = " + simpleType + ".values();");
+                               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 + "];");
@@ -1790,9 +1736,10 @@ public class IoTCompiler {
                        List<String> methPrmTypes, String method, boolean isCallbackMethod, String callbackType,
                        boolean isStructMethod) {
 
-               checkAndWriteEnumTypeJavaSkeleton(methParams, methPrmTypes);
+               checkAndWriteEnumTypeJavaSkeleton(methParams, methPrmTypes, isStructMethod);
                Map<Integer,String> mapStubParam = null;
                if (isCallbackMethod) {
+                       println("try {");
                        mapStubParam = writeCallbackJavaStubGeneration(methParams, methPrmTypes, callbackType, isStructMethod);
                }
                // Check if this is "void"
@@ -1965,9 +1912,10 @@ public class IoTCompiler {
                                        String param = methParams.get(i);
                                        String simpleType = getGenericType(paramType);
                                        if (isStructClass(simpleType)) {
-                                               if (!begin) {   // Generate comma for not the beginning variable
-                                                       print(", "); begin = false;
-                                               }
+                                               if (!begin)     // Generate comma for not the beginning variable
+                                                       print(", ");
+                                               else
+                                                       begin = false;
                                                int methodNumId = intDecl.getMethodNumId(method);
                                                print("int struct" + methodNumId + "Size" + i);
                                        }
@@ -2097,17 +2045,18 @@ public class IoTCompiler {
                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);
-                       boolean begin = true;
                        if (isStructClass(simpleType)) {
                                structExist = true;
-                               if (!begin) {
-                                       print(", "); begin = false;
-                               }
+                               if (!begin)
+                                       print(", ");
+                               else
+                                       begin = false;
                                int methodNumId = intDecl.getMethodNumId(method);
                                print("struct" + methodNumId + "Size" + i);
                        }
@@ -2341,9 +2290,10 @@ public class IoTCompiler {
                                        String param = methParams.get(i);
                                        String simpleType = getGenericType(paramType);
                                        if (isStructClass(simpleType)) {
-                                               if (!begin) {   // Generate comma for not the beginning variable
-                                                       print(", "); begin = false;
-                                               }
+                                               if (!begin)     // Generate comma for not the beginning variable
+                                                       print(", ");
+                                               else
+                                                       begin = false;
                                                int methodNumId = intDecl.getMethodNumId(method);
                                                print("int struct" + methodNumId + "Size" + i);
                                        }
@@ -2724,7 +2674,6 @@ public class IoTCompiler {
                        println(") { ");
                        if (isCallbackMethod)
                                writeCallbackMethodBodyCplusStub(intDecl, methParams, methPrmTypes, method, callbackType);
-                       //else
                        writeStdMethodBodyCplusStub(intDecl, methParams, methPrmTypes, method, callbackType, isCallbackMethod);
                        println("}\n");
                        // Write the init callback helper method
@@ -2762,90 +2711,14 @@ public class IoTCompiler {
                                println("vecCallbackObj.push_back(skel" + i + ");");
                                if (isArrayOrList)
                                        println("}");
-                       }
-               }
-               print("int ___paramCB = ");
-               if (isArrayOrList)
-                       println(callbackParam + ".size();");
-               else
-                       println("1;");
-       }
-
-/*     private void writeCallbackMethodBodyCplusStub(InterfaceDecl intDecl, List<String> methParams,
-                       List<String> methPrmTypes, String method, String callbackType) {
-
-               // Check if this is single object, array, or list of objects
-               boolean isArrayOrList = false;
-               String callbackParam = null;
-               for (int i = 0; i < methParams.size(); i++) {
-
-                       String paramType = methPrmTypes.get(i);
-                       if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
-                               String param = methParams.get(i);
-                               if (isArrayOrList(paramType, param)) {  // Generate loop
-                                       println("for (" + getGenericType(paramType) + "* cb : " + getSimpleIdentifier(param) + ") {");
-                                       println(callbackType + "_CallbackSkeleton* skel = new " + callbackType + "_CallbackSkeleton(cb, objIdCnt++);");
-                                       isArrayOrList = true;
-                                       callbackParam = getSimpleIdentifier(param);
-                               } else
-                                       println(callbackType + "_CallbackSkeleton* skel = new " + callbackType + "_CallbackSkeleton(" +
-                                               getSimpleIdentifier(param) + ", objIdCnt++);");
-                               println("vecCallbackObj.push_back(skel);");
+                               print("int ___paramCB" + i + " = ");
                                if (isArrayOrList)
-                                       println("}");
-                       }
-               }
-               println("int numParam = " + methParams.size() + ";");
-               println("int methodId = " + intDecl.getMethodNumId(method) + ";");
-               String retType = intDecl.getMethodType(method);
-               //String retTypeC = checkAndGetCplusType(retType);
-               //println("string retType = \"" + checkAndGetCplusArrayType(getStructType(getEnumType(retTypeC))) + "\";");
-               println("string retType = \"" + checkAndGetCplusRetClsType(getStructType(getEnumType(retType))) + "\";");
-               // Generate array of parameter types
-               print("string paramCls[] = { ");
-               for (int i = 0; i < methParams.size(); i++) {
-                       String paramType = methPrmTypes.get(i);
-                       if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
-                               print("\"int\"");
-                       } else { // Generate normal classes if it's not a callback object
-                               String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
-                               print("\"" + paramTypeC + "\"");
+                                       println(callbackParam + ".size();");
+                               else
+                                       println("1;");
                        }
-                       if (i != methParams.size() - 1) // Check if this is the last element
-                               print(", ");
                }
-               println(" };");
-               print("int ___paramCB = ");
-               if (isArrayOrList)
-                       println(callbackParam + ".size();");
-               else
-                       println("1;");
-               // Generate array of parameter objects
-               print("void* paramObj[] = { ");
-               for (int i = 0; i < methParams.size(); i++) {
-                       String paramType = methPrmTypes.get(i);
-                       if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
-                               print("&___paramCB");
-                       } else
-                               print("&" + getSimpleIdentifier(methParams.get(i)));
-                       if (i != methParams.size() - 1)
-                               print(", ");
-               }
-               println(" };");
-               // Check if this is "void"
-               if (retType.equals("void")) {
-                       println("void* retObj = NULL;");
-                       println("rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);");
-               } else { // We do have a return value
-                       if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES)
-                               println(checkAndGetCplusType(retType) + " retVal;");
-                       else
-                               println(checkAndGetCplusType(retType) + " retVal = " + generateCplusInitializer(retType) + ";");
-                       println("void* retObj = &retVal;");
-                       println("rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);");
-                       println("return retVal;");
-               }
-       }*/
+       }
 
 
        /**
@@ -3017,7 +2890,7 @@ public class IoTCompiler {
                                writeStructMembersCplusStub(simpleType, paramType, param);
                        } else if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
                                println("paramCls[pos] = \"int\";");
-                               println("paramObj[pos++] = &___paramCB;");
+                               println("paramObj[pos++] = &___paramCB" + i + ";");
                        } else {
                                String prmTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
                                println("paramCls[pos] = \"" + prmTypeC + "\";");
@@ -3153,7 +3026,7 @@ public class IoTCompiler {
                        for (int i = 0; i < methParams.size(); i++) {
                                String paramType = returnGenericCallbackType(methPrmTypes.get(i));
                                if (checkCallbackType(paramType, callbackType)) // Check if this has callback object
-                                       print("&___paramCB");
+                                       print("&___paramCB" + i);
                                else
                                        print("&" + getEnumParam(methPrmTypes.get(i), getSimpleIdentifier(methParams.get(i)), i));
                                // Check if this is the last element (don't print a comma)
@@ -4000,13 +3873,13 @@ public class IoTCompiler {
                        for (int i = 0; i < members.size(); i++) {
                                String prmTypeC = checkAndGetCplusType(memTypes.get(i));
                                String prmType = checkAndGetCplusArrayType(prmTypeC, members.get(i));
-                               println(getSimpleType(getEnumType(prmType)) + " param" + i + "[" + counter + "];");
+                               println(getSimpleType(getEnumType(prmType)) + " param" + iVar + i + "[" + counter + "];");
                        }
                } else {        // Just one struct element
                        for (int i = 0; i < members.size(); i++) {
                                String prmTypeC = checkAndGetCplusType(memTypes.get(i));
                                String prmType = checkAndGetCplusArrayType(prmTypeC, members.get(i));
-                               println(getSimpleType(getEnumType(prmType)) + " param" + i + ";");
+                               println(getSimpleType(getEnumType(prmType)) + " param" + iVar + i + ";");
                        }
                }
                if (isArrayOrList(paramType, param)) {  // An array or list
@@ -4016,14 +3889,14 @@ public class IoTCompiler {
                        for (int i = 0; i < members.size(); i++) {
                                String prmTypeC = checkAndGetCplusArgClsType(memTypes.get(i), members.get(i));
                                println("paramCls[pos] = \"" + prmTypeC + "\";");
-                               println("paramObj[pos++] = &param" + i + "[i];");
+                               println("paramObj[pos++] = &param" + iVar + i + "[i];");
                        }
                        println("}");
                } else {        // Just one struct element
                        for (int i = 0; i < members.size(); i++) {
                                String prmTypeC = checkAndGetCplusArgClsType(memTypes.get(i), members.get(i));
                                println("paramCls[pos] = \"" + prmTypeC + "\";");
-                               println("paramObj[pos++] = &param" + i + ";");
+                               println("paramObj[pos++] = &param" + iVar + i + ";");
                        }
                }
        }
@@ -4055,13 +3928,13 @@ public class IoTCompiler {
                                        println("for(int i = 0; i < " + counter + "; i++) {");
                                        for (int j = 0; j < members.size(); j++) {
                                                print("paramStruct" + i + "[i]." + getSimpleIdentifier(members.get(j)));
-                                               println(" = param" + j + "[i];");
+                                               println(" = param" + i + j + "[i];");
                                        }
                                        println("}");
                                } else {        // Just one struct element
                                        for (int j = 0; j < members.size(); j++) {
                                                print("paramStruct" + i + "." + getSimpleIdentifier(members.get(j)));
-                                               println(" = param" + j + ";");
+                                               println(" = param" + i + j + ";");
                                        }
                                }
                        }
@@ -4193,9 +4066,10 @@ public class IoTCompiler {
                                        String param = methParams.get(i);
                                        String simpleType = getGenericType(paramType);
                                        if (isStructClass(simpleType)) {
-                                               if (!begin) {   // Generate comma for not the beginning variable
-                                                       print(", "); begin = false;
-                                               }
+                                               if (!begin)     // Generate comma for not the beginning variable
+                                                       print(", ");
+                                               else
+                                                       begin = false;
                                                int methodNumId = intDecl.getMethodNumId(method);
                                                print("int struct" + methodNumId + "Size" + i);
                                        }
@@ -4508,9 +4382,10 @@ public class IoTCompiler {
                                        String param = methParams.get(i);
                                        String simpleType = getGenericType(paramType);
                                        if (isStructClass(simpleType)) {
-                                               if (!begin) {   // Generate comma for not the beginning variable
-                                                       print(", "); begin = false;
-                                               }
+                                               if (!begin)     // Generate comma for not the beginning variable
+                                                       print(", ");
+                                               else
+                                                       begin = false;
                                                int methodNumId = intDecl.getMethodNumId(method);
                                                print("int struct" + methodNumId + "Size" + i);
                                        }
index a630798..99dd56d 100644 (file)
@@ -91,6 +91,8 @@ void* IoTRMICall::remoteCall(int objectId, int methodId, string retType, string
        methodToBytes(objectId, methodId, paramCls, paramObj, method, numParam);
        // Send bytes
        fflush(NULL);
+       cout << "Length: " << len << endl;
+       IoTRMIUtil::printBytes(method, len, false);
        rmiClient->sendBytes(method, len);
        fflush(NULL);
        // Receive return value and return it to caller
index f7b9642..1dd3d57 100644 (file)
@@ -121,7 +121,7 @@ void IoTRMIObject::sendReturnObj(void* retObj[], string type[], int numRet) {
 char* IoTRMIObject::getMethodBytes() {
 
        // Get method in bytes and update method length
-       //fflush(NULL);
+       fflush(NULL);
        methodBytes = rmiServer->receiveBytes(methodBytes, &methodLen);
        fflush(NULL);
        return methodBytes;
index 642882f..cf62ec1 100644 (file)
@@ -17,6 +17,9 @@
 #define DEBUG_ACK
 
 static const int SOCKET_BUFF_SIZE = 64000;
+// Before, it was too short as we were just using 1 byte to receive the length
+// Now, we allocate 4 bytes (a size of integer) to receive the message length
+static const int MSG_LEN_SIZE = 4;
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -92,7 +95,7 @@ bool IoTSocket::sendBytes(char* pVals, int _iLen) {
        int iLen = _iLen;
        size[0] = iLen;
 
-       if (send(m_iSock, size, 1, 0) == -1) {
+       if (send(m_iSock, size, MSG_LEN_SIZE, 0) == -1) {
                perror("IoTSocket: Send size error!");
                return false;
        }
@@ -125,16 +128,18 @@ char* IoTSocket::receiveBytes(char* pVals, int* len)
 
        int iTotal = 0;
        int iResult = 0;
-       char size[1];
+       int size[1];
+
        while ((iTotal < 1) && (iResult != -1)) {
-               iResult = recv(m_iSock, size, 1, 0);    
+               iResult = recv(m_iSock, size, MSG_LEN_SIZE, 0);         
                iTotal += iResult;
        }
        if (iResult == -1) {
                perror("IoTSocket: Receive size error!");
                return NULL;
        }
-       int iLen = (int) size[0];
+       int iLen = size[0];
+
        // To be returned from this method...
        *len = iLen;
        pVals = new char[iLen];
index a052c0d..573ff64 100644 (file)
@@ -52,6 +52,8 @@ class TestClass : public TestClassInterface {
                vector<Enum>            handleEnumList(vector<Enum> vecEn);
                Enum                            handleEnumComplex(Enum en, int i, char c);
                vector<Enum>            handleEnumComplex2(vector<Enum> en, int i, char c);
+               vector<Enum>            handleEnumTwo(vector<Enum> en1, vector<Enum> en2);
+               vector<Enum>            handleEnumThree(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2);
 
                // Struct
                Struct                          handleStruct(Struct str);
@@ -59,9 +61,13 @@ class TestClass : public TestClassInterface {
                vector<Struct>          handleStructList(vector<Struct> vecStr);
                Struct                          handleStructComplex(int in, char c, Struct str);
                vector<Struct>          handleStructComplex2(int in, char c, vector<Struct> vecStr);
+               vector<Struct>          handleStructTwo(vector<Struct> str1, vector<Struct> str2);
+               vector<Struct>          handleStructThree(vector<Struct> str1, vector<Struct> str2, vector<Struct> str3);
 
                vector<Enum>            handleEnumStruct(vector<Enum> en, vector<Struct> str, char c);
                vector<Enum>            handleAll(vector<Enum> en, vector<Struct> str, char c, vector<CallBackInterfaceWithCallBack*> _cb);
+               vector<Enum>            handleAllTwo(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2, char c, 
+                                                                       vector<CallBackInterfaceWithCallBack*> _cb1, vector<CallBackInterfaceWithCallBack*> _cb2);
 
                int                                     getA();
                void                            setA(int _int);
@@ -348,6 +354,32 @@ vector<Enum> TestClass::handleEnumComplex2(vector<Enum> vecEn, int in, char c) {
 }
 
 
+vector<Enum> TestClass::handleEnumTwo(vector<Enum> en1, vector<Enum> en2) {
+
+       for (Enum en : en1) {
+               cout << "Enum1: " << en << endl;
+       }
+       for (Enum en : en2) {
+               cout << "Enum2: " << en << endl;
+       }
+       
+       return en1;
+}
+
+
+vector<Enum> TestClass::handleEnumThree(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2) {
+
+       for (Enum en : en1) {
+               cout << "Enum1: " << en << endl;
+       }
+       for (Enum en : en2) {
+               cout << "Enum2: " << en << endl;
+       }
+       
+       return en1;
+}
+
+
 
 // Struct
 Struct TestClass::handleStruct(Struct str) {
@@ -402,6 +434,32 @@ vector<Struct> TestClass::handleStructList(vector<Struct> vecStr) {
 }
 
 
+vector<Struct> TestClass::handleStructTwo(vector<Struct> str1, vector<Struct> str2) {
+
+       for (Struct str : str1) {
+
+               cout << "Name: " << str.name << endl;
+               cout << "Value: " << str.value << endl;
+               cout << "Year: " << str.year << endl;
+       }
+
+       return str2;
+}
+
+
+vector<Struct> TestClass::handleStructThree(vector<Struct> str1, vector<Struct> str2, vector<Struct> str3) {
+
+       for (Struct str : str1) {
+
+               cout << "Name: " << str.name << endl;
+               cout << "Value: " << str.value << endl;
+               cout << "Year: " << str.year << endl;
+       }
+
+       return str2;
+}
+
+
 Struct TestClass::handleStructComplex(int in, char c, Struct str) {
 
        cout << "Name: " << str.name << endl;
@@ -469,6 +527,26 @@ vector<Enum> TestClass::handleAll(vector<Enum> en, vector<Struct> str, char c, v
 }
 
 
+vector<Enum> TestClass::handleAllTwo(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2, char c, 
+               vector<CallBackInterfaceWithCallBack*> _cb1, vector<CallBackInterfaceWithCallBack*> _cb2) {
+
+       for (CallBackInterfaceWithCallBack* cb : _cb1) {
+               cbvec.push_back(cb);
+               cout << "Registering callback object in array!" << endl;
+       }
+
+       for (Struct st : str1) {
+               cout << "Name: " << st.name << endl;
+               cout << "Value: " << st.value << endl;
+               cout << "Year: " << st.year << endl;
+       }
+
+       cout << "Char: " << c << endl;
+
+       return en1;
+}
+
+
 vector<Enum> TestClass::handleCallbackEnum(vector<Enum> en, char c, vector<CallBackInterfaceWithCallBack*> _cb) {
 
        for (CallBackInterfaceWithCallBack* cb : _cb) {
index 8e23210..e224bca 100644 (file)
@@ -80,11 +80,11 @@ int main(int argc, char *argv[])
                cout << "Name: " << st.name << endl;
                cout << "Value:" << st.value << endl;
                cout << "Year" << st.year << endl;
-       }*/
+       }
        vector<Enum> vecRes4 = tcStub->handleEnumStruct(vecEn, vecStr, 'c');
        for (Enum en : vecRes4) {
                cout << "Enum value: " << en << endl;
-       }
+       }*/
 
 /*     cout << "==== CALLBACK ====" << endl;
        CallBackInterface *cbSingle = new CallBack(2354);
@@ -113,11 +113,36 @@ int main(int argc, char *argv[])
        vector<Enum> vecRes5 = tcStub->handleAll(vecEn, vecStr, 'c', cblist);
        for (Enum en : vecRes5) {
                cout << "Enum value: " << en << endl;
-       }*/
+       }
 
        vector<Enum> vecRes6 = tcStub->handleCallbackEnum(vecEn, 'c', cblist);
        for (Enum en : vecRes6) {
                cout << "Enum value: " << en << endl;
+       }*/
+       //vector<Enum> vecRes7 = tcStub->handleAllTwo(vecEn, vecStr, vecStr, vecEn, 'c', cblist, cblist);
+       /*vector<Enum> vecRes7 = tcStub->handleAllTwo(vecEn, vecEn, vecStr, vecStr, 'c', cblist, cblist);
+       for (Enum en : vecRes7) {
+               cout << "Enum value: " << en << endl;
+       }
+       vector<Enum> vecRes8 = tcStub->handleEnumTwo(vecEn, vecEn);
+       for (Enum en : vecRes8) {
+               cout << "Enum value: " << en << endl;
+       }
+       vector<Enum> vecRes9 = tcStub->handleEnumThree(vecEn, vecEn, vecStr, vecStr);
+       for (Enum en : vecRes9) {
+               cout << "Enum value: " << en << endl;
+       }
+       vector<Struct> vecRetStr2 = tcStub->handleStructTwo(vecStr, vecStr);
+       for (Struct st : vecRetStr2) {
+               cout << "Name: " << st.name << endl;
+               cout << "Value:" << st.value << endl;
+               cout << "Year" << st.year << endl;
+       }*/
+       vector<Struct> vecRetStr3 = tcStub->handleStructThree(vecStr, vecStr, vecStr);
+       for (Struct st : vecRetStr3) {
+               cout << "Name: " << st.name << endl;
+               cout << "Value:" << st.value << endl;
+               cout << "Year" << st.year << endl;
        }
 
        return 0;
index 411e7db..1bfe8e2 100644 (file)
@@ -288,6 +288,32 @@ public class TestClass implements TestClassInterface {
        }
 
 
+       public Enum[] handleEnumTwo(Enum en1[], Enum en2[]) {
+
+               for (Enum e : en1) {
+                       System.out.println("Enum1: " + e);
+               }
+               for (Enum e : en2) {
+                       System.out.println("Enum2: " + e);
+               }
+               
+               return en1;
+       }
+
+
+       public Enum[] handleEnumThree(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2) {
+
+               for (Enum e : en1) {
+                       System.out.println("Enum1: " + e);
+               }
+               for (Enum e : en2) {
+                       System.out.println("Enum2: " + e);
+               }
+               
+               return en1;
+       }
+
+
        // Struct
        public Struct handleStruct(Struct str) {
 
@@ -394,6 +420,30 @@ public class TestClass implements TestClassInterface {
        }
 
 
+       public List<Struct> handleStructTwo(List<Struct> str1, List<Struct> str2) {
+
+               for (Struct st : str1) {
+                       System.out.println("Name: " + st.name);
+                       System.out.println("Value: " + st.value);
+                       System.out.println("Year: " + st.year);
+               }
+
+               return str1;
+       }
+
+
+       public List<Struct> handleStructThree(List<Struct> str1, List<Struct> str2, List<Struct> str3) {
+
+               for (Struct st : str1) {
+                       System.out.println("Name: " + st.name);
+                       System.out.println("Value: " + st.value);
+                       System.out.println("Year: " + st.year);
+               }
+
+               return str2;
+       }
+
+
        public Enum[] handleAll(Enum en[], List<Struct> str, char c, List<CallBackInterfaceWithCallBack> _cb) {
 
                for (CallBackInterfaceWithCallBack cb : _cb) {
@@ -426,6 +476,25 @@ public class TestClass implements TestClassInterface {
        }
 
 
+       public Enum[] handleAllTwo(Enum en1[], Enum en2[], List<Struct> str1, List<Struct> str2, char c, List<CallBackInterfaceWithCallBack> _cb1, List<CallBackInterfaceWithCallBack> _cb2) {
+
+               for (CallBackInterfaceWithCallBack cb : _cb1) {
+                       cblist.add(cb);
+                       System.out.println("Registering callback objects in list!");
+               }
+
+               for (Struct st : str1) {
+                       System.out.println("Name: " + st.name);
+                       System.out.println("Value: " + st.value);
+                       System.out.println("Year: " + st.year);
+               }
+
+               System.out.println("Char: " + c);
+
+               return en1;
+       }
+
+
        // Getters
        public String sumArray(String[] newA) {
 
index 759d3a6..d40bda6 100644 (file)
@@ -46,20 +46,20 @@ public class TestClassAdvanced_Stub {
                Struct strRes2 = tcstub.handleStructComplex(23, 'c', str);
                System.out.println("Name: " + strRes2.name);
                System.out.println("Value: " + strRes2.value);
-               System.out.println("Year: " + strRes2.year);
+               System.out.println("Year: " + strRes2.year);*/
                Struct str2 = new Struct();
                str2.name = "Trimananda";
                str2.value = 0.124f;
                str2.year = 2017;
                Struct[] arrStr = { str, str2 };
-               Struct[] arrRet = tcstub.handleStructArray(arrStr);
+/*             Struct[] arrRet = tcstub.handleStructArray(arrStr);
                for(Struct st : arrRet) {
                        System.out.println("Name: " + st.name);
                        System.out.println("Value: " + st.value);
                        System.out.println("Year: " + st.year);
-               }
+               }*/
                List<Struct> stList = new ArrayList(Arrays.asList(arrStr));
-               List<Struct> stRetList = tcstub.handleStructList(stList);
+/*             List<Struct> stRetList = tcstub.handleStructList(stList);
                for(Struct st : stRetList) {
                        System.out.println("Name: " + st.name);
                        System.out.println("Value: " + st.value);
@@ -94,9 +94,28 @@ public class TestClassAdvanced_Stub {
 /*             tcstub.registerCallbackComplex(23, cblist, 0.1234);
                System.out.println("Return value from callback: " + tcstub.callBack());
                Enum[] resArr4 = tcstub.handleAll(enArr, stList, 'c', cblist);
-               System.out.println("Enum members: " + Arrays.toString(resArr4));*/
+               System.out.println("Enum members: " + Arrays.toString(resArr4));
 
                Enum[] resArr5 = tcstub.handleCallbackEnum(enArr, 'c', cblist);
                System.out.println("Enum members: " + Arrays.toString(resArr5));
+               //Enum[] resArr6 = tcstub.handleAllTwo(enArr, stList, stList, enArr, 'c', cblist, cblist);
+//             Enum[] resArr6 = tcstub.handleAllTwo(enArr, enArr, stList, stList, 'c', cblist, cblist);
+//             System.out.println("Enum members: " + Arrays.toString(resArr6));
+               Enum[] resArr7 = tcstub.handleEnumTwo(enArr, enArr);
+               System.out.println("Enum members: " + Arrays.toString(resArr7));
+               Enum[] resArr8 = tcstub.handleEnumThree(enArr, enArr, stList, stList);
+               System.out.println("Enum members: " + Arrays.toString(resArr8));
+               List<Struct> stRetList2 = tcstub.handleStructTwo(stList, stList);
+               for(Struct st : stRetList2) {
+                       System.out.println("Name: " + st.name);
+                       System.out.println("Value: " + st.value);
+                       System.out.println("Year: " + st.year);
+               }*/
+               List<Struct> stRetList3 = tcstub.handleStructThree(stList, stList, stList);
+               for(Struct st : stRetList3) {
+                       System.out.println("Name: " + st.name);
+                       System.out.println("Value: " + st.value);
+                       System.out.println("Year: " + st.year);
+               }
        }
 }