We had a banner for C, a banner for target languages (parameterised
to allow the comment sequence to be specified) and a special banner
for XML files in scilab.cxx.
The XML variant was only needed because the standard banner contains
`--` for a hyphen, so we now use ` - ` for that instead.
The C banner now calls Swig_banner_target_lang() with a suitable
comment sequence to print the actual banner text.
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
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#1465Fixes#2389
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
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
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.
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.
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.
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.
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.
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.
Unfortunately the changes of 26bf86322 (Use SWIG-specific for
non-overloaded synthesized functions too, 2021-11-09) did break some
existing code bases using SWIG as they hardcoded the old wrapper
function names.
So turn this off by default and add a global variable allowing to enable
this, which can be done for a specific language only. This is ugly but,
unfortunately, there is no way to use the Language object from the C
function Swig_MethodToFunction(), so the only alternative would be to
add another parameter to it, but it already has 6 of them, so it
wouldn't really be that much better.
See #2366, #2368, #2370.
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.
I don't think any valid C program can contain `<=>` in a tokenisable
context, but it's more helpful to fail with a syntax error at SWIG
parse time and not potentially generate C code trying to use `<=>` in
an expression which then fails at compile time.
This reverts commit 0ff9a0959a.
The modified fix breaks Java and C#, where C constant expressions
get used in the generated target language code in some cases.
Revert this fix for now.
Remove some erroneously added brackets_increment() calls.
Reject <=> in preprocessor expressions with a clear error message (it
seems it isn't supported here - clang and gcc don't at least).
The type returned by `<=>` is not `bool`. We pretend it's
`int` for now, which should work for how it's likely to be used
in constant expressions.
Fixes#1622
This OS has been unsupported for over 20 years. We stopped providing
macswig builds more than 20 years ago too:
https://sourceforge.net/projects/swig/files/macswig/
The required SIOUX library doesn't seem to be available anywhere
now either.
Closes#2323
Avoid using reserved identifiers such as `_DOHINT_H` (fixes#1989),
fix cases where the name doesn't match the filename, and make the naming
more consistent and less likely to collide with include guards in other
headers.
Under %feature("php:type", "compat") we don't generate return type
declaration for virtual methods if directors are enabled for that class.
However if a base class of the class has a method of the same name which
isn't directed this was still getting a return type declaration which
caused PHP to give an error when it tried to load the module.
Now we detect this situation and suppress the base class method's
return type declaration too.
Re-enable testcase director_redefined which now works again (it was
failing under PHP8 due to this issue).
See #2151
Performance optimisation for parameters passed by value that are C++11 movable.
Test copy constructor and assignment operator calls for movable types
Conflicts:
CHANGES.current
Changing the hash function breaks some testcases.
It seems there's a latent bug here (I suspect something somewhere in
SWIG depends on the hash iteration order), but I didn't see where and
we can't really have CI continuing to fail.
See #2303.
This reverts commit 5a96a39aa4.