Commit graph

22,669 commits

Author SHA1 Message Date
Vadim Zeitlin
f4ee8e5369 Fix names of enums and their elements
Use the containing class name as prefix, and add the name of the enum
itself to the prefix for the scoped enums, instead of doing something
strange and semi-random that we did before, with prefixes including the
namespace (which should never be the case without "nspace" feature), but
not the scoped enum.

This also fixes renaming of enum elements, as a side effect, which
didn't work before, add run test for enum_rename unit test to prove it.
2021-11-07 02:14:16 +01:00
Vadim Zeitlin
81d1fec13c Remove code setting unused "c:retval" attribute
This became unused after the changes of fd3e76365 (Streamline and fix
returning objects by value, 2019-08-06) and allows to simplify code
further as we don't need to override static and non-static member
function handlers at all any more now.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
ec4cfd41de Return scoped_dohptr from get_wrapper_func_return_type()
Ensure that the returned pointer is deleted automatically instead of
doing it manually.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
07e7086b39 Generate wrapper function name in a single place
Rename getGlobalWrapperName() to getFunctionWrapperName() and make it
work for all functions, not just global ones.

This means that we can test whether the function is global or not in a
single place instead of doing it in two different ones.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
7e5e6a4cf0 Avoid unnecessary allocations of function name
Use maybe_owned_dohptr in function wrapper code to avoid making a copy
unnecessarily just to be able to Delete() this pointer later.

No real changes.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
4801a3154e Delete never used variables in function wrapper code
No real changes, just don't bother allocating and deleting strings that
are never used at all.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
ad3db88e44 Add maybe_owned_dohptr helper
This class allows to avoid allocating a new DOH object unnecessarily if
we can reuse an existing one.

It is not used yet, but will be soon.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
ca56f14aa5 Refactor scoped_dohptr() to reuse its reset()
No real changes, just avoid some code duplication and add an optional
argument to reset() to make it more compatible with std::unique_ptr<>
and also more flexible.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
8014af974d Revert accidental change to Python example
This was done way back in f84342a30 (Modified parameter handling using
typemaps. 'Reference' example. Visibility hint now applies only to the
global functions., 2008-06-28), surely accidentally.
2021-11-04 01:31:06 +01:00
Vadim Zeitlin
63a229a40f Don't disable experimental warning for C in GHA workflow any more
This is not necessary any longer after the previous commit and is better
than setting SWIG_FEATURES in the workflow file, as this resulted in
showing "-w524" in the name of C CI build since the changes of 04a6ad3bb
(Add SWIG_FEATURES into GHA name, 2021-10-21), which was a bit ugly.
2021-11-02 17:51:14 +01:00
Vadim Zeitlin
9ac6ab3b8a Disable SWIGWARN_LANG_EXPERIMENTAL while running test suite for C
We really don't need all the warnings while testing, they are only
useful for SWIG users, not when developing it.
2021-11-02 17:51:14 +01:00
Vadim Zeitlin
080d3075e3 Rename getNamespacedName() to getProxyName()
This is a more logical name for this function, as it caches its return
value in "proxyname" attribute and doesn't really have much to do with
namespaces.

No real changes.
2021-10-30 21:11:02 +02:00
Vadim Zeitlin
0434b93cc9 Rename getProxyName() to getClassProxyName()
Show that this function only returns non-null result for classes, as
this was not at all obvious before.

No real changes.
2021-10-30 21:09:41 +02:00
Vadim Zeitlin
d7f06c3721 Reuse Swig_string_mangle() instead of using Replaceall()
Use the same function in getNamespacedName() which was already used in
getGlobalWrapperName() just below, this is more readable and more clear
than just replacing dots with underscores as we did before.

Also use scoped_dohptr instead of manual Delete() calls.

No real changes.
2021-10-30 18:51:19 +02:00
Vadim Zeitlin
1fb0de9e00 Don't call Swig_scopename_prefix() unnecessarily
No real changes, just make the code do what the comment said it did and
only use the namespace as prefix when "nspace" feature is on instead of
always trying to use it as prefix and then resetting it.

This required adding default ctor and assignment operator from raw
pointer to scoped_dohptr, but they can be useful elsewhere too, while
the actual code in getGlobalWrapperName() is simpler and more readable
now.

No real changes.
2021-10-30 18:47:12 +02:00
Vadim Zeitlin
2f6f6df211 Generate wrapper aliases only if requested and not by default
Defining the aliases by default results in conflicts when including
headers from multiple modules as e.g. SWIG_PendingException_get() is
defined in all of them, and could also easily result in other unwanted
clashes, so make this opt-in and update the examples and tests relying
on using the wrappers without the module prefix to define
SWIG_DEFINE_WRAPPER_ALIASES explicitly.
2021-10-20 01:57:20 +02:00
Vadim Zeitlin
d65d7d7df3 Make SWIGIMPORT definition more consistent with SWIGEXPORT
Use the same checks as for the definition of SWIGEXPORT in
swiglabels.swg.

Also avoid defining __DLL_IMPORT symbol with a reserved name.
2021-10-20 01:57:18 +02:00
Vadim Zeitlin
e41234c5bc Inject just the relevant part of changes.swg in generated code
Don't include the entire file, including its header comment, into the
generated code, but just the part that we want to appear there.

This looks nicer and is also more explicit and hence clear.
2021-10-15 23:16:42 +02:00
Vadim Zeitlin
e45d8f94fc Link C modules with libpthread under Unix systems
Specify -pthread option which should be universally supported under
non-{MSW,Mac} platforms by now and which is required under Linux to link
the tests using boost::shared_ptr<>, which uses pthread_mutex_xxx().
2021-10-15 23:02:39 +02:00
Vadim Zeitlin
e78c8f39ed Add minimal shared_ptr support
Enable the tests and support of shared_ptr in them for C (which required
disabling a previously passing, because not doing anything, attributes
test which is currently broken for unrelated reasons).
2021-10-15 01:26:22 +02:00
Vadim Zeitlin
d77e5d8b0e Enable C++11 testing for C backend
Not all C++11 tests pass, but some (and important ones) do, so do check
them.
2021-10-15 00:59:34 +02:00
Vadim Zeitlin
8d7c1c4227 Eliminate a separate FAILING_CPP_TESTS variable in C Makefile
Also undo the changes to common.mk originally done in this branch and
rendered unnecessary by de5e0c865 (C++11 testing moved to a configure
option, 2013-10-08) on master.
2021-10-15 00:57:25 +02:00
Vadim Zeitlin
10dbb92182 Remove another not failing unit test
This test doesn't really work, as directors support is not implemented
at all in C backend, but remove it from here to prevent reports from
"make check-failing" about "failing test passing".
2021-10-14 19:54:50 +02:00
Vadim Zeitlin
d0e979278e Re-enable passing li_std_pair_using test
This must have been fixed by fc1ebd7c1 (Add trivial but working
std::pair typemaps implementation, 2019-08-07).
2021-10-14 19:48:59 +02:00
Vadim Zeitlin
3dd96d5b95 Allow using vector with classes without default ctor in C too
This is similar to be491506a (Java std::vector improvements for types
that do not have a default constructor., 2019-03-01) for Java, except we
don't have to bother with any compatibility constraints for this, not
yet used by anyone. module.
2021-10-07 22:03:47 +02:00
Vadim Zeitlin
5cbdae42d3 Revert "Use std/std_vector.i instead of a poor copy in c/std_vector.i"
This reverts commit d89a95a48c as,
finally, it's not worth trying to use UTL typemaps from C: this required
bad hacks for std::vector and would be even worse for std::map, so don't
bother with them and just correct the "poor" C typemaps to be slightly
less poor and use them instead.
2021-10-07 22:03:47 +02:00
Vadim Zeitlin
45bb179407 Expand "$null" in typemaps in C backend too
This is used in some exception-related typemaps, both in SWIG itself
(although they're not used with C backend currently) and outside of it.
2021-10-07 22:03:47 +02:00
Vadim Zeitlin
0706ed4d35 Add simple std::set<> typemaps too
This is similar to the previous commit for std::map<>.
2021-10-07 22:03:47 +02:00
Vadim Zeitlin
9efb508eda Fix std::map<> typemap
Use simple fixed typemap instead of trying to use the much more complex
one from the UTL which doesn't work for C.

Add a simple test case for std::map<>.
2021-10-07 22:03:47 +02:00
Vadim Zeitlin
b88491fe89 Add at least a very minimal run test for std::vector
The test is trivial, but still better than nothing.
2021-10-07 22:03:47 +02:00
Vadim Zeitlin
e1815634ec Clean the generated headers for C too
This fixes a check-maintainer-clean problem.
2021-10-05 01:34:32 +02:00
Vadim Zeitlin
5bbaecfb81 Set LD_LIBRARY_PATH when running C examples too
This is needed to find the SWIG-generated shared library when using C
too, as it's already the case for many (but, surprisingly, not all)
other target languages.
2021-10-05 01:01:37 +02:00
Vadim Zeitlin
d2e3cce7d4 Avoid -Wformat warnings in C std_vector example
Use "%zd" for printing size_t values rather than "%d".
2021-10-05 00:57:45 +02:00
Vadim Zeitlin
03b6e2fbe6 Don't use SWIG_exit() in C examples
There doesn't seem to be any reason for using it rather than just
returning from main() as usual, and it provokes warnings about
implicitly declared function when compiling them.
2021-10-05 00:26:12 +02:00
Vadim Zeitlin
86205e86e3 Disable warnings about C backend being experimental in CI builds
These warnings are perhaps useful for the SWIG end users, but not really
in the CI build logs, where they just create noise and are distracting.
2021-10-05 00:23:20 +02:00
Vadim Zeitlin
52bd63b31d Test C backend in GitHub CI workflow 2021-10-04 22:17:06 +02:00
Vadim Zeitlin
3da85eb4c5 Disable only part of cpp11_alternate_function_syntax test
Instead of skipping it entirely, just disable the part using member
function pointers, which are not supported in C backend.
2021-10-04 22:11:29 +02:00
Vadim Zeitlin
b5a8ccffa3 Explicitly refuse to wrap vararg functions
They were not supported currently, but processing them resulted in just
a warning about missing ctype typemap and generated uncompilable code.

Give an error and don't generate any code at all now, which is more
clear and helpful.

Also exclude the part of kwargs_feature test using varargs from C test
suite.
2021-10-04 22:09:12 +02:00
Vadim Zeitlin
ac4f3c78be Merge branch 'master' into C
Merge with the latest master before making more changes.
2021-10-04 16:03:36 +02:00
Vadim Zeitlin
8a0ec051db Don't run non-node JS tests in parallel in the CI builds
This seems to be broken and sporadically results in "Text file busy"
errors when the tests are run actually in parallel, as is the case in
GitHub CI environment.
2021-10-03 17:19:29 +02:00
Anthony Heading
6c59cae799 Avoid gcc 11 misleading indentation warning in generated code
Closes https://github.com/swig/swig/pull/2074
2021-10-03 17:18:58 +02:00
Julien Schueller
42ed181e08 [CMake] Add option to enable pcre
Closes #2031, #2065.
2021-10-03 16:32:11 +02:00
Vadim Zeitlin
892db20d12 Merge branch 'ci-improvements'
Re-add most of the Linux CI builds previously run by Travis CI to GitHub
Actions CI workflow.

See #2084.
2021-10-03 16:08:46 +02:00
Vadim Zeitlin
3b7e46dd19 Try using one less make job to see its effect on total time
Check if using -j2, rather than -j3, may help with speeding up Octave
unit tests run which takes ~25 minutes currently.
2021-10-01 04:28:11 +02:00
Vadim Zeitlin
f038fcb44d Do nothing in li_std_functors test when using Ruby 2.6
This test sporadically crashes when run in GitHub Actions environment,
so skip it for now when using the Ruby 2.6 version installed by rvm.
2021-10-01 04:26:15 +02:00
Vadim Zeitlin
51cb07711f Add most of Linux builds from Travis CI
Don't add the builds known/allowed to fail and don't add all the
variations of Python builds, there are just too many of those, but do
add mostly all the rest, with the exceptions below:

Builds using JavaScript backend with node <= 10 had to be disabled as
well, as they just seem to be broken and there is no real motivation in
supporting these ancient versions.

Builds using D can't be run currently due to incompatibility between the
ancient dmd version being used and the earliest support Ubuntu version
(18.04) on GitHub Actions and not supporting newer versions in SWIG.

Builds using Scilab had to be disabled as running the test suite
reliably hangs. This would need to be debugged by somebody motivated in
doing it.

Note that some builds need to be run under Ubuntu 18.04 (Bionic) and not
the default 20.04 (Focal) as they use old dependencies that don't exist
in Focal any longer. In the future we ought to switch to using newer
versions of these dependencies.
2021-10-01 03:20:13 +02:00
Vadim Zeitlin
11c8760639 Install rvm in CI setup script if it's not available
It is not available out of the box in GitHub environment, unlike under
Travis CI, so install it ourselves.

Note that we do it manually because installing the rael-gc/rvm PPA
doesn't seem to work with weird failures in GitHub Actions environment.

We also can't use gpg2 --recv-keys in this environment as it doesn't
work, apparently due to a firewall.
2021-10-01 03:20:13 +02:00
Vadim Zeitlin
4b05d8d947 Don't run ccomplextest as part of JavaScript test suite
This test currently fails due to "I" being undefined, so disable it to
let the rest of the tests to pass and add it later when this can be
fixed.
2021-10-01 02:11:11 +02:00
Vadim Zeitlin
58a49bac66 Suppress more -Wignored-qualifiers in JavaScript tests
This is probably not the greatest idea, and it would be better to change
the generated code to avoid these tests instead, but it was already done
like this for several tests, so just add two more of them that generate
warnings such as

../../member_funcptr_galore_wrap.cxx: In function ‘SwigV8ReturnValue _wrap_MemberFuncPtrs_aaa6(const SwigV8Arguments&)’:
../../member_funcptr_galore_wrap.cxx:3495:90: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
 3495 |   result = (int)((MemberFuncPtrs const *)arg1)->aaa6((short (Funcs::*const )(bool) const)arg2);
      |                                                                                          ^~~~

when using gcc 9.
2021-10-01 01:39:12 +02:00
Vadim Zeitlin
f0b3010440 Avoid another warning about deprecated implicit copy ctor
This is similar to the previous commit, but in the other direction, with
the warning being generated for the implicitly-declared copy ctor due to
having an explicitly-declared assignment operator.

And the fix is different too because we need to have an assignment
operator in this test, so define the copy ctor explicitly too.
2021-10-01 01:39:12 +02:00