Commit graph

23,256 commits

Author SHA1 Message Date
William S Fulton
05b93b1f06 Improved template template parameters support.
Previously, specifying more than one simple template template parameter
resulted in a parse error. Now multiple template template parameters are
working including instantiation with %template. Example:

  template <template<template<class> class, class> class Op, template<class> class X, class Y>
    class C { ... };

Closes #624
Closes #1021
2022-12-02 19:16:02 +00:00
William S Fulton
c85e7f1625 Add ccache-swig hash fix to RELEASENOTES 2022-11-30 07:34:19 +00:00
William S Fulton
95951cb4db Merge branch 'fixes/push-pop-mismatch'
* fixes/push-pop-mismatch:
  Fix push/pop mismatch
2022-11-29 08:09:14 +00:00
William S Fulton
c5e02bf327 Ocaml name mangling fix
Fixes testcase template_expr which was resulting in OCaml syntax errors.
2022-11-29 08:04:37 +00:00
Bernhard Rosenkränzer
8ece583aa0 Fix push/pop mismatch
Without this, perlhead.swg does `#pragma GCC diagnostic pop`
if `__GNUC__ >= 10` - without any prior `#pragma GCC diagnostic push`.

There's also a mismatch between the conditions that trigger
`#pragma GCC diagnostic ignored` (where the `push` should be)
and the attempt to `#pragma GCC diagnostic pop`.
2022-11-29 00:55:07 +01:00
William S Fulton
acf040c3fe Add SWIG-4.1.1 RELEASENOTES summary 2022-11-28 08:02:37 +00:00
William S Fulton
60af317956 Fix UBSAN errors in ccache-swig
ccache.c:738:18: runtime error: null pointer passed as argument 1, which is declared to never be null
Fixes stderr redirect in testname CCACHE_CPP2, when the CCACHE_CPP2
environment variable is defined.

mdfour.c:91:20: runtime error: left shift of 139 by 24 places cannot be represented in type 'int'
Looks like this brings some stability to the md4 hash calculation.

Closes #2449
2022-11-26 18:18:55 +00:00
William S Fulton
637e297672 Test case fix for std::complex and non-floating types deprecation
From Visual Studio 2022:

warning C4996: 'std::complex<int>::complex': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning.
2022-11-26 10:18:11 +00:00
William S Fulton
ecf05445b9 Test cases fix 2022-11-26 10:04:35 +00:00
William S Fulton
15692f0e89 Add missing testcase cpp11_template_parameters_decltype 2022-11-26 01:27:04 +00:00
William S Fulton
2a1711e436 Slightly better decltype() support for expressions
decltype now accepts C++ expressions instead of just an ID, such as:

  int i,j;
  ...  decltype(i+j) ...
  ...  decltype(&i) ...

These result in a warning for non-trivial expressions which SWIG cannot evaluate:

  Warning 344: Unable to deduce decltype for 'i+j'.

See 'Type Inference' in CPlusPlus.html for workarounds.

Issue #1589
Issue #1590
2022-11-26 01:16:20 +00:00
William S Fulton
9b91b24d6b Fix syntax error parsing unnamed template parameters with a default.
Closes #961
2022-11-25 08:37:39 +00:00
Olly Betts
081d44d45e Follow-on fix for previous change
These cases don't trigger ubsan warnings and seem to work locally
for me, but CI was failing on a number of builds.

See #2447
2022-11-25 12:29:52 +13:00
Olly Betts
81c6a63898 Fix undefined behaviour in parser
Fix undefined behaviour in swig's parser when handling default parameter
expressions containing method calls.

Fixes #2447
2022-11-25 09:51:58 +13:00
William S Fulton
5a8d58c3a7 Merge branch 'rtests2'
* rtests2:
  more r tests
  more r tests
  added testcase pointer_reference
  [PHP] Update docs for removal of -noproxy in SWIG 4.1.0

Conflicts:
	CHANGES.current
