Fix SF #3194294 - corner case bug when 'NULL' is used as the default value for a primitive type parameter in a method declaration.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12525 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b69b793d8e
commit
5f4d8c6112
5 changed files with 33 additions and 1 deletions
|
|
@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 2.0.3 (in progress)
|
||||
===========================
|
||||
|
||||
2011-03-09: wsfulton
|
||||
[Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value
|
||||
for a primitive type parameter in a method declaration.
|
||||
|
||||
2011-03-07: olly
|
||||
[PHP] Don't use zend_error_noreturn() for cases where the function
|
||||
returns void - now this issue can only matter if you have a function
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ CPP_TEST_CASES += \
|
|||
cpp_static \
|
||||
cpp_typedef \
|
||||
default_args \
|
||||
default_arg_values \
|
||||
default_constructor \
|
||||
defvalue_constructor \
|
||||
derived_byvalue \
|
||||
|
|
|
|||
10
Examples/test-suite/default_arg_values.i
Normal file
10
Examples/test-suite/default_arg_values.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module default_arg_values
|
||||
|
||||
%inline %{
|
||||
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; }
|
||||
};
|
||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||
%}
|
||||
17
Examples/test-suite/python/default_arg_values_runme.py
Normal file
17
Examples/test-suite/python/default_arg_values_runme.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from default_arg_values import *
|
||||
|
||||
d = Display()
|
||||
|
||||
if d.draw1() != 0:
|
||||
raise RuntimeError
|
||||
|
||||
if d.draw1(12) != 12:
|
||||
raise RuntimeError
|
||||
|
||||
p = createPtr(123);
|
||||
if d.draw2() != 0:
|
||||
raise RuntimeError
|
||||
|
||||
if d.draw2(p) != 123:
|
||||
raise RuntimeError
|
||||
|
||||
|
|
@ -1437,7 +1437,7 @@ public:
|
|||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("False");
|
||||
if (Strcmp(v, "NULL") == 0)
|
||||
return NewString("None");
|
||||
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue