Go, Guile, Racket, Scilab: Add throws typemaps for std::string so that
thrown string exception messages can be seen.
Test all language for std::string throws typemaps
For implementing full move semantics when passing parameters by value.
Based on SWIGTYPE && and std::unique_ptr typemaps which implement move
semantics.
Added for all languages, but untested for: Go, Ocaml, R, Scilab (and
unlikely to be fully functional for same reasons as for std::unique_ptr
support).
Issue #999
Support running testcases conditional on the compiler supporting
a each language version, like we already handle C++11.
Currently no testcases are actually run in this way for these
newer language versions.
Most of these test D_d twice when they really should be testing
D_d once and D_i once (the variable name is `di` and the values
assigned are integers).
This was wrong in the initial version for Python in
708021a809 and it looks like subsequent
additions for other languages have just copied that mistake.
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.
This works by transferring ownership of the underlying C++ memory
from the target language proxy class to an instance of the unique_ptr
which is passed to the wrapped function via std::move.
The proxy class has a new swigRelease() method which sets the
underlying C++ pointer for the proxy class to null, so working
in much the same way as std::unique_ptr::release(). Any attempt at
using the proxy class will be the same as if the delete() function
has been called on the proxy class. That is, using a C++ null pointer,
when a non-null pointer is usually expected.
This commit relies on the previous commit that uses std::move
on the temporary variable used for the wrapped function's input parameter
as std::unique_ptr is not copyable, it has move-only semantics.
The C++ wrappers create a temporary variable for a parameter to be passed to a
function. This is initially default constructed and then copy assigned from the
instance being passed in from the target language. This is unchanged, however,
when the temporary variable is passed to wrapped function, it is now done using
std::move. If the type is move constructible, the move constructor will be used
instead of the copy constructor.
Note that the implementation calls std::move for all user-defined types
(non-primitive types passed by value), this excludes anything passed by pointer,
reference and arrays. It does also include any type that has not been
defined/parsed by SWIG, that is, unknown types. std::move is called via the
SWIG_STD_MOVE macro which only calls std::move for C++11 and later code.
This is the current state of play where the copy constructor and copy
assignment operators are called, even for movable types passed as
function parameters.
The directorin typemaps in the director methods now use std::move on the
input parameter when copying the object from the stack to the heap prior
to the callback into the target language, thereby taking advantage of
move semantics if available.
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 #999Closes#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.
* imfunc:
Add special variable imfuncname expansion for C# and D
Test and document imfuncname special variable expansion
Update docs.
Also expose in proxyClassFunctionHandler
Expose to javaout typemaps.
Conflicts:
CHANGES.current
Move HAVE_CXX11 into makefiles so that running test-suite
from top level directory or in the language's test-suite directory
is consistent. For example, running 'make check-java-test-suite'
behaves the same as 'cd Examples/test-suite/java && make check'.
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
Language::unrollVirtualMethods was assuming that the using
declaration would only introduce one method. Fix this by adding
in all the overloaded methods from a base class.
Affects code generation in C# and Java, but I was not able
to construct a test that failed before this commit.
- Document change in CHANGES file
- Minor tweaks and whitespace fixes in stype.c
- Enhance testcase
- Synchronise Java and Python runt test in testcase
Closes#1977Fixes#1603
Squashed commit of the following:
commit 61f794184e127e4a4b46fb306b2dfea71f7cd7bb
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 15:20:25 2021 +0100
added python version for second part of testcase
commit bb80e236b8a7033d1ee45e392352ec0539730db3
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 15:10:14 2021 +0100
reworked comment in fixed code
commit 5a94bcc481ea1c068b62a3dbc6cbc2032c9896db
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 15:07:34 2021 +0100
removed new unittests; I switched to the official test cases
commit 36603f3c8dd27ee7b27d4a40804a844e1964b5aa
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 15:05:33 2021 +0100
removed new unittests; I switched to the official test cases
commit 1f20ea00d22e6c59edb9ae69d6bb31aacab09c4b
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 14:39:19 2021 +0100
adapted testcase
commit ab492794c0f26a27761b205fe1d67e2e9aa1f5b6
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 14:29:10 2021 +0100
fixed test
commit 9b5dd0c8f9b110a3492753b466e707d7f786c909
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 13:04:06 2021 +0100
C99 compatible comments
commit 1a89425ac8c85d68c6af1974e07573b9468d421e
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 20 11:41:48 2021 +0100
added extra checks to prevent accidental partial matches
commit 20e76f511ac139c8ea2a9a7fd89c29391579665f
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:42:56 2021 +0100
minor
commit 0e383bbb764f9a019f62b9f620f80908dead50d2
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:41:45 2021 +0100
cleanup
commit b644767121440c77f4caeb45f672e3c698ee9d78
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:39:43 2021 +0100
cleanup
commit 2574468c0f9352040759e680214b40ee59b03650
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:38:35 2021 +0100
cleanup
commit 9dc7f1ed30171649e8a70b12ff4f76d93e545074
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:35:28 2021 +0100
removed ide files
commit a442a9df460c52d4dbf7adf8e4f0c5bc5ad3b0cf
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:32:36 2021 +0100
removed printf
commit da4c6e91e3b70e72e89cf09dfabfef7416274637
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:29:02 2021 +0100
possible fix found
commit 6fad8d40e36195be422d5822e6f49d610e3ab693
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Thu Mar 18 21:01:11 2021 +0100
found difference between good/bad case... next: analyze why replacement did not work here...
commit 72a7693340358d2067e63c5489191917ccb818dd
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Wed Mar 17 22:43:08 2021 +0100
ideintified location where the template-template type is inserted in the final type (with the missing specialization).
commit 1b53312c07ab0696d9cade144bdbad1c84ebf6a3
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Wed Mar 17 22:28:19 2021 +0100
more notes (to be reverted)
commit a9a0b589389784e0e95dc6f9edd27c78a16b481d
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Wed Mar 17 22:19:16 2021 +0100
some experiments (to be reverted)
commit 0e7a24bbd5944d6e4f5c96ffd03003465f6d80f5
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Wed Mar 17 21:46:20 2021 +0100
added some notes
commit 2f77911a12a38735cadeb93223981f3a6d9e7450
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Tue Mar 16 22:01:01 2021 +0100
comment changed
commit 2cb7213b06f9b912c0ba56350ec6c318edba1ffb
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Tue Mar 16 21:55:47 2021 +0100
renamed example template parameters to easily distinguish them.
commit ff457d73977e05adf84b095bcfa1dccd21203c48
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Tue Mar 16 21:21:10 2021 +0100
added reset parser functionality (required for unittests, to reset parser)
commit 617bbde3b4b3d9dd16d3a2d85041fc78a87ae81f
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Tue Mar 16 20:47:41 2021 +0100
adjusted test for simple templates
commit beb7e7f77cedd4ecfa4165534781d417710aff7e
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Mon Mar 15 07:41:17 2021 +0100
added note how it should be...
commit 7b3328431ce41f7ec05657c69d3cb1a886cb8437
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 17:07:24 2021 +0100
found a place which is maybe problematic for the template_template problem (#1603)
commit 46c2443d15a6288318723b7e730687791475cf7b
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 16:11:56 2021 +0100
unitests: reset parser for each testcase
commit b3a0f1516ffdbf9f0fbb2d8362e2375fd1893c3f
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 15:30:47 2021 +0100
first experiment with templates
commit 32a11c6c77b840f11b9e926edd465e6a7108267f
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 14:31:17 2021 +0100
wip
commit 37b805ba6eaadb4a34a929204d539f555f8313be
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 14:21:05 2021 +0100
integrated unittests in ctest
commit 79f7bee168ecfbd2f2f5feeb9ca43fb7113bc2a4
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 14:18:26 2021 +0100
wip: new test created; problem: not in c++ mode
commit 345d503d557d67fa431f528e637bac5816f50ab1
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 14:08:09 2021 +0100
cleanup test code
commit 0a26adec10435af36bfad4e1f6a073460c63fbc6
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 14:05:24 2021 +0100
some more tests (first steps with c++ code)
commit 6f628e0fa9e2659f5a7ca08b9954e81d4cd4f012
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sun Mar 14 12:56:41 2021 +0100
experiments
commit c4a13bf3e12cd83886cbc54e32194bf916a643d3
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 13 18:18:01 2021 +0100
first experiment
commit 7d265861052f205d48b1ccec8ab0fe053de19858
Author: goto40 <pierre.bayerl@googlemail.com>
Date: Sat Mar 13 17:23:13 2021 +0100
setup catch2 framework (w/o tests)
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.
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).
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).
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.