summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Jung2011-07-15 14:31:05 (EDT)
committerThomas Jung2011-07-15 14:31:05 (EDT)
commit65a6b74bfd3e9a88067c2c0a5bb4f0d3639d3196 (patch)
treeab603d55726c2e8a9e21bc0c271938486504d509
parent98968549cc42126d8c9fc6234d8ed1d1a06dbe70 (diff)
downloadorg.eclipse.etrice-65a6b74bfd3e9a88067c2c0a5bb4f0d3639d3196.zip
org.eclipse.etrice-65a6b74bfd3e9a88067c2c0a5bb4f0d3639d3196.tar.gz
org.eclipse.etrice-65a6b74bfd3e9a88067c2c0a5bb4f0d3639d3196.tar.bz2
[generator.java] type system improved. int8 mapped to byte and string
mapped to String.
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/extensions/Extensions.ext7
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/JavaGenerator.java3
2 files changed, 8 insertions, 2 deletions
diff --git a/plugins/org.eclipse.etrice.generator.java/src/extensions/Extensions.ext b/plugins/org.eclipse.etrice.generator.java/src/extensions/Extensions.ext
index 3d912ca..45bcb75 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/extensions/Extensions.ext
+++ b/plugins/org.eclipse.etrice.generator.java/src/extensions/Extensions.ext
@@ -42,22 +42,24 @@ switch(prim.toString()) {
case 'uint8': 'undefined_type'
case 'uint16': 'undefined_type'
case 'uint32': 'undefined_type'
- case 'int8': 'undefined_type'
+ case 'int8': 'byte'
case 'int16': 'short'
case 'int32': 'int'
case 'float32': 'float'
case 'float64': 'double'
+ case 'string' : 'String'
default: prim.toString()};
String toJavaObjectType(PrimitiveType prim):
switch(prim.toString()) {
case 'uint8': 'undefined_type'
case 'uint16': 'undefined_type'
case 'uint32': 'undefined_type'
- case 'int8': 'undefined_type'
+ case 'int8': 'Byte'
case 'int16': 'Short'
case 'int32': 'Integer'
case 'float32': 'Float'
case 'float64': 'Double'
+ case 'string': 'String'
default: prim.toString()};
String typeName(Type type): type.type!=null? type.type.name : type.prim.toJavaType();
String freeTypeName(FreeType type): type.type!=null? type.type : type.prim.toJavaType();
@@ -74,6 +76,7 @@ switch(prim.toString()) {
case 'int32': '0'
case 'float32': '0.0'
case 'float64': '0.0'
+ case 'string': '""'
default: prim.toString()};
String defaultValue(TypedID a): a.type.type!=null? "new "+a.type.type.name+"()" : a.type.prim.defaultValue();
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/JavaGenerator.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/JavaGenerator.java
index db299eb..9c22b55 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/JavaGenerator.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/JavaGenerator.java
@@ -118,6 +118,9 @@ public class JavaGenerator {
case FLOAT32: t = "float"; ct = "Float"; break;
case FLOAT64: t = "double"; ct = "Double"; break;
case INT32: t = "int"; ct = "Integer"; break;
+ case STRING: t="String"; ct="String"; break;
+ case INT8: t="byte"; ct="Byte"; break;
+ case INT16: t="short"; ct="Short"; break;
default: t = "invalid Java data type"; ct = ""; assert(false): "Java doesn't support type "+type.getPrim().name()+"!";
}
}