Use the swig generated enum ScilabIntegerTypeEnum for int declaration instead of... 81/1881/6
Sylvestre Ledru [Fri, 10 Sep 2010 13:17:46 +0000 (15:17 +0200)]
Change-Id: I3b61d265c3c13dbe85d90bf1db16bce41f37b05a

scilab/modules/graph/src/java/org/scilab/modules/graph/io/ScilabIntegerCodec.java
scilab/modules/hdf5/src/java/org/scilab/modules/hdf5/write/H5WriteScilabInteger.java
scilab/modules/javasci/src/java/org/scilab/modules/javasci/Scilab.java
scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabInteger.java
scilab/modules/types/tests/java/org/scilab/tests/modules/types/testEquals.java

index 88bfcb7..6c09894 100644 (file)
@@ -16,7 +16,7 @@ import java.util.Map;
 
 import org.apache.commons.logging.LogFactory;
 import org.scilab.modules.types.scilabTypes.ScilabInteger;
-import org.scilab.modules.types.scilabTypes.ScilabInteger.IntegerType;
+import org.scilab.modules.types.scilabTypes.ScilabIntegerTypeEnum;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
@@ -28,21 +28,22 @@ import com.mxgraph.io.mxCodecRegistry;
  */
 public class ScilabIntegerCodec extends ScilabObjectCodec {
 
-    private static final String BUNSIGNED = "bUnsigned";
-    private static final String VALUE = "value";
-    private static final String PREC = "precision";
+       private static final String BUNSIGNED = "bUnsigned"; /* With old IntegerType */
+       private static final String VALUE = "value";
+       private static final String PREC = "precision"; /* With old IntegerType */
+       private static final String PRECISION = "intPrecision"; /* with ScilabIntegerTypeEnum */
 
-    /**
-     * Default constructor
+       /**
+        * Default constructor
         * @param template Prototypical instance of the object to be encoded/decoded.
         * @param exclude Optional array of fieldnames to be ignored.
         * @param idrefs Optional array of fieldnames to be converted to/from references.
         * @param mapping Optional mapping from field- to attributenames.
-     */
-    public ScilabIntegerCodec(Object template, String[] exclude, String[] idrefs, Map<String, String> mapping) {
+        */
+       public ScilabIntegerCodec(Object template, String[] exclude, String[] idrefs, Map<String, String> mapping) {
        super(template, exclude, idrefs, mapping);
 
-    }
+       }
 
        /**
         * Encodes the specified object and returns a node representing then given
@@ -53,41 +54,40 @@ public class ScilabIntegerCodec extends ScilabObjectCodec {
         * @param obj Object to be encoded.
         * @return Returns the resulting XML node that represents the given object. 
         */
-    @Override
-    public Node encode(mxCodec enc, Object obj) {
-       String name = mxCodecRegistry.getName(obj);
+       @Override
+       public Node encode(mxCodec enc, Object obj) {
+               String name = mxCodecRegistry.getName(obj);
        Node node = enc.getDocument().createElement(name);
 
        ScilabInteger scilabInteger = (ScilabInteger) obj;
        mxCodec.setAttribute(node, WIDTH, scilabInteger.getWidth());
        mxCodec.setAttribute(node, HEIGHT, scilabInteger.getHeight());
-       mxCodec.setAttribute(node, PREC, scilabInteger.getPrec().name());
+       mxCodec.setAttribute(node, PRECISION, scilabInteger.getPrec().name());
 
        for (int i = 0; i < scilabInteger.getHeight(); ++i) {
-           for (int j = 0; j < scilabInteger.getWidth(); ++j) {
+               for (int j = 0; j < scilabInteger.getWidth(); ++j) {
                Node data = enc.getDocument().createElement(DATA);
                mxCodec.setAttribute(data, LINE, i);
                mxCodec.setAttribute(data, COLUMN, j);
                mxCodec.setAttribute(data, VALUE, scilabInteger.getData()[i][j]);
-               mxCodec.setAttribute(data, BUNSIGNED, scilabInteger.isUnsigned());
                node.appendChild(data);
-           }
+               }
        }
        return node;
-    }
+       }
 
        /**
         * Parses the given node into the object or returns a new object
         * representing the given node.
         * 
         * @param dec
-        *            Codec that controls the encoding process.
+        *                      Codec that controls the encoding process.
         * @param node
-        *            XML node to be decoded.
+        *                      XML node to be decoded.
         * @param into
-        *            Optional object to encode the node into.
+        *                      Optional object to encode the node into.
         * @return Returns the resulting object that represents the given XML node
-        *         or the object given to the method as the into parameter.
+        *               or the object given to the method as the into parameter.
         */
        @Override
        public Object decode(mxCodec dec, Node node, Object into) {
@@ -112,38 +112,50 @@ public class ScilabIntegerCodec extends ScilabObjectCodec {
                                return obj;
                        }
                        
-                       final Node u = attrs.getNamedItem(BUNSIGNED);
-                       final boolean unsigned;
-                       /*
-                        * the default boolean value is false, this value is not serialized
-                        * by jgraphx this if we doesn't have attribute the value is
-                        * "false".
-                        */
-                       unsigned = u != null;
-                       
+
+                       final Node precNode = attrs.getNamedItem(PRECISION);
+                       ScilabIntegerTypeEnum precision = ScilabIntegerTypeEnum.valueOf(precNode.getNodeValue());
+
                        final Node prec = attrs.getNamedItem(PREC);
-                       final IntegerType precision = IntegerType.valueOf(prec.getNodeValue());
-                       
+                       if (prec != null) {
+                               /* Old version, we have to convert to the new one */
+                               final Node u = attrs.getNamedItem(BUNSIGNED);
+                               final boolean unsigned;
+                               /*
+                                * the default boolean value is false, this value is not serialized
+                                * by jgraphx this if we doesn't have attribute the value is
+                                * "false".
+                                */
+                               unsigned = u != null;
+                               
+                               precision = ScilabInteger.convertOldType(prec.getNodeValue(), unsigned);
+
+                       }
+
+
                        switch (precision) {
-                               case TYPE8:
+                               case sci_int8:
+                               case sci_uint8:
                                        final byte[][] data8 = new byte[height][width];
                                        fillData(node, data8);
-                                       obj.setData(data8, unsigned);
+                                       obj.setData(data8, precision == ScilabIntegerTypeEnum.sci_uint8);
                                        break;
-                               case TYPE16:
+                               case sci_int16:
+                               case sci_uint16:
                                        final short[][] data16 = new short[height][width];
                                        fillData(node, data16);
-                                       obj.setData(data16, unsigned);
+                                       obj.setData(data16, precision == ScilabIntegerTypeEnum.sci_uint16);
                                        break;
-                               case TYPE32:
+                               case sci_int32:
+                               case sci_uint32:
                                        final int[][] data32 = new int[height][width];
                                        fillData(node, data32);
-                                       obj.setData(data32, unsigned);
+                                       obj.setData(data32, precision == ScilabIntegerTypeEnum.sci_uint32);
                                        break;
                                default:
                                        final long[][] data64 = new long[height][width];
                                        fillData(node, data64);
-                                       obj.setData(data64, unsigned);
+                                       obj.setData(data64, precision == ScilabIntegerTypeEnum.sci_uint64);
                                        break;
                        }
 
@@ -159,11 +171,11 @@ public class ScilabIntegerCodec extends ScilabObjectCodec {
         * Fill the data from the node.
         * 
         * @param node
-        *            the ScilabInteger node
+        *                      the ScilabInteger node
         * @param data
-        *            the allocated data
+        *                      the allocated data
         * @throws UnrecognizeFormatException
-        *             when we are unable to decode the node.
+        *                       when we are unable to decode the node.
         */
        private void fillData(Node node, byte[][] data)
                        throws UnrecognizeFormatException {
@@ -193,11 +205,11 @@ public class ScilabIntegerCodec extends ScilabObjectCodec {
         * Fill the data from the node.
         * 
         * @param node
-        *            the ScilabInteger node
+        *                      the ScilabInteger node
         * @param data
-        *            the allocated data
+        *                      the allocated data
         * @throws UnrecognizeFormatException
-        *             when we are unable to decode the node.
+        *                       when we are unable to decode the node.
         */
        private void fillData(Node node, short[][] data)
                        throws UnrecognizeFormatException {
@@ -227,11 +239,11 @@ public class ScilabIntegerCodec extends ScilabObjectCodec {
         * Fill the data from the node.
         * 
         * @param node
-        *            the ScilabInteger node
+        *                      the ScilabInteger node
         * @param data
-        *            the allocated data
+        *                      the allocated data
         * @throws UnrecognizeFormatException
-        *             when we are unable to decode the node.
+        *                       when we are unable to decode the node.
         */
        private void fillData(Node node, int[][] data)
                        throws UnrecognizeFormatException {
@@ -261,11 +273,11 @@ public class ScilabIntegerCodec extends ScilabObjectCodec {
         * Fill the data from the node.
         * 
         * @param node
-        *            the ScilabInteger node
+        *                      the ScilabInteger node
         * @param data
-        *            the allocated data
+        *                      the allocated data
         * @throws UnrecognizeFormatException
-        *             when we are unable to decode the node.
+        *                       when we are unable to decode the node.
         */
        private void fillData(Node node, long[][] data)
                        throws UnrecognizeFormatException {
index 64aedd7..b72ae7a 100644 (file)
@@ -17,28 +17,30 @@ import ncsa.hdf.hdf5lib.HDF5Constants;
 import ncsa.hdf.hdf5lib.exceptions.HDF5Exception;
 
 import org.scilab.modules.hdf5.H5ScilabConstant;
-import org.scilab.modules.types.scilabTypes.ScilabInteger;;
+import org.scilab.modules.types.scilabTypes.ScilabInteger;
+import org.scilab.modules.types.scilabTypes.ScilabIntegerTypeEnum;
+
 
 public class H5WriteScilabInteger {
        public static void writeInDataSet(int file_id, String dataSetName, ScilabInteger data) throws NullPointerException, HDF5Exception {
                Object[] dataToWrite = null; 
-               ScilabInteger.IntegerType prec = data.getPrec();
+               ScilabIntegerTypeEnum prec = data.getPrec();
                int nativeType = 0;
                String classType = "";
 
-               if(prec == ScilabInteger.IntegerType.TYPE8) {
+               if (prec == ScilabIntegerTypeEnum.sci_int8 || prec == ScilabIntegerTypeEnum.sci_uint8) {
                        nativeType = data.isUnsigned() ? HDF5Constants.H5T_NATIVE_UINT8 : HDF5Constants.H5T_NATIVE_INT8; 
                        classType = data.isUnsigned() ? H5ScilabConstant.SCILAB_CLASS_UINT8 : H5ScilabConstant.SCILAB_CLASS_INT8; 
                        dataToWrite = getDataToWrite8(data);
-               }else if(prec == ScilabInteger.IntegerType.TYPE16) {
+               }else if (prec == ScilabIntegerTypeEnum.sci_int16 || prec == ScilabIntegerTypeEnum.sci_uint16) {
                        nativeType = data.isUnsigned() ? HDF5Constants.H5T_NATIVE_UINT16 : HDF5Constants.H5T_NATIVE_INT16; 
                        classType = data.isUnsigned() ? H5ScilabConstant.SCILAB_CLASS_UINT16 : H5ScilabConstant.SCILAB_CLASS_INT16; 
                        dataToWrite = getDataToWrite16(data);
-               }else if(prec == ScilabInteger.IntegerType.TYPE32) {
+               }else if (prec == ScilabIntegerTypeEnum.sci_int32 || prec == ScilabIntegerTypeEnum.sci_uint32) {
                        nativeType = data.isUnsigned() ? HDF5Constants.H5T_NATIVE_UINT32 : HDF5Constants.H5T_NATIVE_INT32; 
                        classType = data.isUnsigned() ? H5ScilabConstant.SCILAB_CLASS_UINT32 : H5ScilabConstant.SCILAB_CLASS_INT32; 
                        dataToWrite = getDataToWrite32(data);
-               }else if(prec == ScilabInteger.IntegerType.TYPE64) {
+               }else if (prec == ScilabIntegerTypeEnum.sci_int64 || prec == ScilabIntegerTypeEnum.sci_uint64) {
                        nativeType = data.isUnsigned() ? HDF5Constants.H5T_NATIVE_UINT64 : HDF5Constants.H5T_NATIVE_INT64; 
                        classType = data.isUnsigned() ? H5ScilabConstant.SCILAB_CLASS_UINT64 : H5ScilabConstant.SCILAB_CLASS_INT64; 
                        dataToWrite = getDataToWrite64(data);
index b9a781f..b4c4a69 100644 (file)
@@ -5,7 +5,7 @@
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at       
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
@@ -25,8 +25,8 @@ import org.scilab.modules.javasci.Call_Scilab;
 import org.scilab.modules.javasci.JavasciException.InitializationException;
 
 public class Scilab {
-    private String SCI = null;
-    
+       private String SCI = null;
+       
 
        /**
         * Creator of the Scilab Javasci object. 
@@ -37,10 +37,10 @@ public class Scilab {
         * Under Windows, use also the registery
         * @param SCI provide the path to Scilab data
         */
-    public Scilab() throws InitializationException {
+       public Scilab() throws InitializationException {
                // Auto detect 
                String detectedSCI;
-        try {
+               try {
                        detectedSCI = System.getProperty("SCI");
                        if (detectedSCI == null || detectedSCI.length() == 0) {
                                detectedSCI = System.getenv("SCI");
@@ -50,19 +50,19 @@ public class Scilab {
                        }
                        this.initScilab(detectedSCI);
 
-        } catch (Exception e) {
+               } catch (Exception e) {
                        throw new InitializationException("Auto detection of SCI failed.\nCould not retrieve the variable SCI.", e);
-        }
+               }
                // @TODO manage windows through the registery
-    }
+       }
 
        /**
         * Creator of the Scilab Javasci object. 
         * @param SCI provide the path to Scilab data
         */
-    public Scilab(String SCI) throws InitializationException {
+       public Scilab(String SCI) throws InitializationException {
                this.initScilab(SCI);
-    }
+       }
 
        private void initScilab(String SCI) throws InitializationException {
                File f = new File(SCI);
@@ -73,15 +73,15 @@ public class Scilab {
                this.SCI = SCI;
        }
 
-    /**
-     * Open a connection to the Scilab engine
-     * This function is based on Call_ScilabOpen from call_scilab
+       /**
+        * Open a connection to the Scilab engine
+        * This function is based on Call_ScilabOpen from call_scilab
         * Note: For now, only one instance of Scilab can be launched
         * A second launch will return FALSE
-     * @return if the operation is successful
-     */
-    public boolean open() throws InitializationException {
-//        System.out.println("SCI : " + SCI);
+        * @return if the operation is successful
+        */
+       public boolean open() throws InitializationException {
+//             System.out.println("SCI : " + SCI);
                int res = Call_Scilab.Call_ScilabOpen(this.SCI, null, -1);
                switch (res) {
                        case -1: 
@@ -93,182 +93,182 @@ public class Scilab {
                                throw new InitializationException("No existing directory");
                }
                return true;
-               //        return Call_Scilab.Call_ScilabOpen(this.SCI, null, null) == 0;
-    }
+               //              return Call_Scilab.Call_ScilabOpen(this.SCI, null, null) == 0;
+       }
 
-    /**
-     * Open a connection to the Scilab engine and run the command job
-     * This function is based on Call_ScilabOpen from call_scilab
+       /**
+        * Open a connection to the Scilab engine and run the command job
+        * This function is based on Call_ScilabOpen from call_scilab
         * Note: For now, only one instance of Scilab can be launched
         * A second launch will return FALSE
-     * @param job The job to run on startup
-     * @return if the operation is successful
-     */
-    public boolean open(String job) throws InitializationException {
-        if (!this.open()) {
+        * @param job The job to run on startup
+        * @return if the operation is successful
+        */
+       public boolean open(String job) throws InitializationException {
+               if (!this.open()) {
                        return false;
                }
 
-        return this.exec(job);
-    }
+               return this.exec(job);
+       }
 
-    /**
-     * Open a connection to the Scilab engine and run commands job
-     * This function is based on Call_ScilabOpen from call_scilab
+       /**
+        * Open a connection to the Scilab engine and run commands job
+        * This function is based on Call_ScilabOpen from call_scilab
         * Note: For now, only one instance of Scilab can be launched
         * A second launch will return FALSE
-     * @param jobs The serie of jobs to run on startup
-     * @return if the operation is successful
-     */
-    public boolean open(String jobs[]) throws InitializationException {
-        if (!this.open()) {
+        * @param jobs The serie of jobs to run on startup
+        * @return if the operation is successful
+        */
+       public boolean open(String jobs[]) throws InitializationException {
+               if (!this.open()) {
                        return false;
                }
 
-        return this.exec(jobs);
-    }
+               return this.exec(jobs);
+       }
 
 
-    /**
-     * Open a connection to the Scilab engine and run thefile scriptFilename
-     * This function is based on Call_ScilabOpen from call_scilab
+       /**
+        * Open a connection to the Scilab engine and run thefile scriptFilename
+        * This function is based on Call_ScilabOpen from call_scilab
         * Note: For now, only one instance of Scilab can be launched
         * A second launch will return FALSE
-     * @param job The script to execute on startup
-     * @return if the operation is successful
-     */
-    public boolean open(File scriptFilename) throws InitializationException, FileNotFoundException {
-        if (!this.open()) {
+        * @param job The script to execute on startup
+        * @return if the operation is successful
+        */
+       public boolean open(File scriptFilename) throws InitializationException, FileNotFoundException {
+               if (!this.open()) {
                        return false;
                }
 
-        return this.exec(scriptFilename);
-    }
-
-
-    /**
-     * Execute a single command in Scilab
-     * This function is based on SendScilabJob from call_scilab
-     * @param job the job to execute
-     * @return if the operation is successful
-     */
-    public boolean exec(String job) {
-        return (Call_Scilab.SendScilabJob(job) == 0);
-    }
-
-
-    /**
-     * Execute several commands in Scilab
-     * This function is based on SendScilabJob from call_scilab
-     * @param job the serie of job to execute
-     * @return if the operation is successful
-     */
-    public boolean exec(String jobs[]) {
-        return (Call_Scilab.SendScilabJobs(jobs, jobs.length) == 0);
-    }
-
-
-    /**
-     * Execute a Scilab script .sce/.sci
-     * This function is based on SendScilabJob from call_scilab
-     * @param job the script to execute
-     * @return if the operation is successful
-     */
-    public boolean exec(File scriptFilename) throws FileNotFoundException {
-        if (!scriptFilename.exists()) {
-            throw new FileNotFoundException("Could not find " + scriptFilename);
-        }
-        return this.exec("exec('" + scriptFilename + "');");
-    }
-
-
-    /**
-     * Detect if a variable (varname) exists in Scilab
-     * @param varname the variable to check
-     * @return if the variable exists or not
-     */
-    public boolean isExistingVariable(String varname) {
-        return true;
-    }
-
-
-    /**
-     * Shutdown Scilab
-     * This function is based on TerminateScilab from call_scilab
-     * @return if the operation is successful
-     */
-    public boolean close() {
+               return this.exec(scriptFilename);
+       }
+
+
+       /**
+        * Execute a single command in Scilab
+        * This function is based on SendScilabJob from call_scilab
+        * @param job the job to execute
+        * @return if the operation is successful
+        */
+       public boolean exec(String job) {
+               return (Call_Scilab.SendScilabJob(job) == 0);
+       }
+
+
+       /**
+        * Execute several commands in Scilab
+        * This function is based on SendScilabJob from call_scilab
+        * @param job the serie of job to execute
+        * @return if the operation is successful
+        */
+       public boolean exec(String jobs[]) {
+               return (Call_Scilab.SendScilabJobs(jobs, jobs.length) == 0);
+       }
+
+
+       /**
+        * Execute a Scilab script .sce/.sci
+        * This function is based on SendScilabJob from call_scilab
+        * @param job the script to execute
+        * @return if the operation is successful
+        */
+       public boolean exec(File scriptFilename) throws FileNotFoundException {
+               if (!scriptFilename.exists()) {
+                       throw new FileNotFoundException("Could not find " + scriptFilename);
+               }
+               return this.exec("exec('" + scriptFilename + "');");
+       }
+
+
+       /**
+        * Detect if a variable (varname) exists in Scilab
+        * @param varname the variable to check
+        * @return if the variable exists or not
+        */
+       public boolean isExistingVariable(String varname) {
+               return true;
+       }
+
+
+       /**
+        * Shutdown Scilab
+        * This function is based on TerminateScilab from call_scilab
+        * @return if the operation is successful
+        */
+       public boolean close() {
                boolean res = Call_Scilab.TerminateScilab(null);
-        return res;
-    }
-
-
-    /**
-     * Return the last error code
-     * @return the error code
-     * @todo Check what is actually this number
-     */
-    public int getLastErrorCode() {
-        return Call_Scilab.GetLastErrorCode();
-    }
-
-
-    /**
-     * Return the last error message
-     * @return the error message itself
-     */
-    public String getLastErrorMessage() {
-        return Call_Scilab.getLastErrorMessage();
-    }
-
-
-    /**
-     * Detect if a Scilab graphic window is still opened
-     * This function is based on ScilabHaveAGraph from call_scilab
-     * @return if the graphic is open or not
-     */
-    public boolean isGraphicOpened() {
-        return false;
-    }
-
-
-    /**
-     * Return the code type of a variable varname
-     * The int refers to a Java enum from ScilabType.types
-     * @param varname the name of the variable
-     * @return the type of the variable
-     * @todo check the enum here
-    */
-    public ScilabTypeEnum getVariableType(String varName) {
-        ScilabTypeEnum variableType = null;
-        try {
-            variableType = Call_Scilab.getVariableType(varName);
-        } catch (IllegalArgumentException e) {
-            System.err.println("Could not find variable type: " + e.getLocalizedMessage());
-        }
-
-        return variableType;
-
-    }
-
-
-
-
-    /**
-     * Returns a variable named varname
-     * Throws an exception if the datatype is not managed or if the variable is not available
-     * @param varname the name of the variable
-     * @return return the variable 
-    */
-    public ScilabType get(String varname) {
+               return res;
+       }
+
+
+       /**
+        * Return the last error code
+        * @return the error code
+        * @todo Check what is actually this number
+        */
+       public int getLastErrorCode() {
+               return Call_Scilab.GetLastErrorCode();
+       }
+
+
+       /**
+        * Return the last error message
+        * @return the error message itself
+        */
+       public String getLastErrorMessage() {
+               return Call_Scilab.getLastErrorMessage();
+       }
+
+
+       /**
+        * Detect if a Scilab graphic window is still opened
+        * This function is based on ScilabHaveAGraph from call_scilab
+        * @return if the graphic is open or not
+        */
+       public boolean isGraphicOpened() {
+               return false;
+       }
+
+
+       /**
+        * Return the code type of a variable varname
+        * The int refers to a Java enum from ScilabType.types
+        * @param varname the name of the variable
+        * @return the type of the variable
+        * @todo check the enum here
+       */
+       public ScilabTypeEnum getVariableType(String varName) {
+               ScilabTypeEnum variableType = null;
+               try {
+                       variableType = Call_Scilab.getVariableType(varName);
+               } catch (IllegalArgumentException e) {
+                       System.err.println("Could not find variable type: " + e.getLocalizedMessage());
+               }
+
+               return variableType;
+
+       }
+
+
+
+
+       /**
+        * Returns a variable named varname
+        * Throws an exception if the datatype is not managed or if the variable is not available
+        * @param varname the name of the variable
+        * @return return the variable 
+       */
+       public ScilabType get(String varname) {
                ScilabTypeEnum sciType = this.getVariableType(varname);
                switch (sciType) {
                        case sci_matrix:
-                if (!Call_Scilab.isComplex(varname)) {
-                    return new ScilabDouble(Call_Scilab.getDouble(varname));
-                } else {
-                    return new ScilabDouble(Call_Scilab.getDoubleComplexReal(varname), Call_Scilab.getDoubleComplexImg(varname));
-                }
+                               if (!Call_Scilab.isComplex(varname)) {
+                                       return new ScilabDouble(Call_Scilab.getDouble(varname));
+                               } else {
+                                       return new ScilabDouble(Call_Scilab.getDoubleComplexReal(varname), Call_Scilab.getDoubleComplexImg(varname));
+                               }
 
                        case sci_boolean:
                                return new ScilabBoolean(Call_Scilab.getBoolean(varname));
@@ -304,87 +304,84 @@ public class Scilab {
                //              throw new UnsupportedTypeException();
                }
                return null;
-    }
+       }
 
 
-    /**
-     * Send to Scilab a variable theVariable named varname
-     * Throws an exception if the datatype is not managed or if the variable is not available
-     * @param varname the name of the variable
-     * @param varname the variable itself
-     * @return if the operation is successful
-    */
-    public boolean put(String varname, ScilabType theVariable) {
+       /**
+        * Send to Scilab a variable theVariable named varname
+        * Throws an exception if the datatype is not managed or if the variable is not available
+        * @param varname the name of the variable
+        * @param varname the variable itself
+        * @return if the operation is successful
+       */
+       public boolean put(String varname, ScilabType theVariable) {
                int err = -999;
 
-        if (theVariable instanceof ScilabDouble) {
-            ScilabDouble sciDouble = (ScilabDouble)theVariable;
-            if (sciDouble.isReal()) {
+               if (theVariable instanceof ScilabDouble) {
+                       ScilabDouble sciDouble = (ScilabDouble)theVariable;
+                       if (sciDouble.isReal()) {
                                err = Call_Scilab.putDouble(varname, sciDouble.getRealPart());
-            } else {
+                       } else {
 // Special case. Serialize the matrix from Scilab same way Scilab stores them
 // (columns by columns)
 // plus the complex values at the second part of the array
-                err = Call_Scilab.putDoubleComplex(varname,sciDouble.getSerializedComplexMatrix(), sciDouble.getHeight(), sciDouble.getWidth());
-            }
+                               err = Call_Scilab.putDoubleComplex(varname,sciDouble.getSerializedComplexMatrix(), sciDouble.getHeight(), sciDouble.getWidth());
+                       }
                }
 
                if (theVariable instanceof ScilabInteger) {
-            ScilabInteger sciInteger = (ScilabInteger)theVariable;
+                       ScilabInteger sciInteger = (ScilabInteger)theVariable;
                        switch (sciInteger.getPrec()) {
-                               case TYPE8: // byte
-                                       if (sciInteger.isUnsigned()) {
-                                               err = Call_Scilab.putUnsignedByte(varname, sciInteger.getDataAsByte());
-                                       } else {
-                                               err = Call_Scilab.putByte(varname, sciInteger.getDataAsByte());
-                                       }
+                               case sci_uint8:
+                                       err = Call_Scilab.putUnsignedByte(varname, sciInteger.getDataAsByte());
+                                       break;
+                               case sci_int8:
+                                       err = Call_Scilab.putByte(varname, sciInteger.getDataAsByte());
+                                       break;
+                               case sci_uint16:
+                                       err = Call_Scilab.putUnsignedShort(varname, sciInteger.getDataAsShort());
                                        break;
-                               case TYPE16: // short 
-                                       if (sciInteger.isUnsigned()) {
-                                               err = Call_Scilab.putUnsignedShort(varname, sciInteger.getDataAsShort());
-                                       } else {
-                                               err = Call_Scilab.putShort(varname, sciInteger.getDataAsShort());
-                                       }
+                               case sci_int16:
+                                       err = Call_Scilab.putShort(varname, sciInteger.getDataAsShort());
                                        break;
-                               case TYPE32: // int
-                                       if (sciInteger.isUnsigned()) {
-                                               err = Call_Scilab.putUnsignedInt(varname, sciInteger.getDataAsInt());
-                                       } else {
-                                               err = Call_Scilab.putInt(varname, sciInteger.getDataAsInt());
-                                               }
+                               case sci_uint32:
+                                       err = Call_Scilab.putUnsignedInt(varname, sciInteger.getDataAsInt());
+                               case sci_int32:
+                                       err = Call_Scilab.putInt(varname, sciInteger.getDataAsInt());
                                        break;
-                               case TYPE64: // long. unsupported by Scilab 5.X
+                               case sci_uint64:
+//                                     err = Call_Scilab.putUnsignedLong(varname, sciInteger.getData_());
+                               case sci_int64:
+//                                     err = Call_Scilab.putLong(varname, sciInteger.getData_());
                                        break;
                        }
-
-                       //                      Call_Scilab.putLong(varname, sciInteger.getData_());
                }
 
                if (theVariable instanceof ScilabBoolean) {
-            ScilabBoolean sciBoolean = (ScilabBoolean)theVariable;
-            err = Call_Scilab.putBoolean(varname, sciBoolean.getData());
-        }
+                       ScilabBoolean sciBoolean = (ScilabBoolean)theVariable;
+                       err = Call_Scilab.putBoolean(varname, sciBoolean.getData());
+               }
 
                if (theVariable instanceof ScilabString) {
-            ScilabString sciString = (ScilabString)theVariable;
-            err = Call_Scilab.putString(varname, sciString.getData());
-        }
+                       ScilabString sciString = (ScilabString)theVariable;
+                       err = Call_Scilab.putString(varname, sciString.getData());
+               }
 
 
                //TODO: a remplacer par la bonne exception return new UnsupportedTypeException();
                //              throw new UnsupportedTypeException();
-        if (err == -999) {
-                // Exception a lancer
-
-            System.err.println("Type not managed: " + theVariable.getClass());
-        } else {
-            if (err != 0) {
-                // Exception a lancer
-                System.err.println("put failed");
-            }
-        }
+               if (err == -999) {
+                               // Exception a lancer
+
+                       System.err.println("Type not managed: " + theVariable.getClass());
+               } else {
+                       if (err != 0) {
+                               // Exception a lancer
+                               System.err.println("put failed");
+                       }
+               }
 
                return true;
-    }
+       }
 
 }
index 1f6a8d8..6372b52 100644 (file)
@@ -23,22 +23,7 @@ public class ScilabInteger implements ScilabType {
        private short[][] shortData = null;
        private int[][] intData = null;
        private byte[][] byteData = null;
-       private IntegerType prec;
-       private boolean bUnsigned;
-
-       /**
-        * The different size of the integer type.
-        */
-       public enum IntegerType {
-               /** Integer of size 8 */
-               TYPE8,
-               /** Integer of size 16 */
-               TYPE16,
-               /** Integer of size 32 */
-               TYPE32,
-               /** Integer of size 64 */
-               TYPE64
-       }
+       private ScilabIntegerTypeEnum type;
        
        /**
         * Default constructor
@@ -95,7 +80,7 @@ public class ScilabInteger implements ScilabType {
        public ScilabInteger(byte value) {
                this.byteData = new byte[1][1];
                this.byteData[0][0] = value;
-               this.prec = IntegerType.TYPE8;
+               this.type = ScilabIntegerTypeEnum.sci_int8;
        }
 
        /**
@@ -106,7 +91,7 @@ public class ScilabInteger implements ScilabType {
        public ScilabInteger(short value) {
                this.shortData = new short[1][1];
                this.shortData[0][0] = value;
-               this.prec = IntegerType.TYPE16;
+               this.type = ScilabIntegerTypeEnum.sci_int16;
        }
 
        /**
@@ -117,7 +102,7 @@ public class ScilabInteger implements ScilabType {
        public ScilabInteger(int value) {
                this.intData = new int[1][1];
                this.intData[0][0] = value;
-               this.prec = IntegerType.TYPE32;
+               this.type = ScilabIntegerTypeEnum.sci_int32;
        }
 
        /**
@@ -128,7 +113,7 @@ public class ScilabInteger implements ScilabType {
        public ScilabInteger(long value) {
                this.longData = new long[1][1];
                this.longData[0][0] = value;
-               this.prec = IntegerType.TYPE64;
+               this.type = ScilabIntegerTypeEnum.sci_int64;
        }
 
        /**
@@ -139,8 +124,11 @@ public class ScilabInteger implements ScilabType {
         */
        public void setData(byte[][] data, boolean bUnsigned) {
                this.byteData = data;
-               prec = IntegerType.TYPE8;
-               this.bUnsigned = bUnsigned; 
+               if (bUnsigned) {
+                       this.type = ScilabIntegerTypeEnum.sci_uint8;
+               } else {
+                       this.type = ScilabIntegerTypeEnum.sci_int8;
+               }
        }
 
        /**
@@ -151,8 +139,11 @@ public class ScilabInteger implements ScilabType {
         */
        public void setData(short[][] data, boolean bUnsigned) {
                this.shortData = data;
-               prec = IntegerType.TYPE16;
-               this.bUnsigned = bUnsigned; 
+               if (bUnsigned) {
+                       this.type = ScilabIntegerTypeEnum.sci_uint16;
+               } else {
+                       this.type = ScilabIntegerTypeEnum.sci_int16;
+               }
        }
 
        /**
@@ -163,8 +154,11 @@ public class ScilabInteger implements ScilabType {
         */
        public void setData(int[][] data, boolean bUnsigned) {
                this.intData = data;
-               prec = IntegerType.TYPE32;
-               this.bUnsigned = bUnsigned; 
+               if (bUnsigned) {
+                       this.type = ScilabIntegerTypeEnum.sci_uint32;
+               } else {
+                       this.type = ScilabIntegerTypeEnum.sci_int32;
+               }
        }
 
        /**
@@ -175,8 +169,11 @@ public class ScilabInteger implements ScilabType {
         */
        public void setData(long[][] data, boolean bUnsigned) {
                this.longData = data;
-               prec = IntegerType.TYPE64;
-               this.bUnsigned = bUnsigned; 
+               if (bUnsigned) {
+                       this.type = ScilabIntegerTypeEnum.sci_uint64;
+               } else {
+                       this.type = ScilabIntegerTypeEnum.sci_int64;
+               }
        }
 
        /**
@@ -189,28 +186,32 @@ public class ScilabInteger implements ScilabType {
                long[][] convertedMatrix = new long[this.getHeight()][this.getWidth()];
                switch (this.getPrec()) {
 
-                       case TYPE8:
+                       case sci_int8:
+                       case sci_uint8:
                                for (int i = 0; i < this.getHeight(); i++) {
                                        for (int j = 0; j < this.getWidth(); j++) {
                                                convertedMatrix[i][j] = Long.valueOf(byteData[i][j]);
                                        }
                                }
                                return convertedMatrix;
-                       case TYPE16:
+                       case sci_int16:
+                       case sci_uint16:
                                for (int i = 0; i < this.getHeight(); i++) {
                                        for (int j = 0; j < this.getWidth(); j++) {
                                                convertedMatrix[i][j] = Long.valueOf(shortData[i][j]);
                                        }
                                }
                                return convertedMatrix;
-                       case TYPE32:
+                       case sci_int32:
+                       case sci_uint32:
                                for (int i = 0; i < this.getHeight(); i++) {
                                        for (int j = 0; j < this.getWidth(); j++) {
                                                convertedMatrix[i][j] = Long.valueOf(intData[i][j]);
                                        }
                                }
                                return convertedMatrix;
-                       case TYPE64:
+                       case sci_int64:
+                       case sci_uint64:
                                return longData;
                }
                return null;
@@ -253,17 +254,70 @@ public class ScilabInteger implements ScilabType {
        /**
         * @return the precision of the values
         */
-       public IntegerType getPrec() {
-               return prec;
+       public ScilabIntegerTypeEnum getPrec() {
+               return type;
        }
 
        /**
         * @return true, if the values are signed, false otherwise.
         */
        public boolean isUnsigned() {
-               return bUnsigned;
+               switch (type) {
+                       case sci_int8:
+                       case sci_int16:
+                       case sci_int32:
+                       case sci_int64:
+                               return false;
+                       case sci_uint8:
+                       case sci_uint16:
+                       case sci_uint32:
+                       case sci_uint64:
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * Manage the old representation of IntegerType 
+        * @param typeName the typeName (TYPE8, TYPE16, TYPE32, TYPE64)
+        * @param unsigned unsigned or not
+        * @return the converted type to ScilabIntegerTypeEnum. null is cannot convert
+        */
+       public static ScilabIntegerTypeEnum convertOldType(String typeName, boolean unsigned) {
+               
+               if (typeName.equals("TYPE8")) {
+                       if (unsigned) {
+                               return ScilabIntegerTypeEnum.sci_uint8;
+                       } else {
+                               return ScilabIntegerTypeEnum.sci_int8;
+                       }
+               }
+               if (typeName.equals("TYPE16")) {
+                       if (unsigned) {
+                               return ScilabIntegerTypeEnum.sci_uint16;
+                       } else {
+                               return ScilabIntegerTypeEnum.sci_int16;
+                       }
+               }
+               if (typeName.equals("TYPE32")) {
+                       if (unsigned) {
+                               return ScilabIntegerTypeEnum.sci_uint32;
+                       } else {
+                               return ScilabIntegerTypeEnum.sci_int32;
+                       }
+               }
+               if (typeName.equals("TYPE64")) {
+                       if (unsigned) {
+                               return ScilabIntegerTypeEnum.sci_uint64;
+                       } else {
+                               return ScilabIntegerTypeEnum.sci_int64;
+                       }
+               }
+               return null;
+
        }
 
+
        /**
         * @return the height of the value matrix
         * @see org.scilab.modules.types.scilabTypes.ScilabType#getHeight()
@@ -271,22 +325,26 @@ public class ScilabInteger implements ScilabType {
        @Override
                public int getHeight() {
                switch (this.getPrec()) {
-                       case TYPE8:
+                       case sci_int8:
+                       case sci_uint8:
                                if (byteData == null) {
                                        return 0;
                                }
                                return byteData.length;
-                       case TYPE16:
+                       case sci_int16:
+                       case sci_uint16:
                                if (shortData == null) {
                                        return 0;
                                }
                                return shortData.length;
-                       case TYPE32:
+                       case sci_int32:
+                       case sci_uint32:
                                if (intData == null) {
                                        return 0;
                                }
                                return intData.length;
-                       case TYPE64:
+                       case sci_int64:
+                       case sci_uint64:
                                if (longData == null) {
                                        return 0;
                                }
@@ -303,22 +361,26 @@ public class ScilabInteger implements ScilabType {
        @Override
        public int getWidth() {
                switch (this.getPrec()) {
-                       case TYPE8:
+                       case sci_int8:
+                       case sci_uint8:
                                if (byteData == null) {
                                        return 0;
                                }
                                return byteData[0].length;
-                       case TYPE16:
+                       case sci_int16:
+                       case sci_uint16:
                                if (shortData == null) {
                                        return 0;
                                }
                                return shortData[0].length;
-                       case TYPE32:
+                       case sci_int32:
+                       case sci_uint32:
                                if (intData == null) {
                                        return 0;
                                }
                                return intData[0].length;
-                       case TYPE64:
+                       case sci_int64:
+                       case sci_uint64:
                                if (longData == null) {
                                        return 0;
                                }
@@ -334,39 +396,43 @@ public class ScilabInteger implements ScilabType {
        /**
         * @return true, if there is no values; false otherwise.
         */
-    public boolean isEmpty() {
+       public boolean isEmpty() {
                switch (this.getPrec()) {
-                       case TYPE8:
+                       case sci_int8:
+                       case sci_uint8:
                                return byteData == null;
-                       case TYPE16:
+                       case sci_int16:
+                       case sci_uint16:
                                return shortData == null;
-                       case TYPE32:
+                       case sci_int32:
+                       case sci_uint32:
                                return intData == null;
-                       case TYPE64:
+                       case sci_int64:
+                       case sci_uint64:
                                return longData == null;
                        default:
                                return true;
                }
-    }
+       }
        
-    /**
+       /**
         * @see org.scilab.modules.types.scilabTypes.ScilabType#equals(Object)
-     */
-    public boolean equals(Object obj) {
-        if (obj instanceof ScilabInteger) {
-            return Arrays.deepEquals(this.getData(), ((ScilabInteger)obj).getData());
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * @return the pretty-printed values 
-     * @see java.lang.Object#toString()
-     */
-    @Override
+        */
+       public boolean equals(Object obj) {
+               if (obj instanceof ScilabInteger) {
+                       return Arrays.deepEquals(this.getData(), ((ScilabInteger)obj).getData());
+               } else {
+                       return false;
+               }
+       }
+
+       /**
+        * @return the pretty-printed values 
+        * @see java.lang.Object#toString()
+        */
+       @Override
        public String toString() {
-       StringBuilder result = new StringBuilder();
+               StringBuilder result = new StringBuilder();
                
                
                if (isEmpty()) {
@@ -380,24 +446,28 @@ public class ScilabInteger implements ScilabType {
                result.append("int");
                
                switch (this.getPrec()) {
-               case TYPE8:
-                       result.append("8");
+                       case sci_int8:
+                       case sci_uint8:
+                               result.append("8");
                        break;
 
-               case TYPE16:
-                       result.append("16");
-                       break;
+                       case sci_int16:
+                       case sci_uint16:
+                               result.append("16");
+                               break;
                        
-               case TYPE32:
-                       result.append("32");
-                       break;
+                       case sci_int32:
+                       case sci_uint32:
+                               result.append("32");
+                               break;
                        
-               case TYPE64:
-                       result.append("64");
-                       break;
+                       case sci_int64:
+                       case sci_uint64:
+                               result.append("64");
+                               break;
                        
-               default:
-                       break;
+                       default:
+                               break;
                }
 
                result.append("([");
index 43e698e..92782fe 100644 (file)
@@ -9,7 +9,7 @@
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
-package org.scilab.tests.modules.javasci;
+package org.scilab.tests.modules.types;
 
 import org.testng.annotations.*;
 
@@ -18,6 +18,7 @@ import java.util.Arrays;
 import org.scilab.modules.types.scilabTypes.ScilabType;
 import org.scilab.modules.types.scilabTypes.ScilabDouble;
 import org.scilab.modules.types.scilabTypes.ScilabInteger;
+import org.scilab.modules.types.scilabTypes.ScilabIntegerTypeEnum;
 import org.scilab.modules.types.scilabTypes.ScilabBoolean;
 import org.scilab.modules.types.scilabTypes.ScilabString;
 import org.scilab.modules.types.scilabTypes.ScilabList;
@@ -25,63 +26,63 @@ import org.scilab.modules.types.scilabTypes.ScilabList;
 public class testEquals {
 
        @Test
-    public void compareDoubleTest() throws NullPointerException {
-        double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
-        double [][]b={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
-        double [][]c={{42,43},{21,22}};
-        ScilabDouble aMatrix = new ScilabDouble(a);
-        ScilabDouble bMatrix = new ScilabDouble(b);
-        ScilabDouble cMatrix = new ScilabDouble(c);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert Arrays.deepEquals(aMatrix.getRealPart(), bMatrix.getRealPart()) == true;
+       public void compareDoubleTest() throws NullPointerException {
+               double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
+               double [][]b={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
+               double [][]c={{42,43},{21,22}};
+               ScilabDouble aMatrix = new ScilabDouble(a);
+               ScilabDouble bMatrix = new ScilabDouble(b);
+               ScilabDouble cMatrix = new ScilabDouble(c);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert Arrays.deepEquals(aMatrix.getRealPart(), bMatrix.getRealPart()) == true;
                assert aMatrix.toString().equals("[21.2, 22.0, 42.0, 39.0 ; 23.2, 24.0, 44.0, 40.0]") == true;
                assert cMatrix.toString().equals("[42.0, 43.0 ; 21.0, 22.0]") == true;
-    }
+       }
 
 
        @Test
-    public void compareDoubleComplexTest() throws NullPointerException {
-        double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
-        double [][]aImg={{210.2, 220.0, 420.0, 390.0},{230.2, 240.0, 440.0, 400.0}};
-        double [][]b={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
-        double [][]bImg={{210.2, 220.0, 420.0, 390.0},{230.2, 240.0, 440.0, 400.0}};
-        double [][]c={{42,43},{21,22}};
-        double [][]cImg={{420,430},{210,220}};
-        ScilabDouble aMatrix = new ScilabDouble(a, aImg);
-        ScilabDouble bMatrix = new ScilabDouble(b, bImg);
-        ScilabDouble cMatrix = new ScilabDouble(c, cImg);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert Arrays.deepEquals(aMatrix.getRealPart(), bMatrix.getRealPart()) == true;
-        assert Arrays.deepEquals(aMatrix.getImaginaryPart(), bMatrix.getImaginaryPart()) == true;
+       public void compareDoubleComplexTest() throws NullPointerException {
+               double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
+               double [][]aImg={{210.2, 220.0, 420.0, 390.0},{230.2, 240.0, 440.0, 400.0}};
+               double [][]b={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
+               double [][]bImg={{210.2, 220.0, 420.0, 390.0},{230.2, 240.0, 440.0, 400.0}};
+               double [][]c={{42,43},{21,22}};
+               double [][]cImg={{420,430},{210,220}};
+               ScilabDouble aMatrix = new ScilabDouble(a, aImg);
+               ScilabDouble bMatrix = new ScilabDouble(b, bImg);
+               ScilabDouble cMatrix = new ScilabDouble(c, cImg);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert Arrays.deepEquals(aMatrix.getRealPart(), bMatrix.getRealPart()) == true;
+               assert Arrays.deepEquals(aMatrix.getImaginaryPart(), bMatrix.getImaginaryPart()) == true;
                assert aMatrix.toString().equals("[21.2 + 210.2 * %i, 22.0 + 220.0 * %i, 42.0 + 420.0 * %i, 39.0 + 390.0 * %i ; 23.2 + 230.2 * %i, 24.0 + 240.0 * %i, 44.0 + 440.0 * %i, 40.0 + 400.0 * %i]") == true;
                assert cMatrix.toString().equals("[42.0 + 420.0 * %i, 43.0 + 430.0 * %i ; 21.0 + 210.0 * %i, 22.0 + 220.0 * %i]") == true;
 
-        double [] result = new double[]{21.2, 23.2, 22.0, 24.0, 42.0, 44.0, 39.0, 40.0, 210.2, 230.2, 220.0, 240.0, 420.0, 440.0, 390.0, 400.0};
-        assert aMatrix.getSerializedComplexMatrix().length == result.length;
-        assert Arrays.equals(aMatrix.getSerializedComplexMatrix(),result) == true;
+               double [] result = new double[]{21.2, 23.2, 22.0, 24.0, 42.0, 44.0, 39.0, 40.0, 210.2, 230.2, 220.0, 240.0, 420.0, 440.0, 390.0, 400.0};
+               assert aMatrix.getSerializedComplexMatrix().length == result.length;
+               assert Arrays.equals(aMatrix.getSerializedComplexMatrix(),result) == true;
 
 
-    }
+       }
 
 
        @Test
-    public void compareInteger8Test() throws NullPointerException {
-        byte [][]a={{32,42,41}, {12,13,32}};
-        byte [][]b={{32,42,41}, {12,13,32}};
-        byte [][]c={{42,43},{21,22}};
-        ScilabInteger aMatrix = new ScilabInteger(a, true);
-        ScilabInteger bMatrix = new ScilabInteger(b, true);
-        ScilabInteger cMatrix = new ScilabInteger(c, true);
-        ScilabInteger dMatrix = new ScilabInteger(c, false);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert cMatrix.equals(dMatrix) == true;
-        assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
+       public void compareInteger8Test() throws NullPointerException {
+               byte [][]a={{32,42,41}, {12,13,32}};
+               byte [][]b={{32,42,41}, {12,13,32}};
+               byte [][]c={{42,43},{21,22}};
+               ScilabInteger aMatrix = new ScilabInteger(a, true);
+               ScilabInteger bMatrix = new ScilabInteger(b, true);
+               ScilabInteger cMatrix = new ScilabInteger(c, true);
+               ScilabInteger dMatrix = new ScilabInteger(c, false);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert cMatrix.equals(dMatrix) == true;
+               assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
                assert aMatrix.toString().equals("uint8([32, 42, 41 ; 12, 13, 32])") == true;
                assert cMatrix.toString().equals("uint8([42, 43 ; 21, 22])") == true;
                assert dMatrix.toString().equals("int8([42, 43 ; 21, 22])") == true;
@@ -92,23 +93,29 @@ public class testEquals {
                assert d[0][0] == 32;
                assert d2[0][0] == 32;
                assert Arrays.deepEquals(a,d);
-    }
+               assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint8;
+               assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int8;
+               assert aMatrix.isUnsigned() == true;
+               assert dMatrix.isUnsigned() == false;
+               assert ScilabInteger.convertOldType("TYPE8", true) == ScilabIntegerTypeEnum.sci_uint8;
+               assert ScilabInteger.convertOldType("TYPE8", false) == ScilabIntegerTypeEnum.sci_int8;
+       }
 
 
        @Test
-    public void compareInteger16Test() throws NullPointerException {
-        short [][]a={{32,42,41}, {12,13,32}};
-        short [][]b={{32,42,41}, {12,13,32}};
-        short [][]c={{42,43},{21,22}};
-        ScilabInteger aMatrix = new ScilabInteger(a, true);
-        ScilabInteger bMatrix = new ScilabInteger(b, true);
-        ScilabInteger cMatrix = new ScilabInteger(c, true);
-        ScilabInteger dMatrix = new ScilabInteger(c, false);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert cMatrix.equals(dMatrix) == true;
-        assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
+       public void compareInteger16Test() throws NullPointerException {
+               short [][]a={{32,42,41}, {12,13,32}};
+               short [][]b={{32,42,41}, {12,13,32}};
+               short [][]c={{42,43},{21,22}};
+               ScilabInteger aMatrix = new ScilabInteger(a, true);
+               ScilabInteger bMatrix = new ScilabInteger(b, true);
+               ScilabInteger cMatrix = new ScilabInteger(c, true);
+               ScilabInteger dMatrix = new ScilabInteger(c, false);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert cMatrix.equals(dMatrix) == true;
+               assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
                assert aMatrix.toString().equals("uint16([32, 42, 41 ; 12, 13, 32])") == true;
                assert cMatrix.toString().equals("uint16([42, 43 ; 21, 22])") == true;
                assert dMatrix.toString().equals("int16([42, 43 ; 21, 22])") == true;
@@ -119,22 +126,28 @@ public class testEquals {
                assert d[0][0] == 32;
                assert d2[0][0] == 32;
                assert Arrays.deepEquals(a,d);
-    }
+               assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint16;
+               assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int16;
+               assert aMatrix.isUnsigned() == true;
+               assert dMatrix.isUnsigned() == false;
+               assert ScilabInteger.convertOldType("TYPE16", true) == ScilabIntegerTypeEnum.sci_uint16;
+               assert ScilabInteger.convertOldType("TYPE16", false) == ScilabIntegerTypeEnum.sci_int16;
+       }
 
        @Test
-    public void compareInteger32Test() throws NullPointerException {
-        int [][]a={{32,42,41}, {12,13,32}};
-        int [][]b={{32,42,41}, {12,13,32}};
-        int [][]c={{42,43},{21,22}};
-        ScilabInteger aMatrix = new ScilabInteger(a, true);
-        ScilabInteger bMatrix = new ScilabInteger(b, true);
-        ScilabInteger cMatrix = new ScilabInteger(c, true);
-        ScilabInteger dMatrix = new ScilabInteger(c, false);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert cMatrix.equals(dMatrix) == true;
-        assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
+       public void compareInteger32Test() throws NullPointerException {
+               int [][]a={{32,42,41}, {12,13,32}};
+               int [][]b={{32,42,41}, {12,13,32}};
+               int [][]c={{42,43},{21,22}};
+               ScilabInteger aMatrix = new ScilabInteger(a, true);
+               ScilabInteger bMatrix = new ScilabInteger(b, true);
+               ScilabInteger cMatrix = new ScilabInteger(c, true);
+               ScilabInteger dMatrix = new ScilabInteger(c, false);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert cMatrix.equals(dMatrix) == true;
+               assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
                assert aMatrix.toString().equals("uint32([32, 42, 41 ; 12, 13, 32])") == true;
                assert cMatrix.toString().equals("uint32([42, 43 ; 21, 22])") == true;
                assert dMatrix.toString().equals("int32([42, 43 ; 21, 22])") == true;
@@ -145,22 +158,28 @@ public class testEquals {
                assert d[0][0] == 32;
                assert d2[0][0] == 32;
                assert Arrays.deepEquals(a,d);
-    }
+               assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint32;
+               assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int32;
+               assert aMatrix.isUnsigned() == true;
+               assert dMatrix.isUnsigned() == false;
+               assert ScilabInteger.convertOldType("TYPE32", true) == ScilabIntegerTypeEnum.sci_uint32;
+               assert ScilabInteger.convertOldType("TYPE32", false) == ScilabIntegerTypeEnum.sci_int32;
+       }
 
        @Test
-    public void compareInteger64Test() throws NullPointerException {
-        long [][]a={{32,42,41}, {12,13,32}};
-        long [][]b={{32,42,41}, {12,13,32}};
-        long [][]c={{42,43},{21,22}};
-        ScilabInteger aMatrix = new ScilabInteger(a, true);
-        ScilabInteger bMatrix = new ScilabInteger(b, true);
-        ScilabInteger cMatrix = new ScilabInteger(c, true);
-        ScilabInteger dMatrix = new ScilabInteger(c, false);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert cMatrix.equals(dMatrix) == true;
-        assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
+       public void compareInteger64Test() throws NullPointerException {
+               long [][]a={{32,42,41}, {12,13,32}};
+               long [][]b={{32,42,41}, {12,13,32}};
+               long [][]c={{42,43},{21,22}};
+               ScilabInteger aMatrix = new ScilabInteger(a, true);
+               ScilabInteger bMatrix = new ScilabInteger(b, true);
+               ScilabInteger cMatrix = new ScilabInteger(c, true);
+               ScilabInteger dMatrix = new ScilabInteger(c, false);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert cMatrix.equals(dMatrix) == true;
+               assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
                assert aMatrix.toString().equals("uint64([32, 42, 41 ; 12, 13, 32])") == true;
                assert cMatrix.toString().equals("uint64([42, 43 ; 21, 22])") == true;
                assert dMatrix.toString().equals("int64([42, 43 ; 21, 22])") == true;
@@ -171,61 +190,67 @@ public class testEquals {
                assert d[0][0] == 32;
                assert d2[0][0] == 32;
                assert Arrays.deepEquals(a,d);
-    }
+               assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint64;
+               assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int64;
+               assert aMatrix.isUnsigned() == true;
+               assert dMatrix.isUnsigned() == false;
+               assert ScilabInteger.convertOldType("TYPE64", true) == ScilabIntegerTypeEnum.sci_uint64;
+               assert ScilabInteger.convertOldType("TYPE64", false) == ScilabIntegerTypeEnum.sci_int64;
+       }
 
 
        @Test
-    public void compareBooleanTest() throws NullPointerException {
-        boolean [][]a={{true,false,true}, {true,true,true}};
-        boolean [][]b={{true,false,true}, {true,true,true}};
-        boolean [][]c={{true,false},{false,true}};
-        ScilabBoolean aMatrix = new ScilabBoolean(a);
-        ScilabBoolean bMatrix = new ScilabBoolean(b);
-        ScilabBoolean cMatrix = new ScilabBoolean(c);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
-        assert aMatrix.toString().equals("[%t, %f, %t ; %t, %t, %t]") == true;
-        assert cMatrix.toString().equals("[%t, %f ; %f, %t]") == true;
-    }
+       public void compareBooleanTest() throws NullPointerException {
+               boolean [][]a={{true,false,true}, {true,true,true}};
+               boolean [][]b={{true,false,true}, {true,true,true}};
+               boolean [][]c={{true,false},{false,true}};
+               ScilabBoolean aMatrix = new ScilabBoolean(a);
+               ScilabBoolean bMatrix = new ScilabBoolean(b);
+               ScilabBoolean cMatrix = new ScilabBoolean(c);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
+               assert aMatrix.toString().equals("[%t, %f, %t ; %t, %t, %t]") == true;
+               assert cMatrix.toString().equals("[%t, %f ; %f, %t]") == true;
+       }
 
        @Test
-    public void compareStringTest() throws NullPointerException {
-        String [][]a={{"This","is","my","string"},{"and","I want to", "compare"," them"}};
-        String [][]b={{"This","is","my","string"},{"and","I want to", "compare"," them"}};
-        String [][]c={{"Wrong","string"},{"right","string"}};
-        ScilabString aMatrix = new ScilabString(a);
-        ScilabString bMatrix = new ScilabString(b);
-        ScilabString cMatrix = new ScilabString(c);
-        assert aMatrix.equals(bMatrix) == true;
-        assert bMatrix.equals(aMatrix) == true;
-        assert cMatrix.equals(aMatrix) == false;
-        assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
-        assert aMatrix.toString().equals("[\"This\", \"is\", \"my\", \"string\" ; \"and\", \"I want to\", \"compare\", \" them\"]") == true;
+       public void compareStringTest() throws NullPointerException {
+               String [][]a={{"This","is","my","string"},{"and","I want to", "compare"," them"}};
+               String [][]b={{"This","is","my","string"},{"and","I want to", "compare"," them"}};
+               String [][]c={{"Wrong","string"},{"right","string"}};
+               ScilabString aMatrix = new ScilabString(a);
+               ScilabString bMatrix = new ScilabString(b);
+               ScilabString cMatrix = new ScilabString(c);
+               assert aMatrix.equals(bMatrix) == true;
+               assert bMatrix.equals(aMatrix) == true;
+               assert cMatrix.equals(aMatrix) == false;
+               assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
+               assert aMatrix.toString().equals("[\"This\", \"is\", \"my\", \"string\" ; \"and\", \"I want to\", \"compare\", \" them\"]") == true;
                assert cMatrix.toString().equals("[\"Wrong\", \"string\" ; \"right\", \"string\"]") == true;
 
-    }
+       }
 
        @Test
-    public void compareListTest() throws NullPointerException {
-        ScilabList data = new ScilabList();
-        data.add(new ScilabDouble(2));
-        data.add(new ScilabDouble(51));
-        data.add(new ScilabString("hello"));
-        ScilabList data2 = new ScilabList();
-        data2.add(new ScilabDouble(2));
-        data2.add(new ScilabDouble(51));
-        data2.add(new ScilabString("hello"));
-        ScilabList data3 = new ScilabList();
-        data3.add(new ScilabDouble(2));
-        data3.add(new ScilabDouble(42));
-        data3.add(new ScilabBoolean(true));
-        data3.add(new ScilabString("hello"));
-        assert data.equals(data2) == true;
-        assert data.equals(data3) == false;
+       public void compareListTest() throws NullPointerException {
+               ScilabList data = new ScilabList();
+               data.add(new ScilabDouble(2));
+               data.add(new ScilabDouble(51));
+               data.add(new ScilabString("hello"));
+               ScilabList data2 = new ScilabList();
+               data2.add(new ScilabDouble(2));
+               data2.add(new ScilabDouble(51));
+               data2.add(new ScilabString("hello"));
+               ScilabList data3 = new ScilabList();
+               data3.add(new ScilabDouble(2));
+               data3.add(new ScilabDouble(42));
+               data3.add(new ScilabBoolean(true));
+               data3.add(new ScilabString("hello"));
+               assert data.equals(data2) == true;
+               assert data.equals(data3) == false;
                assert data.toString().equals("list([2.0],\n[51.0],\n[\"hello\"])") == true;
                assert data3.toString().equals("list([2.0],\n[42.0],\n[%t],\n[\"hello\"])") == true;
 
-    }
+       }
 }