java: remove complex.
MultiPart: 3/5
Change-Id: I720b03e4c53bb8352952d608d35a82136a336fe7
diff --git a/android-lib/build.gradle b/android-lib/build.gradle
index 92a3adc..d76b3dc 100644
--- a/android-lib/build.gradle
+++ b/android-lib/build.gradle
@@ -8,7 +8,7 @@
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
- classpath 'io.v:gradle-plugin:1.4'
+ classpath 'io.v:gradle-plugin:1.6'
}
}
@@ -59,8 +59,11 @@
}
}
+def jiriRoot = VanadiumEnvironment.getVanadiumEnvironment().jiriRoot.getAbsolutePath()
+
vdl {
inputPaths += 'src/main/java'
+ vdlToolPath = 'vdl'
}
public static isDarwin() {
@@ -85,7 +88,6 @@
class VanadiumEnvironment {
File jiriRoot;
- File jiriBin;
public static getVanadiumEnvironment() {
VanadiumEnvironment result = new VanadiumEnvironment()
@@ -97,13 +99,6 @@
}
result.jiriRoot = new File(System.getenv()['JIRI_ROOT'])
- result.jiriBin = new File(result.jiriRoot, ['.jiri_root', 'scripts', 'jiri'].join(File.separator))
- if (!result.jiriBin.exists() || !result.jiriBin.isFile() || !result.jiriBin.canExecute()) {
- throw new InvalidUserDataException(
- result.jiriBin.toString() + " does not exist or is not an executable file. "
- + "Please follow the Vanadium installation instructions at "
- + "https://vanadium.github.io/installation/")
- }
return result
}
}
@@ -124,10 +119,9 @@
// Returns a task that will build the Vanadium native library for the given architecture.
def buildVanadiumLib(VanadiumSupportedArchitecture arch) {
def jiriRoot = VanadiumEnvironment.getVanadiumEnvironment().jiriRoot.getAbsolutePath()
- def jiriBin = VanadiumEnvironment.getVanadiumEnvironment().jiriBin.getAbsolutePath()
def check = task("checkVanadiumAndroidEnvironment-${arch.goArch}", type: Exec) {
- commandLine jiriBin, 'profile', 'list',
+ commandLine 'jiri', 'profile', 'list',
'--info', 'Target.InstallationDir', "--target=${arch.goArch}-android", 'v23:android'
standardOutput = new ByteArrayOutputStream()
doLast {
@@ -150,7 +144,7 @@
// safe here.)
environment "GOOS", "android"
environment "GOARCH", "${arch.goArch}"
- commandLine jiriBin, 'go', "--target=${arch.goArch}-android", 'install',
+ commandLine 'jiri', 'go', "--target=${arch.goArch}-android", 'install',
'-buildmode=c-shared', '-v', '-tags', 'android',
'-installsuffix=shared', 'v.io/x/jni/main'
}
diff --git a/gradle-plugin/build.gradle b/gradle-plugin/build.gradle
index 4f1cbe9..8bea40a 100644
--- a/gradle-plugin/build.gradle
+++ b/gradle-plugin/build.gradle
@@ -1,6 +1,6 @@
// You should change this after releasing a new version of the gradle plugin. See the
// list of published versions at https://repo1.maven.org/maven2/io/v/gradle-plugin.
-def releaseVersion = '1.5'
+def releaseVersion = '1.7'
buildscript {
repositories {
diff --git a/gradle-plugin/src/main/groovy/io/v/vdl/vdl.groovy b/gradle-plugin/src/main/groovy/io/v/vdl/vdl.groovy
index c90bf1e..aba3c56 100644
--- a/gradle-plugin/src/main/groovy/io/v/vdl/vdl.groovy
+++ b/gradle-plugin/src/main/groovy/io/v/vdl/vdl.groovy
@@ -42,10 +42,10 @@
generateTask.environment(VDLROOT: getVdlRootPath(project))
generateTask.environment(VDLPATH: vdlPaths.join(":"))
- String vdlToolPath = 'build/vdltool/vdl-' + getOsName()
- if (project.vdl.vdlToolPath != "") {
- vdlToolPath = project.vdl.vdlToolPath
- }
+ String vdlToolPath = 'build/vdltool/vdl-' + getOsName()
+ if (project.vdl.vdlToolPath != "") {
+ vdlToolPath = project.vdl.vdlToolPath
+ }
List<String> commandLine = [vdlToolPath,
'generate',
'--lang=java',
diff --git a/lib/build.gradle b/lib/build.gradle
index f79bd35..00250ea 100644
--- a/lib/build.gradle
+++ b/lib/build.gradle
@@ -7,7 +7,7 @@
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
- classpath 'io.v:gradle-plugin:1.4'
+ classpath 'io.v:gradle-plugin:1.6'
}
}
@@ -78,13 +78,11 @@
}
def jiriRoot = VanadiumEnvironment.getVanadiumEnvironment().jiriRoot.getAbsolutePath()
-def jiriBin = VanadiumEnvironment.getVanadiumEnvironment().jiriBin.getAbsolutePath()
sourceSets.main.java.srcDirs += 'generated-src/vdl'
class VanadiumEnvironment {
File jiriRoot;
- File jiriBin;
public static getVanadiumEnvironment() {
VanadiumEnvironment result = new VanadiumEnvironment()
@@ -96,13 +94,6 @@
}
result.jiriRoot = new File(System.getenv()['JIRI_ROOT'])
- result.jiriBin = new File(result.jiriRoot, ['.jiri_root', 'scripts', 'jiri'].join(File.separator))
- if (!result.jiriBin.exists() || !result.jiriBin.isFile() || !result.jiriBin.canExecute()) {
- throw new InvalidUserDataException(
- result.jiriBin.toString() + " does not exist or is not an executable file. "
- + "Please follow the Vanadium installation instructions at "
- + "https://vanadium.github.io/installation/")
- }
return result
}
}
@@ -134,7 +125,7 @@
// NOTE(spetrovic): we add the '-installsuffix=shared' flag because the build doesn't work
// without it on linux/arm. (There is some conflict with "regular", i.e., non-shared builds).
- commandLine jiriBin, 'go', '--profiles=v23:java', 'install', '-buildmode=c-shared', '-v',
+ commandLine 'jiri', 'go', '--profiles=v23:java', 'install', '-buildmode=c-shared', '-v',
'-tags', 'java', '-installsuffix=shared', 'v.io/x/jni/main'
}
@@ -333,7 +324,7 @@
inputPaths += [jiriRoot, 'release', 'go', 'src'].join(File.separator)
vdlRootPath = [jiriRoot, 'release', 'go', 'src', 'v.io', 'v23', 'vdlroot'].join(File.separator)
generateVdlRoot = true
- vdlToolPath = [jiriRoot, 'release', 'go', 'bin', 'vdl'].join(File.separator)
+ vdlToolPath = 'vdl'
}
bintray {
diff --git a/lib/src/main/java/io/v/v23/vdl/Kind.java b/lib/src/main/java/io/v/v23/vdl/Kind.java
index 66130f9..5d69118 100644
--- a/lib/src/main/java/io/v/v23/vdl/Kind.java
+++ b/lib/src/main/java/io/v/v23/vdl/Kind.java
@@ -19,8 +19,6 @@
INT64,
FLOAT32,
FLOAT64,
- COMPLEX64,
- COMPLEX128,
STRING,
ENUM,
TYPEOBJECT,
diff --git a/lib/src/main/java/io/v/v23/vdl/Types.java b/lib/src/main/java/io/v/v23/vdl/Types.java
index 10d6c1d..6215464 100644
--- a/lib/src/main/java/io/v/v23/vdl/Types.java
+++ b/lib/src/main/java/io/v/v23/vdl/Types.java
@@ -101,16 +101,6 @@
public static final VdlType FLOAT64 = createPrimitiveType(Kind.FLOAT64);
/**
- * The {@code VdlType} object representing the VDL type complex64, it is unnamed.
- */
- public static final VdlType COMPLEX64 = createPrimitiveType(Kind.COMPLEX64);
-
- /**
- * The {@code VdlType} object representing the VDL type complex128, it is unnamed.
- */
- public static final VdlType COMPLEX128 = createPrimitiveType(Kind.COMPLEX128);
-
- /**
* The {@code VdlType} object representing the VDL type string, it is unnamed.
*/
public static final VdlType STRING = createPrimitiveType(Kind.STRING);
@@ -138,8 +128,6 @@
typeCache.put(VdlInt64.class, INT64);
typeCache.put(VdlFloat32.class, FLOAT32);
typeCache.put(VdlFloat64.class, FLOAT64);
- typeCache.put(VdlComplex64.class, COMPLEX64);
- typeCache.put(VdlComplex128.class, COMPLEX128);
typeCache.put(VdlString.class, STRING);
typeCache.put(VdlTypeObject.class, TYPEOBJECT);
@@ -214,10 +202,6 @@
return FLOAT32;
case FLOAT64:
return FLOAT64;
- case COMPLEX64:
- return COMPLEX64;
- case COMPLEX128:
- return COMPLEX128;
case STRING:
return STRING;
case TYPEOBJECT:
@@ -384,10 +368,6 @@
return Boolean.class;
case BYTE:
return Byte.class;
- case COMPLEX128:
- return VdlComplex128.class;
- case COMPLEX64:
- return VdlComplex64.class;
case FLOAT32:
return Float.class;
case FLOAT64:
diff --git a/lib/src/main/java/io/v/v23/vdl/VdlComplex128.java b/lib/src/main/java/io/v/v23/vdl/VdlComplex128.java
deleted file mode 100644
index 0140d06..0000000
--- a/lib/src/main/java/io/v/v23/vdl/VdlComplex128.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package io.v.v23.vdl;
-
-/**
- * VdlComplex128 is a representation of a VDL complex128.
- */
-public class VdlComplex128 extends VdlValue {
- private static final long serialVersionUID = 1L;
-
- private final double real;
- private final double imag;
-
- public VdlComplex128(VdlType type, double real, double imag) {
- super(type);
- assertKind(Kind.COMPLEX128);
- this.real = real;
- this.imag = imag;
- }
-
- public VdlComplex128(double real, double imag) {
- this(Types.COMPLEX128, real, imag);
- }
-
- public VdlComplex128(double real) {
- this(real, 0);
- }
-
- public VdlComplex128() {
- this(0, 0);
- }
-
- public double getReal() {
- return real;
- }
-
- public double getImag() {
- return imag;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (!(obj instanceof VdlComplex128)) return false;
- VdlComplex128 other = (VdlComplex128) obj;
- return real == other.real && imag == other.imag;
- }
-
- @Override
- public int hashCode() {
- return Double.valueOf(real).hashCode() ^ Double.valueOf(imag).hashCode();
- }
-
- @Override
- public String toString() {
- return "{real=" + Double.toString(real) + ", imag=" + Double.toString(imag) + "}";
- }
-}
diff --git a/lib/src/main/java/io/v/v23/vdl/VdlComplex64.java b/lib/src/main/java/io/v/v23/vdl/VdlComplex64.java
deleted file mode 100644
index 1766ab4..0000000
--- a/lib/src/main/java/io/v/v23/vdl/VdlComplex64.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package io.v.v23.vdl;
-
-/**
- * VdlComplex64 is a representation of a VDL complex64.
- */
-public class VdlComplex64 extends VdlValue {
- private static final long serialVersionUID = 1L;
-
- private final float real;
- private final float imag;
-
- public VdlComplex64(VdlType type, float real, float imag) {
- super(type);
- assertKind(Kind.COMPLEX64);
- this.real = real;
- this.imag = imag;
- }
-
- public VdlComplex64(float real, float imag) {
- this(Types.COMPLEX64, real, imag);
- }
-
- public VdlComplex64(float real) {
- this(real, 0);
- }
-
- public VdlComplex64() {
- this(0, 0);
- }
-
- public float getReal() {
- return real;
- }
-
- public float getImag() {
- return imag;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (!(obj instanceof VdlComplex64)) return false;
- VdlComplex64 other = (VdlComplex64) obj;
- return real == other.real && imag == other.imag;
- }
-
- @Override
- public int hashCode() {
- return Float.valueOf(real).hashCode() ^ Float.valueOf(imag).hashCode();
- }
-
- @Override
- public String toString() {
- return "{real=" + Float.toString(real) + ", imag=" + Float.toString(imag) + "}";
- }
-}
diff --git a/lib/src/main/java/io/v/v23/vdl/VdlValue.java b/lib/src/main/java/io/v/v23/vdl/VdlValue.java
index b123df0..de6a453 100644
--- a/lib/src/main/java/io/v/v23/vdl/VdlValue.java
+++ b/lib/src/main/java/io/v/v23/vdl/VdlValue.java
@@ -111,10 +111,6 @@
return new VdlBool();
case BYTE:
return new VdlByte();
- case COMPLEX128:
- return new VdlComplex128(0);
- case COMPLEX64:
- return new VdlComplex64(0);
case ENUM:
return new VdlEnum(type, type.getLabels().get(0));
case FLOAT32:
diff --git a/lib/src/main/java/io/v/v23/vom/BinaryDecoder.java b/lib/src/main/java/io/v/v23/vom/BinaryDecoder.java
index b4c011d..e9323a0 100644
--- a/lib/src/main/java/io/v/v23/vom/BinaryDecoder.java
+++ b/lib/src/main/java/io/v/v23/vom/BinaryDecoder.java
@@ -217,9 +217,6 @@
return readVdlBool(target);
case BYTE:
return readVdlByte(target);
- case COMPLEX64:
- case COMPLEX128:
- return readVdlComplex(target);
case ENUM:
return readVdlEnum(actualType, target);
case FLOAT32:
@@ -375,11 +372,6 @@
return ConvertUtil.convertFromByte(b, target);
}
- private Object readVdlComplex(ConversionTarget target) throws IOException, ConversionException {
- return ConvertUtil.convertFromComplex(BinaryUtil.decodeDouble(in),
- BinaryUtil.decodeDouble(in), target);
- }
-
private Object readVdlEnum(VdlType actualType, ConversionTarget target) throws IOException,
ConversionException {
int enumIndex = (int) BinaryUtil.decodeUint(in);
diff --git a/lib/src/main/java/io/v/v23/vom/BinaryEncoder.java b/lib/src/main/java/io/v/v23/vom/BinaryEncoder.java
index 4296d00..3182060 100644
--- a/lib/src/main/java/io/v/v23/vom/BinaryEncoder.java
+++ b/lib/src/main/java/io/v/v23/vom/BinaryEncoder.java
@@ -11,8 +11,6 @@
import io.v.v23.vdl.VdlArray;
import io.v.v23.vdl.VdlBool;
import io.v.v23.vdl.VdlByte;
-import io.v.v23.vdl.VdlComplex128;
-import io.v.v23.vdl.VdlComplex64;
import io.v.v23.vdl.VdlEnum;
import io.v.v23.vdl.VdlField;
import io.v.v23.vdl.VdlFloat32;
@@ -192,8 +190,6 @@
case INT64:
case FLOAT32:
case FLOAT64:
- case COMPLEX64:
- case COMPLEX128:
case STRING:
return new WireType.NamedT(new WireNamed(
type.getName(), getTypeInternal(Types.primitiveTypeFromKind(type.getKind()), pending)));
@@ -286,9 +282,6 @@
}
case BOOL:
return writeVdlBool(out, value);
- case COMPLEX64:
- case COMPLEX128:
- return writeVdlComplex(out, value);
case ENUM:
return writeVdlEnum(out, value);
case FLOAT32:
@@ -464,24 +457,6 @@
}
/**
- * Writes a VDL complex to output stream and returns true iff the value is non-zero.
- */
- private boolean writeVdlComplex(EncodingStream out, Object value) throws IOException {
- if (value instanceof VdlComplex64) {
- boolean isNonZero = BinaryUtil.encodeDouble(out, ((VdlComplex64) value).getReal());
- isNonZero |= BinaryUtil.encodeDouble(out, ((VdlComplex64) value).getImag());
- return isNonZero;
- } else if (value instanceof VdlComplex128) {
- boolean isNonZero = BinaryUtil.encodeDouble(out, ((VdlComplex128) value).getReal());
- isNonZero |= BinaryUtil.encodeDouble(out, ((VdlComplex128) value).getImag());
- return isNonZero;
- } else {
- throw new IOException("Unsupported VDL complex value (type " + value.getClass()
- + ", value " + value + ")");
- }
- }
-
- /**
* Writes a VDL enum to output stream and returns true iff the value is non-zero.
*/
private boolean writeVdlEnum(EncodingStream out, Object value) throws IOException {
diff --git a/lib/src/main/java/io/v/v23/vom/BinaryUtil.java b/lib/src/main/java/io/v/v23/vom/BinaryUtil.java
index cb8fa43..7fcfdd4 100644
--- a/lib/src/main/java/io/v/v23/vom/BinaryUtil.java
+++ b/lib/src/main/java/io/v/v23/vom/BinaryUtil.java
@@ -158,8 +158,6 @@
switch (type.getKind()) {
case ANY:
case ARRAY:
- case COMPLEX64:
- case COMPLEX128:
case LIST:
case MAP:
case OPTIONAL:
diff --git a/lib/src/main/java/io/v/v23/vom/BootstrapType.java b/lib/src/main/java/io/v/v23/vom/BootstrapType.java
index 9c81e97..c044561 100644
--- a/lib/src/main/java/io/v/v23/vom/BootstrapType.java
+++ b/lib/src/main/java/io/v/v23/vom/BootstrapType.java
@@ -34,8 +34,6 @@
.put(Types.INT64, Constants.WIRE_ID_INT_64)
.put(Types.FLOAT32, Constants.WIRE_ID_FLOAT_32)
.put(Types.FLOAT64, Constants.WIRE_ID_FLOAT_64)
- .put(Types.COMPLEX64, Constants.WIRE_ID_COMPLEX_64)
- .put(Types.COMPLEX128, Constants.WIRE_ID_COMPLEX_128)
.put(Types.TYPEOBJECT, Constants.WIRE_ID_TYPE_OBJECT)
.put(Types.ANY, Constants.WIRE_ID_ANY)
diff --git a/lib/src/main/java/io/v/v23/vom/ConversionTarget.java b/lib/src/main/java/io/v/v23/vom/ConversionTarget.java
index 8c552cf..a8602ad 100644
--- a/lib/src/main/java/io/v/v23/vom/ConversionTarget.java
+++ b/lib/src/main/java/io/v/v23/vom/ConversionTarget.java
@@ -11,8 +11,6 @@
import io.v.v23.vdl.VdlArray;
import io.v.v23.vdl.VdlBool;
import io.v.v23.vdl.VdlByte;
-import io.v.v23.vdl.VdlComplex128;
-import io.v.v23.vdl.VdlComplex64;
import io.v.v23.vdl.VdlEnum;
import io.v.v23.vdl.VdlFloat32;
import io.v.v23.vdl.VdlFloat64;
@@ -50,8 +48,6 @@
case ARRAY: return new TypeToken<VdlArray<VdlValue>>(){}.getType();
case BOOL: return VdlBool.class;
case BYTE: return VdlByte.class;
- case COMPLEX128: return VdlComplex128.class;
- case COMPLEX64: return VdlComplex64.class;
case ENUM: return VdlEnum.class;
case FLOAT32: return VdlFloat32.class;
case FLOAT64: return VdlFloat64.class;
diff --git a/lib/src/main/java/io/v/v23/vom/ConvertUtil.java b/lib/src/main/java/io/v/v23/vom/ConvertUtil.java
index 166d35c..7d58008 100644
--- a/lib/src/main/java/io/v/v23/vom/ConvertUtil.java
+++ b/lib/src/main/java/io/v/v23/vom/ConvertUtil.java
@@ -101,7 +101,7 @@
}
/**
- * Converts uint values to uint, int, float or complex values only.
+ * Converts uint values to uint, int or float values only.
* This is used to check O(n) conversion rules instead of O(n^2) for n numeric types.
*/
private static Object convertUint(long value, ConversionTarget target)
@@ -133,7 +133,7 @@
}
/**
- * Converts int values to int, float or complex values only.
+ * Converts int values to int or float values only.
* This is used to check O(n) conversion rules instead of O(n^2) for n numeric types.
*/
private static Object convertInt(long value, ConversionTarget target)
@@ -157,7 +157,6 @@
case INT64:
return ReflectUtil.createPrimitive(target, value, Long.TYPE);
case FLOAT32:
- case COMPLEX64:
if (ConvertUtil.canConvertIntToFloat(value, 32)) {
return convertDouble(value, target);
}
@@ -171,7 +170,7 @@
}
/**
- * Converts float values to float or complex values only.
+ * Converts float values to float values only.
* This is used to check O(n) conversion rules instead of O(n^2) for n numeric types.
*/
private static Object convertDouble(double value, ConversionTarget target)
@@ -181,36 +180,26 @@
return ReflectUtil.createPrimitive(target, (float) value, Float.TYPE);
case FLOAT64:
return ReflectUtil.createPrimitive(target, value, Double.TYPE);
- default:
- return convertComplex(value, 0, target);
}
+ throw new ConversionException("Can't convert " + value + " to " + target.getTargetType());
}
/**
- * Converts complex values to complex values only.
- * This is used to check O(n) conversion rules instead of O(n^2) for n numeric types.
- */
- private static Object convertComplex(double real, double imag, ConversionTarget target)
- throws ConversionException {
- return ReflectUtil.createComplex(target, real, imag);
- }
-
- /**
- * Converts from uint to number, one of uint, int, float or complex.
+ * Converts from uint to number, one of uint, int or float.
*/
static Object convertFromUint(long value, ConversionTarget target) throws ConversionException {
return convertUint(value, target);
}
/**
- * Converts from byte to number, one of uint, int, float or complex.
+ * Converts from byte to number, one of uint, int or float.
*/
static Object convertFromByte(byte value, ConversionTarget target) throws ConversionException {
return convertUint(value & 0xffL, target);
}
/**
- * Converts from int to number, one of uint, int, float or complex.
+ * Converts from int to number, one of uint, int or float.
*/
static Object convertFromInt(long value, ConversionTarget target) throws ConversionException {
if (canConvertIntToUint(value, 64)) {
@@ -221,7 +210,7 @@
}
/**
- * Converts from float to number, one of uint, int, float or complex.
+ * Converts from float to number, one of uint, int or float.
*/
static Object convertFromDouble(double value, ConversionTarget target)
throws ConversionException {
@@ -233,8 +222,6 @@
break;
case FLOAT32:
case FLOAT64:
- case COMPLEX128:
- case COMPLEX64:
break;
default:
if (canConvertFloatToInt(value, 64)) {
@@ -245,18 +232,6 @@
}
/**
- * Converts from complex to number, one of uint, int, float or complex.
- */
- static Object convertFromComplex(double real, double imag, ConversionTarget target)
- throws ConversionException {
- if (imag == 0) {
- return convertFromDouble(real, target);
- } else {
- return convertComplex(real, imag, target);
- }
- }
-
- /**
* Converts from []byte to []number, [N]number, string or enum.
*/
static Object convertFromBytes(byte[] bytes, ConversionTarget target)
diff --git a/lib/src/main/java/io/v/v23/vom/ReflectUtil.java b/lib/src/main/java/io/v/v23/vom/ReflectUtil.java
index fcbd55d..92771d8 100644
--- a/lib/src/main/java/io/v/v23/vom/ReflectUtil.java
+++ b/lib/src/main/java/io/v/v23/vom/ReflectUtil.java
@@ -5,8 +5,6 @@
package io.v.v23.vom;
import io.v.v23.vdl.VdlArray;
-import io.v.v23.vdl.VdlComplex128;
-import io.v.v23.vdl.VdlComplex64;
import io.v.v23.vdl.VdlEnum;
import io.v.v23.vdl.VdlList;
import io.v.v23.vdl.VdlMap;
@@ -57,32 +55,6 @@
}
/**
- * Creates an instance of VDL complex. The target class should be inherited from
- * {@code VdlValue}.
- */
- static VdlValue createComplex(ConversionTarget target, double real, double imag)
- throws ConversionException {
- Class<?> targetClass = target.getTargetClass();
- try {
- if (targetClass == VdlComplex64.class) {
- return new VdlComplex64(target.getVdlType(), (float) real, (float) imag);
- } else if (targetClass == VdlComplex128.class) {
- return new VdlComplex128(target.getVdlType(), real, imag);
- } else if (VdlComplex64.class.isAssignableFrom(targetClass)) {
- return (VdlValue) targetClass.getConstructor(Float.TYPE, Float.TYPE)
- .newInstance((float) real, (float) imag);
- } else if (VdlComplex128.class.isAssignableFrom(targetClass)) {
- return (VdlValue) targetClass.getConstructor(Double.TYPE, Double.TYPE)
- .newInstance(real, imag);
- }
- } catch (Exception e) {
- throw new ConversionException(
- new VdlComplex128(real, imag), targetClass, e);
- }
- throw new ConversionException(new VdlComplex128(real, imag), targetClass);
- }
-
- /**
* Creates an instance of VDL enum. The target class should be inherited from {@code VdlEnum}.
*/
static VdlEnum createEnum(ConversionTarget target, String label) throws ConversionException {
diff --git a/lib/src/main/java/io/v/v23/vom/TypeCompatibility.java b/lib/src/main/java/io/v/v23/vom/TypeCompatibility.java
index 96de1e6..4257deb 100644
--- a/lib/src/main/java/io/v/v23/vom/TypeCompatibility.java
+++ b/lib/src/main/java/io/v/v23/vom/TypeCompatibility.java
@@ -139,8 +139,6 @@
private static boolean isNumber(VdlType type) {
switch (type.getKind()) {
case BYTE:
- case COMPLEX128:
- case COMPLEX64:
case FLOAT32:
case FLOAT64:
case INT16:
diff --git a/lib/src/test/java/io/v/v23/vdl/TypeTest.java b/lib/src/test/java/io/v/v23/vdl/TypeTest.java
index efe0169..02161b5 100644
--- a/lib/src/test/java/io/v/v23/vdl/TypeTest.java
+++ b/lib/src/test/java/io/v/v23/vdl/TypeTest.java
@@ -66,14 +66,6 @@
private static final class MyString extends VdlString {
private static final long serialVersionUID = 1L;
}
- @GeneratedFromVdl(name = "MyComplex64")
- private static final class MyComplex64 extends VdlComplex64 {
- private static final long serialVersionUID = 1L;
- }
- @GeneratedFromVdl(name = "MyComplex128")
- private static final class MyComplex128 extends VdlComplex128 {
- private static final long serialVersionUID = 1L;
- }
@SuppressWarnings("unused")
@GeneratedFromVdl(name = "MyUnion")
@@ -178,8 +170,6 @@
VdlType myFloat32 = Types.named("MyFloat32", Types.FLOAT32);
VdlType myFloat64 = Types.named("MyFloat64", Types.FLOAT64);
VdlType myString = Types.named("MyString", Types.STRING);
- VdlType myComplex64 = Types.named("MyComplex64", Types.COMPLEX64);
- VdlType myComplex128 = Types.named("MyComplex128", Types.COMPLEX128);
VdlType myUnion = Types.named("MyUnion", Types.unionOf(new VdlField("A", myInt16),
new VdlField("B", Types.INT32), new VdlField("C", Types.INT64)));
@@ -210,8 +200,6 @@
.put(myFloat32, MyFloat32.class)
.put(myFloat64, MyFloat64.class)
.put(myString, MyString.class)
- .put(myComplex64, MyComplex64.class)
- .put(myComplex128, MyComplex128.class)
.put(myUnion, MyUnion.class)
.put(myEnum, MyEnum.class)
.put(myArray12, MyArray12.class)
diff --git a/lib/src/test/java/io/v/v23/vom/BinaryEncoderTest.java b/lib/src/test/java/io/v/v23/vom/BinaryEncoderTest.java
index 002b3ef..9abb3a4 100644
--- a/lib/src/test/java/io/v/v23/vom/BinaryEncoderTest.java
+++ b/lib/src/test/java/io/v/v23/vom/BinaryEncoderTest.java
@@ -13,8 +13,6 @@
import io.v.v23.vdl.Types;
import io.v.v23.vdl.VdlAny;
import io.v.v23.vdl.VdlArray;
-import io.v.v23.vdl.VdlComplex128;
-import io.v.v23.vdl.VdlComplex64;
import io.v.v23.vdl.VdlEnum;
import io.v.v23.vdl.VdlField;
import io.v.v23.vdl.VdlOptional;
@@ -37,8 +35,6 @@
new VdlArray<Integer>(Types.arrayOf(4, Types.INT32), new Integer[]{0, 0, 0, 0}))
.put(Types.BOOL, false)
.put(Types.BYTE, (byte) 0)
- .put(Types.COMPLEX128, new VdlComplex128(0, 0))
- .put(Types.COMPLEX64, new VdlComplex64(0, 0))
.put(Types.enumOf("A", "B", "C"), new VdlEnum(Types.enumOf("A", "B", "C"), "A"))
.put(Types.FLOAT32, 0f)
.put(Types.FLOAT64, 0.)
diff --git a/lib/src/test/java/io/v/v23/vom/ConvertUtilTest.java b/lib/src/test/java/io/v/v23/vom/ConvertUtilTest.java
index 253fed8..15b07a5 100644
--- a/lib/src/test/java/io/v/v23/vom/ConvertUtilTest.java
+++ b/lib/src/test/java/io/v/v23/vom/ConvertUtilTest.java
@@ -10,8 +10,6 @@
import io.v.v23.vdl.Types;
import io.v.v23.vdl.VdlByte;
-import io.v.v23.vdl.VdlComplex128;
-import io.v.v23.vdl.VdlComplex64;
import io.v.v23.vdl.VdlFloat32;
import io.v.v23.vdl.VdlFloat64;
import io.v.v23.vdl.VdlInt16;
@@ -24,8 +22,6 @@
import io.v.v23.vdl.VdlUint64;
import io.v.v23.vom.testdata.types.NArray2Uint64;
import io.v.v23.vom.testdata.types.NByte;
-import io.v.v23.vom.testdata.types.NComplex128;
-import io.v.v23.vom.testdata.types.NComplex64;
import io.v.v23.vom.testdata.types.NEnum;
import io.v.v23.vom.testdata.types.NFloat32;
import io.v.v23.vom.testdata.types.NFloat64;
@@ -77,85 +73,74 @@
{Long.TYPE, Long.class, VdlInt64.class, NInt64.class},
{Float.TYPE, Float.class, VdlFloat32.class, NFloat32.class},
{Double.TYPE, Double.class, VdlFloat64.class, NFloat64.class},
- {NComplex64.class, VdlComplex64.class},
- {NComplex128.class, VdlComplex128.class}
};
private static final NumericConversionTestCase[] numericTests = {
+ // TODO(bprosnitz) This test is really cryptic - it should probably use a list or set of types instead.
// bytes
- new NumericConversionTestCase((byte) 0, "11111111111"),
- new NumericConversionTestCase((byte) 0xf, "11111111111"),
- new NumericConversionTestCase((byte) 0xff, "11111111111"),
+ new NumericConversionTestCase((byte) 0, "111111111"),
+ new NumericConversionTestCase((byte) 0xf, "111111111"),
+ new NumericConversionTestCase((byte) 0xff, "111111111"),
// uints
- new NumericConversionTestCase(new VdlUint64(0L), "11111111111"),
- new NumericConversionTestCase(new VdlUint64(0xfL), "11111111111"),
- new NumericConversionTestCase(new VdlUint64(0xffL), "11111111111"),
- new NumericConversionTestCase(new VdlUint64(0xfffL), "01111111111"),
- new NumericConversionTestCase(new VdlUint64(0x7ffL), "01111111111"),
- new NumericConversionTestCase(new VdlUint64(0xffffL), "01110111111"),
- new NumericConversionTestCase(new VdlUint64(0xffffffL), "00110111111"),
- new NumericConversionTestCase(new VdlUint64(0x1000000L), "00110111111"),
- new NumericConversionTestCase(new VdlUint64(0x1000001L), "00110110101"),
- new NumericConversionTestCase(new VdlUint64(0x7fffffffL), "00110110101"),
- new NumericConversionTestCase(new VdlUint64(0xffffffffL), "00110010101"),
- new NumericConversionTestCase(new VdlUint64(0xffffffffffffL), "00010010101"),
- new NumericConversionTestCase(new VdlUint64(0x20000000000000L), "00010010101"),
- new NumericConversionTestCase(new VdlUint64(0x20000000000001L), "00010010000"),
- new NumericConversionTestCase(new VdlUint64(0x7fffffffffffffffL), "00010010000"),
- new NumericConversionTestCase(new VdlUint64(0xffffffffffffffffL), "00010000000"),
+ new NumericConversionTestCase(new VdlUint64(0L), "111111111"),
+ new NumericConversionTestCase(new VdlUint64(0xfL), "111111111"),
+ new NumericConversionTestCase(new VdlUint64(0xffL), "111111111"),
+ new NumericConversionTestCase(new VdlUint64(0xfffL), "011111111"),
+ new NumericConversionTestCase(new VdlUint64(0x7ffL), "011111111"),
+ new NumericConversionTestCase(new VdlUint64(0xffffL), "011101111"),
+ new NumericConversionTestCase(new VdlUint64(0xffffffL), "001101111"),
+ new NumericConversionTestCase(new VdlUint64(0x1000000L), "001101111"),
+ new NumericConversionTestCase(new VdlUint64(0x1000001L), "001101101"),
+ new NumericConversionTestCase(new VdlUint64(0x7fffffffL), "001101101"),
+ new NumericConversionTestCase(new VdlUint64(0xffffffffL), "001100101"),
+ new NumericConversionTestCase(new VdlUint64(0xffffffffffffL), "000100101"),
+ new NumericConversionTestCase(new VdlUint64(0x20000000000000L), "000100101"),
+ new NumericConversionTestCase(new VdlUint64(0x20000000000001L), "000100100"),
+ new NumericConversionTestCase(new VdlUint64(0x7fffffffffffffffL), "000100100"),
+ new NumericConversionTestCase(new VdlUint64(0xffffffffffffffffL), "000100000"),
// positive ints
- new NumericConversionTestCase(0L, "11111111111"),
- new NumericConversionTestCase(0xfL, "11111111111"),
- new NumericConversionTestCase(0xffL, "11111111111"),
- new NumericConversionTestCase(0xfffL, "01111111111"),
- new NumericConversionTestCase(0x7ffL, "01111111111"),
- new NumericConversionTestCase(0xffffL, "01110111111"),
- new NumericConversionTestCase(0xffffffL, "00110111111"),
- new NumericConversionTestCase(0x1000000L, "00110111111"),
- new NumericConversionTestCase(0x1000001L, "00110110101"),
- new NumericConversionTestCase(0x7fffffffL, "00110110101"),
- new NumericConversionTestCase(0xffffffffL, "00110010101"),
- new NumericConversionTestCase(0xffffffffffffL, "00010010101"),
- new NumericConversionTestCase(0x20000000000000L, "00010010101"),
- new NumericConversionTestCase(0x7fffffffffffffffL, "00010010000"),
+ new NumericConversionTestCase(0L, "111111111"),
+ new NumericConversionTestCase(0xfL, "111111111"),
+ new NumericConversionTestCase(0xffL, "111111111"),
+ new NumericConversionTestCase(0xfffL, "011111111"),
+ new NumericConversionTestCase(0x7ffL, "011111111"),
+ new NumericConversionTestCase(0xffffL, "011101111"),
+ new NumericConversionTestCase(0xffffffL, "001101111"),
+ new NumericConversionTestCase(0x1000000L, "001101111"),
+ new NumericConversionTestCase(0x1000001L, "001101101"),
+ new NumericConversionTestCase(0x7fffffffL, "001101101"),
+ new NumericConversionTestCase(0xffffffffL, "001100101"),
+ new NumericConversionTestCase(0xffffffffffffL, "000100101"),
+ new NumericConversionTestCase(0x20000000000000L, "000100101"),
+ new NumericConversionTestCase(0x7fffffffffffffffL, "000100100"),
// negative ints
- new NumericConversionTestCase(-1L, "00001111111"),
- new NumericConversionTestCase(-0x10L, "00001111111"),
- new NumericConversionTestCase(-0x80L, "00001111111"),
- new NumericConversionTestCase(-0x800L, "00001111111"),
- new NumericConversionTestCase(-0x8000L, "00001111111"),
- new NumericConversionTestCase(-0x800000L, "00000111111"),
- new NumericConversionTestCase(-0x80000000L, "00000110101"),
- new NumericConversionTestCase(-0x800000000000L, "00000010101"),
- new NumericConversionTestCase(-0x20000000000000L, "00000010101"),
- new NumericConversionTestCase(-0x8000000000000000L, "00000010000"),
+ new NumericConversionTestCase(-1L, "000011111"),
+ new NumericConversionTestCase(-0x10L, "000011111"),
+ new NumericConversionTestCase(-0x80L, "000011111"),
+ new NumericConversionTestCase(-0x800L, "000011111"),
+ new NumericConversionTestCase(-0x8000L, "000011111"),
+ new NumericConversionTestCase(-0x800000L, "000001111"),
+ new NumericConversionTestCase(-0x80000000L, "000001101"),
+ new NumericConversionTestCase(-0x800000000000L, "000000101"),
+ new NumericConversionTestCase(-0x20000000000000L, "000000101"),
+ new NumericConversionTestCase(-0x8000000000000000L, "000000100"),
// positive floats
- new NumericConversionTestCase(1e0f, "11111111111"),
- new NumericConversionTestCase(1e2f, "11111111111"),
- new NumericConversionTestCase(1e4f, "01111111111"),
- new NumericConversionTestCase(1e8f, "00110111111"),
- new NumericConversionTestCase(1e16f, "00010011111"),
- new NumericConversionTestCase(1e19f, "00010001111"),
- new NumericConversionTestCase(1e20f, "00000001111"),
- new NumericConversionTestCase(1.1e0f, "00000001111"),
+ new NumericConversionTestCase(1e0f, "111111111"),
+ new NumericConversionTestCase(1e2f, "111111111"),
+ new NumericConversionTestCase(1e4f, "011111111"),
+ new NumericConversionTestCase(1e8f, "001101111"),
+ new NumericConversionTestCase(1e16f, "000100111"),
+ new NumericConversionTestCase(1e19f, "000100011"),
+ new NumericConversionTestCase(1e20f, "000000011"),
+ new NumericConversionTestCase(1.1e0f, "000000011"),
// negative doubles
- new NumericConversionTestCase(-1e0f, "00001111111"),
- new NumericConversionTestCase(-1e2f, "00001111111"),
- new NumericConversionTestCase(-1e4f, "00001111111"),
- new NumericConversionTestCase(-1e8f, "00000111111"),
- new NumericConversionTestCase(-1e16f, "00000011111"),
- new NumericConversionTestCase(-1e20f, "00000001111"),
- new NumericConversionTestCase(-1.1e0f, "00000001111"),
- // complex values
- new NumericConversionTestCase(new VdlComplex128(0f), "11111111111"),
- new NumericConversionTestCase(new VdlComplex128(1e8f), "00110111111"),
- new NumericConversionTestCase(new VdlComplex128(1e20f), "00000001111"),
- new NumericConversionTestCase(new VdlComplex128(1.1e0f), "00000001111"),
- new NumericConversionTestCase(new VdlComplex128(-1f), "00001111111"),
- new NumericConversionTestCase(new VdlComplex128(-1e8f), "00000111111"),
- new NumericConversionTestCase(new VdlComplex128(-1e20f), "00000001111"),
- new NumericConversionTestCase(new VdlComplex128(-1.1e0f), "00000001111"),
- new NumericConversionTestCase(new VdlComplex128(0f, 1f), "00000000011"),
+ new NumericConversionTestCase(-1e0f, "000011111"),
+ new NumericConversionTestCase(-1e2f, "000011111"),
+ new NumericConversionTestCase(-1e4f, "000011111"),
+ new NumericConversionTestCase(-1e8f, "000001111"),
+ new NumericConversionTestCase(-1e16f, "000000111"),
+ new NumericConversionTestCase(-1e20f, "000000011"),
+ new NumericConversionTestCase(-1.1e0f, "000000011"),
};
private static final Type[][] bytesTypes = {
@@ -192,10 +177,6 @@
return ConvertUtil.convertFromInt((Long) value, target);
} else if (value instanceof Float) {
return ConvertUtil.convertFromDouble((Float) value, target);
- } else if (value instanceof VdlComplex128) {
- double real = ((VdlComplex128) value).getReal();
- double imag = ((VdlComplex128) value).getImag();
- return ConvertUtil.convertFromComplex(real, imag, target);
} else {
throw new IllegalArgumentException("Unexpected value " + value);
}
@@ -226,14 +207,6 @@
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(2).pow(power));
}
- private BigDecimal normalizeComplex(VdlComplex128 value) {
- BigDecimal result = normalizeDouble(value.getReal());
- if (value.getImag() !=0 ) {
- result = result.add(normalizeDouble(value.getImag()).multiply(BigDecimal.TEN.pow(100)));
- }
- return result;
- }
-
private BigDecimal normalize(Object value) {
if (value instanceof Byte) {
return normalizeUint(((Byte) value) & 0xffL);
@@ -262,14 +235,9 @@
} else if (value instanceof Double) {
return normalizeDouble((Double) value);
} else if (value instanceof VdlFloat32) {
- return normalizeComplex(new VdlComplex128(((VdlFloat32) value).getValue()));
+ return normalizeDouble(((VdlFloat32)value).getValue());
} else if (value instanceof VdlFloat64) {
- return normalizeComplex(new VdlComplex128(((VdlFloat64) value).getValue()));
- } else if (value instanceof VdlComplex64) {
- return normalizeComplex(new VdlComplex128(((VdlComplex64) value).getReal(),
- ((VdlComplex64) value).getImag()));
- } else if (value instanceof VdlComplex128) {
- return normalizeComplex((VdlComplex128) value);
+ return normalizeDouble(((VdlFloat64)value).getValue());
} else {
throw new IllegalArgumentException("Unexpected value " + value);
}