%implicitconv will now accept None where the implicit conversion takes a C/C++ pointer.
Problem highlighted by Bo Peng on the swig-user mailing list. SF patch #230.
This commit is contained in:
parent
628b4710e5
commit
1cc735df5e
4 changed files with 79 additions and 5 deletions
|
|
@ -11,6 +11,14 @@ check(1, A(1).get())
|
|||
check(2, A(1.0).get())
|
||||
check(3, A(B()).get())
|
||||
check(4, A("hello").get())
|
||||
try:
|
||||
check(3, A(None).get())
|
||||
raise RuntimeError
|
||||
except ValueError:
|
||||
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
|
||||
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
|
||||
# references and pointers to different types, where pointers ought to be given a slightly higher precedence.
|
||||
pass
|
||||
|
||||
check(1, get(1))
|
||||
check(2, get(1.0))
|
||||
|
|
@ -71,3 +79,38 @@ try:
|
|||
except TypeError:
|
||||
pass
|
||||
|
||||
#### Class testing None ####
|
||||
|
||||
# No implicit conversion
|
||||
check(1, AA(1).get())
|
||||
check(2, AA(1.0).get())
|
||||
check(3, AA(B()).get())
|
||||
check(3, AA(None).get())
|
||||
check(4, AA("hello").get())
|
||||
check(5, AA(BB()).get())
|
||||
|
||||
check(1, get_AA_val(1))
|
||||
check(2, get_AA_val(1.0))
|
||||
check(3, get_AA_val(B()))
|
||||
check(3, get_AA_val(None))
|
||||
check(5, get_AA_val(BB()))
|
||||
|
||||
# Explicit constructor:
|
||||
try:
|
||||
check(4, get_AA_val("hello"))
|
||||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
check(1, get_AA_ref(1))
|
||||
check(2, get_AA_ref(1.0))
|
||||
check(3, get_AA_ref(B()))
|
||||
check(3, get_AA_ref(None))
|
||||
check(5, get_AA_ref(BB()))
|
||||
|
||||
# Explicit constructor:
|
||||
try:
|
||||
check(4, get_AA_ref("hello"))
|
||||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue