1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2009-2010 - DIGITEO - Bruno JOFRET
//
// 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-en.txt
//
//
function scilab2c(varargin)
[lhs, rhs] = argn();
select rhs
//
// scilab2c()
//
case 0
sci2c_gui();
return
//
// scilab2c(UserScilabMainFile, CCodeOutputDir)
//
case 2
for i = 1:2
if typeof(varargin(i)) <> "string"
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
return
end
end
UserScilabMainFile = varargin(1);
CCodeOutputDir = varargin(2);
UserSciFilesPaths = [];
RunMode = 'All';
BuildTool = getNativeBuildTool();
Target = "StandAlone"
//
// scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths)
//
case 3
for i = 1:3
if typeof(varargin(i)) <> "string"
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
return
end
end
UserScilabMainFile = varargin(1);
CCodeOutputDir = varargin(2);
if varargin(3) == ""
UserSciFilesPaths = [];
else
UserSciFilesPaths = varargin(3);
end
RunMode = "All";
BuildTool = getNativeBuildTool();
Target = "StandAlone"
//
// scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths, RunMode)
//
case 4
for i = 1:4
if typeof(varargin(i)) <> "string"
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
return
end
end
if varargin(4) <> "All" & varargin(4) <> "Translate" & varargin(4) <> "GenLibraryStructure"
error(msprintf(gettext("%s: argument #%d must be: ""All"", ""Translate"" or ""GenLibraryStructure"".\n"),"scilab2c",4));
return
end
UserScilabMainFile = varargin(1);
CCodeOutputDir = varargin(2);
if varargin(3) == ""
UserSciFilesPaths = [];
else
UserSciFilesPaths = varargin(3);
end
RunMode = varargin(4);
BuildTool = getNativeBuildTool();
Target = "StandAlone"
case 5
for i = 1:4
if typeof(varargin(i)) <> "string"
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
return
end
end
if varargin(4) <> "All" & varargin(4) <> "Translate" & varargin(4) <> "GenLibraryStructure"
error(msprintf(gettext("%s: argument #%d must be: ""All"", ""Translate"" or ""GenLibraryStructure"".\n"),"scilab2c",4));
return
end
if varargin(5) <> "make" & varargin(5) <> "nmake"
error(msprintf(gettext("%s: argument #%d must be: ""make"" or ""nmake"".\n"),"scilab2c",5));
return
end
UserScilabMainFile = varargin(1);
CCodeOutputDir = varargin(2);
if varargin(3) == ""
UserSciFilesPaths = [];
else
UserSciFilesPaths = varargin(3);
end
RunMode = varargin(4);
BuildTool = varargin(5);
Target = "StandAlone"
case 6
for i = 1:4
if typeof(varargin(i)) <> "string"
error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i));
return
end
end
if varargin(4) <> "All" & varargin(4) <> "Translate" & varargin(4) <> "GenLibraryStructure"
error(msprintf(gettext("%s: argument #%d must be: ""All"", ""Translate"" or ""GenLibraryStructure"".\n"),"scilab2c",4));
return
end
if varargin(5) <> "make" & varargin(5) <> "nmake"
error(msprintf(gettext("%s: argument #%d must be: ""make"" or ""nmake"".\n"),"scilab2c",5));
return
end
if varargin(6) <> "StandAlone" & varargin(6) <> "Arduino" & varargin(6) <> "AVR" & varargin(6) <> "RPi"
error(msprintf(gettext("%s: argument #%d must be: ""StandAlone"" or ""Arduino"" or ""AVR"".\n"),"scilab2c",5));
return
end
UserScilabMainFile = varargin(1);
CCodeOutputDir = varargin(2);
if varargin(3) == ""
UserSciFilesPaths = [];
else
UserSciFilesPaths = varargin(3);
end
RunMode = varargin(4);
BuildTool = varargin(5);
Target = varargin(6);
else
//
// Calling scilab2c with more than understood values
//
error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"scilab2c",2));
end
// --- LAUNCH USER SCI CODE TO TEST IT BEFORE TRANSLATING IT!!! ---
// If Target choosen is 'Standalone' then only execute the code, otherwise directly start conversion.
if Target == "StandAlone"
runscicode(UserScilabMainFile, UserSciFilesPaths);
// --- ASK USER FOR CONTINUATION. ---
// Do not open confirmation box if we are not in STD mode.
if(getscilabmode() == "STD")
userchoice = messagebox("Exection Succesfull. Start translation ?", "modal", "info", ["Yes" "No"])
else
userchoice = 1
end
else
userchoice = 1;
end
if (userchoice == 1)
// --- LAUNCH SCI2C ---
runsci2c(UserScilabMainFile, UserSciFilesPaths, CCodeOutputDir, RunMode, BuildTool,Target);
end
endfunction
function BuildTool = getNativeBuildTool()
if getos() == "Windows"
BuildTool = "nmake"
else
BuildTool = "make"
end
endfunction
|