Skip to content

Commit e95af9c

Browse files
committed
Merge branch 'scilab-6' of https://github.com/davidcl/swig
Fixes swig#1751
2 parents 4986b87 + 5a18105 commit e95af9c

File tree

12 files changed

+256
-185
lines changed

12 files changed

+256
-185
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ jobs:
180180
VER: '3.0'
181181
CPPSTD: c++11
182182
- SWIGLANG: scilab
183-
os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working
183+
VER: '5.5.2'
184+
- SWIGLANG: scilab
185+
os: ubuntu-18.04 # scilab 6.0
186+
- SWIGLANG: scilab
184187
- SWIGLANG: tcl
185188
# c++11 testing
186189
- SWIGLANG: csharp
@@ -213,7 +216,9 @@ jobs:
213216
CPPSTD: c++11
214217
- SWIGLANG: scilab
215218
CPPSTD: c++11
216-
os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working
219+
os: ubuntu-18.04 # scilab 6.0
220+
- SWIGLANG: scilab
221+
CPPSTD: c++11
217222
- SWIGLANG: tcl
218223
CPPSTD: c++11
219224
# c++14 testing
@@ -249,7 +254,9 @@ jobs:
249254
CPPSTD: c++14
250255
- SWIGLANG: scilab
251256
CPPSTD: c++14
252-
os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working
257+
os: ubuntu-18.04 # scilab 6.0
258+
- SWIGLANG: scilab
259+
CPPSTD: c++14
253260
- SWIGLANG: tcl
254261
CPPSTD: c++14
255262
# c++17 testing (using gcc11)
@@ -298,7 +305,6 @@ jobs:
298305
- SWIGLANG: scilab
299306
CPPSTD: c++17
300307
GCC: 11
301-
os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working
302308
- SWIGLANG: tcl
303309
CPPSTD: c++17
304310
GCC: 11

CHANGES.current

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ Version 4.1.0 (in progress)
3535

3636
Warning 202: Error: 'Can't mix strings and integers in expression'
3737

38+
2022-02-21: davidcl
39+
[Scilab] Improve 5.5.2, 6.0.0 and 6.1.0 support.
40+
41+
The `-targetversion` option has been removed as the generated code
42+
now detects the Scilab version in loader.sce or builder.sce.
43+
44+
For Scilab 5, long names are reduced to small names preserving the
45+
class prefix and accessor suffix (get or set).
46+
47+
For Scilab 6, long names with the class prefix and accessor suffix
48+
should be used on the user code.
49+
3850
2022-02-20: wsfulton
3951
Fix %warnfilter warning suppress for warning 315 SWIGWARN_PARSE_USING_UNDEF.
4052

Doc/Manual/Scilab.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,6 @@ <H3><a name="Scilab_running_swig_options">36.2.5 Scilab command line options</a>
304304
<td>Generate the gateway XML with the given &lt;gateway_id&gt;</td>
305305
</tr>
306306

307-
<tr>
308-
<td><tt>-targetversion</tt></td>
309-
<td>Generate for Scilab target (major) version</td>
310-
</tr>
311-
312307
</table>
313308

314309
<p>
@@ -343,10 +338,6 @@ <H3><a name="Scilab_wrapping_identifiers">36.3.2 Identifiers</a></H3>
343338
In these cases, the <a href="SWIG.html#SWIG_rename_ignore">%rename directive</a> can be used to choose a different Scilab name.
344339
</p>
345340

346-
<p>
347-
Note: truncations can be disabled by specifying the target version 6 of Scilab in the <tt>targetversion</tt> argument (i.e. <tt>-targetversion 6</tt>).
348-
</p>
349-
350341
<H3><a name="Scilab_wrapping_functions">36.3.3 Functions</a></H3>
351342

352343

Examples/Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,7 @@ r_clean:
13571357
SCILAB = @SCILAB@
13581358
SCILAB_INC= @SCILABINCLUDE@
13591359
SCILAB_OPT = @SCILABOPT@
1360+
SCILAB_VERSION = @SCILAB_VERSION@
13601361
SCILAB_LIBPREFIX = lib
13611362

13621363
# ----------------------------------------------------------------
@@ -1389,7 +1390,7 @@ scilab_run:
13891390
# -----------------------------------------------------------------
13901391

13911392
scilab_version:
1392-
echo `$(SCILAB) -version | head -1`
1393+
echo `$(SCILAB) -nwni -version | head -1`
13931394

13941395
# -----------------------------------------------------------------
13951396
# Cleaning the scilab examples