2022-11-23 21:12:07 +00:00
William S Fulton
eef3de6574 Variadic template docs correction 2022-11-23 20:39:24 +00:00
William S Fulton
d3095144e1 Optimise SwigType_base implementation
Also fixes assumption that templates start '<' instead of '<('.
Checked java and python test-suite - no changes in output.
2022-11-23 20:22:40 +00:00
William S Fulton
e0904f44eb Restore testing template_expr testcase
Problems handling < and > in template parameters are now fixed.
Remove illegal C++ code (template typedefs) - replace with a function
using same template.
2022-11-23 07:32:12 +00:00
William S Fulton
ca5c68e544 Fix seg fault handling template parameter expressions containing '>='
Similar to previous commit

Issue #1037
2022-11-22 21:40:38 +00:00
William S Fulton
0341258af7 Fix seg fault handling template parameter expressions containing '<='
Recent commits ensure types are correctly stored in SwigType *. In
particular template parameters are enclosed within '<(' and ')>'.
Now we can confidently handle template parameters as really being
delimited as such to fix an infinite loop handling template expressions
containing '<' or '>'. The previous implementation only assumed
template parameters were delimited by '<' and '>'.

Issue #1037
2022-11-22 08:37:35 +00:00
AndLLA
1dd31446ce more r tests 2022-11-20 18:52:00 +01:00
William S Fulton
29bc7492a2 SwigType * handling corrections - Python builtin mangling
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Swig_string_mangle() takes a generic String *, but it was calling
functions that require SwigType *. Swig_string_mangle_type() is
now provided for SwigType *.

The previous commit is a pre-requisite in order to prevent duplicate
symbols from being generated in the C++ wrappers.
2022-11-18 19:44:00 +00:00
William S Fulton
4729cf2b1f Duplicate class template instantiations via %template changes
Named duplicate class template instantiations now issue a warning and are ignored.
Duplicate empty class template instantiations are quietly ignored.

The test cases are fixed for this new behaviour.

This commit is a pre-requisite for the near future so that the Python
builtin wrappers can correctly use the SwigType_namestr function without
generating duplicate symbol names.
2022-11-18 19:35:47 +00:00
AndLLA
a88995a11d more r tests 2022-11-16 22:17:25 +01:00
AndLLA
aab9c9843c Merge branch 'master' into rtests2 2022-11-16 20:57:03 +01:00
AndLLA
63821f1bb5 added testcase pointer_reference 2022-11-16 20:54:45 +01:00
Olly Betts
f1f77c218f [PHP] Update docs for removal of -noproxy in SWIG 4.1.0
Closes #2419
2022-11-13 15:23:42 +13:00
William S Fulton
777fd2c280 Minor refactor of D, C#, Java director code
for overloaded methods. Fixes regression (crash) in director_ignore D
testcase since string mangling names change.
2022-11-12 16:30:25 +00:00
William S Fulton
e3ccabbd4d Simpler names when using SwigType_manglestr for templates
The default template name is generated instead of one with the default
template parameter.

Used in various places such as the type system.
2022-11-12 11:46:52 +00:00
William S Fulton
46f2778412 Consolidate name mangling functions
Swig_string_mangle      => Swig_name_mangle_string
Swig_name_mangle        => Swig_name_mangle_string
Swig_string_mangle_type => Swig_name_mangle_type
2022-11-12 09:18:19 +00:00
William S Fulton
3364c18d06 Remove unused code in mzscheme.cxx 2022-11-12 09:06:26 +00:00
William S Fulton
6a9be797e1 SwigType * handling corrections - mangling
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Swig_string_mangle() takes a generic String *, but it was calling
functions that require SwigType *. Swig_string_mangle_type() is
now provided for SwigType *r. The special template handling
on types now occurs in this function.
2022-11-12 06:42:36 +00:00
William S Fulton
2acdfd77e9 SwigType * handling corrections
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Required reworking code that adds a fake inheritance for smart pointers
using the smartptr feature. Swig_smartptr_upcast() added as a support
function for this.
2022-11-09 22:11:27 +00:00
William S Fulton
ea3f043920 SwigValueWrapper and SwigType * correction
Modifying the type by adding in SwigValueWrapper needs to follow the
normal SwigType conventions for correct and proper type handling.
2022-11-08 09:11:35 +00:00
William S Fulton
c0026d036a
Merge pull request #2430 from AndLLA/rtests
more tests for R
2022-11-06 17:17:33 +00:00
William S Fulton
62be0de3d0 Workaround for incomplete or/and keyword support in VC++ 2022-11-06 17:08:12 +00:00
AndLLA
db9df1b3be more tests for R 2022-11-05 20:43:15 +01:00
William S Fulton
86b3e60617 rename cpp14_enable_if_t to cpp17_enable_if_t
std::enable_if_t is in C++14, but std::is_integral_v
is in C++17
2022-11-05 17:13:30 +00:00
William S Fulton
8ab66c3125 Add changes entry for -swiglib CMake fix 2022-11-05 10:19:36 +00:00
William S Fulton
1bc3b63b11 Correct ordering in CHANGES.current file 2022-11-05 10:18:02 +00:00
William S Fulton
be46d464a9 Merge branch 'swiglib'
* swiglib:
  CMake: Fix -swiglib on win32
