[Python] Deal with an integer as the default value of a bool
parameter in the C++ prototype. Fixes github #327, reported by Greg Allen.
This commit is contained in:
parent
c2a13b9b7b
commit
c2972b8bf0
4 changed files with 18 additions and 0 deletions
|
|
@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 3.0.6 (in progress)
|
||||
===========================
|
||||
|
||||
2015-05-07: olly
|
||||
[Python] Deal with an integer as the default value of a bool
|
||||
parameter in the C++ prototype. Fixes github #327, reported by
|
||||
Greg Allen.
|
||||
|
||||
2015-05-07: LindleyF
|
||||
[Java] Allow feature("director") and feature("ref") to be used
|
||||
together. Github PR#403.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ struct Display {
|
|||
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||
float draw1(float v = 0) { return v; }
|
||||
float draw2(float *v = 0) { return v ? *v : 0; }
|
||||
bool bool0(bool x = 0) { return x; }
|
||||
bool bool1(bool x = 1) { return x; }
|
||||
};
|
||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||
%}
|
||||
|
|
@ -14,5 +16,7 @@ struct Display {
|
|||
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||
float draw1(float v = NULL) { return v; }
|
||||
float draw2(float *v = NULL) { return v ? *v : 0; }
|
||||
bool bool0(bool x = 0) { return x; }
|
||||
bool bool1(bool x = 1) { return x; }
|
||||
};
|
||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||
|
|
|
|||
|
|
@ -15,3 +15,8 @@ if d.draw2() != 0:
|
|||
if d.draw2(p) != 123:
|
||||
raise RuntimeError
|
||||
|
||||
if d.bool0() != False or type(d.bool0()) != type(False):
|
||||
raise RuntimeError
|
||||
|
||||
if d.bool1() != True or type(d.bool1()) != type(True):
|
||||
raise RuntimeError
|
||||
|
|
|
|||
|
|
@ -1927,6 +1927,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// Allow integers as the default value for a bool parameter.
|
||||
if (Cmp(t, "bool") == 0)
|
||||
return NewString(value ? "True" : "False");
|
||||
|
||||
// Deal with the values starting with 0 first as they can be octal or
|
||||
// hexadecimal numbers or even pointers.
|
||||
if (s[0] == '0') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue