Commit graph

1,766 commits

Author SHA1 Message Date
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
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
Corey Minyard
562effb50f Move the attribute.i docs into Library.html
Per comments on the merge request, this is the appropriate place for it,
and add a reference to it from the structures and unions section so
someone looking there will see it.

Also remove the changes in Contents.html, since that is regenerated and
those changes are just noise in the commit.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2022-01-28 08:59:08 -06: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
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
Corey Minyard
f77af57bd7 Move %attribute documentation into the manual
It's fairly hidden where it is, put it where users can see it more
easily.

Fixes #2166
2022-01-26 09:18:55 -06:00
sethg
e941f7e3fa Updated and verified CMake build docs 2022-01-26 14:30:06 +01:00