Update functions and help pages with new cell format. 11/17111/4
Charlotte HECQUET [Wed, 26 Aug 2015 09:15:36 +0000 (11:15 +0200)]
Change-Id: I3a2ce5b3a08baf39acad771a5bb1f27547c78454

17 files changed:
scilab/modules/ast/includes/types/struct.hxx
scilab/modules/compatibility_functions/macros/char.sci
scilab/modules/core/tests/unit_tests/typeof.dia.ref
scilab/modules/core/tests/unit_tests/typeof.tst
scilab/modules/data_structures/help/en_US/typeof.xml
scilab/modules/data_structures/help/ja_JP/typeof.xml
scilab/modules/data_structures/help/pt_BR/typeof.xml
scilab/modules/data_structures/help/ru_RU/typeof.xml
scilab/modules/data_structures/macros/%lss_typeof.sci [deleted file]
scilab/modules/data_structures/macros/%r_typeof.sci [deleted file]
scilab/modules/data_structures/macros/iscellstr.sci
scilab/modules/elementary_functions/macros/cat.sci
scilab/modules/elementary_functions/macros/permute.sci
scilab/modules/io/macros/%_sodload.sci
scilab/modules/linear_algebra/macros/squeeze.sci
scilab/modules/output_stream/macros/prettyprint.sci
scilab/modules/types/sci_gateway/cpp/sci_typeof.cpp

