Commit graph

4,967 commits

Author SHA1 Message Date
William S Fulton
638ca8152d complex can now be used as an identifier
Remove final vestiges of 'complex' keyword.

Closes #252
2020-10-10 16:07:55 +01:00
William S Fulton
4f184500d7 Merge commit '8245277ad3' into c99-complex
* commit '8245277ad3':
  Remove test for unsupported complex or _Complex by itself
  More C99 complex fixes, plus Python tests
  Restore _Complex as standalone type
  Small corrections for handling C99 _Complex
  Properly handle C99 complex types even in C++ mode

Conflicts:
	Examples/test-suite/python/complextest_runme.py
2020-10-10 14:53:33 +01:00
William S Fulton
fe676f840a Merge branch 'director-return-const-pointer'
* director-return-const-pointer:
  Put test in alphabetical order
  Perform proper spacing in director method declarations
2020-10-07 22:26:25 +01:00
William S Fulton
8889635683
Merge pull request #1859 from adelva1984/no-host-exceptions
javascript: replace exceptions with SWIG_exit
2020-10-07 22:09:01 +01:00
William S Fulton
e71f781140
Apply suggestions from code review
Print errors to stderr instead of stdout
2020-10-07 22:06:47 +01:00
William S Fulton
c1b004f4fa Add access modifier support for interface feature
Add ability to change the modifiers for the C# and Java
interface generated when using the %interface macros.

For C# use the 'csinterfacemodifiers' typemap.
For Java use the 'javainterfacemodifiers' typemap.

For example:

  %typemap(csinterfacemodifiers) X "internal interface"

Closes #1874
2020-09-25 18:54:25 +01:00
Olly Betts
975f8fcfdb Avoid undefined behaviour in DOH Replace() function
If the source and replacement strings were the same length, the code
was performing undefined pointer arithmetic involving a NULL pointer.
I'm not aware of any observable effects of this in practice, but it's
potentially problematic.  It's detected by ubsan, for example when
running `make check-python-test-suite`:

DOH/string.c:839:4: runtime error: applying non-zero offset to non-null pointer 0x602000001558 produced null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior DOH/string.c:839:4 in
2020-09-04 10:44:49 +12:00
William S Fulton
b018c32f9d Fix crashes in swig_connect_director during director class construction.
Occurs when using the director class from multiple threads - a race condition
initialising block scope static variables.

Block scope static variables are guaranteed to be thread safe in C++11,
so the fix is guaranteed when using C++11. However, most modern compilers
also fix it when using C++03/C++98.

Closes #1862
2020-08-28 18:23:47 +01:00
William S Fulton
e774fe5cfd Python 3.9 support for -builtin
Add missing initializer for member ‘_heaptypeobject::ht_module’ to complete
Python 3.9 support.
2020-08-27 20:22:39 +01:00
Alistair Delva
baf2fbb98f naming: Add unreachable return to !HAVE_PCRE path
Android builds all host tools with -Werror=no-return, which generates a
false positive in name_regexmatch_value() if HAVE_PCRE is not present.

Fix this by adding a return code to the !HAVE_PCRE path. This return
will not be reached but will suppress the compiler warning.

If/when SWIG can require C++11 compilers, a better fix would be to make
SWIG_exit() [[noreturn]].

Closes #1860
2020-08-13 09:19:37 -07:00
Alistair Delva
4d844a8dc2 javascript: replace exceptions with SWIG_exit
When building SWIG for Android, there is no support for C++ exceptions.

In the cases there is "Illegal state", it seems more like an internal
error, so we can replace the throw calls with a debug print and exit
immediately.

Closes #1858
2020-08-13 07:55:35 -07:00
Leo Singer
511df0e642 More C99 complex fixes, plus Python tests 2020-06-24 20:21:47 -04:00
Leo Singer
07b4b274e5 Restore _Complex as standalone type 2020-06-24 20:21:47 -04:00
Leo Singer
1adc7dac5d Small corrections for handling C99 _Complex 2020-06-24 20:21:47 -04:00
Leo Singer
13260f95b0 Properly handle C99 complex types even in C++ mode
Use the `_Complex` keyword rather than the `complex` macro.

Fixes #1487.
2020-06-24 20:21:47 -04:00
Thomas Reitmayr
c259702314 Perform proper spacing in director method declarations
If a director method returns a const pointer, eg. 'int *const', then in its
method declaration a space has to be inserted between 'const' and the
method name.
This fixes swig#1810.
2020-06-20 12:14:42 +02:00
William S Fulton
ee7eb6b58a Merge branch 'directors-comparison-operators'
* directors-comparison-operators:
  Use %rename
  Fix wrapping of virtual comparison operators with directors
2020-06-14 22:23:57 +01:00
William S Fulton
991c2afe11 Merge branch 'python-doxygen-quotes'
* python-doxygen-quotes:
  Fix generated Python code for Doxygen comments with triple quotes
  Fix generated Python code for Doxygen comments ending with quote
2020-06-07 10:23:33 +01:00
Zackery Spytz
4e57c5536d Fix wrapping of virtual comparison operators with directors
Closes #1642.
2020-06-05 10:25:20 -06:00
Noah Stegmaier
cf7802c5cc escape phony targets as well 2020-06-04 12:24:08 +02:00
Noah Stegmaier
e224194735 escape target name 2020-06-04 12:17:51 +02:00
Noah Stegmaier
d723f82160 escape path of generated file 2020-06-04 12:10:24 +02:00
Noah Stegmaier
3cc4d76e23 escape filepaths 2020-06-04 12:10:24 +02:00
William S Fulton
85f2378b84 Merge branch 'r-script-fixes'
* r-script-fixes:
  Fix further missing semicolons in R code.
  fixed some missing semicolons. Each one caused a compile error in generated code
2020-06-02 18:11:12 +01:00
William S Fulton
6542d848dc Fix further missing semicolons in R code.
Fixes errors in R code when using -small as this option causes lines to be joined.
2020-06-02 10:16:18 +01:00
Karl Wette
d9c94848ec octave.cxx: fix exception raising for newer Octave versions
- Since (at least) Octave 5.1.0, the Octave error() function now raises a C++
  exception, which if uncaught immediately exits a SWIG wrapper function,
  bypassing any cleanup code that may appear after a "fail:" label.
- This patch adds a "try { ... } catch(...) { }" block around the contents of
  SWIG wrapper functions to first execute the cleanup code before rethrowing any
  exception raised.
- It is backward compatible with earlier versions of Octave where error() does
  not raise an exception, which will still branch to the "fail:" block to
  execute cleanup code if an error is encountered.
2020-05-31 06:43:15 +10:00
Karl Wette
e67f125582 octave.cxx: add missing return statement before "fail:" label 2020-05-31 06:43:15 +10:00
Karl Wette
f6286a1b19 octave.cxx: this belongs in the code (as opposed to definition) section 2020-05-31 06:43:15 +10:00
Karl Wette
99bb5dcc70 octave.cxx: remote whitespaces 2020-05-31 06:43:15 +10:00
Karl Wette
66f4f7de8e octave.cxx: replace Printf() with Append() for consistency 2020-05-31 06:43:15 +10:00
William S Fulton
305a824a6e
Merge pull request #1726 from vadz/unsigned-char
Fix reading options files on platforms with unsigned char
2020-05-30 00:01:51 +01:00
William S Fulton
558ed0bb71 Merge branch 'DOH_POOL_SIZE-increase'
* DOH_POOL_SIZE-increase:
  Increase DOH_POOL_SIZE
2020-05-28 23:04:11 +01:00
John McFarland
61dbc4b50c Fix for missing space after \endlink in doxygen
The "endlink" command is processed in processWordCommands, which by
default skips space occuring after the command, which is intended for
removing leading space from a command argument.  For "end" commands,
we don't want to do this.  Note that certain end commands such as
"endcode" aren't processed by processWordCommands (believe
addCommandUnique ends up handling them).

Update usage of \link in doxygen_translate_all_tags.i to test handling
of space after \endlink.

Tweaking some of the usage in doxygen_misc_constructs.i to remove what
seems to be an extra space from the input (otherwise we would need to
add an extra space to the expected output).
2020-05-02 18:42:55 -05:00
Zackery Spytz
3b0db10aa4 Increase DOH_POOL_SIZE
Increase DOH_POOL_SIZE to 2^22.

