* Bug #12979 fixed - exportUI did not work with vectorial export.
+* Bug #13003 fixed - EOJ: add a converter to handle string to enum.
+
* Bug #13004 fixed - Debug infos were printed on an error with eoj.
return from.isArray() && to.isAssignableFrom(ArrayList.class);
}
});
+
+ // Converter to convert a String to a Enum
+ registerConverter(new Converter() {
+ @Override
+ public Object convert(Object original, Class<?> to) {
+ return Enum.valueOf((Class) to, (String) original);
+ }
+
+ @Override
+ public boolean canConvert(Class<?> from, Class<?> to) {
+ return String.class.isAssignableFrom(from) && to.isEnum();
+ }
+ });
}
/**
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+c = jcompile("Test", ["public class Test {";
+"public enum foo { ONE, TWO, THREE; }";
+"public static double bar(foo x) { return (double) x.ordinal(); }}"]);
+assert_checkequal(c.bar("ONE"), 0);
+assert_checkequal(c.bar("TWO"), 1);
+assert_checkequal(c.bar("THREE"), 2);
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+c = jcompile("Test", ["public class Test {";
+"public enum foo { ONE, TWO, THREE; }";
+"public static double bar(foo x) { return (double) x.ordinal(); }}"]);
+
+assert_checkequal(c.bar("ONE"), 0);
+assert_checkequal(c.bar("TWO"), 1);
+assert_checkequal(c.bar("THREE"), 2);