summaryrefslogtreecommitdiffstats
path: root/scilab/modules/types
diff options
context:
space:
mode:
authorAllan CORNET <allan.cornet@scilab.org>2010-04-06 11:00:34 +0200
committerAllan CORNET <allan.cornet@scilab.org>2010-04-06 11:00:34 +0200
commit732a59a2e69d48df925ea2289e3923f5c328d42a (patch)
treeea4d0f5cf380344c0f989fcca95d718b1bd53f69 /scilab/modules/types
parent767cee6037a541be2c9b032d3e1fa7330951c71a (diff)
downloadscilab-732a59a2e69d48df925ea2289e3923f5c328d42a.zip
scilab-732a59a2e69d48df925ea2289e3923f5c328d42a.tar.gz
types module (to do update makefile)
Diffstat (limited to 'scilab/modules/types')
-rw-r--r--scilab/modules/types/.gitignore5
-rw-r--r--scilab/modules/types/Makefile.am91
-rw-r--r--scilab/modules/types/build.xml23
-rw-r--r--scilab/modules/types/changelog.txt4
-rw-r--r--scilab/modules/types/etc/types.quit0
-rw-r--r--scilab/modules/types/etc/types.start0
-rw-r--r--scilab/modules/types/license.txt9
-rw-r--r--scilab/modules/types/macros/buildmacros.bat11
-rw-r--r--scilab/modules/types/macros/buildmacros.sce16
-rw-r--r--scilab/modules/types/macros/cleanmacros.bat13
-rw-r--r--scilab/modules/types/readme.txt1
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabBoolean.java132
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabDouble.java119
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabInteger.java195
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabList.java55
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabMList.java68
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabString.java102
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabTList.java68
-rw-r--r--scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabType.java42
-rw-r--r--scilab/modules/types/src/java/types-JAVA.vcproj119
-rw-r--r--scilab/modules/types/version.xml11
21 files changed, 1084 insertions, 0 deletions
diff --git a/scilab/modules/types/.gitignore b/scilab/modules/types/.gitignore
new file mode 100644
index 0000000..bc3ddde
--- /dev/null
+++ b/scilab/modules/types/.gitignore
@@ -0,0 +1,5 @@
1#
2#generated .def files (windows)
3#
4types.def
5*.bak
diff --git a/scilab/modules/types/Makefile.am b/scilab/modules/types/Makefile.am
new file mode 100644
index 0000000..79dfa3f
--- /dev/null
+++ b/scilab/modules/types/Makefile.am
@@ -0,0 +1,91 @@
1#
2# Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3# Copyright (C) DIGITEO - 2010 - Allan CORNET
4#
5# This file must be used under the terms of the CeCILL.
6# This source file is licensed as described in the file COPYING, which
7# you should have received as part of this distribution. The terms
8# are also available at
9# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10#
11
12#### Target ######
13modulename=types
14
15
16#### types : Conf files ####
17libscitypes_la_rootdir = $(mydatadir)
18libscitypes_la_root_DATA = changelog.txt license.txt readme.txt version.xml
19
20
21#### types : init scripts ####
22libscitypes_la_etcdir = $(mydatadir)/etc
23libscitypes_la_etc_DATA = etc/types.quit \
24 etc/types.start
25
26include $(top_srcdir)/Makefile.incl.am
27
28
29TYPES_JNI_SOURCES =
30
31TYPES_C_SOURCES =
32
33TYPES_CPP_SOURCES =
34
35GIWS_WRAPPERS =
36
37if GIWS
38BUILT_SOURCES=giws
39endif
40
41
42GATEWAY_C_SOURCES =
43
44GATEWAY_CPP_SOURCES =
45
46libscitypes_la_CFLAGS=
47
48
49libscitypes_la_CPPFLAGS =
50
51# Without the types module
52libscitypes_disable_la_CFLAGS =
53
54TYPES_DISABLE_C_SOURCES =
55libscitypes_disable_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION) $(LD_FLAGS)
56libscitypes_disable_la_SOURCES = $(TYPES_DISABLE_C_SOURCES)
57
58pkglib_LTLIBRARIES = libscitypes-disable.la
59
60if GUI
61pkglib_LTLIBRARIES += libscitypes.la
62endif
63
64libscitypes_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION) $(LD_FLAGS) $(X_LIBS) $(X_EXTRA_LIBS)
65
66libscitypes_la_SOURCES = $(TYPES_C_SOURCES) $(TYPES_JNI_SOURCES) $(GATEWAY_C_SOURCES) $(GATEWAY_CPP_SOURCES) $(TYPES_CPP_SOURCES)
67
68# For the code check (splint)
69CHECK_SRC= $(TYPES_C_SOURCES) $(GATEWAY_C_SOURCES)
70INCLUDE_FLAGS = $(libscitypes_la_CFLAGS)
71
72
73#### SWIG Declaration ####
74SWIG_WRAPPERS =
75
76if SWIG
77BUILT_SOURCES=swig
78endif
79
80libscitypes_la_LIBADD = $(top_builddir)/modules/core/libscicore.la \
81$(top_builddir)/libs/MALLOC/libscimalloc.la \
82$(top_builddir)/modules/output_stream/libscioutput_stream.la
83
84
85#### types : gateway declaration ####
86libscitypes_la_sci_gatewaydir = $(mydatadir)/sci_gateway
87libscitypes_la_sci_gateway_DATA =
88
89if GUI
90USEANT=1
91endif
diff --git a/scilab/modules/types/build.xml b/scilab/modules/types/build.xml
new file mode 100644
index 0000000..aae4807
--- /dev/null
+++ b/scilab/modules/types/build.xml
@@ -0,0 +1,23 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2010 - DIGITEO - Allan CORNET
5 *
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 *
12 -->
13
14<project name="types" default="jar">
15
16 <import file="../../build.incl.xml"/>
17 <property name="library.name" value="${library.types.name}" />
18
19 <description>
20 Build the Scilab types module
21 </description>
22
23</project>
diff --git a/scilab/modules/types/changelog.txt b/scilab/modules/types/changelog.txt
new file mode 100644
index 0000000..0e1ae04
--- /dev/null
+++ b/scilab/modules/types/changelog.txt
@@ -0,0 +1,4 @@
1types (0.1-1) stable; urgency=medium
2
3 * First version of the module
4
diff --git a/scilab/modules/types/etc/types.quit b/scilab/modules/types/etc/types.quit
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scilab/modules/types/etc/types.quit
diff --git a/scilab/modules/types/etc/types.start b/scilab/modules/types/etc/types.start
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scilab/modules/types/etc/types.start
diff --git a/scilab/modules/types/license.txt b/scilab/modules/types/license.txt
new file mode 100644
index 0000000..46ae42e
--- /dev/null
+++ b/scilab/modules/types/license.txt
@@ -0,0 +1,9 @@
1Copyright:
2Copyright (c) 2010 - DIGITEO
3
4License:
5This module must be used under the terms of the CeCILL.
6This module file is licensed as described in the file COPYING, which
7you should have received as part of this distribution. The terms
8are also available at
9http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
diff --git a/scilab/modules/types/macros/buildmacros.bat b/scilab/modules/types/macros/buildmacros.bat
new file mode 100644
index 0000000..f9bd674
--- /dev/null
+++ b/scilab/modules/types/macros/buildmacros.bat
@@ -0,0 +1,11 @@
1
2rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3rem Copyright (C) 2009 - DIGITEO
4rem
5rem This file must be used under the terms of the CeCILL.
6rem This source file is licensed as described in the file COPYING, which
7rem you should have received as part of this distribution. The terms
8rem are also available at
9rem http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10
11@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit;
diff --git a/scilab/modules/types/macros/buildmacros.sce b/scilab/modules/types/macros/buildmacros.sce
new file mode 100644
index 0000000..590b940
--- /dev/null
+++ b/scilab/modules/types/macros/buildmacros.sce
@@ -0,0 +1,16 @@
1
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2010 - DIGITEO - Allan CORNET <allan.cornet@inria.fr>
4//
5// This file must be used under the terms of the CeCILL.
6// This source file is licensed as described in the file COPYING, which
7// you should have received as part of this distribution. The terms
8// are also available at
9// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10
11if (isdef('genlib') == %f) then
12 exec(SCI+'/modules/functions/scripts/buildmacros/loadgenlib.sce');
13end
14
15//genlib("typeslib","SCI/modules/types/macros",%f,%t);
16
diff --git a/scilab/modules/types/macros/cleanmacros.bat b/scilab/modules/types/macros/cleanmacros.bat
new file mode 100644
index 0000000..d8e26bf
--- /dev/null
+++ b/scilab/modules/types/macros/cleanmacros.bat
@@ -0,0 +1,13 @@
1
2rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3rem Copyright (C) 2009 - DIGITEO
4rem
5rem This file must be used under the terms of the CeCILL.
6rem This source file is licensed as described in the file COPYING, which
7rem you should have received as part of this distribution. The terms
8rem are also available at
9rem http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10
11@del *.bin 2>NUL
12@del lib 2>NUL
13@del names 2>NUL
diff --git a/scilab/modules/types/readme.txt b/scilab/modules/types/readme.txt
new file mode 100644
index 0000000..785eeec
--- /dev/null
+++ b/scilab/modules/types/readme.txt
@@ -0,0 +1 @@
README File
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabBoolean.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabBoolean.java
new file mode 100644
index 0000000..33d7cb9
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabBoolean.java
@@ -0,0 +1,132 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15/**
16 * This class provides a wrapping on the Scilab boolean datatype
17 */
18public class ScilabBoolean implements ScilabType {
19
20 /* the boolean data */
21 private boolean[][] data;
22
23 /**
24 * Create an empty object
25 */
26 public ScilabBoolean() {
27 data = null;
28 }
29
30 /**
31 * Create an object from an array of array of boolean
32 *
33 * @param data the array of boolean
34 */
35 public ScilabBoolean(boolean[][] data) {
36 this.data = data;
37 }
38
39 /**
40 * Create a scalar boolean from a boolean
41 *
42 * @param value the boolean
43 */
44 public ScilabBoolean(boolean value) {
45 this.data = new boolean[1][1];
46 this.data[0][0] = value;
47 }
48
49 /**
50 * Change the value with the provided data
51 *
52 * @param data array of boolean
53 */
54 public void setData(boolean[][] data) {
55 this.data = data;
56 }
57
58 /**
59 * Return the data
60 *
61 * @return the array of array of boolean
62 */
63 public boolean[][] getData() {
64 return data;
65 }
66
67 /**
68 * Return the height (number of element) of the stored data
69 *
70 * @return the height
71 */
72 public int getHeight() {
73 if (data == null) {
74 return 0;
75 }
76 return data.length;
77 }
78
79 /**
80 * Return the width (number of element) of the stored data
81 *
82 * @return the width
83 */
84 public int getWidth() {
85 if (data == null) {
86 return 0;
87 }
88 return data[0].length;
89 }
90
91 /**
92 * If it is empty / uninitialized
93 *
94 * @return true if empty
95 */
96 public boolean isEmpty(){
97 return (data == null);
98 }
99
100
101 /**
102 * Display the matrix
103 *
104 * @return the pretty print
105 */
106 public String toString() {
107 StringBuffer result = new StringBuffer();
108 if (isEmpty()) {
109 result.append("[]");
110 return result.toString();
111 }
112
113 result.append("[");
114 for (int i = 0 ; i < getHeight() ; ++i) {
115 for (int j = 0 ; j < getWidth() ; ++j) {
116 if (getData()[i][j] == true){
117 result.append("%t");
118 }else{
119 result.append("%f");
120 }
121 if (j != getWidth() - 1) {
122 result.append(", ");
123 }
124 }
125 if (i != getHeight() - 1) {
126 result.append(" ; ");
127 }
128 }
129 result.append("]");
130 return result.toString();
131 }
132}
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabDouble.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabDouble.java
new file mode 100644
index 0000000..ef80e2f
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabDouble.java
@@ -0,0 +1,119 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15/**
16 * This class provides a wrapping on the Scilab Double datatype<br />
17 * Note that double is the default datatype in Scilab
18 */
19public class ScilabDouble implements ScilabType {
20
21 private double[][] realPart;
22 private double[][] imaginaryPart;
23
24 public ScilabDouble() {
25 realPart = null;
26 imaginaryPart = null;
27 }
28
29 public ScilabDouble(double data) {
30 realPart = new double[1][1];
31 realPart[0][0] = data;
32 imaginaryPart = null;
33 }
34
35 public ScilabDouble(double realData, double imagData) {
36 realPart = new double[1][1];
37 realPart[0][0] = realData;
38 imaginaryPart = new double[1][1];
39 imaginaryPart[0][0] = imagData;
40 }
41
42 public ScilabDouble(double[][] data) {
43 realPart = data;
44 imaginaryPart = null;
45 }
46
47 public ScilabDouble(double[][] realData, double[][] imagData) {
48 realPart = realData;
49 imaginaryPart = imagData;
50 }
51
52 public boolean isEmpty() {
53 return (realPart == null && imaginaryPart == null);
54 }
55
56 public boolean isReal() {
57 return (imaginaryPart == null);
58 }
59
60 public double[][] getRealPart() {
61 return realPart;
62 }
63
64 public void setRealPart(double[][] realPart) {
65 this.realPart = realPart;
66 }
67
68 public double[][] getImaginaryPart() {
69 return imaginaryPart;
70 }
71
72 public void setImaginaryPart(double[][] imaginaryPart) {
73 this.imaginaryPart = imaginaryPart;
74 }
75
76 public int getHeight() {
77 if (isEmpty()) {
78 return 0;
79 }
80 return realPart.length;
81 }
82
83 public int getWidth() {
84 if (isEmpty()|| realPart.length == 0 ) {
85 return 0;
86 }
87
88 return realPart[0].length;
89 }
90
91 public String toString() {
92 StringBuffer result = new StringBuffer();
93 if (isEmpty()) {
94 result.append("[]");
95 return result.toString();
96 }
97
98 result.append("[");
99 for (int i = 0 ; i < getHeight() ; ++i) {
100 for (int j = 0 ; j < getWidth() ; ++j) {
101 if(isReal()) {
102 result.append(getRealPart()[i][j]);
103 }
104 else {
105 result.append(getRealPart()[i][j]+" + "+getImaginaryPart()[i][j]+" %i");
106 }
107 if (j != getWidth() - 1) {
108 result.append(", ");
109 }
110 }
111 if (i != getHeight() - 1) {
112 result.append(" ; ");
113 }
114 }
115 result.append("]");
116 return result.toString();
117 }
118
119}
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabInteger.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabInteger.java
new file mode 100644
index 0000000..9f406ca
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabInteger.java
@@ -0,0 +1,195 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Antoine ELIAS
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15/**
16 * This class provides a wrapping on the Scilab Integer datatype
17 */
18public class ScilabInteger implements ScilabType {
19
20 private Long[][] data;
21 private IntegerType prec;
22 private boolean bUnsigned;
23
24 public enum IntegerType{
25 /** Integer of size 8 */
26 TYPE8,
27 /** Integer of size 16 */
28 TYPE16,
29 /** Integer of size 32 */
30 TYPE32,
31 /** Integer of size 64 */
32 TYPE64
33 }
34
35 public ScilabInteger() {
36 data = null;
37 }
38
39 public ScilabInteger(byte[][] data, boolean bUnsigned) {
40 this.setData(data, bUnsigned);
41 }
42
43 public ScilabInteger(short[][] data, boolean bUnsigned) {
44 this.setData(data, bUnsigned);
45 }
46
47 public ScilabInteger(int[][] data, boolean bUnsigned) {
48 this.setData(data, bUnsigned);
49 }
50
51 public ScilabInteger(long[][] data, boolean bUnsigned) {
52 this.setData(data, bUnsigned);
53 }
54
55 public ScilabInteger(byte value) {
56 this.data = new Long[1][1];
57 this.data[0][0] = new Long(value);
58 }
59
60 public ScilabInteger(short value) {
61 this.data = new Long[1][1];
62 this.data[0][0] = new Long(value);
63 }
64
65 public ScilabInteger(int value) {
66 this.data = new Long[1][1];
67 this.data[0][0] = new Long(value);
68 }
69
70 public ScilabInteger(long value) {
71 this.data = new Long[1][1];
72 this.data[0][0] = new Long(value);
73 }
74
75 public void setData(byte[][] data, boolean bUnsigned) {
76 this.data = new Long[data.length][data[0].length];
77 prec = IntegerType.TYPE8;
78 this.bUnsigned = bUnsigned;
79 for(int i = 0 ; i < data.length ; i++) {
80 for(int j = 0 ; j < data[0].length ; j++) {
81 this.data[i][j] = new Long(data[i][j]);
82 }
83 }
84 }
85
86 public void setData(short[][] data, boolean bUnsigned) {
87 this.data = new Long[data.length][data[0].length];
88 prec = IntegerType.TYPE16;
89 this.bUnsigned = bUnsigned;
90 for(int i = 0 ; i < data.length ; i++) {
91 for(int j = 0 ; j < data[0].length ; j++) {
92 this.data[i][j] = new Long(data[i][j]);
93 }
94 }
95 }
96
97 public void setData(int[][] data, boolean bUnsigned) {
98 this.data = new Long[data.length][data[0].length];
99 prec = IntegerType.TYPE32;
100 this.bUnsigned = bUnsigned;
101 for(int i = 0 ; i < data.length ; i++) {
102 for(int j = 0 ; j < data[0].length ; j++) {
103 this.data[i][j] = new Long(data[i][j]);
104 }
105 }
106 }
107
108 public void setData(long[][] data, boolean bUnsigned) {
109 this.data = new Long[data.length][data[0].length];
110 prec = IntegerType.TYPE64;
111 this.bUnsigned = bUnsigned;
112 for(int i = 0 ; i < data.length ; i++) {
113 for(int j = 0 ; j < data[0].length ; j++) {
114 this.data[i][j] = new Long(data[i][j]);
115 }
116 }
117 }
118
119 public Long[][] getData() {
120 return data;
121 }
122
123 public IntegerType getPrec() {
124 return prec;
125 }
126
127 public boolean isUnsigned() {
128 return bUnsigned;
129 }
130
131 public int getHeight() {
132 if (data == null) {
133 return 0;
134 }
135 return data.length;
136 }
137
138 public int getWidth() {
139 if (data == null) {
140 return 0;
141 }
142 return data[0].length;
143 }
144
145 // int32(X), int8(x) , int16([x,x,x;x,x,x])
146 // uint32(X), uint8(x) , uint16([x,x,x;x,x,x])
147
148 public boolean isEmpty(){
149 return (data == null);
150 }
151
152 public String toString() {
153 StringBuffer result = new StringBuffer();
154
155
156 if (isEmpty()) {
157 result.append("int()");
158 return result.toString();
159 }
160
161 if (isUnsigned() ){
162 result.append("u");
163 }
164 result.append("int");
165 if (getPrec() == IntegerType.TYPE8){
166 result.append("8");
167 } else if (getPrec() == IntegerType.TYPE16){
168 result.append("16");
169 } else if (getPrec() == IntegerType.TYPE32){
170 result.append("32");
171 } else if (getPrec() == IntegerType.TYPE64){
172 result.append("64");
173 }
174
175 result.append("(");
176 for (int i = 0 ; i < getHeight() ; ++i) {
177 for (int j = 0 ; j < getWidth() ; ++j) {
178
179 result.append(getData()[i][j]);
180
181
182 if (j != getWidth() - 1) {
183 result.append(", ");
184 }
185 }
186 if (i != getHeight() - 1) {
187 result.append(" ; ");
188 }
189 }
190 result.append(")");
191
192 return result.toString();
193 }
194
195}
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabList.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabList.java
new file mode 100644
index 0000000..9a284f9
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabList.java
@@ -0,0 +1,55 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15import java.util.ArrayList;
16
17/**
18 * This class provides a wrapping on the Scilab List datatype
19 */
20public class ScilabList extends ArrayList<ScilabType> implements ScilabType {
21 public int getHeight() {
22 if (isEmpty()) {
23 return 0;
24 }
25 return 1;
26 }
27
28 public int getWidth() {
29 if (isEmpty()) {
30 return 0;
31 }
32 return size();
33 }
34
35
36 public String toString() {
37
38 StringBuffer result = new StringBuffer();
39 if (isEmpty()) {
40 result.append("list()");
41 return result.toString();
42 }
43
44 result.append("list(");
45 for (int i = 0 ; i < size() ; i++){
46 result.append(get(i).toString());
47 if (i != size() - 1) {
48 result.append(",\n");
49 }
50 }
51 result.append(")");
52
53 return result.toString();
54 }
55}
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabMList.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabMList.java
new file mode 100644
index 0000000..54a3f53
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabMList.java
@@ -0,0 +1,68 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15import java.util.ArrayList;
16
17/**
18 * This class provides a wrapping on the Scilab Mlist datatype
19 */
20public class ScilabMList extends ArrayList<ScilabType> implements ScilabType {
21
22 public ScilabMList() {
23 super();
24 }
25
26 public ScilabMList(String []types) {
27 super();
28 String [][] typesData = new String[1][types.length];
29 typesData[0] = types;
30 add(new ScilabString(typesData));
31 }
32
33 public int getHeight() {
34 if (isEmpty()) {
35 return 0;
36 }
37 return 1;
38 }
39
40 public int getWidth() {
41 if (isEmpty()) {
42 return 0;
43 }
44 return size();
45 }
46
47
48 public String toString() {
49
50 StringBuffer result = new StringBuffer();
51 if (isEmpty()) {
52 result.append("mlist()");
53 return result.toString();
54 }
55
56 result.append("mlist");
57 for (int i = 0 ; i < size() ; i++){
58 result.append(get(i).toString());
59 if (i != size() - 1) {
60 result.append(", ");
61 }
62
63 }
64 result.append(")");
65
66 return result.toString();
67 }
68}
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabString.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabString.java
new file mode 100644
index 0000000..4c01a0a
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabString.java
@@ -0,0 +1,102 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15/**
16 * This class provides a wrapping on the Scilab String datatype
17 */
18public class ScilabString implements ScilabType {
19
20 private String[][] data;
21
22 public ScilabString() {
23 data = null;
24 }
25
26 public ScilabString(String[][] data) {
27 this.data = data;
28 }
29
30 public ScilabString(String[] data) {
31 if(data == null || data.length == 0) {
32 this.data = new String[1][1];
33 this.data[0][0] = "";
34 } else {
35 this.data = new String[1][data.length];
36 for (int i = 0 ; i < data.length ; i++){
37 this.data[0][i] = data[i] ;
38 }
39 }
40 }
41
42 public ScilabString(String string) {
43 if(string == null) {
44 System.err.println("string == null");
45 }
46 this.data = new String[1][1];
47 this.data[0][0] = string;
48 }
49
50 public void setData(String[][] data) {
51 this.data = data;
52 }
53
54 public String[][] getData() {
55 return data;
56 }
57
58 public int getHeight() {
59 if (data == null) {
60 return 0;
61 }
62 return data.length;
63 }
64
65 public int getWidth() {
66 if (data == null) {
67 return 0;
68 }
69 return data[0].length;
70 }
71
72 public boolean isEmpty(){
73 return (data == null);
74 }
75
76 public String toString() {
77 StringBuffer result = new StringBuffer();
78 if (isEmpty()) {
79 result.append("[]");
80 return result.toString();
81 }
82
83 result.append("[");
84 for (int i = 0 ; i < getHeight() ; ++i) {
85 for (int j = 0 ; j < getWidth() ; ++j) {
86
87 result.append('"');
88 result.append(getData()[i][j]);
89 result.append('"');
90
91 if (j != getWidth() - 1) {
92 result.append(", ");
93 }
94 }
95 if (i != getHeight() - 1) {
96 result.append(" ; ");
97 }
98 }
99 result.append("]");
100 return result.toString();
101 }
102}
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabTList.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabTList.java
new file mode 100644
index 0000000..4b69926
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabTList.java
@@ -0,0 +1,68 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15import java.util.ArrayList;
16
17/**
18 * This class provides a wrapping on the Scilab TList datatype
19 */
20public class ScilabTList extends ArrayList<ScilabType> implements ScilabType {
21
22 public ScilabTList() {
23 super();
24 }
25
26 public ScilabTList(String []types) {
27 super();
28 String [][] typesData = new String[1][types.length];
29 typesData[0] = types;
30 add(new ScilabString(typesData));
31 }
32
33 public int getHeight() {
34 if (isEmpty()) {
35 return 0;
36 }
37 return 1;
38 }
39
40 public int getWidth() {
41 if (isEmpty()) {
42 return 0;
43 }
44 return size();
45 }
46
47
48 public String toString() {
49
50 StringBuffer result = new StringBuffer();
51 if (isEmpty()) {
52 result.append("tlist()");
53 return result.toString();
54 }
55
56 result.append("tlist(");
57 for (int i = 0 ; i < size() ; i++){
58 result.append(get(i).toString());
59 if (i != size() - 1) {
60 result.append(", ");
61 }
62
63 }
64 result.append(")");
65
66 return result.toString();
67 }
68}
diff --git a/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabType.java b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabType.java
new file mode 100644
index 0000000..9abd5da
--- /dev/null
+++ b/scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabType.java
@@ -0,0 +1,42 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13package org.scilab.modules.types.scilabTypes;
14
15import java.io.Serializable;
16
17/**
18 * This interface specifies what is a Scilab types
19 */
20public interface ScilabType extends Serializable, Cloneable {
21
22 /**
23 * Return the width (number of elements) of the stored data
24 *
25 * @return the width
26 */
27 public int getWidth();
28
29 /**
30 * Return the height (number of elements) of the stored data
31 *
32 * @return the height
33 */
34 public int getHeight();
35
36 /**
37 * Display the data
38 *
39 * @return the pretty print
40 */
41 public String toString();
42}
diff --git a/scilab/modules/types/src/java/types-JAVA.vcproj b/scilab/modules/types/src/java/types-JAVA.vcproj
new file mode 100644
index 0000000..cf32536
--- /dev/null
+++ b/scilab/modules/types/src/java/types-JAVA.vcproj
@@ -0,0 +1,119 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="9,00"
5 Name="types-Ant"
6 ProjectGUID="{ABCB724E-8534-4420-AC12-7C33A606ABA3}"
7 RootNamespace="types-Ant"
8 Keyword="MakeFileProj"
9 TargetFrameworkVersion="0"
10 >
11 <Platforms>
12 <Platform
13 Name="Win32"
14 />
15 <Platform
16 Name="x64"
17 />
18 </Platforms>
19 <ToolFiles>
20 </ToolFiles>
21 <Configurations>
22 <Configuration
23 Name="Debug|Win32"
24 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
25 IntermediateDirectory="$(ConfigurationName)"
26 ConfigurationType="0"
27 >
28 <Tool
29 Name="VCNMakeTool"
30 BuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant&#x0D;&#x0A;"
31 ReBuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;call ant&#x0D;&#x0A;"
32 CleanCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;&#x0D;&#x0A;"
33 Output=""
34 PreprocessorDefinitions="WIN32;_DEBUG"
35 IncludeSearchPath=""
36 ForcedIncludes=""
37 AssemblySearchPath=""
38 ForcedUsingAssemblies=""
39 CompileAsManaged=""
40 />
41 </Configuration>
42 <Configuration
43 Name="Debug|x64"
44 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
45 IntermediateDirectory="$(ConfigurationName)"
46 ConfigurationType="0"
47 >
48 <Tool
49 Name="VCNMakeTool"
50 BuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant&#x0D;&#x0A;"
51 ReBuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;call ant&#x0D;&#x0A;"
52 CleanCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;&#x0D;&#x0A;"
53 Output=""
54 PreprocessorDefinitions="WIN32;_DEBUG"
55 IncludeSearchPath=""
56 ForcedIncludes=""
57 AssemblySearchPath=""
58 ForcedUsingAssemblies=""
59 CompileAsManaged=""
60 />
61 </Configuration>
62 <Configuration
63 Name="Release|Win32"
64 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
65 IntermediateDirectory="$(ConfigurationName)"
66 ConfigurationType="0"
67 >
68 <Tool
69 Name="VCNMakeTool"
70 BuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant&#x0D;&#x0A;"
71 ReBuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;call ant&#x0D;&#x0A;"
72 CleanCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;&#x0D;&#x0A;"
73 Output=""
74 PreprocessorDefinitions="WIN32;NDEBUG"
75 IncludeSearchPath=""
76 ForcedIncludes=""
77 AssemblySearchPath=""
78 ForcedUsingAssemblies=""
79 CompileAsManaged=""
80 />
81 </Configuration>
82 <Configuration
83 Name="Release|x64"
84 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
85 IntermediateDirectory="$(ConfigurationName)"
86 ConfigurationType="0"
87 >
88 <Tool
89 Name="VCNMakeTool"
90 BuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant&#x0D;&#x0A;"
91 ReBuildCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;call ant&#x0D;&#x0A;"
92 CleanCommandLine="set JAVA_HOME=$(SolutionDir)\java\jdk&#x0D;&#x0A;set PATH=$(SolutionDir)\java\ant\bin;%PATH%;&#x0D;&#x0A;cd ..\..&#x0D;&#x0A;call ant clean&#x0D;&#x0A;&#x0D;&#x0A;"
93 Output=""
94 PreprocessorDefinitions="WIN32;NDEBUG"
95 IncludeSearchPath=""
96 ForcedIncludes=""
97 AssemblySearchPath=""
98 ForcedUsingAssemblies=""
99 CompileAsManaged=""
100 />
101 </Configuration>
102 </Configurations>
103 <References>
104 </References>
105 <Files>
106 <Filter
107 Name="Source Files"
108 Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
109 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
110 >
111 </Filter>
112 <File
113 RelativePath="..\..\build.xml"
114 >
115 </File>
116 </Files>
117 <Globals>
118 </Globals>
119</VisualStudioProject>
diff --git a/scilab/modules/types/version.xml b/scilab/modules/types/version.xml
new file mode 100644
index 0000000..3e7889b
--- /dev/null
+++ b/scilab/modules/types/version.xml
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2010 - DIGITEO
5 *
6 * This file is distributed under the same license as the Scilab package.
7 -->
8<!DOCTYPE MODULE_VERSION SYSTEM "../core/xml/version.dtd">
9<MODULE_VERSION name="types">
10<VERSION major="1" minor="0" maintenance="0" revision="0" string="unstable-git" />
11</MODULE_VERSION>