Commit graph

1,778 commits

Author SHA1 Message Date
William S Fulton
1db04bf322 Improvements to the -debug command line options
The debug command line options that display parse tree nodes
(-debug-module, -debug-top, -debug-symtabs) now display previously hidden
linked list pointers which are useful for debugging parse trees.

Added new command line option -debug-quiet. This suppresses the display
of most linked list pointers and symbol table pointers in the parse tree nodes.

The keys in the parse tree node are now shown in alphabetical order.
2022-03-25 23:34:52 +00:00
William S Fulton
a343b7e254 Remove -py3 command line option
Closes #1779
2022-03-23 18:13:07 +00:00
William S Fulton
f068f2c2d6 Add Python < 3.3 support for pyabc.i
pyabc.i for abstract base classes now supports versions of Python
prior to 3.3 by using the collection module for these older versions.
Python-3.3 and later continue to use the collections.abc module.
The -py3 option no longer has any effect on the %pythonabc feature.
2022-03-23 07:58:01 +00:00
William S Fulton
21c2e47661 Python -flatstaticmethod corrections
Correct logic for suppressing static methods.
Previous logic was missing director disown methods.
Add changes file entry for -flatstaticmethod.

Closes #2137
2022-03-21 19:22:49 +00:00
Julien Schueller
484e5316f2 Python: Option to generate flat class methods 2022-03-18 11:10:14 +01:00
Olly Betts
a6eae77dd5 Fix module example so generated code compiles
Fixes https://sourceforge.net/p/swig/bugs/1141/
2022-03-18 19:26:16 +13:00
Seth R. Johnson
8f9a432040
Update python manual scripts to py3 compatibility (#2204) 2022-03-18 13:29:22 +13:00
Olly Betts
2da3815f99 [Go] Make -intgosize optional
We no longer support Go < 1.2 so we can default intgo to ptrdiff_t
and uintgo to size_t.

Fixes #683
Fixes #2233
2022-03-16 18:30:05 +13:00
Ian Lance Taylor
46aaf11b01 [Go] Add documentation note about Go and C++ exceptions.
For #418
Fixes #518
2022-03-15 09:48:53 -07:00
William S Fulton
598736a6b2 %interface family of macros no longer add variable wrappers
The getter/setter methods used for wrapping methods are no longer
added to the interface class.

Closes #1524

Also add in testcase for enums.
2022-03-12 23:04:24 +00:00
William S Fulton
b6ece11fc1 Fixes for the family of %interface macros for overloaded methods
When C++ methods are not able to be overloaded in a derived class,
such as when they differ by just const, or the target language
parameters types are identical even when the C++ parameter types
are different, SWIG will ignore one of the overloaded methods with
a warning. A %ignore is required to explicitly ignore one of the
overloaded methods to avoid the warning message. Methods added
in the derived classes due to one of the %interface macros are now
similarly ignored/not added to the derived class.

The adding of additional methods into the parse tree is now more
robust and complete resulting in support for %feature and %rename
for the added methods.

Closes #1277
2022-03-12 23:04:24 +00:00
William S Fulton
3bf728f038 HTML fixes 2022-03-12 23:04:24 +00:00
Olly Betts
2a9431ebfb Remove confusing extra parameter from doc example
The initial prototype shown in these examples has a `len` parameter
but that the rest of the example is as if that parameter isn't there
so remove it from the initial prototype.

Fixes https://sourceforge.net/p/swig/bugs/1289/
2022-03-09 15:05:44 +13:00
Ian Lance Taylor
7ebe5cead3 Go docs: add note on thread local storage
Fixes #374
2022-03-08 14:18:59 -08:00
Olly Betts
f137840aa9 Clarify name used for matching out typemaps
Based on a patch from Dustin J. Mitchell in
https://sourceforge.net/p/swig/bugs/915/
2022-03-07 17:40:25 +13:00
Olly Betts
d7625ee6b2 Fix fatal error implemented by assert
Calling assert() on a condition that's always false is not an
appropriate way to exit after emitting "Fatal error [...]" because
if NDEBUG is defined the assert() becomes a no-op and the error
stops actually being fatal.
2022-03-07 14:24:48 +13:00
Olly Betts
46bdb1bb29 Add/update docs for Malloc(), Exit(), etc
See #2223
2022-03-07 14:24:48 +13:00
Olly Betts
70553f01dc Stop suggesting %name in Guile.html
%name has been deprecated since 2004.
2022-03-07 10:31:52 +13:00
Kris Thielemans
bb36862872
add doc on %attribute and templates (#2224)
Document behaviour found in #2142
2022-03-07 06:34:26 +13:00
Olly Betts
55377bdc08 Add DOH Exit() and SetExitHandler()
Exit() is a wrapper for exit() by default, but SetExitHandler() allows
specifying a function to call instead.

This means that failures within DOH (e.g. Malloc() failing due to lack
of memory) will now perform cleanup such as removing output files.

This commit also cleans up exit statuses so SWIG should now reliably
exit with status 0 if the run was successful and status 1 if there was
an error (or a warning and -Werror was in effect).

Previously in some situations SWIG would try to exit with the status set
to the number of errors encountered, but that's problematic - for
example if there were 256 errors this would result in exit status 0 on
most platforms.  Also some error statuses have special meanings e.g.
those defined by <sysexits.h>.

Also SWIG/Javascript tried to exit with status -1 in a few places (which
typically results in exit status 255).
2022-03-06 12:33:54 +13:00
Olly Betts
8f54f6180a Update docs for expression parsing improvements 2022-03-04 16:36:04 +13:00
Olly Betts
9eb75a0c07 Improve typemap method and attribute checking
Specifying a value on the typemap method now gives an error, e.g.:

%typemap(argout=123) char * ""

The old way of specifying a language name in the typemap attributes
is no longer supported (it has been deprecated for 16 years).

Closes #891
2022-03-03 18:46:15 +13:00
William S Fulton
5682d940e5 HTML fixes 2022-03-02 19:42:44 +00:00
William S Fulton
3159de3e9f Add support for Python variable annotations as a feature.
Both function annotations and variable annotations are turned on using the
"python:annotations" feature. Example:

  %feature("python:annotations", "c");

  struct V {
    float val;
  };

The generated code contains a variable annotation containing the C float type:

  class V(object):
      val: "float" = property(_example.V_val_get, _example.V_val_set)
      ...

Python 3.5 and earlier do not support variable annotations, so variable
annotations can be turned off with a "python:annotations:novar" feature flag.
Example turning on function annotations but not variable annotations globally:

  %feature("python:annotations", "c");
  %feature("python:annotations:novar");

or via the command line:

  -features python:annotations=c,python:annotations:novar

Closes #1951
2022-03-02 19:33:03 +00:00
William S Fulton
5a945bb135 More docs on -fastproxy and annotations 2022-03-02 07:44:04 +00:00
William S Fulton
bc68a9b034 Document limitations with Python annotations
[skip ci]
2022-02-28 19:58:21 +00:00
William S Fulton
2072ae19c9 Python function annotations removed from -py3 option.
Python function annotations containing C/C++ types are no longer
generated when using the -py3 option. Function annotations support
has been moved to a feature to provide finer grained control.
It can be turned on globally by adding:

  %feature("python:annotations", "c");

or by using the command line argument:

  -features python:annotations=c

The implementation is designed to be expandable to support different
annotations implementations. Future implementations could implement
something like the following for generating pure Python types:

  %feature("python:annotations", "python");

or typing module types to conform to PEP-484:

  %feature("python:annotations", "typing");

Closes #1561
Issue #735
2022-02-27 10:47:50 +00:00
Olly Betts
b127e11f1e Fix typos in docs and comments 2022-02-27 18:15:46 +13:00
William S Fulton
f995bad785 Add detailed docs and info on match in %rename 2022-02-26 12:49:07 +00:00
William S Fulton
546062fdf1 Add %rename matching docs and improvements
Add in %$isusing macro for %rename.
Improve docs for %$not and notmatch.
2022-02-26 12:49:07 +00:00
William S Fulton
79a1bbee8b Using declarations in inheritance hierarchy improvements.
- Improved documentation for using declarations.
- Issue new warning WARN_LANG_USING_NAME_DIFFERENT when there
  is a conflict in the target language name to be used when
  introducing a method via a using declaration. Previously
  the method was silently ignored. Issue #1840. Issue #655.
2022-02-26 12:46:06 +00:00
Olly Betts
e95af9c474 Merge branch 'scilab-6' of https://github.com/davidcl/swig
Fixes #1751
2022-02-24 10:45:13 +13:00
Olly Betts
4db4b999ca Document strings in preprocessor expressions
These appear to have been supported for at least 20 years and are used
in SWIG's library files.
2022-02-24 09:39:21 +13:00
Clément DAVID
f93f8ad1d5 [Scilab] remove targetversion argument
This commit handles multi-version support at runtime, it
fixes:
 * 5.5.2 - with cutted long identifier name
 * 6.0.0 - with full string identifier
 * 6.1.0 - with 1 or 0 output argument

It also improves the codebase by:
 * Using `Char(X)` instead of `DohCheck(X)` and `Data(X)`
 * Using `Len(X)` instead of `strlen()`
 * Correctly detecting old Scilab versions
2022-02-21 10:01:59 +01:00
Olly Betts
0b12398b2c Perl.html: Fix incorrect references to python 2022-02-16 11:16:36 +13:00
Olly Betts
a7ed8be8b4 Improve wording in docs 2022-02-10 16:13:43 +13:00
Dimitris Apostolou
40c3bf30b2 Fix typos 2022-02-10 16:12:24 +13:00
William S Fulton
d59cbf1c39 Fragments: additional testing and documentation enhancements
Add test for original syntax when using a single fragment key containing
the list of dependent fragments. I couldn't find a test for this.

Spaces in the fragment list don't seem to work - document it.
2022-02-07 21:45:33 +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
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
6c41db3b8c Add documentation 2022-02-05 19:12:06 -05: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
William S Fulton
34d80dcb8b attribute library documentation edits 2022-02-05 20:52:50 +00:00
William S Fulton
aef4a0f90a Merge branch 'doc-work' into upstream-master
* doc-work:
  Move the attribute.i docs into Library.html
  Move %attribute documentation into the manual
2022-02-05 20:52:42 +00:00
Olly Betts
bf8ee5fb70 Fix stale links to doxygen docs 2022-02-04 14:04:48 +13:00
Olly Betts
11009f8e23 Document calling extend methods from C/C++
Note that it's necessary to use the naming scheme we already document
to do this.

Fixes https://sourceforge.net/p/swig/bugs/889/
2022-02-03 11:22:16 +13:00
Olly Betts
eb13261950 [Java] Note use of %ignore with %native
This is needed if you're wanting to effectively replace the generated
JNI wrapper for a C/C++ function.

Fixes https://sourceforge.net/p/swig/bugs/368/
2022-02-01 16:38:16 +13:00
Olly Betts
f003e9bcba [Tcl] Document objects aren't destroyed on exit
Fixes https://sourceforge.net/p/swig/bugs/1330/
2022-02-01 12:47:19 +13:00
Olly Betts
9c16ce8ab3 [ocaml] Improve the Qt example
Drop a method which has been deprecated then removed in Qt (but isn't
actually used in the example anyway) and clean up the steps a bit.

The example still doesn't build for me as the final step fails with:

File "_none_", line 1:
Error: Module `Dynlink' is unavailable (required by `Camlp4')

I know next to nothing about ocaml, so that may be something I've
failed to install, but I couldn't work out what.  I think the Qt
library linking needs updating too - there doesn't seem to be a
single `-lqt` now, but I don't use Qt either.
2022-02-01 11:46:39 +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