Commit Graph

234 Commits

Author SHA1 Message Date
Olly Betts 8a73e25fe2 argcargv.i: NULL terminate argv with empty input
Fixes needed for: C# R
2023-05-23 10:12:49 +12:00
Olly Betts 4ba7e68c28 Test empty array and empty string with argcargv.i
Adding test coverage for target languages where this already works.
2023-05-22 16:08:09 +12:00
Olly Betts 915dc93b0d [octave] Fix argcargv.i bug
The strings from the Octave array are returned in a temporary
std::string object so we need to make a copy of them or else the
final string ends up replicated as all elements.

Unfortunately argcargvtest.i was only checking the final element's
value, so fix it to test both the elements as a regression test for
this, and to catch any similar issues with other target languages.
2023-05-22 13:38:59 +12:00
Olly Betts d8887091fe Support deducing decltype for false and true 2023-05-20 09:09:48 +12:00
Olly Betts 4e4369a4a4 Improve #2446 fix
It seems the parser limitation isn't actually a problem as non of
the cases are valid C++ so drop that from the docs.

Extend test coverage by adding some class methods, including `static` and
`const`.
2023-05-19 14:27:34 +12:00
Olly Betts f215365609 Merge branch 'cpp14-auto-return-type' 2023-05-19 12:02:30 +12:00
Olly Betts 1c309da897 Implement cpp11_decltype_runme.php 2023-05-18 18:48:06 +12:00
Olly Betts 5104040dc9 Partial support for auto without trailing return type
This is a C++14 feature.

SWIG can now parse some cases of this.  The limitation is that there
can either be nothing or `const` between the `)` and the end of the
parameter list and the `{` at the start of the body.

Fixes #2446
2023-05-18 15:19:23 +12:00
Olly Betts 5b709dd163 Merge branch 'JS-check-fix' 2023-05-12 16:18:46 +12:00
Olly Betts a44a7de348 Expand li_std_string_runme.*
Add testing of the empty and null cases for all languages which
already have a runme.
2023-05-12 16:05:48 +12:00
Erez Geva b6eaee8d12 Add li_constraints test, testing 'constraints.i'.
For: JavaScript, C#, go, Java, Lua, Perl, PHP, python, Ruby, TCL and Octave.

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2023-05-12 01:23:31 +02:00
Olly Betts 6085a9661e Initial support for std::string_view
So far C#, Java, Lua and PHP are supported.

Closes: #2540
See #1567
2023-05-08 15:56:37 +12:00
Olly Betts 15b739d60e [PHP] Wrap method with both static and non-static overloads
We now wrap this as a non-static method in PHP, which means the static
form only callable via an object.

Previously this case could end up wrapped as static or non-static
in PHP.  If it was wrapped as static, attempting to call non-static
overloaded forms would crash with a segmentation fault.

See #2544
2023-05-08 15:44:24 +12:00
Olly Betts d9aeb01306 catches_strings_runme.php: Check exact exception message
There's no need to do a substring check here.
2023-04-24 15:15:44 +12:00
Olly Betts d45884bab5 [php] Add throws typemaps for string* + const string* 2023-04-24 12:18:52 +12:00
Olly Betts 6cd19ba926 [php] Support INPUT,INOUT,OUTPUT for std::string&
By default SWIG/PHP wraps std::string& as a pass-by-reference PHP
string parameter, but sometimes such a parameter is only for input
or only for output, so add support for the named typemaps that other
target languages support.
2023-04-21 17:50:25 +12:00
Olly Betts 3275331886 Add regression test for << in array size bug
Go is happy with the testcase if the type is changed from int to
char, so just go with that.

See https://sourceforge.net/p/swig/bugs/983/
2023-04-20 14:55:09 +12:00
Olly Betts 9873ff107a Remove remaining traces of PHP7 support
The bulk of this was already removed in
e3b112c69c.
2023-04-20 13:45:30 +12:00
Olly Betts e3b112c69c Remove support for PHP7
PHP7 security support ended 2022-11-28 so it doesn't make sense to
include support for it in the SWIG 4.2.x release series.
2023-04-14 17:38:01 +12:00
Olly Betts 747a6a264f [php] Fix handling of multi-module cases
Look up unknown base classes using SWIG_MangledTypeQueryModule().

Revert to using SWIG_TypeCheck() instead of SWIG_TypeCheckStruct()
as the latter doesn't seem to work for this case (at least for PHP
right now).

Add mod_runme.php as a regression test for this.

Adjust the PHP test harness not to set up reflection for the module
unless it's actually needed for a testcase.  Currently the approach
to find the module name doesn't work for multi-module testcases.

