summaryrefslogtreecommitdiffstats
path: root/scilab/modules/data_structures/macros/struct.sci
diff options
context:
space:
mode:
authorantoine ELIAS <antoine.elias@scilab.org>2010-09-22 10:33:28 +0200
committerBruno JOFRET <bruno.jofret@scilab.org>2010-09-22 14:45:49 +0200
commit1790f0f6f7067ce61b0984f58aefd7ad0de87947 (patch)
treee3d3017d8f7c892b9028c67e9ca924be509ad8fd /scilab/modules/data_structures/macros/struct.sci
parent3cc10243fef3a96ba20cac2d1928482850d4a3dd (diff)
downloadscilab-1790f0f6f7067ce61b0984f58aefd7ad0de87947.zip
scilab-1790f0f6f7067ce61b0984f58aefd7ad0de87947.tar.gz
add isfile and with_module functions
Change-Id: I2ef8ef0d4e3eb582b792a2195a6551b71f44850e
Diffstat (limited to 'scilab/modules/data_structures/macros/struct.sci')
-rw-r--r--scilab/modules/data_structures/macros/struct.sci77
1 files changed, 0 insertions, 77 deletions
diff --git a/scilab/modules/data_structures/macros/struct.sci b/scilab/modules/data_structures/macros/struct.sci
deleted file mode 100644
index b147071..0000000
--- a/scilab/modules/data_structures/macros/struct.sci
+++ /dev/null
@@ -1,77 +0,0 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) ????-2008 - INRIA - Vincent COUVERT
3//
4// This file must be used under the terms of the CeCILL.
5// This source file is licensed as described in the file COPYING, which
6// you should have received as part of this distribution. The terms
7// are also available at
8// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9
10
11function s=struct(varargin)
12// Equivalent for Matlab struct function
13
14rhs=argn(2)
15
16fields=["st","dims"];
17
18if rhs==0 then
19 // No Matlab equivalent
20 s=mlist(fields,int32([0,0]))
21 return
22end
23
24if floor(rhs/2)*2<>rhs then
25 error(msprintf(gettext("%s: Wrong number of input argument(s) : an even number is expected.\n"),"struct"));
26end
27
28nbfields=size(varargin)/2
29
30dims=[]
31for kf=1:2:size(varargin)
32 if varargin(kf)=="dims" then
33 error(msprintf(gettext("%s: ''dims'' can not be used as a field name.\n"),"struct"));
34 end
35 if or(varargin(kf)==fields(2:$)) then
36 error(msprintf(gettext("%s: field name ''%s'' defined twice.\n"),"struct",varargin(kf)));
37 end
38 fields=[fields varargin(kf)]
39end
40
41dims=[1 1]
42// Search struct size
43for kf=2:2:size(varargin)
44 if typeof(varargin(kf))=="ce" then
45 if or(double(varargin(kf).dims)<>[1 1]) then
46 dims=varargin(kf).dims
47 break
48 end
49 end
50end
51s=mlist(fields,int32(dims))
52
53// Search if one value is a scalar cell
54fnb=3
55for kf=2:2:size(varargin)
56 if typeof(varargin(kf))<>"ce" then
57 value=list()
58 for kk=1:prod(double(dims))
59 value(kk)=varargin(kf)
60 end
61 elseif and(double(varargin(kf).dims)==[1 1]) then
62 value=list()
63 for kk=1:prod(double(dims))
64 value(kk)=varargin(kf).entries
65 end
66 else
67 value=varargin(kf).entries
68 end
69 if prod(double(dims))==1 then
70 setfield(fnb,value(1),s)
71 else
72 setfield(fnb,value,s)
73 end
74 fnb=fnb+1
75end
76
77endfunction