[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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue