summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2021-03-01 14:20:18 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2021-03-01 14:20:18 +0000
commit4b64becbbb6fa86afe3aa00ce89ac26dafad45ab (patch)
tree0b1599f790c5fd2f3c6bf910fdc3f1394bddbfca /Examples
parent5ed74fd19b7771ffa564c970fa5e1d496abad0a4 (diff)
downloadswig-4b64becbbb6fa86afe3aa00ce89ac26dafad45ab.tar.gz
OUTPUT typemaps on methods that don't return void
SWIGJSC_ValueIsArray could be implemented by JSValueIsArray in later versions of Javascript webkit, similar fix to previous commits for v8. Enhance testing of OUTPUT typemaps to test more than one output.
Diffstat (limited to 'Examples')
-rw-r--r--Examples/test-suite/javascript/li_typemaps_runme.js3
-rw-r--r--Examples/test-suite/li_typemaps.i6
-rw-r--r--Examples/test-suite/lua/li_typemaps_runme.lua4
-rw-r--r--Examples/test-suite/perl5/li_typemaps_runme.pl5
4 files changed, 12 insertions, 6 deletions
diff --git a/Examples/test-suite/javascript/li_typemaps_runme.js b/Examples/test-suite/javascript/li_typemaps_runme.js
index 987606030..c0b1b43b0 100644
--- a/Examples/test-suite/javascript/li_typemaps_runme.js
+++ b/Examples/test-suite/javascript/li_typemaps_runme.js
@@ -10,7 +10,7 @@ function check_array(a, b) {
if (a.length != b.length)
throw new Error("Array length mismatch " + a.length + " " + b.length)
if (!a.every(function(element, index) { return element === b[index]; }))
- throw new Error("Arrays don't match a: " + a + " b:" + b)
+ throw new Error("Arrays don't match a:" + a + " b:" + b)
}
// Check double INPUT typemaps
@@ -47,3 +47,4 @@ check_array(li_typemaps.inoutr_int2(1,2), [1, 2])
fi = li_typemaps.out_foo(10)
check(fi[0].a, 10)
check(fi[1], 20)
+check(fi[2], 30)
diff --git a/Examples/test-suite/li_typemaps.i b/Examples/test-suite/li_typemaps.i
index a53c1c74a..d508c1c84 100644
--- a/Examples/test-suite/li_typemaps.i
+++ b/Examples/test-suite/li_typemaps.i
@@ -2,6 +2,7 @@
%include "typemaps.i"
+%apply int *OUTPUT { int *OUTPUT2 };
%apply int &INOUT { int &INOUT2 };
%newobject out_foo;
%inline %{
@@ -51,10 +52,13 @@ void out_longlong(long long x, long long *OUTPUT) { *OUTPUT = x; }
void out_ulonglong(unsigned long long x, unsigned long long *OUTPUT) { *OUTPUT = x; }
/* Tests a returning a wrapped pointer and an output argument */
-struct Foo *out_foo(int a, int *OUTPUT) {
+struct Foo *out_foo(int a, int *OUTPUT, int *OUTPUT2) {
struct Foo *f = new struct Foo();
f->a = a;
*OUTPUT = a * 2;
+ struct Foo *f2 = new struct Foo();
+ f2->a = a;
+ *OUTPUT2 = a * 3;
return f;
}
diff --git a/Examples/test-suite/lua/li_typemaps_runme.lua b/Examples/test-suite/lua/li_typemaps_runme.lua
index 7456d8245..342634a5b 100644
--- a/Examples/test-suite/lua/li_typemaps_runme.lua
+++ b/Examples/test-suite/lua/li_typemaps_runme.lua
@@ -38,5 +38,5 @@ assert(li_typemaps.inoutr_bool(false)==false)
a,b=li_typemaps.inoutr_int2(1,2)
assert(a==1 and b==2)
-f,i=li_typemaps.out_foo(10)
-assert(f.a==10 and i==20)
+f,i,i2=li_typemaps.out_foo(10)
+assert(f.a==10 and i==20 and i2==30)
diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl
index a573b89a0..2755862a2 100644
--- a/Examples/test-suite/perl5/li_typemaps_runme.pl
+++ b/Examples/test-suite/perl5/li_typemaps_runme.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
-use Test::More tests => 415;
+use Test::More tests => 416;
BEGIN { use_ok('li_typemaps') }
require_ok('li_typemaps');
@@ -75,10 +75,11 @@ SKIP: {
batch('ulonglong', $c);
}
-my($foo, $int) = li_typemaps::out_foo(10);
+my($foo, $int, $int2) = li_typemaps::out_foo(10);
isa_ok($foo, 'li_typemaps::Foo');
is($foo->{a}, 10);
is($int, 20);
+is($int2, 30);
my($a, $b) = li_typemaps::inoutr_int2(13, 31);
is($a, 13);