Commit graph

5,736 commits

Author SHA1 Message Date
William S Fulton
eb8346b958 Convert cpp20_spaceship_operator php test to python 2022-07-31 00:58:35 +01:00
William S Fulton
26fbf99901 Add Tcl support for std::unique_ptr and std::auto_ptr
Equivalent to Ruby/Python implementations.
2022-07-30 16:43:05 +01:00
Olly Betts
379d5b6742 Fix warning suppression in cpp20_lambda_template 2022-07-29 16:29:32 +12:00
Olly Betts
64d72483c6 Clean up Tcl version docs and handling
We require 8.4 now which simplifies things a bit.
2022-07-28 14:30:43 +12:00
Olly Betts
346ede21c3 Fix spaceship preproc tests for previous change 2022-07-27 18:17:31 +12:00
Olly Betts
100d4d5350 Only recognise spaceship operator for C++
I don't think any valid C program can contain `<=>` in a tokenisable
context, but it's more helpful to fail with a syntax error at SWIG
parse time and not potentially generate C code trying to use `<=>` in
an expression which then fails at compile time.
2022-07-27 13:46:53 +12:00
Olly Betts
6e931b0399 Revert "Fix handling of array whose size contains <<"
This reverts commit 2227dc9e53.
2022-07-27 13:45:03 +12:00
Olly Betts
2227dc9e53 Fix handling of array whose size contains <<
Fixes https://sourceforge.net/p/swig/bugs/983/
2022-07-27 10:29:33 +12:00
Olly Betts
88f227b5da Add testcase 2022-07-27 09:30:39 +12:00
Olly Betts
02b4bd8eca Fix spaceship operator bugs, document, add tests
Remove some erroneously added brackets_increment() calls.

Reject <=> in preprocessor expressions with a clear error message (it
seems it isn't supported here - clang and gcc don't at least).

The type returned by `<=>` is not `bool`.  We pretend it's
`int` for now, which should work for how it's likely to be used
in constant expressions.

Fixes #1622
2022-07-27 09:12:40 +12:00
Olly Betts
a80e748565 [php] Add missing qualification in test suite helper
This would cause an error due to failing to find the function to
call if certain testcase checks failed.

Bug introduced in eaf311a650
2022-07-27 08:47:53 +12:00
Olly Betts
8c5c14b9ad Merge branch 'cpp-testing'
Closes #2329
2022-07-27 07:55:24 +12:00
Olly Betts
06d375cdab [Tcl] Fix handling of long long on 32-bit platforms
Fixes https://sourceforge.net/p/swig/bugs/977/ reported by Vera and
Kjell Wooding.

Closes #2331
2022-07-27 07:53:45 +12:00
Olly Betts
4f44d0a1ea Attempt to fix cpp11_result_of for MSVC
MSVC fails with:

cpp11_result_of_wrap.cxx(3211): error C2672: 'test_result_impl': no matching overloaded function found
cpp11_result_of_wrap.cxx(3211): error C2893: Failed to specialize function template 'std::result_of<Fun(Arg)>::type test_result_impl(Fun,Arg)'
cpp11_result_of_wrap.cxx(3150): note: see declaration of 'test_result_impl'
cpp11_result_of_wrap.cxx(3211): note: With the following template arguments:
cpp11_result_of_wrap.cxx(3211): note: 'Fun=double (__cdecl *)(double)'
cpp11_result_of_wrap.cxx(3211): note: 'Arg=int'

Try making the second parameter double to match the template.
2022-07-26 15:28:52 +12:00
Olly Betts
4a15f3934d Fix MSVC error in nested_class.i
MSVC now fails with:

error C4596: 'foo': illegal qualified name in member declaration

