For C++ tests, check header compilation using C++ compiler too, as this
detects constructs valid in C but invalid in C++ and will also be useful
for checking C++-specific parts of the headers that will be generated in
the future.
They are invalid in C++ and there shouldn't actually be any in valid
input, but they do occur in SWIG test suite.
Don't generate anything for them in the output, especially because doing
this is not really more complicated than using "enum_is_empty" field
that we had previously and might even be a tad simpler, as it doesn't
split the "{" and "}" output between two different functions.
Such declarations are invalid without specifying the underlying type
(which is only possible since C++11) and are useless anyhow, so just
don't bother emitting them.
Support compiling and running either _runme.c or _runme.cxx files for
the given test (but not both).
Add a simple C++ test file to check that it actually works.
The -namespace option provides a better way of using the wrapped API, so
drop the optional wrapper generation, which is useless when this option
is used and just generates many lines of unwanted junk in the header.
Update the test suite and the examples to compensate to not rely on
being able to define SWIG_DEFINE_WRAPPER_ALIASES and add -namespace
option to all C++ tests, as it's done for C# test suite, and update them
to use the correct prefix and also use the accessors for the global
variables rather than using them directly, as this is impossible when
namespace prefix is used (it would have been possible to define a
preprocessor symbol corresponding to the real variable name, but it's
arguably not worth it).
fixup! Remove wrapper aliases generation and use -namespace in the tests
These tests duplicate the other, more complex, existing unit tests, so
it's just not useful to have them at all any more (they could have been
useful at the very beginning of C backend development, when none of the
other tests worked).
No real changes, just keep everything in a single function because it is
more clear than having both it and functionWrapperCPPSpecificWrapper()
doing the same thing.
Use getCurrentClass() and other existing attributes to check if the
current node is inside a class or not (and hence is global), this is
more explicit and avoids confusion for static member functions that were
marked as being global in spite of being nested inside a class.
This avoids conflicts between functions synthesized by %extend when
adding static methods to an existing class, and the actual wrapper
functions generated by the backend.
This shouldn't result in any user-visible changes.
No real changes, just move the test for "code" to the outer scope to
facilitate the upcoming changes.
This commit is best viewed ignoring whitespace-only changes.
Using this option allows to prefix all exported symbols (functions,
enums and enum elements) with a prefix based on the given namespace.
Note that (global) variables can't be exported directly when using the
global namespace prefix, even if they are of C-compatible type.
These typemaps never worked, but this went unnoticed until now because
the nonsensical "ctype" expansion generated by them still compiled.
With types possibly having a namespace prefix, they didn't any longer,
so define them correctly for the objects using "$resolved_type" and
define the typemap for "void*[]" separately, as "$resolved_type" can't
be used for it.
Use the "type" naming format for the types mangled by "#@" and "##@"
preprocessor operators, in order to allow customizing them for a
particular backend.
This isn't used by any backend yet, so this doesn't change anything so
far.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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().
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).
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.
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".
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.
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.
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<>.
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.