mirror of https://github.com/swig/swig
[Python] Fix wrapping of bool const&x=true param
Fix wrapping of a bool const& parameter with a default value. Regression introduced in SWIG 4.3.0. Fixes #3162
This commit is contained in:
parent
b5deab76bc
commit
f0fb79152e
|
@ -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)
|
||||
===========================
|
||||
|
||||
2025-06-09: olly
|
||||
[Python] #3162 Fix wrapping of a bool const& parameter with a
|
||||
default value. Regression introduced in SWIG 4.3.0.
|
||||
|
||||
2025-06-09: olly
|
||||
[Tcl] #2887 Fix -external-runtime to generate a header which works
|
||||
with Tcl 8.x. Regression introduced in SWIG 4.2.1. As a bonus
|
||||
|
|
|
@ -14,6 +14,7 @@ struct Display {
|
|||
float draw1(float v = NULL_FOR_FLOAT) { return v; }
|
||||
float draw2(float *v = NULL_FOR_FLOAT) { return v ? *v : 0; }
|
||||
int draw3(int index = 0, const bool interpolate = true) { return interpolate ? index : -index; }
|
||||
int draw4(bool const& interpolate = true) { return interpolate ? 1 : -1; }
|
||||
bool bool0(bool x = 0) { return x; }
|
||||
bool bool1(bool x = 1) { return x; }
|
||||
|
||||
|
|
|
@ -18,6 +18,12 @@ if d.draw2(p) != 123:
|
|||
if d.draw3() != 0:
|
||||
raise RuntimeError
|
||||
|
||||
if d.draw4() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
if d.draw4(False) != -1:
|
||||
raise RuntimeError
|
||||
|
||||
if d.bool0() != False or type(d.bool0()) != type(False):
|
||||
raise RuntimeError
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ raise RuntimeError if d.draw2(p) != 123
|
|||
|
||||
raise RuntimeError if d.draw3() != 0
|
||||
|
||||
raise RuntimeError if d.draw4() != 1
|
||||
|
||||
raise RuntimeError if d.draw4(false) != -1
|
||||
|
||||
raise RuntimeError unless d.bool0() === false
|
||||
|
||||
raise RuntimeError unless d.bool1() === true
|
||||
|
|
|
@ -2150,7 +2150,15 @@ public:
|
|||
// return NewStringf("'%(escape)s'", stringval);
|
||||
}
|
||||
SwigType *resolved_type = SwigType_typedef_resolve_all(type);
|
||||
SwigType *unqualified_type = SwigType_strip_qualifiers(resolved_type);
|
||||
SwigType *unqualified_type = NIL;
|
||||
if (SwigType_isreference(resolved_type)) {
|
||||
SwigType *t = Copy(resolved_type);
|
||||
t = SwigType_del_reference(t);
|
||||
unqualified_type = SwigType_strip_qualifiers(t);
|
||||
Delete(t);
|
||||
} else {
|
||||
unqualified_type = SwigType_strip_qualifiers(resolved_type);
|
||||
}
|
||||
if (numval) {
|
||||
if (Equal(unqualified_type, "bool")) {
|
||||
Delete(resolved_type);
|
||||
|
|
|
@ -777,7 +777,15 @@ private:
|
|||
}
|
||||
if (numval) {
|
||||
SwigType *resolved_type = SwigType_typedef_resolve_all(type);
|
||||
SwigType *unqualified_type = SwigType_strip_qualifiers(resolved_type);
|
||||
SwigType *unqualified_type = NIL;
|
||||
if (SwigType_isreference(resolved_type)) {
|
||||
SwigType *t = Copy(resolved_type);
|
||||
t = SwigType_del_reference(t);
|
||||
unqualified_type = SwigType_strip_qualifiers(t);
|
||||
Delete(t);
|
||||
} else {
|
||||
unqualified_type = SwigType_strip_qualifiers(resolved_type);
|
||||
}
|
||||
if (Equal(unqualified_type, "bool")) {
|
||||
Delete(resolved_type);
|
||||
Delete(unqualified_type);
|
||||
|
|
Loading…
Reference in New Issue