Such redundant qualification is invalid.  Compilers used to be
permissive here (so it's useful for SWIG to handle it), but compilers
increasingly complain about it so adjust the testcase to show the
compiler a valid version, and only test the redundant qualification
with SWIG.
2022-07-26 15:28:51 +12:00
Olly Betts
9d3fb41eef Fix MSVC error in cpp_typedef.i
MSVC in C++20 mode complains:

error C7626: unnamed class used in typedef name cannot declare members other than non-static data members, member enumerations, or member classes

The struct member in question isn't actually used by the testcase, so
just remove it.
2022-07-26 15:28:51 +12:00
Olly Betts
c759da250f Add tests for binary integer literal constants 2022-07-26 15:28:51 +12:00
Olly Betts
1bfe88eeda Support binary integer literals in the preprocessor 2022-07-26 15:28:51 +12:00
Olly Betts
3140acd748 Run C++14 and C++17 tests with appropriate compiler
Previously these testcases had C++98 fallback versions of the
testcase code to feed to the compiler if it didn't set __cplusplus to a
value which indicated support for the required C++ version, as well as
the C++14 or C++17 code which was fed to SWIG, and also to the compiler
if it was new enough.

This approach allowed some testing of such features with an
older compiler, but it complicates the testcases and not all new
C++ features can be tested in this way (indeed some of the existing
testcases don't fully exercise the feature being tested currently).

C++14 and C++17 support are also much more widespread than they
were 3.5 years ago when this approach was first implemented, so
it makes more sense to switch C++14 and C++17 testcases to require
a suitable compiler, like how C++11 testing always has.
2022-07-26 15:28:51 +12:00
Olly Betts
07f0b732ba Add machinery for C++14, C++17 and C++20 testing
Support running testcases conditional on the compiler supporting
a each language version, like we already handle C++11.

Currently no testcases are actually run in this way for these
newer language versions.
2022-07-26 15:28:51 +12:00
Olly Betts
8038cd7ac3 Fix C++20 compatibility in testcases 2022-07-26 15:28:51 +12:00
Olly Betts
de5ce08a7d Fix operator precedence in preprocessor expressions 2022-07-26 14:18:38 +12:00
Olly Betts
0e0f283e48 Fix friends_runme.*
Most of these test D_d twice when they really should be testing
D_d once and D_i once (the variable name is `di` and the values
assigned are integers).

This was wrong in the initial version for Python in
708021a809 and it looks like subsequent
additions for other languages have just copied that mistake.
2022-07-22 17:50:47 +12:00
Olly Betts
2aa979b7a0 [php] Add friends_runme.php 2022-07-22 17:40:40 +12:00
Olly Betts
eaf311a650 [php] Make $message optional in testsuite helpers
Also report the filename and line in the testcase where a check
function which fails was called from.
2022-07-22 17:39:15 +12:00
William S Fulton
7592722e39 Order of interfaces generated for %interface macros
Ensure the order of interfaces generated in proxy interfaces for the
%interface family of macros is the same as that parsed from the bases in C++.
2022-07-20 19:50:53 +01:00
Olly Betts
ccccd6fc1f Add director_multiple_inheritance to CPP_TEST_CASES 2022-07-20 15:06:56 +12:00
Olly Betts
e23d912b49 [python] Fix inheriting from multiple director classes
Fix mishandling of a Python class inheriting from multiple SWIG-wrapped
director classes.

Fixes #422
Fixes https://sourceforge.net/p/swig/bugs/1379/
2022-07-20 14:18:49 +12:00
Olly Betts
8a03c7d555 Remove nonsensical comment
A testcase can't be a copy of itself.

Seems to have been accidentally added in
50fec04759.
2022-07-20 14:18:49 +12:00
William S Fulton
8b654afdef Merge branch 'unique_ptr-inputs'
* unique_ptr-inputs:
  std::unique_ptr std::auto_ptr tidyup
  Add support for std::auto_ptr inputs
  Cosmetic formatting and doc updates in std_unique_ptr.i files
  Add Perl support for std::unique_ptr inputs
  Add Ruby support for std::unique_ptr inputs
  Add Python support for std::unique_ptr inputs
  Add C# support std::unique_ptr inputs
  Java unique_ptr test ownership enhancement to test
  Java unique_ptr enhance test for double release
  SWIGTYPE && input typemaps now assume object has been moved
  Add Java support for std::unique<T> for input parameters.

Closes #692

Conflicts:
	CHANGES.current
2022-07-19 20:26:18 +01:00
William S Fulton
1b63af0f2c std::unique_ptr std::auto_ptr tidyup
Add docs on additional support
Additional testing for invalid usage for parameter inputs
2022-07-19 20:23:06 +01:00
Olly Betts
0b9d4eff09 Update everything for dropping Python 3.2 support 2022-07-19 13:20:07 +12:00
Olly Betts
892557e799 Improve #include guard macros
Avoid using reserved identifiers such as `_DOHINT_H` (fixes #1989),
fix cases where the name doesn't match the filename, and make the naming
more consistent and less likely to collide with include guards in other
headers.
2022-07-19 09:35:46 +12:00
William S Fulton
db5e37a1d7 Add support for std::auto_ptr inputs
Ported from std::unique, behaviour is identical with regard to memory ownership/handling
2022-07-18 08:32:26 +01:00
William S Fulton
50fc600e8c Add Perl support for std::unique_ptr inputs
Equivalent to Java/C#/Python/Ruby implementations.
2022-07-17 20:23:52 +01:00
William S Fulton
f99a2e6f64 Add Ruby support for std::unique_ptr inputs
Equivalent to Java/C#/Python implementations.
2022-07-17 15:20:25 +01:00
William S Fulton
c3c061cac8 Add Python support for std::unique_ptr inputs
Equivalent to Java/C# implementation.
2022-07-17 15:20:20 +01:00
William S Fulton
c737bd5713 Add C# support std::unique_ptr inputs
Based on Java implementation.
2022-07-17 15:20:13 +01:00
William S Fulton
8bd9eb3f16 Java unique_ptr test ownership enhancement to test
Make sure the object is owned before releasing ownership
and passing ownership to unique_ptr instance.
2022-07-17 15:15:24 +01:00
William S Fulton
1bf15210ef Java unique_ptr enhance test for double release 2022-07-17 15:15:24 +01:00
William S Fulton
bf761998ed SWIGTYPE && input typemaps now assume object has been moved
Change these typemaps to assume that after a function call,
the parameter has been moved. The parameter's proxy class
that owns the C++ object thus has the underlying pointer set
to null so the object cannot be used again and the object is deleted.

Scrap new javarelease typemap and move contents into javabody typemap.
2022-07-17 15:15:24 +01:00
William S Fulton
6b361bf050 Add Java support for std::unique<T> for input parameters.
This works by transferring ownership of the underlying C++ memory
from the target language proxy class to an instance of the unique_ptr
which is passed to the wrapped function via std::move.

The proxy class has a new swigRelease() method which sets the
underlying C++ pointer for the proxy class to null, so working
in much the same way as std::unique_ptr::release(). Any attempt at
using the proxy class will be the same as if the delete() function
has been called on the proxy class. That is, using a C++ null pointer,
when a non-null pointer is usually expected.

This commit relies on the previous commit that uses std::move
on the temporary variable used for the wrapped function's input parameter
as std::unique_ptr is not copyable, it has move-only semantics.
2022-07-17 15:15:24 +01:00
Olly Betts
64fa88c0eb [php] Omit incompatible return type declaraction
Under %feature("php:type", "compat") we don't generate return type
declaration for virtual methods if directors are enabled for that class.
However if a base class of the class has a method of the same name which
isn't directed this was still getting a return type declaration which
caused PHP to give an error when it tried to load the module.

Now we detect this situation and suppress the base class method's
return type declaration too.

Re-enable testcase director_redefined which now works again (it was
failing under PHP8 due to this issue).

See #2151
2022-07-13 16:01:59 +12:00
Olly Betts
6c083b208c [php] Reenable 3 testcases which now pass
See #2151
2022-07-13 15:21:12 +12:00
Olly Betts
732af1d7b8 Tweak testcase comments 2022-07-13 15:21:12 +12:00
William S Fulton
ea193a98f3 Merge two commits from movable-types-inputs
Performance optimisation for parameters passed by value that are C++11 movable.
  Test copy constructor and assignment operator calls for movable types

Conflicts:
	CHANGES.current
2022-07-12 09:48:17 +01:00
William S Fulton
2bba78f757 Add std::auto_ptr support for Perl based on std::unique_ptr 2022-07-12 09:41:56 +01:00
William S Fulton
3cbcdbf681 Merge branch 'unique_ptr'
* unique_ptr:
  Add std::unique_ptr<type> to Perl5.
2022-07-12 08:23:28 +01:00
Olly Betts
29354ed19d Update comment in PHP testcase
The PHP7 workaround we currently use has evolved a bit since this
comment was written.
2022-07-11 13:20:25 +12:00
Erez Geva
adb85d3d05 Add std::unique_ptr<type> to Perl5.
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2022-07-09 13:52:43 +02:00