2022-11-05 10:15:44 +00:00
William S Fulton
58324db9d2 Merge branch 'patch-5'
* patch-5:
  build: harden nuget.yml permissions
2022-11-05 09:50:55 +00:00
William S Fulton
52edda64c1 Fix infinite loop handling non-type template parameters
Fixes infinite loop due to () brackets in a non-type template
parameter containing an expression

Fixes #2418

Non-trivial expressions are still not qualified properly though.
2022-11-05 08:41:10 +00:00
William S Fulton
973590ff91 R rtypecheck typemaps
Further switch to use rtypecheck typemaps instead of hard coded logic.
The full switch to typemaps is deferred until swig-4.2 as it can't be fully
backwards compatible. For now a warning is provided to help the
transition. It provides the full typemap that should be placed into
a user's interface file, for example:

%typemap("rtype") int32_t * "integer"
void testmethod(int32_t * i);
void testmethod();

If there is no rtypecheck typemap for int32_t *, the warning shown is:

example.i:7: Warning 750: Optional rtypecheck code is deprecated. Add the
following typemap to fix as the next version of SWIG will not work without it:
%typemap("rtypecheck") int32_t * %{ (is.integer($arg) || is.numeric($arg)) %}

The warning is shown for any code that previously used "numeric", "integer" or
"character" for the rtype typemap. Copying the rtypecheck typemap as
shown into the user interface file will provide the appropriate fix and
the warning will disappear. This is important to do as swig-4.2 will
not be able to provide this helpful warning.
2022-11-05 08:40:26 +00:00
William S Fulton
d6d83f4df4 Overloading fixes for R and rtypecheck typemap
- Fix for special variable $argtype expansion in rtypecheck typemap.
- Remove unnecessary () brackets when using rtypecheck typemap for
  single parameter functions.
- Add rtypecheck typemaps for shared_ptr so that NULL can be used
  in overloaded functions taking shared_ptr.
2022-11-05 08:40:26 +00:00
William S Fulton
f2da4f2ade Improve R wrapper error message calling overloaded methods
when incorrect types passed are passed to the overloaded methods.

Old unhelpful error message:
  Error in f(...) : could not find function "f"

Example of new improved error message:
  Error in use_count(k) :
    cannot find overloaded function for use_count with argtypes (NULL)
2022-11-05 08:40:19 +00:00
William S Fulton
9e7610f972 Fix memory leak in R shared_ptr wrappers
Fix leak when a cast up a class inheritance chain is
required.

Adds implementation of SWIG_ConvertPtrAndOwn for R.

Closes #2386
2022-11-05 08:32:05 +00:00
William S Fulton
24b0e68391 li_boost_shared_ptr testcase for R
Synchronise test with Python version of testcase
2022-11-05 08:02:59 +00:00
William S Fulton
ed09dd948f cpp11_attribute_specifiers testcase warning suppression 2022-11-05 08:02:59 +00:00
William S Fulton
fe2d781b42 Bump version to 4.2.0 and migrate CHANGES to CHANGES.current 2022-11-04 20:09:13 +00:00