Commit graph

23,118 commits

Author SHA1 Message Date
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
bc87fe151e Fix python/c++ coding confusion!
Visual c++ does not support 'and' yet.
2022-10-06 00:45:53 +01:00
William S Fulton
07f265a3bf Changes file typo fix 2022-10-06 00:38:03 +01:00
William S Fulton
7a5c5896f1 Testcase warning suppression 2022-10-06 00:36:59 +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
William S Fulton
6f1532e35a Warning fix for OCaml test 2022-10-05 22:41:22 +01:00
Olly Betts
06296a7128 Report errors in preprocessor expressions by default
Until now SWIG quietly ignored such errors unless -Wextra (or -Wall
which implies -Wextra) was passed, but this is unhelpful as it hides
problems.  To illustrate this point, enabling this warning by
default revealled a typo in the preproc_defined.i testcase in
SWIG's own testsuite.

If you really don't want to see this warning, you can suppress it
with command line option -w202 or by using this in your interface
file:

%warnfilter(SWIGWARN_PP_EVALUATION);

Both will work with older versions of SWIG too.

Fixes #1465
Fixes #2389
2022-10-05 17:07:06 +13:00
Olly Betts
befcd1bf58 Fix SWIG version reference in recent doc change
The upcoming release is 4.1.0 not 4.2.0.
2022-10-05 13:48:21 +13:00
Olly Betts
3096e8aa00 Fix doc typo 2022-10-05 12:41:34 +13:00
Olly Betts
4ac3c87a29 Sort out predefined SWIG-specific macros
Ensure that SWIG_VERSION is defined both at SWIG-time and in the
generated C/C++ wrapper code (it was only defined in the wrapper
for some target languages previously).

SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers
to match behaviour for all other target languages.

Stop defining SWIGVERSION in the wrapper.  This only happened as a
side-effect of how SWIG_VERSION was defined but was never documented and
is redundant.

The new testcase also checks that SWIG is defined at SWIG-time but not
in the generated wrapper, and that exactly one of a list of
target-language specific macros is defined.

Fixes #1050
2022-10-05 12:40:15 +13:00
Olly Betts
abc1c59c4e [php] Fix emitted PHP type declarations in corner cases
See #2151
2022-10-04 16:09:02 +13:00
Olly Betts
c7e1e64538 Prefer !Equal() to Cmp() != 0 2022-10-03 12:44:14 +13:00
William S Fulton
28202a0e27
Merge pull request #2249 from geographika/pcre-nuget
Update Windows CMake builds to use NuGet package for PCRE2
2022-09-30 23:43:45 +01:00
William S Fulton
929cfde883 C# CreateWStringFromUTF32 optimisation
Avoid UTF-32 to UTF-8 conversion then get string from UTF-8
Missing change that should have gone into eaf468e9e8
2022-09-30 23:21:39 +01:00
William S Fulton
e147f2af69 Generate richcompare switch statements in sorted order 2022-09-30 23:04:06 +01:00
William S Fulton
77b08daca7 Add DohSortedKeys function
Returns a list of sorted keys in a DOH Hash.
2022-09-30 22:48:04 +01:00
Olly Betts
216b47320b [ci] Revert continue-on-error for PHP 8.2
Tests are now passing there.
2022-09-30 09:22:03 +13:00
Olly Betts
eaaf893605 Adjust the DOH string hash function
The one we're currently using only considers the last five characters
plus the least significant bit of the last-but-sixth character, which
unsurprisingly generates a lot of many-way collisions.

This change seems to give about a 4% reduction in wallclock time for
processing li_std_list_wrap.i from the testsuite for Python.  The
hash collision rate for this example drops from 39% to 0!

Closes #2303
2022-09-30 09:17:50 +13:00
William S Fulton
cd46d65beb Testcase overloading warning fix 2022-09-29 19:40:52 +01:00
William S Fulton
15b2ec53e3 Runtime tables deterministic ordering (4)
Output C/C++ type strings (| separated) in swig_type_info tables in
fixed order. The types are output in alphabetically sorted order,
with an exception. The final type is a fully resolved type, but
does not necessarily include default template parameters.
This type is the one used by SWIG_TypePrettyName which is commonly
used to display a type when the wrong type is passed in as a
parameter.

Previously the order was not very deterministic due to the use of
internal hash tables which do not have an ordering guarantee.
2022-09-29 19:40:47 +01:00
William S Fulton
5fdb591a62 Runtime tables deterministic ordering (3)
Output conversion functions used in the type tables in sorted order.
Sorted order in this case is the type being converted from.
So _p_BarTo_p_Foo comes before _p_ZarTo_p_Foo.

Previously the order was roughly in the order that the types were
parsed, but not necessarily due to the use of internal hash tables
which do not have an ordering guarantee.
2022-09-29 19:30:20 +01:00
William S Fulton
04af102578 Runtime tables deterministic ordering (2)
Output conversion functions used in the type tables in sorted order.
Sorted order in this case is the type being converted to.
So _p_BarTo_p_Foo comes before _p_BarTo_p_Zoo.

Previously the order was roughly in the order that the types were
parsed, but not necessarily due to the use of internal hash tables
which do not have an ordering guarantee.
2022-09-29 19:30:20 +01:00
William S Fulton
acbe8ed49c Runtime tables deterministic ordering (1)
Many parts of the runtime tables are alphabetically sorted before
for the generated code. This patch sorts the elements within the
swig_cast_info lists. Order now is first the elements without a
converter then the elements with a converter.
For example:

