Commit graph

5,183 commits

Author SHA1 Message Date
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
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
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
9b10534879 [php] Make internal function wrappers static 2022-01-22 13:03:58 +13:00
William S Fulton
f8e4a5cc25 Few more PCRE to PCRE2 changes 2022-01-21 18:35:20 +00:00
Julien Schueller
15515f390c PCRE2
Closes #2120
2022-01-21 07:46:08 +01:00
Olly Betts
1c76000e38 [php] Add type declarations for optional params too
See #2151
2022-01-21 16:34:59 +13:00
Olly Betts
91470ca62d [php] Actually generate parameter type declarations 2022-01-21 13:27:54 +13:00
Olly Betts
d43f28a666 [php] Use -prefix setting in type declarations 2022-01-21 11:08:24 +13:00
Olly Betts
c417250b4e [php] Allow testing if an object is SWIG-wrapped
Since the switch to wrapping classes using PHP's C API, we now
internally need to be able to tell if a PHP object is of or derived
from a class that is wrapped by SWIG so we know if we can offset the
zend_object pointer to get to the swig_object_wrapper.  If we try to
do this to an object which isn't wrapped by SWIG then we invoke C/C++
undefined behaviour (and typically get a segmentation fault).

This check is implemented by having a SWIG\wrapped empty interface which
we make all SWIG-wrapped classes implement simply so we can test for it
to detect such classes.

Fixes #2125
2022-01-20 14:42:02 +13:00
Olly Betts
1f1349741f
[php] Generate PHP type declarations
We now automatically generate PHP type declarations for PHP >= 8.0.

The generated code still compiles with PHP 7.x but without type declarations.
2022-01-20 10:07:44 +13:00
Olly Betts
748a9a5452 [perl] Require at least Perl 5.8.0
As discussed and agreed in #1629, it's become hard to test with Perl
5.6 or earlier, such old versions are no longer in active use, and
4.1.0 is an appropriate time to make such a change.

I've dropped the compatibility code that was obvious to me, but there's
probably more that can be cleaned up now.
2022-01-19 10:07:30 +13:00
William S Fulton
3aa302c08f %callback and Python class access for C++ static member functions fixes
Fix access to C++ static member functions using Python class
staticmethod syntax, such as Klass.memberfunction instead of
Klass_memberfunction, when using -fastproxy and -builtin in
combination with %callback.

The docstring containing the callback pointers were not being patched
during module initialisation.
2022-01-14 23:00:59 +00:00
William S Fulton
627f7214db [Python] Add missing Python kwargs builtin support
Accept keyword arguments accessing C++ static member functions when
using -builtin and kwargs feature and Python class staticmethod syntax.
The missing keyword argument support was only when using the
class staticmethod syntax, not when using the flat static method
syntax.
2022-01-14 23:00:42 +00:00
William S Fulton
3200a815d4
Merge pull request #2095 from vadz/extend-suffix
Use suffix for static methods added by %extend
2022-01-08 21:11:14 +00:00
Olly Betts
499fb74707 Remove unused Printf parameters 2021-12-18 11:24:00 +13:00
Olly Betts
4672318b42 Make some generated variables static 2021-12-17 22:32:34 +13:00
Olly Betts
cf802c63f2 Improve naming of zend_class_entry structs
Previously the zend_class_entry for Foo was named SWIGTYPE_Foo_ce, but
this can collide in some cases - e.g. if there's a class named p_Foo
then its zend_class entry will be SWIGTYPE_p_Foo_ce, but that's the same
as the swig_type_info for a class named p_Foo_ce.
2021-12-17 17:14:54 +13:00
Olly Betts
f976927d52 Fix source code comment typo 2021-12-17 14:54:05 +13:00
Olly Betts
78f5404727 Improve generated object handlers
Do more initialisation at module load time.

Use a shared set of handlers for cases when the C/C++ object is
destroyed with free().

Most of the code in the free_obj and create_object handlers is the
same for every wrapped class so factor that out into common functions.
2021-12-17 14:50:49 +13:00