Commit graph

22,495 commits

Author SHA1 Message Date
Olly Betts
7ec2f89fe2
Remove redundant NULL checks before free()/delete (#2184)
Remove redundant NULL checks before free()/delete

The ISO C and C++ standards guarantee that it's safe to call these
on a NULL pointer, so it's not necessary for the calling code to
also check.

Fixes https://sourceforge.net/p/swig/feature-requests/70/
2022-01-29 22:03:48 +13:00
Thomas Reitmayr
5a10e10399 Ruby: Fix warnings in generated code about missing parameter in variadic macro
The Ruby C API function 'rb_funcall' is used in various places in generated
code for invoking a Ruby method without parameters. The C function uses a
variadic parameter list for the arguments passed to Ruby, therefore in these
cases the list of variadic parameters is empty.
As an optimization Ruby may implement the 'rb_funcall' function as a macro
which however will not accept an empty list of arguments for '...' as of
C99 and C++11.
In order to prevent compiler warnings, this commit replaces all such
occurrences with a call to 'rb_funcall2' (which in its current name
'rb_funcallv' is invoked by the 'rb_funcall' macro anyway, at least for
Ruby 2.6.6).
2022-01-29 11:07:57 +13:00
sethg
c7cfabd0a7 Update CMake build to use NuGet Bison3 2022-01-29 09:19:04 +13:00
Corey Minyard
97b4cccbbd Talk about namespaces and unignoring
It was not obvious to at least one person that namespaces need to be
unignored just like classes and methods.  Add an explicit reference to
that in the docs.

Also add something to unignore all classes in the example that shows how
to ignore all classes, as that might not be obvious.

Fixes #193
2022-01-29 09:18:33 +13:00
Corey Minyard
4949b2e760 Add an example for unignoring everything
In the example for ignoring everything, it didn't show how to undo the
ignore all, and the obvious '%rename("") ""' didnt work.
'"%rename("%s") ""' is the right way to do that, so add it to the
example.

Fixes #2173
2022-01-29 08:58:25 +13:00
Corey Minyard
69f94723d2 Fix the recent %rename docs
The example I recently added about renaming didn't compile.  Here's the
fix.

There was also a use of the term "override" which should have been
changed to "replace".
2022-01-29 08:57:17 +13:00
William S Fulton
fa8c89ddf5 Move docs on replacing c++ class methods to C++ section
[skip ci]
2022-01-27 21:25:35 +00:00
William S Fulton
7c44526180 Merge branch 'doc-work2-v2'
* doc-work2-v2:
  Improve documentation on %rename
2022-01-27 20:54:20 +00:00
William S Fulton
67de990506 HTML formatting fixes 2022-01-27 20:39:04 +00:00
William S Fulton
c886c96316 Merge branch 'cmake-docs'
* cmake-docs:
  Add CXX flag
  Updated and verified CMake build docs
2022-01-27 20:30:12 +00:00
Olly Betts
cb1c60e3d8 [python] Fix GCC -Wunused-variable with -builtin
Fixes #1697
2022-01-27 22:34:30 +13:00
Olly Betts
bb011e28a9 Try to fix Bison portability issue
YYEOF works as a token for "end of file" on my dev box but fails in
CI.  I assume it must be a Bison version difference.

Based on the Bison manual, I'm trying this fix (which also works on my
dev box).
2022-01-27 20:17:21 +13:00
Olly Betts
f0c0816cde Update out-of-date docs re _runme3.py 2022-01-27 16:10:10 +13:00
Olly Betts
282e4ed4ab Issue error for missing ; after %constant
Previously there was no warning or error, no files were produced,
but exit status was 0.

Fixes #346
2022-01-27 15:35:24 +13:00
Corey Minyard
f878b17679 Improve documentation on %rename
Add documentation on %rename of names replacing previous %renames of
the same name, and how to replace methods in classes using %rename.
2022-01-26 19:37:58 -06:00
sethg
720397baba Add CXX flag 2022-01-26 23:12:18 +01:00
Olly Betts
7963807308 [python] Remove unused bogus fallback macro
This fallback version of PyString_AS_STRING() for Python 3 makes use of
PyUnicode_AS_STRING, but I can find no evidence that ever existed in
Python - all references I've found are to SWIG or SWIG-generated code.

The only uses of PyString_AS_STRING() in SWIG generated code are for
Python 2 #if-branches, so this fallback is never used by SWIG.