index a276431..38bdd3e 100644 (file)
@@ -78,13 +78,13 @@ public :
     /* return type as string ( double, int, cell, list, ... )*/
     virtual std::wstring        getTypeStr()
     {
-        return L"st";
+        return L"struct";
     }
     /* return type as short string ( s, i, ce, l, ... )*/
     virtual std::wstring        getShortTypeStr()
     {
         return L"st";
-    };
+    }
     virtual bool                isContainer(void)
     {
         return true;
index a28821d..9901a9a 100644 (file)
@@ -30,48 +30,48 @@ function y=char(varargin)
     if rhs==1 then
         if typeof(varargin(1))=="ce" then // input argument is a cell of characters arrays
             c=varargin(1)
-            lst=c.entries
             if size(c)==1 then // cell contains one element
-                if typeof(lst)=="hypermat" then // cell elements are characters arrays
-                    if type(lst.entries)==10 then
-                        t=emptystr(size(lst,1),1)
-                        lst=matrix(lst,[size(lst,1),size(lst,"*")/size(lst,1)])
+                lst = c{1};
+                if size(lst, 2) > 2 then
+                    if type(lst) == 10 then
+                        t = emptystr(size(lst,1),1);
+                        lst = matrix(lst,[size(lst,1),size(lst,"*")/size(lst,1)]);
                         for j=1:size(lst,2)
-                            t=t+lst(:,j)
+                            t = t+lst(:,j);
                         end
-                        y=[y;t]
+                        y = [y;t];
                     else
                         error(msprintf(gettext("%s: Wrong type for input argument: Cell elements must be character arrays.\n"),"char"));
                     end
-                elseif type(lst)==10 then // cell elements are a string matrix
-                    t=emptystr(size(lst,1),1)
+                elseif type(lst) == 10 then // cell elements are a string matrix
+                    t = emptystr(size(lst,1),1);
                     for k=1:size(lst,2)
-                        t=t+lst(:,k)
+                        t = t+lst(:,k);
                     end
-                    y=[y,t]
+                    y = [y,t];
                 else
                     error(msprintf(gettext("%s: Wrong type for input argument: Cell elements must be character arrays.\n"),"char"));
                 end
             else // cell contains more than one element
-                for i=1:size(lst)
-                    if typeof(lst(i))=="hypermat" then
-                        if type(lst(i).entries)==10 then
-                            ctemp=lst(i)
-                            t=emptystr(size(ctemp,1),1)
-                            ctemp=matrix(ctemp,[size(ctemp,1),size(ctemp,"*")/size(ctemp,1)])
+                for i=1:size(c, "*")
+                    if size(c{i}, 2) > 2 then
+                        if type(c{i}) == 10 then
+                            ctemp = c{i};
+                            t = emptystr(size(ctemp,1),1);
+                            ctemp = matrix(ctemp,[size(ctemp,1),size(ctemp,"*")/size(ctemp,1)]);
                             for j=1:size(ctemp,2)
-                                t=t+ctemp(:,j)
+                                t = t+ctemp(:,j);
                             end
-                            y=[y;t]
+                            y = [y;t];
                         else
                             error(msprintf(gettext("%s: Wrong type for input argument: Cell elements must be character arrays.\n"),"char"));
                         end
-                    elseif type(lst(i))==10 then
-                        t=emptystr(size(lst(i),1),1)
-                        for k=1:size(lst(i),2)
-                            t=t+lst(i)(:,k)
+                    elseif type(c{i}) == 10 then
+                        t = emptystr(size(c{i},1),1);
+                        for k=1:size(c{i},2)
+                            t = t+c{i}(:,k);
                         end
-                        y=[y;t]
+                        y = [y;t];
                     else
                         error(msprintf(gettext("%s: Wrong type for input argument: Cell elements must be character arrays.\n"),"char"));
                     end
@@ -79,24 +79,24 @@ function y=char(varargin)
             end
             // Add blank at the length of strings
             bl=" "
-            maxstr=max(length(y))
+            maxstr = max(length(y));
             for i=1:size(y,"*")
-                nb_bl=maxstr-length(y(i))
+                nb_bl = maxstr-length(y(i));
                 if nb_bl>0 then
-                    y(i)=y(i)+part(bl,ones(1,nb_bl))
+                    y(i) = y(i)+part(bl,ones(1,nb_bl));
                 end
             end
-        elseif type(varargin(1))==1|type(varargin(1))==8 then // Input is a matrix of integers (or reals)
-            y=asciimat(varargin(1))
-        elseif type(varargin(1))==10 then // Input is a matrix of strings
+        elseif (type(varargin(1))==1|type(varargin(1))==8) & size(varargin(1),2)<3 then // Input is a matrix of integers (or reals)
+            y = asciimat(varargin(1));
+        elseif type(varargin(1))==10 & size(varargin(1),2)<3 then // Input is a matrix of strings
             for i=1:size(varargin(1),1)
-                y(i)=strcat(varargin(1)(i,:))
+                y(i) = strcat(varargin(1)(i,:));
             end
-        elseif typeof(varargin(1))=="hypermat" then // Input is a hypermatrix of strings
-            if type(varargin(1).entries)==10 then
-                y=varargin(1)
-            elseif type(varargin(1).entries)==1|type(varargin(1).entries)==8 then // Input is a hypermatrix of integers (or reals)
-                y=asciimat(varargin(1))
+        elseif size(varargin(1), 2) > 2 then
+            if type(varargin(1)) == 10 then
+                y=varargin(1);
+            elseif type(varargin(1))==1|type(varargin(1))==8 then // Input is a hypermatrix of integers (or reals)
+                y=asciimat(varargin(1));
             else
                 error(msprintf(gettext("%s: This feature has not been implemented.\n"),"char"));
             end
@@ -106,36 +106,36 @@ function y=char(varargin)
         // More than one input argument
     elseif rhs > 1 then
         for i=1:size(varargin)
-            if typeof(varargin(i))=="hypermat" then // Input sti is a hypermatrix of strings
+            if size(varargin(i), 2) > 2 then
                 lst=varargin(i)
-                if type(lst.entries)==10 then
-                    t=emptystr(size(lst,1),1)
-                    lst=matrix(lst,[size(lst,1),size(lst,"*")/size(lst,1)])
+                if type(lst) == 10 then
+                    t = emptystr(size(lst,1),1);
+                    lst = matrix(lst,[size(lst,1),size(lst,"*")/size(lst,1)]);
                     for j=1:size(lst,2)
-                        t=t+lst(:,j)
+                        t = t+lst(:,j);
                     end
-                    y=[y;t]
+                    y = [y;t];
                 else
                     error(msprintf(gettext("%s: Wrong type for input arguments: String expected.\n"),"char"));
                 end
             elseif type(varargin(i))==10 then // Input sti is a matrix of strings
-                lst=varargin(i)
-                t=emptystr(size(lst,1),1)
+                lst = varargin(i);
+                t = emptystr(size(lst,1),1);
                 for k=1:size(lst,2)
-                    t=t+lst(:,k)
+                    t = t+lst(:,k);
                 end
-                y=[y;t]
+                y = [y;t];
             else
                 error(msprintf(gettext("%s: Wrong type for input arguments: String expected.\n"),"char"));
             end
         end
         // Add blanks at the length of strings
         bl=" "
-        maxstr=max(length(y))
+        maxstr = max(length(y))
         for i=1:size(y,"*")
-            nb_bl=maxstr-length(y(i))
+            nb_bl = maxstr-length(y(i));
             if nb_bl>0 then
-                y(i)=y(i)+part(bl,ones(1,nb_bl))
+                y(i) = y(i)+part(bl,ones(1,nb_bl));
             end
         end
     end
index a4e4d87..e7cac11 100644 (file)
@@ -23,9 +23,6 @@ assert_checkequal(typeof("s"=="s"),"boolean");
 assert_checkequal(typeof(sparse([0,1,0,1:1,0,1,0])),"sparse");
 // boolean sparse
 assert_checkequal(typeof(sparse([1,1;2,2;3,3],[%t,%t,%t])),"boolean sparse");
-// Matlab sparse
-X=sparse(rand(2,2)); Y=mtlb_sparse(X);
-assert_checkequal(typeof(Y),"Matlab sparse");
 // int
 assert_checkequal(typeof(int8(1:4)),"int8");
 assert_checkequal(typeof(uint8(1:4)),"uint8");
@@ -63,7 +60,7 @@ x=lusolve(h,b);a*x-b;
 ludel(h);
 assert_checkequal(typeof(h),"pointer");
 // size implicit
-assert_checkequal(typeof(1:1:$), "size implicit");
+assert_checkequal(typeof(1:1:$), "implicitlist");
 // list
 assert_checkequal(typeof(list(1,2)),"list");
 t = tlist(["listtype","field1","field2"], [], []);
@@ -85,11 +82,6 @@ l1 = uiCreateNode("CONST_m","default","");
 assert_checkequal(typeof(l1),"uitree");
 tree = uiCreateTree(l1);
 assert_checkequal(typeof(tree),"uitree");
-// hypermat
-assert_checkequal(typeof(hypermat([2 3 2 2],1:24)),"hypermat");
-A=[1,2,3;4,5,6];
-A(:,:,2)=[1,2,3;4,5,6];
-assert_checkequal(typeof(A),"hypermat");
 // fptr
 assert_checkequal(typeof(abs),"fptr");
 // cell
index 0f44792..4adef52 100644 (file)
@@ -29,10 +29,6 @@ assert_checkequal(typeof(sparse([0,1,0,1:1,0,1,0])),"sparse");
 // boolean sparse
 assert_checkequal(typeof(sparse([1,1;2,2;3,3],[%t,%t,%t])),"boolean sparse");
 
-// Matlab sparse
-X=sparse(rand(2,2)); Y=mtlb_sparse(X);
-assert_checkequal(typeof(Y),"Matlab sparse");
-
 // int
 assert_checkequal(typeof(int8(1:4)),"int8");
 assert_checkequal(typeof(uint8(1:4)),"uint8");
@@ -76,7 +72,7 @@ ludel(h);
 assert_checkequal(typeof(h),"pointer");
 
 // size implicit
-assert_checkequal(typeof(1:1:$), "size implicit");
+assert_checkequal(typeof(1:1:$), "implicitlist");
 
 // list
 assert_checkequal(typeof(list(1,2)),"list");
@@ -101,12 +97,6 @@ assert_checkequal(typeof(l1),"uitree");
 tree = uiCreateTree(l1);
 assert_checkequal(typeof(tree),"uitree");
 
-// hypermat
-assert_checkequal(typeof(hypermat([2 3 2 2],1:24)),"hypermat");
-A=[1,2,3;4,5,6];
-A(:,:,2)=[1,2,3;4,5,6];
-assert_checkequal(typeof(A),"hypermat");
-
 // fptr
 assert_checkequal(typeof(abs),"fptr");
 
index 21c346e..2021df9 100644 (file)
@@ -2,11 +2,11 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA
- * 
+ *
  * 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.1-en.txt
  *
  -->
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"hypermat"</term>
-                <listitem>
-                    <para>
-                        if <varname>object</varname> is a <link linkend="hypermatrices">hypermatrix</link> (<literal>N</literal>-dimension array with <literal><![CDATA[N<=3]]></literal>.
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
                 <term>"st"</term>
                 <listitem>
                     <para>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"size implicit"</term>
+                <term>"implicitlist"</term>
                 <listitem>
                     <para>
                         if <varname>object</varname> is a size implicit polynomial used for indexing. This a purely internal value.
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 typeof(1)
 typeof(poly(0,'x'))
+
 typeof(1/poly(0,'x'))
 typeof(%t)
+
 w=sprand(100,100,0.001);
 typeof(w)
 typeof(w==w)
+
 deff('y=f(x)','y=2*x');
 typeof(f)
+
 L=tlist(['V','a','b'],18,'Scilab');
 typeof(L)
+
 typeof(corelib)
  ]]></programlisting>
     </refsection>
