mirror of https://github.com/swig/swig
Fix initializer lists used with -keyword or compactdefaultargs option
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 commit is contained in:
parent
7af22e929a
commit
3cda507e57
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.4.0 (in progress)
|
||||
===========================
|
||||
|
||||
2024-10-30: wsfulton
|
||||
#1851 Fix handling of parameters with default arguments that are
|
||||
initializer lists when using -keyword or the compactdefaultargs option.
|
||||
|
||||
2024-10-27: olly
|
||||
#3058 Fix precedence of casts, which should have the same high
|
||||
precedence as unary plus and minus, but actually had a lower
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
%rename(OperatorRValue) Thingy::operator int&&;
|
||||
%rename(memberFnRenamed) memberFn(short &&i);
|
||||
%feature("compactdefaultargs") Thingy::compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef);
|
||||
%feature("compactdefaultargs") Thingy::moreCompactDefaultArgs;
|
||||
%feature("exception") Thingy::privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue);
|
||||
%ignore Thingy::operator=;
|
||||
|
||||
|
@ -35,6 +36,7 @@ struct Thingy {
|
|||
static short && staticRvalueInOut(short &&i) { return std::move(i); }
|
||||
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
|
||||
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
|
||||
void moreCompactDefaultArgs(UserDef&& ud1 = UserDef(), UserDef&& ud2 = {}, const UserDef&& ud3= {}, UserDef ud4 = {}) {}
|
||||
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
|
||||
operator int &&() { return std::move(valval); }
|
||||
Thingy(const Thingy& rhs) : valval(rhs.valval), lvalref(rhs.lvalref), rvalref(std::move(rhs.rvalref)) {}
|
||||
|
|
|
@ -112,11 +112,9 @@ static String *Swig_clocal(SwigType *t, const_String_or_char_ptr name, const_Str
|
|||
default:
|
||||
if (value) {
|
||||
String *lcaststr = SwigType_lcaststr(t, value);
|
||||
String *lstr = SwigType_lstr(t, 0);
|
||||
String *lstrn = SwigType_lstr(t, name);
|
||||
Printf(decl, "%s = (%s) %s", lstrn, lstr, lcaststr);
|
||||
Printf(decl, "%s = %s", lstrn, lcaststr);
|
||||
Delete(lcaststr);
|
||||
Delete(lstr);
|
||||
Delete(lstrn);
|
||||
} else {
|
||||
String *lstrname = SwigType_lstr(t, name);
|
||||
|
|
Loading…
Reference in New Issue