new:
static swig_cast_info _swigc__p_Foo[] = {
  {&_swigt__p_Foo, 0, 0, 0},
  {&_swigt__p_Bar, _p_BarTo_p_Foo, 0, 0},
  {&_swigt__p_Spam, _p_SpamTo_p_Foo, 0, 0},
  {0, 0, 0, 0}};

old:
static swig_cast_info _swigc__p_Foo[] = {
  {&_swigt__p_Bar, _p_BarTo_p_Foo, 0, 0},
  {&_swigt__p_Foo, 0, 0, 0},
  {&_swigt__p_Spam, _p_SpamTo_p_Foo, 0, 0},
  {0, 0, 0, 0}};

Previously the order was roughly in the order that the types were
parsed, but not necessarily due to the use of internal hash tables
which do not have an ordering guarantee.
2022-09-29 19:30:20 +01:00
Olly Betts
3bf1da4298 Fix a few documentation typos 2022-09-29 18:17:32 +13:00
Olly Betts
9a4dea06c8 [php] Add php:allowdynamicproperties feature
This follows PHP 8.2 deprecating dynamic features.

The new feature also provides a clean way to fix the remaining PHP
test case failure under PHP 8.2.
2022-09-29 18:16:51 +13:00
Olly Betts
20ed76a27b [ci] Revert continue-on-error for PHP 8.0
Tests are now passing there.
2022-09-29 14:09:01 +13:00
Olly Betts
9908f9f310 [php] Fix testcase segfaults with PHP 8.0
These testcases were segfaulting:

prefix
director_using_member_scopes
virtual_poly

The fix here is admittedly a hack - we perform the initialisation
of EG(class_table) from CG(class_table) which PHP will do, but
hasn't yet.

PHP doesn't seem to clearly document which API calls are actually
valid in minit or other initialisation contexts, but the code we're
generating works with all PHP 7.x and PHP 8.x versions aside from PHP
8.0 so it seems this is a bug in PHP 8.0 rather than that we're doing
something invalid, and we need to work with existing PHP 8.0 releases
so this hack seems a necessary evil.  It will at least have a limited
life as PHP 8.0 is only in active support until 2022-11-26, with
security support ending a year later.

Fixes #2383.
2022-09-29 13:13:52 +13:00
Olly Betts
cb9c96011a [php] Suppress -Wdeclaration-after-statement in php.h
In PHP 8.2 zend_operators.h contains inline code which triggers this
warning and our testsuite uses with option and -Werror.

I don't see a good way to only do this within our testsuite, but
disabling it globally like this shouldn't be problematic.
2022-09-29 11:06:56 +13:00
Olly Betts
246dd2d787 [php] Workaround PHP 8.2 header problem
We need to include php.h before stdio.h (and probably before most
other libc headers).
2022-09-28 19:01:01 +13:00
Olly Betts
55c95d475c [php] Adapt swig_ptr_cast_object for PHP 8.2
The required return type has changed from int to an enum, which
gives a compiler warning when we assign a function pointer.
2022-09-28 18:59:31 +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
Olly Betts
303cf392f7 [ci] Temporarily allow PHP 8.0 and 8.2 to fail
I'm actively working on fixing them, but meanwhile we don't want PR
jobs failing on these.
2022-09-28 18:50:08 +13:00
Olly Betts
c3ae2aaafc [ci] Fix CI to actually test PHP 8.0; add PHP 8.2
The CI job for PHP 8.0 was relying on not specifying a version
giving us PHP 8.0, but actually it gives us 8.1 currently.

This seems too brittle, so always specify the version explicitly as
at worst it means uninstalling and reinstalling PHP packages in a
case we could avoid.

Also add PHP 8.2 testing.

See #2383
2022-09-28 11:13:36 +13:00
sethg
e45d8d0efd Split build and install 2022-09-27 15:02:58 +02:00
sethg
1d47e11da9 Build and Install are in the same command 2022-09-27 11:01:35 +02:00
sethg
730e49d379 Move install to separate step 2022-09-27 10:32:16 +02:00
sethg
95d255e16e Switch Action and docs to use PowerShell 2022-09-27 09:48:19 +02:00
William S Fulton
eaf468e9e8 C# CreateWStringFromUTF32 optimisation
Avoid UTF-32 to UTF-8 conversion then get string from UTF-8
Issue #2369
2022-09-22 18:54:49 +01:00
Frank Schlimbach
fa00622614 Fixes for classes with the same name in different namespaces
Includes the majority of patch #1484.
Excludes changes in typepass.cxx for specializations which have no effect
on the duplicate_class_name_in_ns testcase, nor the rest of the test-suite.
2022-09-21 22:38:22 +01:00
William S Fulton
ee9e436971 Fix -Wmisleading-indentation in Octave wrappers 2022-09-20 22:31:50 +01:00
William S Fulton
623b7d97a7 Remove swig.spec file
Discussion #2316
2022-09-20 22:31:50 +01:00
William S Fulton
9081e3e878
Merge pull request #2374 from friedrichatgc/fix_octave_horzcat
Fix octave operator horzcat test
2022-09-19 15:10:30 +01:00
William S Fulton
e407ccd4fe Move SWIG_Octave_Raise into a function
For efficiency and to fix some warnings
2022-09-19 14:48:33 +01: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
034e2358f9 Add Racket throws typemaps for char * 2022-09-19 09:09:29 +01:00