Commit graph

23,294 commits

Author SHA1 Message Date
William S Fulton
63bf998b30 Make new testcase c++98 compliant 2023-02-17 18:44:56 +00:00
William S Fulton
817c700ced Template partial specialization improvements
Closes #1300

Changes to support the first example below (partial specialization of
template parameter types like Vect<int>). Previous implementation and
design could only handle one template parameter name per template
specialization argument, such as Vect<TS> for the first template
specialization argument (for first example below)
  template<class TS, typename TTS> class Foo<Vect<TS>, int> { ... };
and not
  template<class TS, typename TTS> class Foo<Vect<TS, TTS>, int> { ... };
New approach is to not modify 'templateparms' in the template node,
(except to fill in default args from primary template)
Previous implementation also assumed a template parameter could not be
used more than once in the specialized arguments, such as
  template<typename T> struct Hey<T, T> { void specialA() {} };

Examples
========
1) For primary:
  template<class T, typename TT> class Foo { ... };
and specialization:
  template<class TS, typename TTS> class Foo<Vect<TS>, TTS> { ... };

Fix specialization template from (wrong)
| templateparms - 'Vect< TS >,typename TTS'
to (correct/new way)
| templateparms - 'class TS,typename TTS'

2) For primary:
  template<typename P1 = int, typename P2 = double> struct Partialler { void primary(P1, P2) {}; };
and specialization:
  template<typename S1, typename S2> struct Partialler<S2, S1*> { void special(S1*, S2, bool) {}; };

Specialized template changes from (wrong)
| templateparms - 'typename S2=int,typename S1=double'
to (correct/new way, default args are removed)
| templateparms - 'typename S1,typename S2'

and subsequent change to partialargs from
| partialargs  - "Partialler<($1,p.$2)>"
to
| partialargs  - "Partialler<($2,p.$1)>"
so that the $n number is now more logically the nth template parameter in templateparms

3) For primary:
  template<typename X, typename Y> struct Hey { void primary() {} };
and specialization:
  template<typename T> struct Hey<T, T> { void specialA() {} };

old (wrong/old way)
| templateparms - 'typename T,typename T'
new (correct/new way)
| templateparms - 'typename T'

These are unchanged and are okay:
| partialargs  - "Hey<($1,$1)>"

4) For primary:
  enum Hello { hi, hello };
  template <Hello, class A> struct C {};
and specialization:
  template <class A> struct C<hello,A> { ... };

old (wrong/old way)
| templateparms - 'hello,class A'
new (correct/new way)
| templateparms - 'class A'

and subsequent changes to partialargs from
| partialargs  - "C<(hi,$2)>"
to
| partialargs  - "C<(hi,$1)>"

Test-suite
==========
Identical output as before in Python but in Java, an unimportant change
in cpp11_variadic_function_templates.i results in one variadic parameter
name being different.

New testcase template_partial_specialization_more.i with more testcases
added including above examples that are not already in the test-suite.
2023-02-17 08:24:25 +00:00
William S Fulton
bd2de6fc06 Fix deduction of partially specialized template parameters
when the specialized parameter is non-trivial, used in a wrapped method
and the type to %template uses typedefs. For example:

  typedef double & DoubleRef;
  template <typename T> struct XX {};
  template <typename T> struct XX<T &> { void fn(T t) {} };
  %template(XXD) XX<DoubleRef>;

The type of the parameter in the instantiated template for fn is now correctly deduced
as double.
2023-02-17 08:23:41 +00:00
William S Fulton
cac16bf94d Rewrite does_parm_match used in template partial specialization
Re-implement this function in preparation for fixing bugs in this
function. This rewrite should result in no change in the way it
previously worked for now.
2023-02-17 08:22:55 +00:00
William S Fulton
728f89adad Add missing template_function_parm testcase 2023-02-17 08:22:55 +00:00
Olly Betts
b9153698db Drop configure probe for popen()
It was only used by the command encoder which we removed.
2023-02-03 11:58:10 +13:00
Olly Betts
f294542198 Fix a couple of typos in CHANGES 2023-01-27 11:21:47 +13:00
Olly Betts
1ee9af51a1 Add CHANGES.current entry for previous commit 2023-01-27 11:19:18 +13:00
Julien Schueller
2cc4f51f9a Avoid unused parameter self warning 2023-01-27 11:17:30 +13:00
Olly Betts
747651c7e4 configure: Check for php8.2 too 2023-01-18 16:11:11 +13:00
William S Fulton
b18b75369c Fix seg fault using %template
Fix seg fault when instantiating templates with parameters that are function
parameters containing templates, such as:

              %template(MyC) C<int(std::vector<int>)>;

Closes #983
2023-01-03 23:53:34 +00:00
William S Fulton
2fc0edc4fd Instantiation of C++11 variadic function templates
Complete support for C++11 variadic function templates. Support was previously limited
to just one template parameter. Now zero or more template parameters are supported
in the %template instantiation.
2023-01-03 22:38:46 +00:00
William S Fulton
cdc08c9325 Move variadic function template tests to separate testcase 2023-01-03 21:26:12 +00:00
William S Fulton
20ff64217d Merge branch 'OCaml-rename_rstrip_encoder-using2-runtime-tests'
* OCaml-rename_rstrip_encoder-using2-runtime-tests:
  Complete copy of testcase from Python
  [OCaml] Runtime tests for rename_rstrip_encoder and using2
2022-12-30 23:49:34 +00:00
William S Fulton
b7f64c4da5 Complete copy of testcase from Python 2022-12-30 23:49:07 +00:00
William S Fulton
223ddc4294
Merge pull request #2460 from swig-fortran/remove-python-sprintf
[Python] Eliminate sprintf in generated code
2022-12-30 23:32:22 +00:00
William S Fulton
ef4c61c23c Allow Scilab 5.5 failure since downloads have moved
Waiting for URL redirects to be put in place.
2022-12-30 22:42:14 +00:00
William S Fulton
041ec79747 More variadic template testing
Test less conventional function ptr parameters
2022-12-30 22:31:56 +00:00
William S Fulton
32c86d9f14 Slight simplification parsing variadic template parameters 2022-12-30 00:20:37 +00:00
William S Fulton
004af63f3c Syntax error fixes parsing more elaborate parameter pack arguments
that are function pointers and member function pointers.

  template <typename... V> struct VariadicParms {
    void ParmsFuncPtrPtr(int (*)(V*...)) {}
    void ParmsFuncPtrPtrRef(int (*)(V*&...)) {}
    void ParmsFuncPtrPtrRValueRef(int (*)(V*&&...)) {}
    void ParmsFuncPtrRef(int (*)(V&...)) {}
    void ParmsFuncPtrRValueRef(int (*)(V&&...)) {}

    void ParmsMemFuncPtrPtr(int (KlassMemFuncs::*)(V*...)) {}
    void ParmsMemFuncPtrPtrRef(int (KlassMemFuncs::*)(V*&...)) {}
    void ParmsMemFuncPtrPtrRValueRef(int (KlassMemFuncs::*)(V*&&...)) {}
    void ParmsMemFuncPtrRef(int (KlassMemFuncs::*)(V&...)) {}
    void ParmsMemFuncPtrRValueRef(int (KlassMemFuncs::*)(V&&...)) {}
  };

  %template(VariadicParms0) VariadicParms<>;
  %template(VariadicParms1) VariadicParms<A>;

  Also in various other places such as within noexcept specifiers:

    template<typename T, typename... Args>
    void emplace(Args &&... args) noexcept(
        std::is_nothrow_constructible<T, Args &&...>::value);

Issue #1863
2022-12-30 00:19:02 +00:00
William S Fulton
674abaddbf Fix instantiation of variadic class templates
containing parameter pack arguments that are function pointers.

  template <typename... V> struct VariadicParms {
    void ParmsFuncPtrVal(int (*)(V...)) {}
  };

  %template(VariadicParms0) VariadicParms<>;
  %template(VariadicParms1) VariadicParms<A>;
2022-12-29 23:38:17 +00:00
William S Fulton
70837bbc26 Fix syntax error parsing variadic template parameter pack arguments
that are function pointers

Issue #1863
2022-12-23 16:25:50 +00:00
William S Fulton
b13f584258 Lua variadic templates sizeof... constants fix 2022-12-22 22:07:45 +00:00
William S Fulton
91af6cba27 Parser code refactor around variadic types 2022-12-22 21:23:44 +00:00
William S Fulton
cdf9a18603 Document improved variadic template support 2022-12-22 21:23:44 +00:00
William S Fulton
f648e58cb1 Extend variadic template support to various type combinations 2022-12-22 21:23:44 +00:00
William S Fulton
67c4c2186c Support multiple arguments in variadic templates.
Remove warning SWIGWARN_CPP11_VARIADIC_TEMPLATE which was issued if more
than one argument was used for a variadic template.

SwigType enhancement: 'v.' now represents a variadic argument.
2022-12-22 21:23:39 +00:00
William S Fulton
1e73045da8 Refactor Swig_cparse_template_parms_expand()
Break up functionality in Swig_cparse_template_parms_expand() to make it
more readable / maintainable.
2022-12-21 20:15:47 +00:00
William S Fulton
9e8a0daf9e Refactor %template parameters handling
Move code from %template parsing in parser.y into new function
Swig_cparse_template_parms_expand
2022-12-09 19:23:57 +00:00
Seth R Johnson
f734c23e8c Eliminate sprintf in generated python code
Newer clang versions emit warnings in generated code:
```
warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
```
2022-12-06 21:54:24 -05:00
William S Fulton
8a24c19d26 Fix syntax error for misplaced Doxygen comment after struct/class member.
Fix syntax error using Doxygen member groups syntax, "///*}", when used after
final struct/class member.

Issue #1636
2022-12-06 21:31:38 +00:00
William S Fulton
dc04564023 Improved handling of Doxygen comments in parameter lists
Fix garbled Doxygen post comments in parameter lists.
Fix syntax error parsing a trailing Doxygen comment in parameter lists.

Closes #2023
2022-12-05 19:47:59 +00:00
Zackery Spytz
90dce1af3e [OCaml] Runtime tests for rename_rstrip_encoder and using2
Add runtime tests for rename_rstrip_encoder and using2.

They are based on the runtime tests that already exist for other
languages.
2022-12-04 19:37:22 -08:00
William S Fulton
f7b4127310 Fix syntax error parsing of Doxygen comments after last enum item
It is unconventional to have a doxygen comment after an enum item. It is
attached to the previous, that is, the enum item to match Doxygen behaviour.

Closes #1609
2022-12-03 10:09:37 +00:00
William S Fulton
24f75aa481 Fix parsing of unconventional Doxygen post comments for enum items.
Closes #1715
2022-12-03 09:49:42 +00:00
William S Fulton
1cdeb458de Testcase fix for -Wdelete-non-virtual-dtor 2022-12-02 22:47:14 +00:00
William S Fulton
8047d5a332 swig-4.1.1 changes
Copy CHANGES.current from release-4.1.1 branch into CHANGES.
Remove items released in 4.1.1 from master CHANGES.current.
2022-12-02 20:57:54 +00:00
William S Fulton
7bdc708e5f Template parameters handling tidy up
Technical correction on how template parameters are stored in a Parm*.
Doesn't actually make any change, but they are now displayed correctly
when using debug options such as -debug-module.
2022-12-02 19:44:59 +00:00
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