Remove wrapper aliases generation and use -namespace in the tests

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
This commit is contained in:
Vadim Zeitlin 2021-11-07 01:34:29 +01:00
commit e8f9bdba80
30 changed files with 294 additions and 311 deletions

View file

@ -197,7 +197,7 @@ Wrapping C functions and variables is obviously performed in a straightforward w
<p>
For each C function declared in the interface file a wrapper function with a prefix, required to make its name different from the original one, is created. The prefix for the global functions is <tt>module_</tt>, i.e. the name of the SWIG module followed by underscore. If <tt>nspace</tt> feature is used, the prefix for a function defined in a namespace is <tt>namespace_</tt> -- note that it does <em>not</em> contain the module prefix, as it's not necessary to make a unique function name in this case. The wrapper function performs a call to the original function, and returns its result. For convenience, a <tt>#define func prefix_func</tt> can be provided in the generated header file to make it possible to call the function under its original name: predefine <tt>SWIG_DEFINE_WRAPPER_ALIASES</tt> before including the wrapper header to enable these defines, which are disabled by default to avoid accidental name clashes.
For each C function declared in the interface file a wrapper function with a prefix, required to make its name different from the original one, is created. The prefix for the global functions is <tt>module_</tt>, i.e. the name of the SWIG module followed by underscore, by default. If <tt>-namespace</tt> option is used, the prefix corresponding to the given fixed namespace is used instead. If <tt>nspace</tt> feature is used, the prefix corresponding to the namespace in which the function is defined is used -- note that, unlike with <tt>-namespace</tt> option, this prefix can be different for different functions. The wrapper function performs a call to the original function, and returns its result.
</p>
<p>
@ -333,8 +333,10 @@ This section briefly covers the essential aspects of this wrapping.
<H3><a name="C_enums"></a>36.3.3 Enums</H3>
<p>
C enums are simply copied to the generated code and keep the same name as in
the original code.
C enums and unscoped C++ enums are simply copied to the generated code and both the enum itself and its elements keep the same name as in the original code unless <tt>-namespace</tt> option is used or <tt>nspace</tt> feature is enabled, in which case the prefix corresponding to the specified namespace is used.
</p>
<p>
For scoped C++11 enums, the enum name itself is used as an additional prefix.
</p>