Commit graph

2,396 commits

Author SHA1 Message Date
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
cdf9a18603 Document improved variadic template support 2022-12-22 21:23:44 +00: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
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
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
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
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
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
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
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
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
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
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
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
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
fe2d781b42 Bump version to 4.2.0 and migrate CHANGES to CHANGES.current 2022-11-04 20:09:13 +00:00
Zackery Spytz
899c9b819e Modify some CHANGES entries that weren't written by me
[skip ci]
2022-10-25 10:16:07 +13:00
William S Fulton
c9dcd0ee78 Add SWIG-4.1.0 release date 2022-10-24 19:47:03 +01:00
William S Fulton
6c4dcbb8fe R shared_ptr fixes
Fix problems in shared_ptr wrappers where the class names were
not consistent when using the shared_ptr template or the actual
underlying type. Move $R_class substitution to typemaps.

Issue #2386
2022-10-24 19:37:56 +01:00
William S Fulton
6370fab025 R - fix $typemap() for R specific typemaps
Add support for special variable replacement in the $typemap()
special variable macro for R specific typemaps (rtype, rtypecheck,
scoercein, scoereout).
2022-10-24 16:27:54 +01:00
William S Fulton
1d73341aa4 Polymorphism in R wrappers fixed for C++ structs 2022-10-24 08:56:55 +01:00
Olly Betts
a5bc48afea [Lua] Fix type resolution between SWIG-wrapped modules
See #2126
2022-10-20 10:14:59 +13:00
William S Fulton
d8a0286012 R - Add support for std::vector<std::vector<std::string>>
Closes #2385
2022-10-17 20:14:45 +01:00
William S Fulton
1b5c4546ba Add v8 numeric change to changes file 2022-10-14 19:25:13 +01:00
Olly Betts
5f96d15943 [R] Run destructors of local C++ objects on SWIG_fail
Arrange that destructors of local C++ objects in the wrapper function
get run on SWIG_fail (which calls Rf_error() which calls longjmp()).

We achieve this by putting almost everything in the function in its
own block, and end that right before Rf_error() at which point those
destructors will get called.
2022-10-14 14:44:19 +13:00
Olly Betts
9ab9c71623 [lua] Run destructors of local C++ objects on SWIG_fail
Arrange that destructors of local C++ objects in the wrapper function
get run on SWIG_fail (which calls lua_error() which calls longjmp()).

We achieve this by putting almost everything in the function in its
own block, and end that right before lua_error() at which point those
destructors will get called.
2022-10-14 14:44:19 +13:00
William S Fulton
752b7e82cd Add missing SWIGTYPE *const& typemaps 2022-10-13 22:22:18 +01:00
William S Fulton
f13de56e5f Revert "[xml] Move to "Experimental" target language status"
This reverts commit 22a4355f34.

Conflicts:
	CHANGES.current
	RELEASENOTES
2022-10-13 21:14:44 +01:00
Olly Betts
87a677b8b3 Fix doc typos 2022-10-11 10:30:33 +13:00
William S Fulton
2268d6ee96 Fix compile error when using directors
Fix when using templates with more than one template parameter
and used as an input parameter in a virtual method in a
director class (problem affecting most of the scripting languages).

Fixes #2160
2022-10-10 19:51:08 +01:00
William S Fulton
2f55379687 Improve director unwrap detection for the return type
Resolve the return type to correctly determine if the type is a pointer or
reference to a director class.

SwigType_refptr_count_return() recently added as a simpler fix is no
longer needed.

The conventional approach of using the "type" rather than "decl" to
analyse the return type is used instead too.

Issue #1823
2022-10-10 08:45:26 +01:00
William S Fulton
e1fdb67f09 Document CFFI removal 2022-10-06 23:29:33 +01:00
Olly Betts
6f3f4fbdf1 [Python] Remove deprecated and apparently useless defarg.swg
The only documentation is in the file itself and describes a Python
wrapper around the C function defined here, but digging though the git
history this Python wrapper doesn't seem to have ever actually been
generated by SWIG.

This file was also marked as deprecated in 2005.

Fixes #2390
Fixes #2391
2022-10-06 12:57:48 +13:00
William S Fulton
07f265a3bf Changes file typo fix 2022-10-06 00:38:03 +01:00
William S Fulton
5644680788 Doxygen Java fix quoting for \image command
Closes #2048
2022-10-06 00:29:03 +01:00
William S Fulton
45f4b4d936 Merge branch 'python_subinterpreter_issues'
* python_subinterpreter_issues:
  added comment in CHANGES.current
  always get the type_pointer from capsule instead of using a static variable as the value may change after re-initilization/due to subinterpreters
  added interpreter_counter to deinitialize only once in case of subinterpreters

Conflicts:
	CHANGES.current
	Lib/python/pyrun.swg
2022-10-05 23:18:15 +01:00
William S Fulton
ba279ae939 Add support for parsing C++11 final classes
Such as:

  class X final {};

This no longer gives a syntax error.
This change has introduced one more shift-reduce conflict in the parser.
with a conflict with a C style variable declaration with name final:

  class X final;

resulting in a syntax error (for C++ not C). This is an an unusual style
for C++ code and more typical declarations do work:

  X final;

Closes #672
2022-10-05 22:42:17 +01:00
William S Fulton
76f5670fa4 Fix OCaml %rename for enum items 2022-10-05 22:42:17 +01:00