Change in default behaviour wrapping C++ bool for Python.
Only a Python True or False will now work for C++ bool parameters. This fixes overloading bool with other types.
This commit is contained in:
parent
7f45cbd178
commit
504c2030bb
11 changed files with 251 additions and 11 deletions
19
Examples/test-suite/overload_bool.i
Normal file
19
Examples/test-suite/overload_bool.i
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
%module overload_bool
|
||||
|
||||
%inline %{
|
||||
const char* overloaded(bool value) { return "bool"; }
|
||||
const char* overloaded(int value) { return "int"; }
|
||||
const char* overloaded(const char *value) { return "string"; }
|
||||
|
||||
const char* boolfunction(bool value) { return value ? "true" : "false"; }
|
||||
const char* intfunction(int value) { return "int"; }
|
||||
|
||||
|
||||
// Const references
|
||||
const char* overloaded_ref(bool const& value) { return "bool"; }
|
||||
const char* overloaded_ref(int const& value) { return "int"; }
|
||||
const char* overloaded_ref(const char *value) { return "string"; }
|
||||
|
||||
const char* boolfunction_ref(bool const& value) { return value ? "true" : "false"; }
|
||||
const char* intfunction_ref(int const& value) { return "int"; }
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue