Commit graph

647 commits

Author SHA1 Message Date
Olly Betts
de5ce08a7d Fix operator precedence in preprocessor expressions 2022-07-26 14:18:38 +12:00
Olly Betts
ccccd6fc1f Add director_multiple_inheritance to CPP_TEST_CASES 2022-07-20 15:06:56 +12:00
William S Fulton
bf761998ed SWIGTYPE && input typemaps now assume object has been moved
Change these typemaps to assume that after a function call,
the parameter has been moved. The parameter's proxy class
that owns the C++ object thus has the underlying pointer set
to null so the object cannot be used again and the object is deleted.

Scrap new javarelease typemap and move contents into javabody typemap.
2022-07-17 15:15:24 +01:00
Julien Marrec
d3759a9b36 Avoid parse errors for C++ attributes
Just ignore anything in between [[ and ]] in the scanner, which is better
that failing with a parse error.

Fixes #1158
Fixes #2286
2022-07-08 15:27:02 +12:00
William S Fulton
299880e6a6 Add std::unique support
Simple copy of current auto_ptr support (just suppport for
functions returning std::unique_ptr).

Closes #1722
2022-07-02 16:17:18 +01:00
William S Fulton
bf36bf7d8a Movable and move-only types supported in "out" typemaps.
Enhance SWIGTYPE "out" typemaps to use std::move when copying
objects, thereby making use of move semantics when wrapping a function returning
by value if the returned type supports move semantics.

Wrapping functions that return move only types 'by value' now work out the box
without having to provide custom typemaps.

The implementation removed all casts in the "out" typemaps to allow the compiler to
appropriately choose calling a move constructor, where possible, otherwise a copy
constructor. The implementation alsoand required modifying SwigValueWrapper to
change a cast operator from:

  SwigValueWrapper::operator T&() const;

to

  #if __cplusplus >=201103L
    SwigValueWrapper::operator T&&() const;
  #else
    SwigValueWrapper::operator T&() const;
  #endif

This is not backwards compatible for C++11 and later when using the valuewrapper feature
if a cast is explicitly being made in user supplied "out" typemaps. Suggested change
in custom "out" typemaps for C++11 and later code:

1. Try remove the cast altogether to let the compiler use an appropriate implicit cast.
2. Change the cast, for example, from static_cast<X &> to static_cast<X &&>, using the
   __cplusplus macro if all versions of C++ need to be supported.

Issue #999
Closes #1044

More about the commit:
Added some missing "varout" typemaps for Ocaml which was falling back to
use "out" typemaps as they were missing.

Ruby std::set fix for SwigValueWrapper C++11 changes.
2022-06-30 17:26:48 +01:00
William S Fulton
088dc6e870 Add move assignment operator to SwigValueWrapper
Closes #2039
2022-06-16 08:02:02 +01:00
William S Fulton
35ec8ca210 Add argcargv test case to test-suite 2022-05-15 19:49:59 +01:00
William S Fulton
b35ebc81a9 Doxygen comments take precedence over the autodoc feature.
If a "docstring" feature is present it will still override a Doxygen comment.
If the "autodoc" feature is also present, the combined "autodoc" and "docstring"
will override the Doxygen comment. If no "docstring" is present then the
"autodoc" feature will not be generated when there is a Doxygen comment.

This way the "autodoc" feature can be specified and used to provide documentation
for 'missing' Doxygen comments.

Closes #1635
2022-04-06 08:08:14 +01:00
William S Fulton
27d6f5c2fe git commit -m "Fix test-suite's make clean to clean cpp11 testcases
Always clean cpp11 tests even if --enable-cpp11-testing is not active
May result in cpp11 tests being deleted twice though" ../
2022-03-27 18:28:49 +01:00
William S Fulton
282fdb1715 MzScheme 'passes' with c++11 testing now
Test c++17 on Github Actions to try keep it passing when
configure detects g++ can test c++17.
2022-03-27 15:06:47 +01:00
William S Fulton
c5f209706e Further makefile refactoring for multicpptests 2022-03-27 11:27:58 +01:00
William S Fulton
f2dd436a5b Rework swig_and_compile_multi_cpp makefile helper
Seems less cryptic and more maintainable to me
2022-03-26 15:16:22 +00:00
Eugene Toder
f733efd3c0 Use different capsule names with and without -builtin
Types generated with and without -builtin are not compatible. Mixing
them in a common type list leads to crashes. Avoid this by using
different capsule names: "type_pointer_capsule" without -builtin and
"type_pointer_capsule_builtin" with.

See #1684
2022-03-18 13:44:54 -04: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
c88a9436bc Fix segfault in C# layer handling using declarations
Segfault was actually avoided in previous commit ab23cb29.
This commit makes handling more robust in the event of
using %ignore just on the derived method, not tested as it is not
what one should do with directors, and possibly other cases.

Go still segfaults with the new testcase director_using_member_scopes.i.

Issue #1441.
2022-03-10 22:18:23 +00:00
William S Fulton
bd5ffe86e4 Using declarations in derived class parameters scoping fix
Fix using declaration in derived class incorrectly introducing a method
from a base class when the using declaration is declared before the method
declaration. Problem occurred when within a namespace and the parameter types
in the method signatures were not fully qualified.

Issue #1441
2022-03-10 22:18:23 +00:00
Olly Betts
4f5613b4e9 Reenable rename_camel testcase
It was on the "broken" list, but it should now work.
2022-03-07 09:22:13 +13:00
Olly Betts
e36e898c0a
Merge pull request #2205 from swig-fortran/extend-tests
Fix and add additional tests to test suite
2022-02-25 10:16:22 +13:00
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
Seth R Johnson
77cdba81ad Add test case for very simple director classes
Test both abstract and concrete base classes, with simple int/bool data.
This level of complexity is very helpful when setting up director
functionality for a new target language.
2022-02-12 19:40:03 -05:00
Seth R Johnson
0da8a9bb44 Test ability to manipulate a daughter class from its base class wrapper
Even in the case of just creating a `DerivedClass` this test says:
```
swig/python detected a memory leak of type 'DerivedClass *', no destructor found.
```
even though the destructor is defined in the base class.
2022-02-12 19:40:03 -05:00
Seth R Johnson
fb0cddfd2b Add C "contract" test
Tests that the `%contract` code (viz., each target language's
implementation of SWIG_contract_assert) compiles in C as expected. Update
the note in the source code since `%contract` is in the official
documentation.
2022-02-12 19:40:03 -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
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
Frank Schlimbach
63452e9fc1 better handling of using directives 2022-01-30 10:55:00 +13:00
Olly Betts
d2d2bfa05f Add CHANGES entry and regression test for #676 2022-01-29 22:35:29 +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
f14c712001 Correct disabling of c++11 testing
C++11 testing was not being turned off when the
C++ compiler check for C++11 features failed and
'configure --enable-cpp11-testing' was used
2021-04-26 22:32:52 +01:00
Olly Betts
ff1c88f5ba Hook up sym testcase
This has existed since at least the "great merge" and even has a
_runme.php, but seems to have never actually been listed as a testcase
to run.
2021-04-20 11:56:27 +12:00
William S Fulton
82fb0540ca Modernise C++11 compiler support detection in autotools
Replace AX_CXX_COMPILE_STDCXX_11 with AX_CXX_COMPILE_STDCXX
from autoconf archive.
2021-03-20 00:53:13 +00:00
Thomas Reitmayr
7963445048 Add and improve Ruby test cases in the context of nesting and namespaces
This is done in preparation for adding namespace support to the Ruby
part of SWIG. Some existing test cases were reorganized or duplicated
for flat/nonflat nesting. For some a Ruby test script was added.
Finally the ruby/Makefile.in was improved so that for test cases
without an explicit test script, the generated wrapper library will
be loaded by the Ruby interpreter to ensure loading works fine.
2020-12-16 22:30:46 +01:00
William S Fulton
bc09d05174 testname typo fix 2020-10-10 17:59:17 +01:00
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
Zackery Spytz
4e57c5536d Fix wrapping of virtual comparison operators with directors
Closes #1642.
2020-06-05 10:25:20 -06:00
Thomas REITMAYR
eb2be58a12 Add test cases for abstract user-defined conversion operators 2020-02-13 20:16:44 +01:00
William S Fulton
3585ee23cf Fix sort order of doxygen testcases 2020-01-16 19:37:07 +00:00
William S Fulton
55d36e3fd3 Merge branch 'Issue-1632'
* Issue-1632:
  Minor workaround in doxygen_basic_translate_style3 test
  Add new test doxygen_basic_translate_style3.i
  Fix for newline handling in doxygen "///" style comments
