Write the wrapper types and declarations directly to f_wrappers_h,
without passing by an intermediate f_wrappers_h_body which just
complicated things unnecessarily.
This means that "extern "C" { ... }" is now around the functions
declarations only, and not around the types and the declarations, but
this seems like a desirable side effect.
No real changes.
Also explain better what each of them is used for and use scoped_dohptr
instead of deleting them manually.
Stop writing everything to f_begin, which didn't make any sense, and use
a separate f_wrappers_cxx object for the contents of the cxx output file.
No real changes.
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.
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
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.
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.
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 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.
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.
Remove the code related to "_result_ref" which was confusing and plain
wrong, as it generated something that compiled but crashed during
run-time due to the use of a pointer to an already destroyed stack
object.
Instead, correct the "out" typemap to create a new copy of the object,
which mostly works fine on its own, except that it depends on using
SwigValueWrapper if necessary, so add the call to cplus_value_type()
does this. This also required removing the code resolving typedefs in
the "type" attribute because it confused the base class logic and still
needs an explicit cast to the actual return type due to the use of (and
probable bug in) get_wrapper_func_return_type().
These changes mean that "cppouttype" typemap is not used any longer, so
remove it too.
A couple more tests pass now.
Prefix them with namespace-based prefix (e.g. "ns1_ns2_" for a function
inside ns1::ns2) if feature:nspace is on. Otherwise, or if the function
is defined in the global namespace, use the module name as prefix
instead of "_wrap": this is slightly less ugly and results in more
unique names.
Not being able to do it is too restrictive in practice and just forces
to use raw DOH pointers, which is not really less dangerous than adding
the assignment operator and reset() method to this class.
There doesn't seem to be any unit tests covering this, but the old code
was wrong because it didn't replace periods used as namespace separators
with underscores, which resulted in periods appearing in the output when
nested namespace were used.
Fix this and also reuse the now fixed getNamespacedName() in
getEnumName() which contained its own buggy version of the same code.
It doesn't seem necessary to muck with sym:name explicitly when we
construct the fully qualified name using getNamespacedName() later
anyhow.
Moreover, the overridden version had a bug which resulted in a crash in
template_empty_inherit unit test and simply removing it entirely allows
the test to pass (without breaking anything else).
This is done not so much to fix the memory leak per se (as there are
gazillions of other ones remaining), but to show that the return value
of getProxyName() does need to be freed, as this was unclear previously,
with it being freed in one place where this function was used, but not
in the other one, here.
Also state this explicitly in the function comment.
Handle char constants defined using #define or %constant correctly.
Also handle static member const variables, which didn't work at all
before, and quote values of such variables of char type.
It's not significantly simpler to use "goto" in this function, so just
replace it with "return".
Also remove the unnecessary checks for strings being deleted being
non-null, as they always are.
No real changes.
We need to make a copy instead of directly returning whatever sym::name
points to, as this value can be overwritten with something different
later, resulting in weird problems with the value of "proxyname"
attribute changing "on its own".
After this bug fix, a few more unit tests pass.
There is no need to override it just to call the base class version.
Also remove the outdated comment, as %extend is supported currently
(albeit with some bugs remaining).
No real changes.
Don't mark functions not intended to be overridden (nor overriding those
in the base class) as "virtual", this is useless and confusing.
No real changes.
By delegating to the base class instead we not only save quite a few
lines of code, but gain support for ctors/dtors defined using %extend,
which didn't work before, allowing to reenable some of the previously
failing tests.
This is useless and the C-specific version didn't handle template
methods added with %extend correctly, so removing this code also fixes
some (but not all yet) failures in extend_template_method.cpptest unit
test.
This is never going to work and just results in generating uncompilable
code.
In principle, we could either generate wrappers for these functions
while still handling the struct as a plain C struct, or switch to
generating class-like wrappers for it if it's %extended with any
functions, but for now just ignore them as this is the simplest thing to
do.
Incidentally, this makes the default_args_c test pass again now, after
the last merge with master pulled in such %extend directives into it.