Commit graph

2,357 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
623b7d97a7 Remove swig.spec file
Discussion #2316
2022-09-20 22:31:50 +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
00190c484f Javascript, Octave, R - Improve exceptions for %catches
and exception specifications for native types.

Now the raised exception contains the string value as the exception
message instead of just the C/C++ type of the exception.

R exceptions were completely swallowed beforehand
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
c5610fd4b3 Guile - Add error checking to SWIGTYPE and SWIGTYPE & in typemaps
To prevent seg faults when passing #nil to these parameter types.
2022-09-16 18:52:52 +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
7eb54a38b1 Note workaround for -DFOO change
Code relying on FOO being defined as empty needs to change, but can
just use -DFOO= instead and remain compatible with older SWIG.

Fixes #2363
2022-09-14 10:11:36 +12:00
William S Fulton
26c0a0c152 CHANGES file tweaks 2022-09-09 19:01:54 +01:00
William S Fulton
0b1d3e3e86 Docs on rvalue parameter changes 2022-09-02 08:24:30 +01:00
William S Fulton
ca9eebcb8d Octave - SWIG now marshalls a C/C++ NULL pointer into the null matrix, []
SWIG has always marshalled the null matrix into a NULL pointer; this remains
and now we have consistency in representing a NULL pointer.

This is a pre-requisite for a pending commit to fully support std::unique_ptr.
2022-08-31 19:40:13 +01:00
William S Fulton
2cfd77b1c0 Racket - NULL pointer handling
SWIG now converts a C/C++ NULL pointer into a null value by calling
scheme_make_null(), so that scheme's null? is true for a NULL C/C++
pointer value.

Consistency with Guile and needed for a pending commit for handling
NULL and std::unique_ptr.
2022-08-31 19:40:13 +01:00
William S Fulton
48c644ea6e Add Racket support for std::unique_ptr and std::auto_ptr
Equivalent to Guile implementation.

Slight tweak to proxy ownership was required by adding in
the own member to swig_mz_proxy.
2022-08-18 22:45:03 +01:00
William S Fulton
23ce0655a6 Add Guile support for std::unique_ptr and std::auto_ptr
Equivalent to Python/Ruby implementations.
2022-08-12 23:50:54 +01:00
William S Fulton
41fddf61ec Add Lua support for std::unique_ptr and std::auto_ptr
Equivalent to Python/Ruby implementations.
2022-08-11 21:38:21 +01:00
William S Fulton
910fd1e3cf [D] Fix occasional undefined behaviour with inheritance hierarchies
Particularly when using virtual inheritance as the pointers weren't
correctly upcast from derived class to base class when stored in the
base's proxy class.

Fixes commented out test code in cpp11_std_unique_ptr_runme
and li_std_auto_ptr_runme D tests.
2022-08-05 22:30:23 +01:00
William S Fulton
5a379d317b Add Tcl support for std::unique_ptr and std::auto_ptr
Equivalent to C#/Java implementations.
2022-08-05 22:30:23 +01:00
William S Fulton
fe17296eb4 Add Javascript support for std::unique_ptr and std::auto_ptr
Equivalent to Ruby/Python implementations.
2022-08-04 07:14:30 +01:00
William S Fulton
2ccc9bd060 Add Octave support for std::unique_ptr and std::auto_ptr
Equivalent to Ruby/Python implementations.
2022-08-02 00:00:54 +01:00
William S Fulton
1d56bc6b85 Add initialisers for additional members in PyHeapTypeObject
(builtin mode) for Python-3.11 - _ht_tpname, _spec_cache.
2022-08-01 08:24:52 +01:00
William S Fulton
ffbde7a132 Fixes for deprecated std::basic_string::reserve() 2022-07-31 01:02:08 +01:00
William S Fulton
26fbf99901 Add Tcl support for std::unique_ptr and std::auto_ptr
Equivalent to Ruby/Python implementations.
2022-07-30 16:43:05 +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
8182740b8e Add documentation 2022-07-27 09:36:27 +12:00
Olly Betts
36310c04e5 Add comments to clarify how #define gets wrapped
It took me a while to fully get my head around this, and I'd like to
help out future developers.
2022-07-27 09:10:51 +12:00
Olly Betts
8c5c14b9ad Merge branch 'cpp-testing'
Closes #2329
2022-07-27 07:55:24 +12:00
Olly Betts
06d375cdab [Tcl] Fix handling of long long on 32-bit platforms
Fixes https://sourceforge.net/p/swig/bugs/977/ reported by Vera and
Kjell Wooding.

Closes #2331
2022-07-27 07:53:45 +12:00
Olly Betts
1bfe88eeda Support binary integer literals in the preprocessor 2022-07-26 15:28:51 +12:00
Olly Betts
de5ce08a7d Fix operator precedence in preprocessor expressions 2022-07-26 14:18:38 +12:00
William S Fulton
7592722e39 Order of interfaces generated for %interface macros
Ensure the order of interfaces generated in proxy interfaces for the
%interface family of macros is the same as that parsed from the bases in C++.
2022-07-20 19:50:53 +01:00
Olly Betts
e23d912b49 [python] Fix inheriting from multiple director classes
Fix mishandling of a Python class inheriting from multiple SWIG-wrapped
director classes.

Fixes #422
Fixes https://sourceforge.net/p/swig/bugs/1379/
2022-07-20 14:18:49 +12:00
William S Fulton
8b654afdef Merge branch 'unique_ptr-inputs'
* unique_ptr-inputs:
  std::unique_ptr std::auto_ptr tidyup
  Add support for std::auto_ptr inputs
  Cosmetic formatting and doc updates in std_unique_ptr.i files
  Add Perl support for std::unique_ptr inputs
  Add Ruby support for std::unique_ptr inputs
  Add Python support for std::unique_ptr inputs
  Add C# support std::unique_ptr inputs
  Java unique_ptr test ownership enhancement to test
  Java unique_ptr enhance test for double release
  SWIGTYPE && input typemaps now assume object has been moved
  Add Java support for std::unique<T> for input parameters.

Closes #692

Conflicts:
	CHANGES.current
2022-07-19 20:26:18 +01:00