From: rtrimana Date: Fri, 28 Oct 2016 16:13:01 +0000 (-0700) Subject: Moving IoTRMITypes class into Java directory X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=78611157ec9a51ae53cca4ebac32fbae5882b193;p=iot2.git Moving IoTRMITypes class into Java directory --- diff --git a/iotjava/Makefile b/iotjava/Makefile index 4f53798..4b8c972 100644 --- a/iotjava/Makefile +++ b/iotjava/Makefile @@ -31,18 +31,17 @@ runtime: PHONY += rmi rmi: mkdir -p $(BIN_DIR) - #$(JAVAC) -cp . -d $(BIN_DIR) iotrmi/*.java - #$(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/*.java - #$(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/sample/*.java + $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/*.java + $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/sample/*.java mkdir -p $(BIN_DIR)/iotrmi/C++ #$(G++) iotrmi/C++/IoTSocketServer.cpp -o $(BIN_DIR)/iotrmi/C++/IoTSocketServer.out #$(G++) iotrmi/C++/IoTSocketClient.cpp -o $(BIN_DIR)/iotrmi/C++/IoTSocketClient.out #$(G++) iotrmi/C++/IoTRMICall.cpp -o $(BIN_DIR)/iotrmi/C++/IoTRMICall.out --std=c++11 #$(G++) iotrmi/C++/IoTRMIObject.cpp -o $(BIN_DIR)/iotrmi/C++/IoTRMIObject.out --std=c++11 mkdir -p $(BIN_DIR)/iotrmi/C++/sample - $(G++) iotrmi/C++/sample/TestClass.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass.out --std=c++11 - $(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 - $(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 + #$(G++) iotrmi/C++/sample/TestClass.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass.out --std=c++11 + #$(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 + #$(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 PHONY += run-rmiserver run-rmiserver: diff --git a/iotjava/iotrmi/Java/IoTRMITypes.java b/iotjava/iotrmi/Java/IoTRMITypes.java new file mode 100644 index 0000000..a72c38d --- /dev/null +++ b/iotjava/iotrmi/Java/IoTRMITypes.java @@ -0,0 +1,150 @@ +package iotrmi.Java; + +/** Class IoTRMITypes is a class that provides type translations. + *

+ * It stores C++ and Java types. + * + * @author Rahmadi Trimananda + * @version 1.0 + * @since 2016-10-03 + */ + +import java.util.HashMap; +import java.util.Map; + +public class IoTRMITypes { + + /** + * Primitive data types in Java + */ + public final static String[] primitivesJava = new String[] { + + "byte", // 1 byte + "Byte", // 1 byte + "short", // 2 bytes + "Short", // 2 bytes + "int", // 4 bytes + "Integer", // 4 bytes + "long", // 8 bytes + "Long", // 8 bytes + "float", // 4 bytes + "Float", // 4 bytes + "double", // 8 bytes + "Double", // 8 bytes + "boolean", // 1 bytes + "Boolean", // 1 bytes + "char", // 2 bytes + "Character", // 2 bytes + "string", // indefinite + "String", // indefinite + "void" // 0 byte + }; + + + /** + * Primitive data types in C++ to map the primitives list + */ + public final static String[] primitivesCplus = new String[] { + + "char", // 1 byte + "char", // 1 byte + "short", // 2 bytes + "short", // 2 bytes + "int", // 4 bytes + "int", // 4 bytes + "long", // 4 bytes + "long", // 4 bytes + "float", // 4 bytes + "float", // 4 bytes + "double", // 8 bytes + "double", // 8 bytes + "bool", // 1 byte + "bool", // 1 byte + "char", // 1 byte + "char", // 1 byte + "string", // indefinite + "string", // indefinite + "void" // 0 byte + }; + + + /** + * Primitive sizes in Java - Long is 8 bytes and char is 2 bytes + */ + public final static Integer[] primitivesJavaSizes = new Integer[] { + + 1, 1, 2, 2, 4, 4, 8, 8, 4, 4, 8, 8, 1, 1, 2, 2, -1, -1, 0 + }; + + + /** + * Primitive sizes in Cplus - Long is 4 bytes and char is 1 byte + */ + public final static Integer[] primitivesCplusSizes = new Integer[] { + + 1, 1, 2, 2, 4, 4, 4, 4, 4, 4, 8, 8, 1, 1, 1, 1, -1, -1, 0 + }; + + + /** + * Non-primitive Java data types + */ + public final static String[] nonPrimitivesJava = new String[] { + + "Set", + "HashSet", + "Map", + "HashMap", + "List", + "ArrayList" + }; + + + /** + * Non-primitive C++ data types + */ + public final static String[] nonPrimitivesCplus = new String[] { + + "set", + "unordered_set", + "map", + "unordered_map", + "list", + "list" + }; + + + /**================ + * Helper functions + **================ + */ + // Inserting array members into a Map object + // that maps arrKey to arrVal objects + public static void arraysToMap(Map map, String[] arrKey, String[] arrVal) { + + for(int i = 0; i < arrKey.length; i++) { + + map.put(arrKey[i], arrVal[i]); + } + } + + // Inserting array members into a Map object + // that maps arrKey to arrVal objects + public static void arraysToMap(Map map, String[] arrKey, Integer[] arrVal) { + + for(int i = 0; i < arrKey.length; i++) { + + map.put(arrKey[i], arrVal[i]); + } + } + + // Inserting array members into a Map object + // that maps arrKey to arrVal objects + public static void arraysToMap(Map map, Object[] arrKey, Object[] arrVal) { + + for(int i = 0; i < arrKey.length; i++) { + + map.put(arrKey[i], arrVal[i]); + } + } +} diff --git a/iotjava/iotrmi/Java/IoTRMIUtil.java b/iotjava/iotrmi/Java/IoTRMIUtil.java index 2463c38..7816106 100644 --- a/iotjava/iotrmi/Java/IoTRMIUtil.java +++ b/iotjava/iotrmi/Java/IoTRMIUtil.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import iotrmi.IoTRMITypes; /** Class IoTRMI provides utility services. *