Examples/test-suite/scilab/allprotected_runme.sci

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ checkequal(PubBase_virtualMethod(pubBase), "PublicBase", "PubBase_virtualMethod(
2121
class = PubBase_instanceMethod(pubBase, klass);
2222
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceMethod(pubBase, klass))");
2323

24-
class = PubBase_instanceOverload(pubBase, klass);
24+
class = PubBase_instanceOverloaded(pubBase, klass);
2525
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass))");
2626

27-
class = PubBase_instanceOverload(pubBase, klass, "allprotected_klass2");
27+
class = PubBase_instanceOverloaded(pubBase, klass, "allprotected_klass2");
2828
checkequal(Klass_getName(class), "allprotected_klass2", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass, ""allprotected_klass2""))");
2929

3030
class = PubBase_staticMethod(klass);
@@ -40,12 +40,22 @@ checkequal(Klass_getName(class), "allprotected_klass3", "Klass_getName(PubBase_s
4040
checkequal(PubBase_EnumVal1_get(), 0, "PubBase_EnumVal1_get()");
4141
checkequal(PubBase_EnumVal2_get(), 1, "(PubBase_EnumVal2_get()");
4242

43+
v=getversion("scilab");
44+
if v(1) < 6 then
45+
PubBase_instanceMemb_set(pubBase, 12);
46+
checkequal(PubBase_instanceMemb_get(pubBase), 12, "PubBase_instanceMemb_get(pubBase)");
47+
else
48+
PubBase_instanceMemberVariable_set(pubBase, 12);
49+
checkequal(PubBase_instanceMemberVariable_get(pubBase), 12, "PubBase_instanceMemberVariable_get(pubBase)");
50+
end
4351

44-
PubBase_instanceMemb_set(pubBase, 12);
45-
checkequal(PubBase_instanceMemb_get(pubBase), 12, "PubBase_instanceMemb_get(pubBase)");
46-
47-
checkequal(PubBase_staticConstM_get(), 20, "PubBase_staticConstM_get()");
48-
checkequal(PubBase_staticMember_get(), 10, "PubBase_staticMember_get()")
52+
if v(1) < 6 then
53+
checkequal(PubBase_staticConstM_get(), 20, "PubBase_staticConstMemberVariable_get()");
54+
checkequal(PubBase_staticMember_get(), 10, "PubBase_staticMemberVariable_get()")
55+
else
56+
checkequal(PubBase_staticConstMemberVariable_get(), 20, "PubBase_staticConstMemberVariable_get()");
57+
checkequal(PubBase_staticMemberVariable_get(), 10, "PubBase_staticMemberVariable_get()")
58+
end
4959

5060
PubBase_stringMember_set(pubBase, "dummy");
5161
checkequal(PubBase_stringMember_get(pubBase), "dummy", "PubBase_stringMember_get()");

Examples/test-suite/scilab/li_std_except_runme.sci

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ checkException('Test_throw_domain_error(t)', 20009, 'ValueError: oops');
1414

1515
checkException('Test_throw_exception(t)', 20010, 'SystemError: std::exception');
1616

17-
checkException('Test_throw_invalid_argum(t)', 20009, 'ValueError: oops');
17+
checkException('Test_throw_invalid_argument(t)', 20009, 'ValueError: oops');
1818

1919
checkException('Test_throw_length_error(t)', 20004, 'IndexError: oops');
2020

2121
checkException('Test_throw_logic_error(t)', 20003, 'RuntimeError: oops');
2222

2323
checkException('Test_throw_out_of_range(t)', 20004, 'IndexError: oops');
2424

25-
checkException('Test_throw_overflow_erro(t)', 20007, 'OverflowError: oops');
25+
checkException('Test_throw_overflow_error(t)', 20007, 'OverflowError: oops');
2626

2727
checkException('Test_throw_range_error(t)', 20007, 'OverflowError: oops');
2828

Examples/test-suite/scilab/li_std_string_extra_runme.sci

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ checkequal(Structure_StaticStr2_get(), "static member string 2", "Structure_Stat
4242
Structure_StaticStr2_set(s);
4343
checkequal(Structure_StaticStr2_get(), s, "Structure_StaticStr2_get()");
4444

45-
checkequal(Structure_ConstStati_get(), "const static member string", "Structure_ConstStaticStr_get()");
46-
45+
v = getversion("scilab");
46+
if v(1) < 6 then
47+
checkequal(Structure_ConstStati_get(), "const static member string", "Structure_ConstStati_get()");
48+
else
49+
checkequal(Structure_ConstStaticStr_get(), "const static member string", "Structure_ConstStaticStr_get()");
50+
end
4751

4852
checkequal(stdstring_empty(), "", "stdstring_empty()");
4953
checkequal(c_empty(), "", "c_empty()");
Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
exec("swigtest.start", -1);
22

3+
v = getversion("scilab");
34

4-
// Test truncating variables, constants, functions identifier names
5+
// Test truncating variables, constants, functions identifier names in Scilab 5
56
// not truncated
67
gvar_identifier_name_set(-101);
78
checkequal(gvar_identifier_name_get(), -101, "gvar_identifier_name_get()");
89
checkequal(CONS_IDENTIFIER_NAME_get(), -11, "CONS_IDENTIFIER_NAME_get()");
910
checkequal(function_identifier_name(), -21, "function_identifier_name()");
1011

11-
// truncated
12+
// truncated in Scilab 5
13+
if v(1) < 6 then
1214
too_long_gvar_identi_set(101);
1315
checkequal(too_long_gvar_identi_get(), 101, "too_long_variable_id_get()");
14-
checkequal(TOO_LONG_CONST_IDENT_get(), 11, "TOO_LONG_CONST_IDENT_get()");
15-
checkequal(too_long_function_identi(), 21, "too_long_function_identi()");
16+
checkequal(TOO_LONG_CONST_IDENT_get(), 11, "TOO_LONG_CONST_IDENTIFIER_NAME_1_get");
17+
checkequal(too_long_function_identi(), 21, "too_long_function_identifier_name_1()");
18+
else
19+
too_long_gvar_identifier_name_1_set(101);
20+
checkequal(too_long_gvar_identifier_name_1_get(), 101, "too_long_variable_id_get()");
21+
checkequal(TOO_LONG_CONST_IDENTIFIER_NAME_1_get(), 11, "TOO_LONG_CONST_IDENTIFIER_NAME_1_get");
22+
checkequal(too_long_function_identifier_name_1(), 21, "too_long_function_identifier_name_1()");
23+
end
1624

1725
// Test truncating when %scilabconst mode is activated
18-
checkequal(SC_CONST_IDENTIFIER_NAME, int32(-12), "SC_TOO_LONG_IDENTIF");
19-
checkequal(SC_TOO_LONG_CONST_IDENTI, int32(14), "SC_TOO_LONG_IDENTIF");
26+
checkequal(SC_CONST_IDENTIFIER_NAME, int32(-12), "SC_CONST_IDENTIFIER_NAME");
27+
if v(1) < 6 then
28+
checkequal(SC_TOO_LONG_CONST_IDENTI, int32(14), "SC_TOO_LONG_CONST_IDENTIFIER_NAME_2");
29+
else
30+
checkequal(SC_TOO_LONG_CONST_IDENTIFIER_NAME_2, int32(14), "SC_TOO_LONG_CONST_IDENTIFIER_NAME_2");
31+
end
2032

2133
// Test truncating in the case of struct
2234
st = new_st();
2335
st_m_identifier_name_set(st, 15);
2436
checkequal(st_m_identifier_name_get(st), 15, "st_m_identifier_name_get(st)");
37+
if v(1) < 6 then
2538
st_too_long_member_i_set(st, 25);
26-
checkequal(st_too_long_member_i_get(st), 25, "st_too_long_member_i_get(st)");
39+
checkequal(st_too_long_member_i_get(st), 25, "st_too_long_member_identifier_name_get(st)");
40+
else
41+
st_too_long_member_identifier_name_set(st, 25);
42+
checkequal(st_too_long_member_identifier_name_get(st), 25, "st_too_long_member_identifier_name_get(st)");
43+
end
2744
delete_st(st);
2845

2946
exec("swigtest.quit", -1);

Examples/test-suite/scilab/swigtest.start

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ lines(0);
22
warning('off');
33
ilib_verbose(0);
44

5+
ver = getversion('scilab');
6+
57
// Get test name (used in swigtest.quit file)
68
[units, typ, names] = file(1);
79
swigtestname = strsubst(fileparts(names, "fname"), "_runme", "");
@@ -23,7 +25,12 @@ end
2325

2426
// Module initialization
2527
try
26-
moduleInit = sprintf("%s_Init()", swigtestname);
28+
if ver(1) < 6 then
29+
entry = stripblanks(part(swigtestname, 1:24-5));
30+
else
31+
entry = swigtestname;
32+
end
33+
moduleInit = sprintf("%s_Init()", entry);
2734
execstr(moduleInit);
2835
catch
2936
mfprintf(0, "*** MODULE INIT FAILED ***\n");

0 commit comments

Comments
 (0)