Because it doesn't work it can't be usefully used in user interface
files either, so let's remove it to avoid potential user confusion
(such as #987).
2022-01-27 09:32:25 +13:00
sethg
e941f7e3fa Updated and verified CMake build docs 2022-01-26 14:30:06 +01:00
Olly Betts
07f5b37c30 Fix invalid code in testcase typemap_qualifier_strip.i
This testcase was using a pointer to a variable which had gone out
of scope, which is undefined behaviour.  The test was only passing
because the tests are compiled without optimisation by default and
the memory where this value lived happened to remain intact in that
case with current versions of compilers we test with.  Running the
testsuite with CXXFLAGS=-O2 causes this test to fail.

Fix by extending the lifetime of the variable to the whole wrapper
function.

Fixes #1925
2022-01-26 15:39:38 +13:00
Olly Betts
4173892cca Add CHANGES.current entry for AIX fixes 2022-01-26 15:31:19 +13:00
Olly Betts
3e42fec457 Use CFLAGS for testcases on AIX
On AIX, one can compile applications either in 32bit or 64bit.
With GCC, this is done by using: -maix64 or -maix32 (default).
Thus, when building & testing Swig in 64bit, the -maix64 option must be
passed to all calls to gcc.

Fixes #1923
2022-01-26 15:27:08 +13:00
Olly Betts
f104c4411f Rename variable in director_thread test
This avoids a clash with thread_terminate defined in an AIX include
file.

Fixes #1921
2022-01-26 15:23:46 +13:00
Olly Betts
e21ea9b167 Fix LDSHARED on AIX
Stop trying to use an ld_so_aix script which hasn't been present in
the tree since at least the start of git history in 1999.

Fixes #1919
2022-01-26 15:16:39 +13:00
Olly Betts
0a7192ce8b [doxygen] Fix crash on unclosed HTML tag
Fixes #1935
2022-01-26 15:12:21 +13:00
Olly Betts
e9a1aa0f9f [python] Reject -builtin with -noproxy
This option combination doesn't make sense, and result in code which
doesn't compile.

Fixes #1990
2022-01-26 14:32:32 +13:00
Olly Betts
005ffc76de [python] Fix double free on error in docs example
Closes #2073
2022-01-26 13:30:15 +13:00
Olly Betts
ccd313ac64 Move new testcase which needs C++11
I don't see how to easily write this without constexpr.
2022-01-26 13:25:36 +13:00
Olly Betts
e03ef3ecb6 Support foo.bar in constant expressions 2022-01-26 12:43:45 +13:00
Olly Betts
98e1251772 Handle ellipsis as a token in the scanner
This is more correct (previously SWIG incorrectly accepted 3 periods
with whitespace between as an ellipsis) and helps avoid conflicts in
the grammar.
2022-01-26 12:31:52 +13:00
Olly Betts
6db66bc350 Drop is_python_modern() in testcase
Python is always "modern" since e4fceee12f.
2022-01-26 12:30:44 +13:00
Olly Betts
7ab24e7e86 Support most cases of sizeof applied to an expression
Previously there was only support for `sizeof(<type>)` and expressions
which syntactically look like a type (such as `sizeof(foo)`).

Fixes #2091.
2022-01-25 23:47:01 +13:00
Olly Betts
6f952806e4 Enable testcase for %
This was commented out with a FIXME, but actually works.  Probably
fixed back in 2009 by 02eb6a81d1!
2022-01-25 14:09:49 +13:00
Olly Betts
f2de21eb83 Parse common cases of < and > comparisons
Adding full support for these in expressions seems hard to do without
introducing conflicts into the parser grammar, but in fact all reported
cases have had parentheses around the comparison and we can support that
with a few restrictions on the left side of `<`.

Fixes #80 and #635.  Also https://sourceforge.net/p/swig/bugs/1139/
2022-01-25 14:09:41 +13:00
William S Fulton
017900d57e Extern template tweaks
Document extern template functions support.
Extern templates result in new warning to differentiate
from template explicit instantiation definition warning.
2022-01-25 00:28:08 +00:00
William S Fulton
40b8416213 Merge branch 'cpp11-explicit-function-template-instantiation' into upstream-master
* cpp11-explicit-function-template-instantiation:
  parser(C++11) : explicit template function support, see https://github.com/swig/swig/issues/2131
2022-01-24 22:41:27 +00:00
Olly Betts
66488e677d [php] Make zend_function_entry arrays const 2022-01-24 14:09:36 +13:00
Olly Betts
5f5a8f2d4a [php] Initialise zval in directorin typemaps
SWIG_SetPointerZval() requires the zval structure passed to be
initialised (so it can handle the constructor case where the zval is
already initialised as a PHP object.

I couldn't think of a suitable regression test for this, but it fixes 2
issues detected by running director_basic under valgrind.
2022-01-24 13:32:22 +13:00
Olly Betts
901d1fc061 Fix comment typo 2022-01-24 12:16:26 +13:00
William S Fulton
3de6fbddab Correct cmake pcreversion test 2022-01-22 23:36:08 +00:00
William S Fulton
7f42e2b3ca Cosmetic updates in mkwindows.sh 2022-01-22 16:36:11 +00:00
William S Fulton
99ceab2cdf Building SWIG on Windows doc re-organisation 2022-01-22 16:36:03 +00:00
William S Fulton
543994c8ee Merge branch 'pcre2' into upstream-master
* pcre2:
  Add changes entry for PCRE2
  Call -pcreversion during appveyor testing
  Few more PCRE to PCRE2 changes
  PCRE2
2022-01-22 16:35:51 +00:00
romin.tomasetti
8be363eae3 parser(C++11) : explicit template function support, see https://github.com/swig/swig/issues/2131 2022-01-22 15:05:23 +00:00
Olly Betts
5656da3f31 [php] Add runmes for more director testcases 2022-01-22 21:12:13 +13:00
Olly Betts
7b929dce82 [php] Fix director upcall check
This resolves an issue uncovered by adding a _runme.php for testcase
director_alternating.
2022-01-22 20:01:00 +13:00
Olly Betts
87c2e7d71a [php] Fix long long handling on 32 bit platforms
The typemaps for long long and unsigned long long didn't handle a
string input correctly, and long_long_runme.php had a flawed test
in this case.

Fixes #2155
2022-01-22 13:09:34 +13:00
Olly Betts
9b10534879 [php] Make internal function wrappers static 2022-01-22 13:03:58 +13:00
William S Fulton
8939470b05 Add changes entry for PCRE2 2022-01-21 19:22:11 +00:00
William S Fulton
da8eb35a51 Call -pcreversion during appveyor testing 2022-01-21 18:35:37 +00:00
William S Fulton
f8e4a5cc25 Few more PCRE to PCRE2 changes 2022-01-21 18:35:20 +00:00