For example:
%typemap(in) int MYINT (int $1_temp) { ... }
$1_temp is typically expanded to arg1_temp, arg2_temp etc depending on
which argument the typemap is applied to.
Perform repeated typedef lookups instead of a single typedef
lookup on the type being applied in %apply when looking for a family
of typemaps to apply.
Closes#3064
When wrapping a default argument such as 'const bool& x = true'
a variable with the exact same type, such as:
bool const &arg2_defvalue = true;
is now used in the generated code instead of a dereferenced type:
bool arg2_defvalue = true;
This can still be used for the wrapped argument without any other
changes:
bool *arg2 = (bool *) &arg2_defrvalue;
and the lifetimes are still the same for the temporary variable.
Works around some typedef issues for enum classes introduced in the
previous commit in the cpp11_strongly_typed_enumerations testcase,
when wrapping a parameter 'const PRINT_SETUP& e = PRINT_SETUP::TO_CONSOLE'
The temporary variable being generated became:
enum MyClass::PRINT_SETUP arg2_defvalue = MyClass::PRINT_SETUP::TO_CONSOLE ;
The enum in the type is wrong for an enum class. Now the original type
is used:
MyClass::PRINT_SETUP const &arg2_defvalue = MyClass::PRINT_SETUP::TO_CONSOLE ;
Remove casts to local variables that have initial values taken from the
default arguments being wrapped. This is for the default case, that is,
for all types, except references.
This fixes handling of parameters with default arguments that are initializer
lists by removing a cast to the initializer.
For wrapping parameter X x = {}, the generated code previously would have
contained:
X arg2 = (X) {};
Now it is:
X arg2 = {};
Closes#1851
This is described in CHANGES as a "Secret developer feature" and
a "SICK HACK". It was only documented in developer documentation, and
had no test coverage.
It allowed specifying an SWIG internal syntax type string, e.g.
`p.a(10).p.f(int, p.f(int).int)` foo(int, int (*x)(int));
However there seems to be no good reason to support this - it's
better to use the C/C++ syntax:
(*(*foo(int, int (*)(int)))[10])(int, int (*)(int));
Fixes#2998Closes#3034
We were treating byte 0xff as EOF after a `#` which wasn't handled by
the preprocessor on platforms with signed char, while EOF was treated as
byte 0xff on platforms with unsigned char.
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).
This is certainly a corner case, but GCC and clang both accept zero
bytes at least in comments, and SWIG's current handling is to ignore
the zero byte and all following characters up to and including the next
newline, so for example if a // comment contains a zero byte SWIG would
quietly ignore the next line.
Closes#3010
SWIG now gives an error for digits 8 and 9 in octal constants -
previously these were quietly accepted resulting in a bogus value.
C++11 binary constants are now treated similarly - only digits 0
and 1 were allowed before, but trying to use other digits now gives
a clearer error.
Fix wrapping of string constants containing bytes 0-8, 11, 12 or 14-31
followed by a digit '0' to '7'. We were emitting these bytes as a one
or two character octal escape sequence which when interpreted would
include the following character.
This was resulting in incorrect generated C# and Java code. For
some cases such as `#define CONSTANT 1.0f` this was a regression
introduced in 4.2.0 when we started more correctly wrapping these
as `float` rather than `double`.
Fixes#1917
* nspacemove:
Improved namespace validity checks for the nspace feature
Add docs for %nspacemove
Add nspacemove example for STL types
Validate scopename in nspace feature
Fix %nspace and %nspacemove for nested classes and enums in a class
Enhance %nspace with %nspacemove for moving symbols into a different target language namespace
nspacemove testcase
Correct code in javascript testcase for jsc
Conflicts:
CHANGES.current
Handle alternative operator names in C++ preprocessor expressions.
Handle full set of alternative operator names in C++ expressions
(previously only "and", "or" and "not" were understood).
Fixes#2914
instead of copy constructor when passing movable types by value.
Additional enhancement when passing movable types to constructors.
Enhancement to e777b054d5.
instead of copy constructor when passing movable types. This was
previously implemented only for parameters passed to a global function
or static member function and is now extended to member methods.
Enhancement to e777b054d5.
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
Create a new T_UNKNOWN type code and use this for the cases where
we previously abused T_INT. This means we can now reliably deduce
`int` when we see T_INT.
Fix the deduced result types of unary plus and unary minus which weren't
getting integer promotion applied to them.
Fix the deduced result type of the C++ logical not operator which was
`int` but should be `bool`.
Fix when variable override contains a pointer dereference ->.
This enables use of $1.x as a variable override value as SWIG
replaces $1.x with a pointer dereference expression, such as
(&arg1)->x.
Added a testcase showing how Python typemaps could alternatively
be written using $typemap() instead of using C++ templates as used in
the UTL. I'm not convinced this is fully reliable or even a good idea,
so the variable replacements in $typemap() remain undocumented.