index 3cfb86b..51fb98f 100644 (file)
@@ -2,11 +2,11 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA
- * 
+ *
  * 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.1-en.txt
  *
  -->
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"hypermat"</term>
-                <listitem>
-                    <para>
-                        オブジェクトがハイパー行列の場合(N &gt;=3 のN次元配列).
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
                 <term>"st"</term>
                 <listitem>
                     <para>オブジェクトが構造体配列の場合.</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"size implicit"</term>
+                <term>"implicitlist"</term>
                 <listitem>
                     <para>
                         オブジェクトが
     </refsection>
     <refsection>
         <title>例</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 typeof(1)
 typeof(poly(0,'x'))
 typeof(1/poly(0,'x'))
index 5ced03a..df43312 100644 (file)
@@ -2,11 +2,11 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA
- * 
+ *
  * 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.1-en.txt
  *
  -->
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"hypermat"</term>
-                <listitem>
-                    <para>se o objeto é uma hipermatriz (array N-dimensional N
-                        &gt;=3).
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
                 <term>"st"</term>
                 <listitem>
                     <para>se o objeto é um array de estrutura</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"size implicit"</term>
+                <term>"implicitlist"</term>
                 <listitem>
                     <para>se o objeto é um polinômio de tamanho implícito para
                         indexação.
     </refsection>
     <refsection>
         <title>Exemplos</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 typeof(1)
 typeof(poly(0,'x'))
 
