Merge branch 'master' into C

Merge with the latest master to resolve (trivial) conflict in the
GitHub workflow file.
This commit is contained in:
Vadim Zeitlin 2021-11-26 20:32:36 +01:00
commit c3b262c2f7
60 changed files with 531 additions and 282 deletions

View file

@ -90,7 +90,7 @@ struct FinalOverrideMethods {
virtual void override(int) {}
virtual ~FinalOverrideMethods() = default;
};
struct FinalOverrideVariables {
struct FinalOverrideVars {
int final;
double override;
};

View file

@ -21,6 +21,11 @@
%include <std_wstring.i>
#endif
#if defined(SWIGLUA)
// Lua uses a parameter called L in every wrapper function
%ignore L;
#endif
%inline %{
#include <iostream>
#include <string>

View file

@ -24,19 +24,19 @@ void takeit3(Thing const*&& t) {}
void takeit4(Thing *const&& t) {}
void takeit5(Thing const*const&& t) {}
struct Containing {
Thing && member_rvalue_ref;
Thing *&& member_rvalue_ref_ptr1;
Thing const*&& member_rvalue_ref_ptr2;
Thing *const&& member_rvalue_ref_ptr3;
Thing const*const &&member_rvalue_ref_ptr4;
struct Contain {
Thing && m_ref;
Thing *&& m_ref_ptr1;
Thing const*&& m_ref_ptr2;
Thing *const&& m_ref_ptr3;
Thing const*const &&m_ref_ptr4;
Containing(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) :
member_rvalue_ref(std::move(r)),
member_rvalue_ref_ptr1(std::move(r1)),
member_rvalue_ref_ptr2(std::move(r2)),
member_rvalue_ref_ptr3(std::move(r3)),
member_rvalue_ref_ptr4(std::move(r4))
Contain(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) :
m_ref(std::move(r)),
m_ref_ptr1(std::move(r1)),
m_ref_ptr2(std::move(r2)),
m_ref_ptr3(std::move(r3)),
m_ref_ptr4(std::move(r4))
{}
};
%}
@ -61,19 +61,19 @@ void int_takeit3(int const*&& t) {}
void int_takeit4(int *const&& t) {}
void int_takeit5(int const*const&& t) {}
struct IntContaining {
int && member_rvalue_ref;
int *&& member_rvalue_ref_ptr1;
int const*&& member_rvalue_ref_ptr2;
int *const&& member_rvalue_ref_ptr3;
int const*const &&member_rvalue_ref_ptr4;
struct IContain {
int && m_ref;
int *&& m_ref_ptr1;
int const*&& m_ref_ptr2;
int *const&& m_ref_ptr3;
int const*const &&m_ref_ptr4;
IntContaining(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) :
member_rvalue_ref(std::move(r)),
member_rvalue_ref_ptr1(std::move(r1)),
member_rvalue_ref_ptr2(std::move(r2)),
member_rvalue_ref_ptr3(std::move(r3)),
member_rvalue_ref_ptr4(std::move(r4))
IContain(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) :
m_ref(std::move(r)),
m_ref_ptr1(std::move(r1)),
m_ref_ptr2(std::move(r2)),
m_ref_ptr3(std::move(r3)),
m_ref_ptr4(std::move(r4))
{}
};
%}

View file

@ -1,5 +1,5 @@
/* This interface checks whether SWIG supports the new double angled brackets
in the template syntax without having a space inbetween. This feature was
in the template syntax without having a space in between. This feature was
introduced in new C++11 standard.
*/
%module cpp11_template_double_brackets

View file

@ -63,12 +63,14 @@ using IntArray = Int[];
// Test that SWIG understands these new types
%{
Int mult2(Int x) { return x * 2; }
%}
%callback("%s_cb");
Int mult2(Int x);
%nocallback;
%inline %{
Int mult2(Int x) { return x * 2; }
IntPtr allocate_int() { return new Int(12); }
void free_int(int* ptr) { delete ptr; }
void inplace_mult2(IntRef x) { x *= 2; }

View file

@ -47,7 +47,7 @@ void main() {
enforce(countUntil(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
}
enforce(countUntil(vector[], 42) == -1, "non-existant item indexOf test failed");
enforce(countUntil(vector[], 42) == -1, "non-existent item indexOf test failed");
vector.clear();
enforce(vector.length == 0, "clear test failed");

View file

@ -39,15 +39,15 @@
;(check (=~ 15 (Overload-byval2cpr o #nil)))
;(check (=~ 16 (Overload-byval2cpr o x)))
; forward class declaration
(check (=~ 17 (Overload-byval1forwardptr o x)))
(check (=~ 18 (Overload-byval1forwardptr o #nil)))
; fwd class declaration
(check (=~ 17 (Overload-byval1fwdptr o x)))
(check (=~ 18 (Overload-byval1fwdptr o #nil)))
(check (=~ 19 (Overload-byval2forwardptr o #nil)))
(check (=~ 20 (Overload-byval2forwardptr o x)))
(check (=~ 19 (Overload-byval2fwdptr o #nil)))
(check (=~ 20 (Overload-byval2fwdptr o x)))
(check (=~ 21 (Overload-byval1forwardref o x)))
(check (=~ 21 (Overload-byval1fwdref o x)))
(check (=~ 22 (Overload-byval2forwardref o x)))
(check (=~ 22 (Overload-byval2fwdref o x)))
(exit 0)

View file

@ -37,13 +37,13 @@ check(13, o.byval1cpr(x));
// check(15, o.byval2cpr(null));
check(16, o.byval2cpr(x));
// forward class declaration
check(17, o.byval1forwardptr(x));
// check(18, o.byval1forwardptr(null));
// fwd class declaration
check(17, o.byval1fwdptr(x));
// check(18, o.byval1fwdptr(null));
// check(19, o.byval2forwardptr(null));
check(20, o.byval2forwardptr(x));
// check(19, o.byval2fwdptr(null));
check(20, o.byval2fwdptr(x));
check(21, o.byval1forwardref(x));
check(21, o.byval1fwdref(x));
check(22, o.byval2forwardref(x));
check(22, o.byval2fwdref(x));

View file

@ -29,13 +29,13 @@ assert(14 == o:byval1cpr(nil))
assert(15 == o:byval2cpr(nil))
assert(16 == o:byval2cpr(x))
-- forward class declaration
assert(17 == o:byval1forwardptr(x))
assert(18 == o:byval1forwardptr(nil))
-- fwd class declaration
assert(17 == o:byval1fwdptr(x))
assert(18 == o:byval1fwdptr(nil))
assert(19 == o:byval2forwardptr(nil))
assert(20 == o:byval2forwardptr(x))
assert(19 == o:byval2fwdptr(nil))
assert(20 == o:byval2fwdptr(x))
assert(21 == o:byval1forwardref(x))
assert(21 == o:byval1fwdref(x))
assert(22 == o:byval2forwardref(x))
assert(22 == o:byval2fwdref(x))

View file

@ -40,13 +40,13 @@ check(14, o.byval1cpr(null));
check(15, o.byval2cpr(null));
check(16, o.byval2cpr(x));
# forward class declaration
check(17, o.byval1forwardptr(x));
check(18, o.byval1forwardptr(null));
# fwd class declaration
check(17, o.byval1fwdptr(x));
check(18, o.byval1fwdptr(null));
check(19, o.byval2forwardptr(null));
check(20, o.byval2forwardptr(x));
check(19, o.byval2fwdptr(null));
check(20, o.byval2fwdptr(x));
check(21, o.byval1forwardref(x));
check(21, o.byval1fwdref(x));
check(22, o.byval2forwardref(x));
check(22, o.byval2fwdref(x));

View file

@ -35,18 +35,18 @@ struct Overload {
int byval2cpr(Y*const& y) { return 15; }
int byval2cpr(X x) { return 16; }
// forward class declaration
int byval1forwardptr(X x) { return 17; }
int byval1forwardptr(F* f) { return 18; }
// fwd class declaration
int byval1fwdptr(X x) { return 17; }
int byval1fwdptr(F* f) { return 18; }
int byval2forwardptr(F* f) { return 19; }
int byval2forwardptr(X x) { return 20; }
int byval2fwdptr(F* f) { return 19; }
int byval2fwdptr(X x) { return 20; }
int byval1forwardref(X x) { return 21; }
int byval1forwardref(F& f) { return -21; }
int byval1fwdref(X x) { return 21; }
int byval1fwdref(F& f) { return -21; }
int byval2forwardref(F& f) { return -22; }
int byval2forwardref(X x) { return 22; }
int byval2fwdref(F& f) { return -22; }
int byval2fwdref(X x) { return 22; }
};
%}

View file

@ -32,13 +32,13 @@ is(14, $o->byval1cpr(undef));
is(15, $o->byval2cpr(undef));
is(16, $o->byval2cpr($x));
# forward class declaration
is(17, $o->byval1forwardptr($x));
is(18, $o->byval1forwardptr(undef));
# fwd class declaration
is(17, $o->byval1fwdptr($x));
is(18, $o->byval1fwdptr(undef));
is(19, $o->byval2forwardptr(undef));
is(20, $o->byval2forwardptr($x));
is(19, $o->byval2fwdptr(undef));
is(20, $o->byval2fwdptr($x));
is(21, $o->byval1forwardref($x));
is(21, $o->byval1fwdref($x));
is(22, $o->byval2forwardref($x));
is(22, $o->byval2fwdref($x));

View file

@ -30,15 +30,15 @@ check::equal(14, $o->byval1cpr(null), "test 14");
check::equal(15, $o->byval2cpr(null), "test 15");
check::equal(16, $o->byval2cpr($x), "test 16");
# forward class declaration
check::equal(17, $o->byval1forwardptr($x), "test 17");
check::equal(18, $o->byval1forwardptr(null), "test 18");
# fwd class declaration
check::equal(17, $o->byval1fwdptr($x), "test 17");
check::equal(18, $o->byval1fwdptr(null), "test 18");
check::equal(19, $o->byval2forwardptr(null), "test 19");
check::equal(20, $o->byval2forwardptr($x), "test 20");
check::equal(19, $o->byval2fwdptr(null), "test 19");
check::equal(20, $o->byval2fwdptr($x), "test 20");
check::equal(21, $o->byval1forwardref($x), "test 21");
check::equal(21, $o->byval1fwdref($x), "test 21");
check::equal(22, $o->byval2forwardref($x), "test 22");
check::equal(22, $o->byval2fwdref($x), "test 22");
check::done();

View file

@ -32,13 +32,13 @@ check(14, o.byval1cpr(None))
check(15, o.byval2cpr(None))
check(16, o.byval2cpr(x))
# forward class declaration
check(17, o.byval1forwardptr(x))
check(18, o.byval1forwardptr(None))
# fwd class declaration
check(17, o.byval1fwdptr(x))
check(18, o.byval1fwdptr(None))
check(19, o.byval2forwardptr(None))
check(20, o.byval2forwardptr(x))
check(19, o.byval2fwdptr(None))
check(20, o.byval2fwdptr(x))
check(21, o.byval1forwardref(x))
check(21, o.byval1fwdref(x))
check(22, o.byval2forwardref(x))
check(22, o.byval2fwdref(x))

View file

@ -9,6 +9,8 @@ class Ai:
def __int__(self):
return self.x
def __index__(self):
return self.x
class Ad:

View file

@ -34,16 +34,16 @@ unittest(12, o$byconstref2(x))
#unittest(15, o$byval2cpr(NULL))
#unittest(16, o$byval2cpr(x))
# forward class declaration
unittest(17, o$byval1forwardptr(x))
unittest(18, o$byval1forwardptr(NULL))
# fwd class declaration
unittest(17, o$byval1fwdptr(x))
unittest(18, o$byval1fwdptr(NULL))
unittest(19, o$byval2forwardptr(NULL))
unittest(20, o$byval2forwardptr(x))
unittest(19, o$byval2fwdptr(NULL))
unittest(20, o$byval2fwdptr(x))
unittest(21, o$byval1forwardref(x))
unittest(21, o$byval1fwdref(x))
unittest(22, o$byval2forwardref(x))
unittest(22, o$byval2fwdref(x))
q(save="no")

View file

@ -4,6 +4,18 @@
struct swig_tree;
%}
%{
#if defined(__cplusplus)
#if __cplusplus >= 201703L
/*
Fix for languages that compile C tests as C++:
error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
*/
#define register
#endif
#endif
%}
// bug # 924413
%inline {
void clear_tree_flags(register struct swig_tree *tp, register int i) {}

View file

@ -40,13 +40,13 @@ swig_assert(14 == o.byval1cpr(nil))
swig_assert(15 == o.byval2cpr(nil))
swig_assert(16 == o.byval2cpr(x))
# forward class declaration
swig_assert(17 == o.byval1forwardptr(x))
swig_assert(18 == o.byval1forwardptr(nil))
# fwd class declaration
swig_assert(17 == o.byval1fwdptr(x))
swig_assert(18 == o.byval1fwdptr(nil))
swig_assert(19 == o.byval2forwardptr(nil))
swig_assert(20 == o.byval2forwardptr(x))
swig_assert(19 == o.byval2fwdptr(nil))
swig_assert(20 == o.byval2fwdptr(x))
swig_assert(21 == o.byval1forwardref(x))
swig_assert(21 == o.byval1fwdref(x))
swig_assert(22 == o.byval2forwardref(x))
swig_assert(22 == o.byval2fwdref(x))

View file

@ -30,16 +30,16 @@ checkequal(14, Overload_byval1cpr(o, NULL), "test 14");
checkequal(15, Overload_byval2cpr(o, NULL), "test 15");
checkequal(16, Overload_byval2cpr(o, x), "test 16");
// forward class declaration
checkequal(17, Overload_byval1forwardptr(o, x), "test 17");
checkequal(18, Overload_byval1forwardptr(o, NULL), "test 18");
// fwd class declaration
checkequal(17, Overload_byval1fwdptr(o, x), "test 17");
checkequal(18, Overload_byval1fwdptr(o, NULL), "test 18");
checkequal(19, Overload_byval2forwardptr(o, NULL), "test 19");
checkequal(20, Overload_byval2forwardptr(o, x), "test 20");
checkequal(19, Overload_byval2fwdptr(o, NULL), "test 19");
checkequal(20, Overload_byval2fwdptr(o, x), "test 20");
checkequal(21, Overload_byval1forwardref(o, x), "test 21");
checkequal(21, Overload_byval1fwdref(o, x), "test 21");
checkequal(22, Overload_byval2forwardref(o, x), "test 22");
checkequal(22, Overload_byval2fwdref(o, x), "test 22");
exec("swigtest.quit", -1);

View file

@ -24,7 +24,7 @@ endfunction
test_global();
// Test assignement in enums
// Test assignment in enums
checkequal(kValue_get(), 4, "kValue");
exec("swigtest.quit", -1);

View file

@ -7,7 +7,7 @@
// Test truncating variables, constants, functions identifier names
%inline %{
// these identifier names wont be truncated
// these identifier names won't be truncated
int gvar_identifier_name = -1;
#define CONS_IDENTIFIER_NAME -11
int function_identifier_name() { return -21; };

View file

@ -70,7 +70,10 @@ class ItkVectorContainerUILSNUS2 : public std::vector< ItkLevelSetNodeUS2 > {
class ItkVectorContainerUILSNUS2_Pointer {
public:
ItkVectorContainerUILSNUS2 * operator->() const { return 0; }
ItkVectorContainerUILSNUS2 * operator->() const {
static ItkVectorContainerUILSNUS2 instance;
return &instance;
}
};
%}

View file

@ -15,8 +15,8 @@ import
set x [new_B]
A_hello $x
if [ catch { $x nonexistant } ] {
if [ catch { $x nonexistent } ] {
} else {
puts stderr "nonexistant method did not throw exception\n"
puts stderr "nonexistent method did not throw exception\n"
exit 1
}

View file

@ -40,13 +40,13 @@ check "testX" 14 [$o byval1cpr "NULL"]
check "testX" 15 [$o byval2cpr "NULL"]
check "testX" 16 [$o byval2cpr $x]
# forward class declaration
check "testX" 17 [$o byval1forwardptr $x]
check "testX" 18 [$o byval1forwardptr "NULL"]
# fwd class declaration
check "testX" 17 [$o byval1fwdptr $x]
check "testX" 18 [$o byval1fwdptr "NULL"]
check "testX" 19 [$o byval2forwardptr "NULL"]
check "testX" 20 [$o byval2forwardptr $x]
check "testX" 19 [$o byval2fwdptr "NULL"]
check "testX" 20 [$o byval2fwdptr $x]
check "testX" 21 [$o byval1forwardref $x]
check "testX" 21 [$o byval1fwdref $x]
check "testX" 22 [$o byval2forwardref $x]
check "testX" 22 [$o byval2fwdref $x]

View file

@ -61,7 +61,11 @@ void CheckRetTypemapUsed() {
%inline {
class FFoo {
public:
char * Bar(bool b) const { return (char *)"x"; }
char * Bar(bool b) const {
char *ret = new char[2];
strcpy(ret, b ? "1" : "0");
return ret;
}
};
}