Addresses GH-1775.
2020-04-18 09:57:20 -06:00
khoran
d58041606e fixed some missing semicolons. Each one caused a compile error in generated code 2020-03-25 11:01:12 -07:00
Vadim Zeitlin
f57b096c92 Fix generated Python code for Doxygen comments with triple quotes
In addition to the changes in the previous commit, also avoid syntax
errors in the generated Python docstrings by splitting them into several
parts if there are 3 quotes in a row in the input, as it's impossible to
have them inside triple-quoted strings, generally speaking (i.e. if
there are occurrences of both """ and ''' inside the string).
2020-03-04 00:57:31 +01:00
Vadim Zeitlin
b81cd1bdab Fix generated Python code for Doxygen comments ending with quote
Single-line Doxygen comments ending with a double quote resulted in
syntactically-invalid Python docstrings in the output, so use triple
single quotes as delimiters in this case to avoid it.
2020-03-04 00:56:27 +01:00
Vadim Zeitlin
45fdcc2fec Fix reading options files on platforms with unsigned char
This fixes EOF detection on platforms where char is unsigned, as
comparing it with EOF could never return true there.

Thanks gcc for the warning "comparison is always true due to limited
range of data type [-Wtype-limits]".
2020-02-16 17:03:14 +01:00
Thomas REITMAYR
059bb0c0a0 Recognize C++ conversion operators with trailing '= 0' as abstract
This fix is done for all supported variants of user-defined conversion
operators and fixes swig#1723.
2020-02-13 20:16:44 +01:00
William S Fulton
0c00daf3a1 Merge branch 'autodoc-doxygen-fix'
* autodoc-doxygen-fix:
  Fix crash in Python backend when using empty docstrings
2020-01-31 18:57:47 +00:00
Arnaud Barré
3fa5c8c652 Fix R memory leak on exception
There is a possible memory leak in case the SWIG_exception_fail macro
is called. The problem is related to its definition that call the
function Rf_warning. This function (as well as Rf_error) involves
a longjmp over C++ destructors on the stack. Thus, all the objects
allocated on the heap are not freed.

Closes #914
2020-01-30 20:43:39 +00:00
William S Fulton
b0ce22625b Remove redundant code from r.cxx 2020-01-30 19:04:32 +00:00
Vadim Zeitlin
e14532ce52 Fix crash in Python backend when using empty docstrings
Due to confusion in build_combined_docstring(), we could call
DohDelete() on the "feature:docstring" string, which resulted in a crash
when trying to use it later.

Fix this and simplify the code at the same time by ensuring that we
always use a copy of "feature:docstring" if it's not empty or don't use
it at all if it's empty -- like this we don't have to check for its
length each time before using it.

Closes #1648.
2020-01-30 16:11:18 +01:00
William S Fulton
88ef6e0931 Fix display of template classnames in generated R code 2020-01-30 08:34:07 +00:00
William S Fulton
7648542775 Merge branch 'RMemberListTrialSimplify2019'
* RMemberListTrialSimplify2019:
  ENH R abstract_access_runme
  ENH R accessor processing test
  Removed some remaining commented sections
  moved registration routine and use swig_name_get
  calling Swig_name_setget
  Used Swig_name_register so that Swig_name_wrapper produces the correct name without a separate replace call.
  Removed last instance of using Strcmp to check for a set/get method. Replaced with check for flag.
  Alternative version of using memberlist processing. This clarifies the logic within OutputMemberReferenceMethod by filtering the lists into classes, rather than doing it internally. Code isn't any shorter.
  commenting out unused code
  first pass at removing string comparisons for set/get methods
  trial changing member list processing
2020-01-30 07:29:45 +00:00
William S Fulton
b3da344765 Add some comments about shared_ptr upcast code 2020-01-24 19:46:39 +00:00
William S Fulton
564a91864a Refactor upcasts code
In preparation for possible improvement in usage of
SwigType_typedef_resolve_all - a SwigType* should be used,
not a readable name in a String*.
2020-01-23 19:30:03 +00:00
William S Fulton
0425a61fa8 shared_ptr upcast fixes for D
Same changes that were applied to Java/C# in ab7f526805
2020-01-23 18:03:22 +00:00
William S Fulton
6910e5f09c Merge branch 'shared-ptr-template-upcast'
* shared-ptr-template-upcast:
  comments
  Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup
  Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class
  WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type
  comments
  Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup
  Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class
  WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type
2020-01-17 18:45:30 +00:00
William S Fulton
6e240e8fba Fix segfault parsing varargs with -doxygen
Closes #1643
2020-01-16 19:16:35 +00:00