2020-01-16 07:19:29 +00:00
William S Fulton
00b47d4d1d Merge branch 'doxy/commands'
* doxy/commands:
  Update documentation for doxygen tags
  Fix doxygen translation of \p command for python
  Fix doxygen handling of \em tag for python
  Minor formatting updates to doxygen docs
  Reformat tag lists in doxygen documentation
  Add doxygen_code_blocks_runme.java
  Special handling for python doctest code blocks
  Add new doxygen test doxygen_code_blocks
  Handle doxygen code command with language option
  Improve doxygen parser handling of \code content
  Flag optional arguments in doxygen pydoc output
  Add parameter direction to doxygen pydoc output
  Support doxygen \param[] commands
2020-01-14 18:36:50 +00:00
William S Fulton
3759fcf999 Merge branch 'builtin-ctor-kwargs'
* builtin-ctor-kwargs:
  Python -builtin constructors silently ignored keyword arguments.
2020-01-13 19:29:47 +00:00
William S Fulton
67e8334ac8 Python -builtin constructors silently ignored keyword arguments.
Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments"
exception is thrown if keyword arguments are used. Hence constructors and normal
methods/functions behave in the same way.

Closes issue #1595
2020-01-13 19:26:22 +00:00
William S Fulton
d53a54b4f7
Merge pull request #1668 from treitmayr/master
Fix code generated for Ruby global variables
2019-12-30 23:49:04 +00:00
Vadim Zeitlin
b52af40398 Disable Doxygen tests when using Java 8 or older
Check Java version in configure and define SKIP_DOXYGEN_TEST_CASES if
it's less than 9, which is required by the new implementation of
CommentParser used in the Doxygen tests.
2019-12-18 16:24:28 +01:00
John McFarland
feea39f352 Add new test doxygen_basic_translate_style3.i
This is used to test the "///" style of doxygen comments.  Previously,
newlines in these doxygen comments were not handled correctly.
2019-11-02 10:43:52 -05:00
Thomas Reitmayr
18a3ef3911 Fix code generated for Ruby global variables
This commit fixes swig#1653 by creating a Ruby virtual variable
for a C/c++ global variable when SWIG is invoked with the
-globalmodule option.
2019-10-27 21:41:03 +01:00
John McFarland
5230afb3e1 Add new doxygen test doxygen_code_blocks
This does somewhat more detailed testing of the code block parsing,
and also exercises the language identification of python doctest
features.  For now, it is only tested by python (javadoc translation
may not correctly handle some of the characters that are used here).
2019-08-07 16:55:38 -05:00
William S Fulton
86cb3a9532 Python STL container method overloading fix
Fix method overloading of methods that take STL containers of different types.
Due to some error handling that was not cleared during typehecking.
2019-08-06 19:36:14 +01:00
William S Fulton
a9a7b03ba6 Split testcases li_std_wstring.i and li_std_wstring_inherit.i
Not many languages have support for std_wstring.i, so disable testing
for these languages until added.
2019-07-22 19:05:21 +01:00
William S Fulton
aea7a6d30f Merge branch 'patch-1'
* patch-1:
  nested_inheritance_interface testcase enhancement
  Add nested_inheritance_interface test for csharp
  Fix class name for nested classes
  Add nested_inheritance_interface test
  Fix class name for nested classes

Conflicts:
	CHANGES.current
2019-07-09 19:37:35 +01:00
Isaac Pascual Monells
84e310402a Add nested_inheritance_interface test 2019-07-02 12:57:16 +02:00