index 9e1e0e7..ccc30bd 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"hypermat"</term>
-                <listitem>
-                    <para>
-                        если <varname>object</varname> - <link linkend="hypermatrices">гиперматрица</link> (<literal>N</literal>-мерный массив <literal><![CDATA[N<=3]]></literal>.
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
                 <term>"st"</term>
                 <listitem>
                     <para>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>"size implicit"</term>
+                <term>"implicitlist"</term>
                 <listitem>
                     <para>
                         если <varname>object</varname> - размер неявного полинома, используемый для индексации. Это чисто внутреннее значение.
diff --git a/scilab/modules/data_structures/macros/%lss_typeof.sci b/scilab/modules/data_structures/macros/%lss_typeof.sci
deleted file mode 100644 (file)
index c1f359e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2014 - Scilab Enterprises - Cedric Delamarre
-//
-// 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
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-
-function s = %lss_typeof(x)
-    s = "state-space";
-endfunction
diff --git a/scilab/modules/data_structures/macros/%r_typeof.sci b/scilab/modules/data_structures/macros/%r_typeof.sci
deleted file mode 100644 (file)
index cf0ce89..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2014 - Scilab Enterprises - Cedric Delamarre
-//
-// 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
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-
-function s = %r_typeof(x)
-    s = "rational";
-endfunction
index 2f27fc2..80601d1 100644 (file)
@@ -21,7 +21,7 @@ function   bool=iscellstr(c)
             if typeof(c)=="ce"
                 bool=%T;
                 for i=1:size(c,"*")
-                    if typeof(c(i).entries)<>"string" then
+                    if typeof(c{i})<>"string" then
                         bool=%F;
                         break
                     end
index 047aee0..cda21d9 100644 (file)
@@ -120,7 +120,7 @@ function  y = cat(dims, varargin)
             lj = size(varargin(j),"*")/prod(sizevarless(j));
             if typeof(permutevarj)=="ce" then
                 for k=1+lj*(i-1):lj*i
-                    ytemp(size(ytemp,"*")+1).entries = permutevarj(k).entries;
+                    ytemp{size(ytemp,"*")+1} = permutevarj{k};
                 end
             else
                 ytemp= [ytemp (permutevarj(1+lj*(i-1):lj*i)).'];
@@ -146,7 +146,7 @@ function  y = cat(dims, varargin)
         if typeof(ytemp)=="ce"
             ceindex = (1:ydimsize*prodxdimless)+ydimsize*prodxdimless*(i);
             for k=1:size(index,"*")
-                y(index(k)).entries = ytemp(ceindex(k)).entries;
+                y{index(k)} = ytemp{ceindex(k)};
             end
         else
             y(index) = ytemp((1:ydimsize*prodxdimless)+ydimsize*prodxdimless*(i));
index b23ec93..e177b6a 100644 (file)
@@ -67,10 +67,11 @@ function y = permute(x, dims)
     execstr("clear "+strsubst(xlist, ",", " "))
 
     // Permutation
-    if typeof(x) == "ce"
-        y = x
-        y.dims = int32(s)
-        y(LI2).entries = x(LI).entries
+    if typeof(x) == "ce" then
+        y = cell(s);
+        for i=1:size(LI2,2)
+            y{LI2(i)} = x{LI(i)};
+        end
     else
         y(LI2) = x(LI)
         y = matrix(y, s)
index 64ac51c..63e4ea1 100644 (file)
@@ -36,7 +36,7 @@ function varargout = %_sodload(%__varnameList__)
 
     function varValue = parseList(varValue)
 
-        if or(typeof(varValue)==["cell","st"]) then
+        if or(typeof(varValue)==["ce","st"]) then
             if typeof(varValue)=="st" then
                 fieldNames = fieldnames(varValue);
             else
index 9656851..38aa40f 100644 (file)
@@ -21,7 +21,7 @@ function A = squeeze(A)
     // ------------------------------------------------------------
 
     Dims=size(A);
-    if or(size(Dims,'*') > 2 || typeof(A)==["cell","st"]) then
+    if or(size(Dims,"*") > 2 || typeof(A)==["ce","st"]) then
         Dims=size(A);
         newDims = Dims(Dims <> 1);
         if size(newDims,"*") < 2 then
index d35009d..706d5f1 100644 (file)
@@ -194,7 +194,7 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
         select a1(1)
             //Cell type
         case "ce" then
-            dim = double(a.dims);
+            dim = double(size(a));
             L = length(dim);
             if L >= 3 then
                 str = unknown_type("ce",a,exportFormat);
@@ -203,7 +203,7 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
             str = emptystr(dim(1),dim(2));
             for i = 1:dim(1) do
                 for j = 1:dim(2) do
-                    str(i,j) = prettyprint(a(i,j).entries,exportFormat,delimiter,%F,%F);
+                    str(i,j) = prettyprint(a{i,j},exportFormat,delimiter,%F,%F);
                 end
             end
         else
@@ -593,4 +593,4 @@ function str = unknown_type(typ,a,exportFormat)
     catch
         error(msprintf(gettext("%s: Type %s is not handled : Define the function %s2%s."),"prettyprint",typ,typ,exportFormat))
     end
-endfunction
\ No newline at end of file
+endfunction
index 7e817e4..64e2888 100644 (file)
@@ -35,15 +35,25 @@ types::Function::ReturnValue sci_typeof(types::typed_list &in, int _iRetCount, t
     // Old typeof call
     if (in.size() == 1)
     {
-        // calls the overload if it exists.
-        if (in[0]->isList())
+        // for compatibilities with scilab 5 (cell and struct was tlist)
+        if (in[0]->isStruct() || in[0]->isCell())
         {
-            std::wstring wstFuncName = L"%"  + in[0]->getShortTypeStr() + L"_typeof";
-            types::InternalType *pIT = symbol::Context::getInstance()->get(symbol::Symbol(wstFuncName));
-            if (pIT)
+            out.push_back(new types::String(in[0]->getShortTypeStr().c_str()));
+            return types::Function::OK;
+        }
+
+        // Special cases for rational and state-space list
+        if (in[0]->isTList())
+        {
+            if (in[0]->getShortTypeStr() == L"r")
+            {
+                out.push_back(new types::String(L"rational"));
+                return types::Function::OK;
+            }
+            else if (in[0]->getShortTypeStr() == L"lss")
             {
-                ast::ExecVisitor exec;
-                return Overload::call(wstFuncName, in, _iRetCount, out, &exec);
+                out.push_back(new types::String(L"state-space"));
+                return types::Function::OK;
             }
         }