Commit graph

5,201 commits

Author SHA1 Message Date
Olly Betts
1707d6b89b [PHP] Fix cleanup code handling issues
Fix to call cleanup code in exception situations and not to invoke
the freearg typemap twice in certain situations.

Fixes https://sourceforge.net/p/swig/bugs/1211/
2022-02-17 13:52:44 +13:00
Olly Betts
a7ff0da1f3 Improve parsing of % followed immediately by identifier
If it's not a recognised directive the scanner now emits MODULO and then
rescans what follows, and if the parser then gives a syntax error we
report it as an unknown directive. This means that `a%b` is now allowed
in an expression, and that things like `%std::vector<std::string>` now
give an error rather than being quietly ignored.

Fixes #300
Fixes #368
2022-02-15 15:09:44 +13:00
Olly Betts
fd6c0255a2 Remove superfluous semicolons 2022-02-15 14:00:12 +13:00
Olly Betts
abfd630c6d Remove comment on how to add new target lang
This information really doesn't belong in lua.cxx, and is covered better
in Doc/Manual/Extending.html already.
2022-02-15 10:35:17 +13:00
Olly Betts
b624d17f3f Merge branch 'swig-fortran/extern-c-int'
Fixes #2199
2022-02-11 08:28:27 +13:00
Seth R Johnson
af56a1f5c7 Preserve "externc" for non-brace thread_local 2022-02-11 08:25:03 +13:00
Seth R Johnson
14c0942505 Preserve thread_local for brace-enclosed extern "C" 2022-02-11 08:25:03 +13:00
Seth R Johnson
2ecc5bc214 Don't warn about legal extern "C++" {} block 2022-02-11 08:25:03 +13:00
Olly Betts
89a0a3c5f7
Merge pull request #2197 from swig-fortran/rename-warn
Print rename warnings except anonymous template methods
2022-02-10 16:15:10 +13:00
Dimitris Apostolou
40c3bf30b2 Fix typos 2022-02-10 16:12:24 +13:00
Seth R Johnson
a81a9452a8 Revert "Enable 'regextarget' option for '%namewarn'"
This reverts commit d7e0aaa57d. I can't
get regextarget to work correctly, and the fortran branch no longer
depends on it since pcre support is optional.
2022-02-09 18:11:12 -05:00
William S Fulton
a5315e1159 gcc warning fix
warning: control reaches end of non-void function [-Wreturn-type]
2022-02-07 21:50:13 +00:00
William S Fulton
013be550ed Merge branch 'fragment-typemap' into upstream-master
* fragment-typemap:
  Add documentation
  Enable multiple 'fragment' keywords to be attached to typemaps
2022-02-07 20:35:08 +00:00
Seth R Johnson
befc9bc1f0 Mark 'externc' storage for variables 2022-02-06 20:49:01 -05:00
Olly Betts
467c530e65 Remove support for the "command" encoder
The "command" encoder was mostly intended for use in `%rename` - most
uses can be achieved using the "regex" encoder, so we recommend using
that instead.

The "command" encoder suffers from a number of issues - as the
documentation for it admitted, "[it] is extremely slow compared to all
the other [encoders] as it involves spawning a separate process and
using it for many declarations is not recommended" and that it "should
generally be avoided because of performance considerations".

But it's also not portable.  The design assumes that `/bin/sh` supports
`<<<` but that's a bash-specific feature so it doesn't work on platforms
where `/bin/sh` is not bash - it fails on Debian, Ubuntu and probably
some other Linux distros, plus most non-Linux platforms.  Microsoft
Windows doesn't even have a /bin/sh as standard.

Finally, no escaping of the passed string is done, so it has potential
security issues (though at least with %rename the input is limited to
valid C/C++ symbol names).

Fixes #1806
2022-02-07 09:47:01 +13:00
Seth R Johnson
018254cca3 Reformat name warnings to reduce changes 2022-02-06 13:51:37 -05:00
Seth R Johnson
307c9814a0 Prevent "__dummy_0__" template methods from matching name warnings 2022-02-06 13:51:37 -05:00
Seth R Johnson
de78b80de9 Renames performed by %namewarn with rename= are printed in warning message
This is necessary for regex-like renames (where you can't use the #define trick
as is done in many of the %keywordwarn directives). It's now unnecessary to print
the "renaming to '`x`'" code explicitly by the kw.swg files.
2022-02-06 13:51:37 -05:00
Seth R Johnson
d7e0aaa57d Enable 'regextarget' option for '%namewarn'
This enables auto-renaming of identifiers beginning with '_', necessary
for Fortran.
2022-02-06 13:51:37 -05:00
Seth R Johnson
325056453a Enable multiple 'fragment' keywords to be attached to typemaps
This is consistent with the use of `%fragment`. Previously only the last
`fragment=` keyword would be added.
2022-02-05 19:03:43 -05:00
Olly Betts
b06ab566cb -DFOO on the SWIG command line now sets FOO to 1
This is consistent with C/C++ compiler preprocessors.  Previously
SWIG set FOO to an empty value.

Fixes #2193
2022-02-06 10:18:49 +13:00
Olly Betts
9d7c962ee8 Clean up uses of Replace()
We were passing flags of DOH_REPLACE_ANY|DOH_REPLACE_FIRST in three
places, which doesn't make sense as those are mutually exclusive
concepts.  In the current implementation DOH_REPLACE_FIRST wins in
this situation, so replace with that and clarify the docs.
2022-02-06 09:59:30 +13:00
Seth R Johnson
5a2656ab80 Don't mark as "noassign" when a variable is immutable
I had assumed member variables could only be noassign by being "const",
but I had forgotten about the `%immutable` keyword being applied via
SWIG.
2022-02-04 14:03:01 -05:00
Seth R Johnson
03dd2ec39d Auto-detect non-assignable classes
Classes with references or const data are now marked as 'noassign'.
This renders many explicit `private: operator=` declarations redundant.
2022-02-04 09:51:18 -05:00
Olly Betts
951f946341 [Python] Improve handling of SWIG_Py*Method_New
The SWIG_PyInstanceMethod_New method is no longer added to wrapped
classes except when it's actually needed, which is when
(!builtin && fastproxy) is true (which it isn't by default).

The SWIG_PyStaticMethod_New method is no longer is now similarly
gated - previously only (fastproxy) was checked.

Finally the C/C++ functions that implement these were always compiled
into the module, but now they're only included if
(!builtin && fastproxy) is true.

Issue noted by vadz in #2190.
2022-02-04 12:58:56 +13:00
Olly Betts
7cb2f46e06 [Python] Sort out handling of self parameter
When not using -builtin, the self parameter is now still made
available so that user typemaps can use it.  Fixes #967.

When using -builtin, fix -Wunused-parameter warnings in the generated
wrapper code.  See #801.

Based on a commit peeled out of #801 by teythoon.
2022-02-03 18:31:18 +13:00
Olly Betts
ebbf2e6077 Allow method calls in expressions
This allows default parameter values containing method calls to be
parsed and handled - e.g. `x->foo(3,4)` and `y.z()`.
Fixes #660 and https://sourceforge.net/p/swig/bugs/1081/
2022-02-03 17:20:30 +13:00
Olly Betts
2e98189564 [Ruby] Fix remove of prefix from method name
The prefix is now only removed at the start.

Fixes https://sourceforge.net/p/swig/bugs/1136/
2022-02-02 15:53:23 +13:00
Olly Betts
27a3d16ac6 Allow object reference in C++ trailing return type
Fixes #231
2022-02-02 11:31:45 +13:00
Clement David
aee380ce82 [scilab] Name init function name to avoid collision
Use SWIG_<module>_Init() function to init the module rather than
<module>_Init() as the latter can collide with a function being wrapped.

Fixes #745
Fixes #1739
2022-02-02 09:43:06 +13:00
Olly Betts
7813793511 [R] Fix CopyToR() generated for struct in namespace
Fixes https://sourceforge.net/p/swig/bugs/1147/
2022-01-31 12:05:09 +13:00
Olly Betts
d9ced1e56d Coding style tweaks 2022-01-30 10:55:00 +13:00
Frank Schlimbach
4ce2964ab8 adding support for structs, docu 2022-01-30 10:55:00 +13:00
Frank Schlimbach
63452e9fc1 better handling of using directives 2022-01-30 10:55:00 +13:00
Shengqiu Li
d3383e254d [Go] Fix overloaded functions with noncapitalized class as parameter type
Fixes #676 #677
2022-01-29 22:19:15 +13:00
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
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
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
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
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
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
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
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