Complete the removal of Ruby's output_helper macro and replacement
with SWIG_AppendOutput for director typemaps.
Requires $isvoid special variable support in director code.
This provides a generic framework to aid converting C/C++ integer and
boolean literals to target language literals, replacing custom code in
several target language backends (and fixing some bugs in that code).
New macro added to the family of %interface macros. This new macro
is for adding additional interfaces for the generated interface to
extend/derive from.
Closes#1188
Also remove stray static method comments from being incorrectly
generated into the PINVOKE class.
Add some missing multi-line tests for static methods, variables and
constants.
The $isvoid special variable expands to 1 if the
wrapped function has a void return, otherwise expands to 0.
In the implementation, use a consistent variable name, returntype,
for a node's "type" attribute.
Issue #2907
A different approach is taken for supporting casting smart pointers up the
inheritance hierarchy. We no longer try to replace the underlying pointer type,
provided in the 'feature:smartptr', with the base class type. Such as morphing
'std::shared_ptr<(Derived)>' into 'std::shared_ptr<(Base)>'. Instead, we simply
use 'feature:smartptr' from the base class. This is more reliable than trying to
pattern match the pointer type in the feature. The base class must of course
also have the 'feature:smartptr' set, and this is still checked for as before.
The feature is now parsed in one place and stored in the parse tree in the
new 'smart' attribute for handling by the target languages.
Fix also improves the handling of the type parsed in 'feature:smartptr' in that
the type is now normalized and resolved in the scope of the class it is attached
to.
Closes#2768
Expanding test cases, which found a bug with static methods and global
functions (they needed their own special handling).
Fixing code to match swig style rules and some other code quality.
And documentation fixes.
We need a way to specify default arguments for functions. Sometimes
we can just take the arguments straight from c++ literals. Sometimes
you can't, and need to specify those by hand.
So to make this work we:
1. Shutoff handling all "defaultargs" variants of methods and constructors
which have cs:defaultargs defined for their node. This gets us a single
constructor or method and skips the variants.
2. As we emit arguments in the function declaration, check if there is a
definition for it it from cs:defaultargs, if so, use that. If not,
and the method has a cs:defaultargs declaration, then fall back to the
literal expression from c++.
Consistently handle variables as constants or as variable wrappers
to match code in Language::staticmembervariableHandler(). This fixes
the following:
#define constexpr
%immutable Foo::Constant;
struct Foo {
static size_t constexpr ConstantA = 22;
static constexpr size_t ConstantB = 64;
};
which is actually invalid C++, but being done to workaround a SWIG
parser limitation for parsing ConstantA (ConstantB is okay) if constexpr
is left in.
Closes#2573
[C#] Support nullable reference types. A generic C# option to the
%module directive allows one to add in any code at the beginning of every
C# file. This can add the #nullable enable preprocessor directive at the beginning
of every C# file in order to enable nullable reference types as follows:
%module(csbegin="#nullable enable\n") mymodule
Closes#2681
[D, Java] Add the dbegin option to the %module directive for generating code at
the beginning of every D file. Similarly javabegin for Java. This enables one
to add a common comment at the start of each D/Java file.
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.
Required reworking code that adds a fake inheritance for smart pointers
using the smartptr feature. Swig_smartptr_upcast() added as a support
function for this.
Add Swig_obligatory_macros which must be called by each
target language to define SWIG_VERSION correctly
in the generated code, as well as the language specific
macro SWIGXXX where XXX is the target language name.
Drop the #ifdef SWIGXXX that was previously generated -
I can't see the point of this and if users are defining
this macro somehow, then users will need to change this
Closes#1050
* 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
* csharp-strenghten-overload-check:
Fix expanded director_basic test.
Improve correctness of SwigDerivedClassHasMethod() by making sure only methods that have `override` are used connected by director.
Segfault was actually avoided in previous commit ab23cb29.
This commit makes handling more robust in the event of
using %ignore just on the derived method, not tested as it is not
what one should do with directors, and possibly other cases.
Go still segfaults with the new testcase director_using_member_scopes.i.
Issue #1441.
Exit() is a wrapper for exit() by default, but SetExitHandler() allows
specifying a function to call instead.
This means that failures within DOH (e.g. Malloc() failing due to lack
of memory) will now perform cleanup such as removing output files.
This commit also cleans up exit statuses so SWIG should now reliably
exit with status 0 if the run was successful and status 1 if there was
an error (or a warning and -Werror was in effect).
Previously in some situations SWIG would try to exit with the status set
to the number of errors encountered, but that's problematic - for
example if there were 256 errors this would result in exit status 0 on
most platforms. Also some error statuses have special meanings e.g.
those defined by <sysexits.h>.
Also SWIG/Javascript tried to exit with status -1 in a few places (which
typically results in exit status 255).
These were officially deprecated in 2001, and attempts to use them have
resulted in a warning (including a pointer to what to update them to)
for most if not all of that time.
Fixes#1984
Add ability to change the modifiers for the C# and Java
interface generated when using the %interface macros.
For C# use the 'csinterfacemodifiers' typemap.
For Java use the 'javainterfacemodifiers' typemap.
For example:
%typemap(csinterfacemodifiers) X "internal interface"
Closes#1874
* shared-ptr-template-upcast:
comments
Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup
Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class
WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type
comments
Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup
Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class
WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type
- Add support to DOH Replace for not replacing inside C comments
- Fix removing 'out' or 'ref' when these are present in C comments
in cstype typemaps.
Closes#1628