static void* getArrayParamObject(void* retObj, const char* type, char* paramBytes, int len);
// Constants
+ const static int OBJECT_ID_LEN = 4; // 4 bytes = 32 bits
const static int METHOD_ID_LEN = 4; // 4 bytes = 32 bits
const static int PARAM_LEN = 4; // 4 bytes = 32 bits (4-byte field that stores the length of the param)
+ const static int RETURN_LEN = 4; // 4 bytes = 32 bits (4-byte field that stores the length of the return object)
const static int CHAR_LEN = 2; // 2 bytes (we follow Java convention)
const static int BOOL_LEN = 1; // 1 byte
int IoTRMIUtil::getVarTypeSize(string type, void* paramObj) {
int paramLen = 0;
- if (type.compare("string") == 0) {
+ if (type.compare("String") == 0) {
// Get the length of the string through void* casting to string*
paramLen = (*(string*)paramObj).length();
- } else if (type.compare("string[]") == 0) {
+ } else if (type.compare("String[]") == 0) {
paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj);
} else if (type.compare("byte[]") == 0) {
int dataSize = getTypeSize("byte");
int dataSize = getTypeSize("double");
paramLen = (*(vector<double>*) paramObj).size() * dataSize;
} else if (type.compare("bool[]") == 0) {
- int dataSize = getTypeSize("bool");
+ int dataSize = getTypeSize("boolean");
paramLen = (*(vector<bool>*) paramObj).size() * dataSize;
} else if (type.compare("char[]") == 0) {
int dataSize = getTypeSize("char");
paramLen = (*(vector<char>*) paramObj).size() * dataSize;
} else {
- string error = "IoTRMICall: Unrecognizable type: " + type;
- throw error;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ exit(-1);
}
return paramLen;
strcmp(type, "double") == 0) {
retObj = (void*) byteArrayToDouble((double*) retObj, paramBytes);
} else if ( strcmp(type, "b") == 0 ||
- strcmp(type, "bool") == 0) {
+ strcmp(type, "boolean") == 0) {
retObj = (void*) byteArrayToBoolean((bool*) retObj, paramBytes);
} else if ( strcmp(type, "c") == 0 ||
strcmp(type, "char") == 0) {
retObj = (void*) byteArrayToChar((char*) retObj, paramBytes);
} else if ( strcmp(type, "Ss") == 0 ||
- strcmp(type, "string") == 0) {
+ strcmp(type, "String") == 0) {
retObj = (void*) byteArrayToString((string*) retObj, paramBytes, len);
} else if ( string(type).find("[]") != string::npos) {
// This is an array type, i.e. vector
retObj = getArrayParamObject(retObj, type, paramBytes, len);
} else {
- string error = "IoTRMIUtil: Unrecognizable type: " + string(type);
- throw error;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ exit(-1);
}
return retObj;
retObj = byteArrayToBooleanArray((vector<bool>*) retObj, paramBytes, len);
} else if (strcmp(type, "char[]") == 0) {
retObj = byteArrayToCharArray((vector<char>*) retObj, paramBytes, len);
- } else if (strcmp(type, "string[]") == 0) {
+ } else if (strcmp(type, "String[]") == 0) {
retObj = byteArrayToStringArray((vector<string>*) retObj, paramBytes, len);
} else {
- string error = "IoTRMIUtil: Unrecognizable type: " + string(type);
- throw error;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ exit(-1);
}
return retObj;
strcmp(type, "double") == 0) {
retObjBytes = doubleToByteArray(*((double*) obj), retObjBytes);
} else if ( strcmp(type, "b") == 0 ||
- strcmp(type, "bool") == 0) {
+ strcmp(type, "boolean") == 0) {
retObjBytes = booleanToByteArray(*((bool*) obj), retObjBytes);
} else if ( strcmp(type, "c") == 0 ||
strcmp(type, "char") == 0) {
retObjBytes = charToByteArray(*((char*) obj), retObjBytes);
} else if ( strcmp(type, "Ss") == 0 ||
+ strcmp(type, "String") == 0 ||
strcmp(type, "string") == 0) {
retObjBytes = stringToByteArray(*((string*) obj), retObjBytes);
} else if ( string(type).find("[]") != string::npos) {
// This is an array type, i.e. vector
retObjBytes = getArrayObjectBytes(retObjBytes, obj, type);
} else {
- string error = "IoTRMIUtil: Unrecognizable type: " + string(type);
- throw error;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ exit(-1);
}
return retObjBytes;
retObjBytes = arrBooleanToByteArray(*((vector<bool>*) obj), retObjBytes);
} else if (strcmp(type, "char[]") == 0) {
retObjBytes = arrCharToByteArray(*((vector<char>*) obj), retObjBytes);
- } else if (strcmp(type, "string[]") == 0) {
+ } else if (strcmp(type, "String[]") == 0) {
retObjBytes = arrStringToByteArray(*((vector<string>*) obj), retObjBytes);
} else {
- string error = "IoTRMIUtil: Unrecognizable type: " + string(type);
- throw error;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ exit(-1);
}
return retObjBytes;