See #2126
2022-10-18 10:28:17 +13:00
Olly Betts fefb231bd8 [php] Update exception_memory_leak_runme.php
Test the new "return by value" case too.
2022-10-14 14:44:19 +13:00
Olly Betts 3dd7e93c77 Fix issues with exception_memory_leak testcase
The out typemap uses a function name which doesn't match the name of the
function we want it to apply to, so this testcase wasn't actually
triggering an exception so wasn't actually testing anything!

With that fixed, the testcase fails to compile for PHP due to use of
SWIG_exception_fail() (which not all target languages implement), and
with that fixed, the _runme.php needs a try ... catch adding to handle
the raised exception.
2022-10-14 12:12:21 +13:00
Olly Betts 91887a10cd [php] Avoid creating dynamic properties in testsuite
This gives a deprecation warning with PHP 8.2.
2022-09-28 18:53:04 +13:00
Olly Betts e789c9e799 [php] Avoid deprecated interpolation syntax
Avoid syntax deprecated in PHP 8.2.
2022-09-28 18:51:53 +13:00
William S Fulton ed333b6b97 std::string throws typemaps
Go, Guile, Racket, Scilab: Add throws typemaps for std::string so that
thrown string exception messages can be seen.

Test all language for std::string throws typemaps
2022-09-19 09:09:29 +01:00
William S Fulton 4a29229bab Add catches_strings test to test throws char * typemap 2022-09-19 09:09:29 +01:00
William S Fulton e97181ebc0 Add missing typecheck typemaps for std::auto_ptr and std::unique_ptr
To fix overloading when using these types.
2022-09-17 10:23:51 +01:00
William S Fulton dad7c93ca0 Provide SWIGTYPE MOVE typemaps in swigmove.i
For implementing full move semantics when passing parameters by value.
Based on SWIGTYPE && and std::unique_ptr typemaps which implement move
semantics.

Added for all languages, but untested for: Go, Ocaml, R, Scilab (and
unlikely to be fully functional for same reasons as for std::unique_ptr
support).

Issue #999
2022-09-16 08:36:25 +01:00
Olly Betts adc2fa9664 Fix default_args_runme.php for 32-bit platforms
On 32-bit platforms -2147483648 is a PHP float (rather than PHP int on
64-bit platforms) so only check equivalence rather than strict equality.

Fixes #2360
2022-09-14 11:30:28 +12:00
William S Fulton 2212af3f4f rvalue reference outputs
Document rvalue reference outputs behaviour
Test rvalue reference outputs
2022-09-08 08:46:32 +01:00
William S Fulton 7934561874 Test/fixes to handle NULL pointer for unique_ptr/auto_ptr
Also add missing unique_ptr tests for Lua and Racket.
2022-08-31 19:42:55 +01:00
William S Fulton e139a36511 SWIGTYPE && input typemaps now assume object has been moved
Replicated Java implementation.

Fully implemented for:
- C#
- D
- Guile
- Javascript (UTL)
- Lua
- MzScheme
- Octave (UTL)
- Perl (UTL)
- PHP
- Python (UTL)
- Ruby (UTL)
- Tcl (UTL)

PHP std::auto_ptr std::unique_ptr minor tweaks and testcase corrections
2022-08-31 19:40:14 +01:00
William S Fulton 63632f80fb Correct raw pointer handling test for virtual inheritance 2022-08-11 18:44:36 +01:00
William S Fulton fa9c7a7197 Add PHP support for std::unique_ptr and std::auto_ptr
Equivalent to Python/Ruby implementations.
2022-08-06 18:34:26 +01: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 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 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 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
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 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
Olly Betts 5ddcbac56b Test [[ and ]] in string literal are preserved
Suggested by wsfulton in #1158
2022-07-08 15:33:01 +12:00
Olly Betts 8987259959 Fix ticket reference in comment 2022-07-07 11:44:51 +12:00
William S Fulton 71cd6a38fe Performance optimisation for directors for classes passed by value
The directorin typemaps in the director methods now use std::move on the
input parameter when copying the object from the stack to the heap prior
to the callback into the target language, thereby taking advantage of
move semantics if available.
2022-07-04 11:19:29 +01:00
Olly Betts 9b096e6561 WIP 2022-06-14 17:40:12 +12:00
Olly Betts 9cdf46e8c8 [php] Adjust #required params for subclass methods
If the same method name is implemented in a parent class then the
subclass can't have more required parameters than that or else we
get a compatibility error when the module is loaded.

The testsuite wasn't catching this problem because it was no longer
trying to load the modules for testcases without _runme.php, because
the mechanism to do that relied on there being a generated .php
wrapper, which we no longer have by default.  Fix that to provide a
regression test for this fix.

See #2151
2022-06-14 16:00:46 +12:00
Olly Betts b41fede827 [php] Fix default_args_runme.php for PHP7.0 2022-06-12 15:27:49 +12:00