InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
List<String> methods = intDecl.getMethods();
Set<String> importClasses = getImportClasses(methods, intDecl);
- printImportStatements(importClasses);
+ List<String> stdImportClasses = getStandardJavaIntfaceImportClasses();
+ List<String> allImportClasses = getAllLibClasses(stdImportClasses, importClasses);
+ printImportStatements(allImportClasses);
// Write interface header
println("");
println("public interface " + intface + " {");
DeclarationHandler decHandler = mapIntDeclHand.get(intface);
InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
// Pass in set of methods and get import classes
- Set<String> importClasses = getImportClasses(intMeth.getValue(), intDecl);
- printImportStatements(importClasses);
+ List<String> methods = intDecl.getMethods();
+ Set<String> importClasses = getImportClasses(methods, intDecl);
+ List<String> stdImportClasses = getStandardJavaIntfaceImportClasses();
+ List<String> allImportClasses = getAllLibClasses(stdImportClasses, importClasses);
+ printImportStatements(allImportClasses);
// Write interface header
println("");
println("public interface " + newIntface + " {\n");
// Write methods
- writeMethodJavaInterface(intMeth.getValue(), intDecl);
+ writeMethodJavaInterface(methods, intDecl);
println("}");
pw.close();
System.out.println("IoTCompiler: Generated interface " + newIntface + ".java...");
List<String> methParams = intDecl.getMethodParams(method);
List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
+
+ //System.out.println("\n\nMethod return type: " + checkAndGetCplusType(intDecl.getMethodType(method)) + "\n\n");
+
print(checkAndGetCplusType(intDecl.getMethodType(method)) + " " +
intDecl.getMethodId(method) + "(");
boolean isCallbackMethod = false;
println("int methodId = " + intDecl.getMethodNumId(method) + ";");
String retType = intDecl.getMethodType(method);
//String retTypeC = checkAndGetCplusType(retType);
- //println("string retType = \"" + checkAndGetCplusArrayType(retTypeC) + "\";");
- println("string retType = \"" + 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++) {
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 = checkAndGetCplusType(methPrmTypes.get(i));
- //String prmType = checkAndGetCplusArrayType(paramTypeC, methParams.get(i));
- String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
- String prmType = getSimpleType(getEnumType(paramTypeC));
+ //String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
+ //String prmType = getSimpleType(getEnumType(paramTypeC));
+ String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
+ String prmType = getEnumType(paramTypeC);
print("\"" + prmType + "\"");
}
if (i != methParams.size() - 1) // Check if this is the last element
String retType = intDecl.getMethodType(method);
//String retTypeC = checkAndGetCplusType(retType);
//println("string retType = \"" + checkAndGetCplusArrayType(getStructType(getEnumType(retTypeC))) + "\";");
- println("string retType = \"" + retType + "\";");
+ println("string retType = \"" + checkAndGetCplusRetClsType(getStructType(getEnumType(retType))) + "\";");
// Generate array of parameter types
if (isStructPresent(methParams, methPrmTypes)) {
writeStructParamClassCplusStub(methParams, methPrmTypes);
println("int numParam = " + methParams.size() + ";");
print("string paramCls[] = { ");
for (int i = 0; i < methParams.size(); i++) {
- //String paramTypeC = checkAndGetCplusType(methPrmTypes.get(i));
- //String paramType = checkAndGetCplusArrayType(paramTypeC, methParams.get(i));
- //print("\"" + getEnumType(paramType) + "\"");
- String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
- String prmType = getSimpleType(getEnumType(paramTypeC));
+ //String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
+ //String prmType = getSimpleType(getEnumType(paramTypeC));
+ String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
+ String prmType = getEnumType(paramTypeC);
print("\"" + prmType + "\"");
// Check if this is the last element (don't print a comma)
if (i != methParams.size() - 1) {
if (getParamCategory(retType) == ParamCategory.ENUM) {
checkAndWriteEnumRetTypeCplusStub(retType);
} else {
- if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES)
+ //if (getParamCategory(retType) == ParamCategory.NONPRIMITIVES)
+ if (isArrayOrList(retType,retType))
println(checkAndGetCplusType(retType) + " retVal;");
- else
+ else {
println(checkAndGetCplusType(retType) + " retVal = " + generateCplusInitializer(retType) + ";");
+ }
println("void* retObj = &retVal;");
println("rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);");
println("return retVal;");
if (isStructClass(getSimpleArrayType(getSimpleType(retType)))) // Struct type
println("rmiObj->sendReturnObj(retObj, retCls, numRetObj);");
else
- //println("rmiObj->sendReturnObj(retObj, \"" + getEnumType(checkAndGetCplusArrayType(retTypeC)) + "\");");
- println("rmiObj->sendReturnObj(retObj, \"" + getEnumType(retType) + "\");");
+ println("rmiObj->sendReturnObj(retObj, \"" + checkAndGetCplusRetClsType(getEnumType(retType)) + "\");");
}
}
callbackType = paramType;
print("\"int\"");
} else { // Generate normal classes if it's not a callback object
- //String paramTypeC = checkAndGetCplusType(methPrmTypes.get(i));
- //String prmType = checkAndGetCplusArrayType(paramTypeC, methParams.get(i));
- //print("\"" + getEnumType(prmType) + "\"");
- String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
- String prmType = getSimpleType(getEnumType(paramTypeC));
+ //String paramTypeC = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
+ //String prmType = getSimpleType(getEnumType(paramTypeC));
+ String paramTypeC = checkAndGetCplusArgClsType(methPrmTypes.get(i), methParams.get(i));
+ String prmType = getEnumType(paramTypeC);
print("\"" + prmType + "\"");
}
if (i != methParams.size() - 1) {
println("vector<int> paramEnumInt" + i + ";");
} else {
String methParamComplete = checkAndGetCplusArray(methPrmType, methParams.get(i));
- //println(methParamComplete + " = " + generateCplusInitializer(methPrmType) + ";");
println(methParamComplete + ";");
}
}
}
+ // Generate a set of standard classes for import statements
+ private List<String> getStandardJavaIntfaceImportClasses() {
+
+ List<String> importClasses = new ArrayList<String>();
+ // Add the standard list first
+ importClasses.add("java.util.List");
+ importClasses.add("java.util.ArrayList");
+
+ return importClasses;
+ }
+
+
// Generate a set of standard classes for import statements
private List<String> getStandardJavaImportClasses() {
} else
return getNonPrimitiveCplusClass(paramType);
} else if(paramType.contains("[]")) { // Array type (used for return type only)
- String cArray = "vector<" + getSimpleArrayType(paramType) + ">";
+ String cArray = "vector<" + convertType(getSimpleArrayType(paramType)) + ">";
return cArray;
} else if(getParamCategory(paramType) == ParamCategory.USERDEFINED) {
return paramType + "*";
}
+ // Return the class type for class resolution (for return value)
+ // - Check and return C++ array class, e.g. int A[] into int*
+ // - Check and return C++ vector class, e.g. List<Integer> A into vector<int>
+ private String checkAndGetCplusRetClsType(String paramType) {
+
+ String paramTypeRet = null;
+ // Check for array declaration
+ if (paramType.contains("[]")) {
+ String type = paramType.split("\\[\\]")[0];
+ paramTypeRet = getSimpleArrayType(type) + "*";
+ } else if (paramType.contains("<") && paramType.contains(">")) {
+ // Just return it as is if it's not an array
+ String type = paramType.split("<")[1].split(">")[0];
+ paramTypeRet = "vector<" + getGenericType(type) + ">";
+ } else
+ paramTypeRet = paramType;
+
+ return paramTypeRet;
+ }
+
+
+ // Return the class type for class resolution (for method arguments)
+ // - Check and return C++ array class, e.g. int A[] into int*
+ // - Check and return C++ vector class, e.g. List<Integer> A into vector<int>
+ private String checkAndGetCplusArgClsType(String paramType, String param) {
+
+ String paramTypeRet = null;
+ // Check for array declaration
+ if (param.contains("[]")) {
+ paramTypeRet = getSimpleArrayType(paramType) + "*";
+ } else if (paramType.contains("<") && paramType.contains(">")) {
+ // Just return it as is if it's not an array
+ String type = paramType.split("<")[1].split(">")[0];
+ paramTypeRet = "vector<" + getGenericType(type) + ">";
+ } else
+ paramTypeRet = paramType;
+
+ return paramTypeRet;
+ }
+
+
// Detect array declaration, e.g. int A[],
// then generate type "int[]"
private String checkAndGetArray(String paramType, String param) {
static int getByteStringLength(vector<string> arrString);
// Primitives to byte array
+ static char* byteToByteArray(char c, char* bytes);
static char* shortToByteArray(short i, char* bytes);
static char* intToByteArray(int i, char* bytes);
static char* longToByteArray(int64_t i, char* bytes);
static char* stringToByteArray(string c, char* bytes);
// Byte array to primitives
+ static char* byteArrayToByte(char* result, char* bytes);
static short* byteArrayToShort(short* result, char* bytes);
static int* byteArrayToInt(int* result, char* bytes);
static int64_t* byteArrayToLong(int64_t* result, char* bytes);
static char* getObjectBytes(char* retObjBytes, void* obj, const char* type);
// Arrays to bytes
+ static char* arrByteToByteArray(vector<char> arrByte, char* bytes);
static char* arrShortToByteArray(vector<short> arrShort, char* bytes);
static char* arrIntToByteArray(vector<int> arrInt, char* bytes);
static char* arrLongToByteArray(vector<int64_t> arrInt, char* bytes);
static char* arrStringToByteArray(vector<string> arrString, char* bytes);
// Bytes to array
+ static vector<char>* byteArrayToByteArray(vector<char>* result, char* bytes, int len);
static vector<short>* byteArrayToShortArray(vector<short>* result, char* bytes, int len);
static vector<int>* byteArrayToIntArray(vector<int>* result, char* bytes, int len);
static vector<int64_t>* byteArrayToLongArray(vector<int64_t>* result, char* bytes, int len);
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 BYTE_LEN = 1; // 1 byte
const static int BOOL_LEN = 1; // 1 byte
private:
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) ||
+ (type.compare("string*") == 0) ||
+ (type.compare("vector<String>") == 0)) {
paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj);
- } else if (type.compare("byte[]") == 0) {
+ } else if ( (type.compare("byte*") == 0) ||
+ (type.compare("Byte*") == 0) ||
+ (type.compare("vector<Byte>") == 0)) {
int dataSize = getTypeSize("byte");
paramLen = (*(vector<char>*) paramObj).size() * dataSize;
- } else if (type.compare("short[]") == 0) {
+ } else if ( (type.compare("short*") == 0) ||
+ (type.compare("Short*") == 0) ||
+ (type.compare("vector<Short>") == 0)) {
int dataSize = getTypeSize("short");
paramLen = (*(vector<short>*) paramObj).size() * dataSize;
- } else if (type.compare("int[]") == 0) {
+ } else if ( (type.compare("int*") == 0) ||
+ (type.compare("Integer*") == 0) ||
+ (type.compare("vector<Integer>") == 0)) {
int dataSize = getTypeSize("int");
paramLen = (*(vector<int>*) paramObj).size() * dataSize;
- } else if (type.compare("long[]") == 0) {
+ } else if ( (type.compare("long*") == 0) ||
+ (type.compare("Long*") == 0) ||
+ (type.compare("vector<Long>") == 0)) {
int dataSize = getTypeSize("long");
paramLen = (*(vector<int64_t>*) paramObj).size() * dataSize;
- } else if (type.compare("float[]") == 0) {
+ } else if ( (type.compare("float*") == 0) ||
+ (type.compare("Float*") == 0) ||
+ (type.compare("vector<Float>") == 0)) {
int dataSize = getTypeSize("float");
paramLen = (*(vector<float>*) paramObj).size() * dataSize;
- } else if (type.compare("double[]") == 0) {
+ } else if ( (type.compare("double*") == 0) ||
+ (type.compare("Double*") == 0) ||
+ (type.compare("vector<Double>") == 0)) {
int dataSize = getTypeSize("double");
paramLen = (*(vector<double>*) paramObj).size() * dataSize;
- } else if (type.compare("bool[]") == 0) {
+ } else if ( (type.compare("boolean*") == 0) ||
+ (type.compare("Boolean*") == 0) ||
+ (type.compare("vector<Boolean>") == 0)) {
int dataSize = getTypeSize("boolean");
paramLen = (*(vector<bool>*) paramObj).size() * dataSize;
- } else if (type.compare("char[]") == 0) {
+ } else if ( (type.compare("char*") == 0) ||
+ (type.compare("Character*") == 0) ||
+ (type.compare("vector<Character>") == 0)) {
int dataSize = getTypeSize("char");
paramLen = (*(vector<char>*) paramObj).size() * dataSize;
} else {
- cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
exit(-1);
}
if (strcmp(type, "b") == 0 ||
strcmp(type, "byte") == 0) {
- retObj = (void*) ¶mBytes[0];
+ retObj = (void*) byteArrayToByte((char*) retObj, paramBytes);
} else if ( strcmp(type, "s") == 0 ||
strcmp(type, "short") == 0) {
retObj = (void*) byteArrayToShort((short*) retObj, paramBytes);
} else if ( strcmp(type, "Ss") == 0 ||
strcmp(type, "String") == 0) {
retObj = (void*) byteArrayToString((string*) retObj, paramBytes, len);
- } else if ( string(type).find("[]") != string::npos) {
+ } else if ( string(type).find("*") != string::npos) {
// This is an array type, i.e. vector
retObj = getArrayParamObject(retObj, type, paramBytes, len);
} else {
- cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
exit(-1);
}
}
-// Get array of objects from byte array - overload getParamObject function
+// Get array of objects from byte array
void* IoTRMIUtil::getArrayParamObject(void* retObj, const char* type, char* paramBytes, int len) {
- if (strcmp(type, "byte[]") == 0) {
- retObj = (vector<char>*) paramBytes;
- } else if (strcmp(type, "short[]") == 0) {
+ if ((strcmp(type, "byte*") == 0) ||
+ (strcmp(type, "Byte*") == 0) ||
+ (strcmp(type, "vector<Byte>") == 0)) {
+ retObj = byteArrayToByteArray((vector<char>*) retObj, paramBytes, len);
+ } else if ( (strcmp(type, "short*") == 0) ||
+ (strcmp(type, "Short*") == 0) ||
+ (strcmp(type, "vector<Short>") == 0)) {
retObj = byteArrayToShortArray((vector<short>*) retObj, paramBytes, len);
- } else if (strcmp(type, "int[]") == 0) {
+ } else if ( (strcmp(type, "int*") == 0) ||
+ (strcmp(type, "Integer*") == 0) ||
+ (strcmp(type, "vector<Integer>") == 0)) {
retObj = byteArrayToIntArray((vector<int>*) retObj, paramBytes, len);
- } else if (strcmp(type, "long[]") == 0) {
+ } else if ( (strcmp(type, "long*") == 0) ||
+ (strcmp(type, "Long*") == 0) ||
+ (strcmp(type, "vector<Long>") == 0)) {
retObj = byteArrayToLongArray((vector<int64_t>*) retObj, paramBytes, len);
- } else if (strcmp(type, "float[]") == 0) {
+ } else if ( (strcmp(type, "float*") == 0) ||
+ (strcmp(type, "Float*") == 0) ||
+ (strcmp(type, "vector<Float>") == 0)) {
retObj = byteArrayToFloatArray((vector<float>*) retObj, paramBytes, len);
- } else if (strcmp(type, "double[]") == 0) {
+ } else if ( (strcmp(type, "double*") == 0) ||
+ (strcmp(type, "Double*") == 0) ||
+ (strcmp(type, "vector<Double>") == 0)) {
retObj = byteArrayToDoubleArray((vector<double>*) retObj, paramBytes, len);
- } else if (strcmp(type, "bool[]") == 0) {
+ } else if ( (strcmp(type, "boolean*") == 0) ||
+ (strcmp(type, "Boolean*") == 0) ||
+ (strcmp(type, "vector<Boolean>") == 0)) {
retObj = byteArrayToBooleanArray((vector<bool>*) retObj, paramBytes, len);
- } else if (strcmp(type, "char[]") == 0) {
+ } else if ( (strcmp(type, "char*") == 0) ||
+ (strcmp(type, "Character*") == 0) ||
+ (strcmp(type, "vector<Character>") == 0)) {
retObj = byteArrayToCharArray((vector<char>*) retObj, paramBytes, len);
- } else if (strcmp(type, "String[]") == 0) {
+ } else if ( (strcmp(type, "String*") == 0) ||
+ (strcmp(type, "vector<String>") == 0)) {
retObj = byteArrayToStringArray((vector<string>*) retObj, paramBytes, len);
} else {
- cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
exit(-1);
}
if (strcmp(type, "b") == 0 ||
strcmp(type, "byte") == 0) {
- retObjBytes = (char*) obj;
+ retObjBytes = byteToByteArray(*((char*) obj), retObjBytes);
} else if ( strcmp(type, "s") == 0 ||
strcmp(type, "short") == 0) {
retObjBytes = shortToByteArray(*((short*) obj), retObjBytes);
strcmp(type, "char") == 0) {
retObjBytes = charToByteArray(*((char*) obj), retObjBytes);
} else if ( strcmp(type, "Ss") == 0 ||
- strcmp(type, "String") == 0 ||
- strcmp(type, "string") == 0) {
+ strcmp(type, "String") == 0) {
retObjBytes = stringToByteArray(*((string*) obj), retObjBytes);
- } else if ( string(type).find("[]") != string::npos) {
+ } else if ( string(type).find("*") != string::npos) {
// This is an array type, i.e. vector
retObjBytes = getArrayObjectBytes(retObjBytes, obj, type);
} else {
- cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
exit(-1);
}
// Getting byte array for arrays of primitives
char* IoTRMIUtil::getArrayObjectBytes(char* retObjBytes, void* obj, const char* type) {
- if (strcmp(type, "byte[]") == 0) {
- retObjBytes = (char*) obj;
- } else if (strcmp(type, "short[]") == 0) {
+ if ((strcmp(type, "byte*") == 0) ||
+ (strcmp(type, "Byte*") == 0) ||
+ (strcmp(type, "vector<Byte>") == 0)) {
+ retObjBytes = arrByteToByteArray(*((vector<char>*) obj), retObjBytes);
+ } else if ( (strcmp(type, "short*") == 0) ||
+ (strcmp(type, "Short*") == 0) ||
+ (strcmp(type, "vector<Short>") == 0)) {
retObjBytes = arrShortToByteArray(*((vector<short>*) obj), retObjBytes);
- } else if (strcmp(type, "int[]") == 0) {
+ } else if ( (strcmp(type, "int*") == 0) ||
+ (strcmp(type, "Integer*") == 0) ||
+ (strcmp(type, "vector<Integer>") == 0)) {
retObjBytes = arrIntToByteArray(*((vector<int>*) obj), retObjBytes);
- } else if (strcmp(type, "long[]") == 0) {
+ } else if ( (strcmp(type, "long*") == 0) ||
+ (strcmp(type, "Long*") == 0) ||
+ (strcmp(type, "vector<Long>") == 0)) {
retObjBytes = arrLongToByteArray(*((vector<int64_t>*) obj), retObjBytes);
- } else if (strcmp(type, "float[]") == 0) {
+ } else if ( (strcmp(type, "float*") == 0) ||
+ (strcmp(type, "Float*") == 0) ||
+ (strcmp(type, "vector<Float>") == 0)) {
retObjBytes = arrFloatToByteArray(*((vector<float>*) obj), retObjBytes);
- } else if (strcmp(type, "double[]") == 0) {
+ } else if ( (strcmp(type, "double*") == 0) ||
+ (strcmp(type, "Double*") == 0) ||
+ (strcmp(type, "vector<Double>") == 0)) {
retObjBytes = arrDoubleToByteArray(*((vector<double>*) obj), retObjBytes);
- } else if (strcmp(type, "bool[]") == 0) {
+ } else if ( (strcmp(type, "boolean*") == 0) ||
+ (strcmp(type, "Boolean*") == 0) ||
+ (strcmp(type, "vector<Boolean>") == 0)) {
retObjBytes = arrBooleanToByteArray(*((vector<bool>*) obj), retObjBytes);
- } else if (strcmp(type, "char[]") == 0) {
+ } else if ( (strcmp(type, "char*") == 0) ||
+ (strcmp(type, "Character*") == 0) ||
+ (strcmp(type, "vector<Character>") == 0)) {
retObjBytes = arrCharToByteArray(*((vector<char>*) obj), retObjBytes);
- } else if (strcmp(type, "String[]") == 0) {
+ } else if ( (strcmp(type, "String*") == 0) ||
+ (strcmp(type, "vector<String>") == 0)) {
retObjBytes = arrStringToByteArray(*((vector<string>*) obj), retObjBytes);
} else {
- cerr << "IoTRMIUtil: Unrecognizable type: " << type;
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
exit(-1);
}
// Conversions
// Array handlers - we use vector data type and not traditional arrays
// Array to bytes
+char* IoTRMIUtil::arrByteToByteArray(vector<char> arrByte, char* bytes) {
+
+ int pos = 0;
+ for (char chr : arrByte) {
+ char tmpBytes[BYTE_LEN];
+ byteToByteArray(chr, tmpBytes);
+ memcpy(bytes + pos, tmpBytes, BYTE_LEN);
+ pos = pos + BYTE_LEN;
+ }
+
+ return bytes;
+}
+
+
char* IoTRMIUtil::arrShortToByteArray(vector<short> arrShort, char* bytes) {
int pos = 0;
// Bytes to array
+vector<char>* IoTRMIUtil::byteArrayToByteArray(vector<char>* result, char* bytes, int len) {
+
+ // Single element bytes
+ char elmt[BYTE_LEN];
+ // Prepare vector
+ int arrLen = len/BYTE_LEN;
+ for(int i = 0; i < arrLen; i++) {
+ int offset = i * BYTE_LEN;
+ memcpy(elmt, bytes + offset, BYTE_LEN);
+ char res;
+ byteArrayToByte(&res, elmt);
+ result->push_back(res);
+ }
+
+ return result;
+}
+
+
vector<short>* IoTRMIUtil::byteArrayToShortArray(vector<short>* result, char* bytes, int len) {
// Single element bytes
// Conversions
// Primitives to byte array
+char* IoTRMIUtil::byteToByteArray(char c, char* bytes) {
+
+ // Just copy the char into char*
+ bytes[0] = c;
+
+ return bytes;
+}
+
+
char* IoTRMIUtil::shortToByteArray(short s, char* bytes) {
short sInvert = htobe16(s);
}
+char* IoTRMIUtil::byteArrayToByte(char* result, char* bytes) {
+
+ *result = bytes[0];
+ return result;
+}
+
+
char* IoTRMIUtil::byteArrayToChar(char* result, char* bytes) {
*result = bytes[1];