diff --git a/CHANGES.current b/CHANGES.current index 613c26851..dc328dd6b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -6,6 +6,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-10-09: olly + [PHP] Fix incorrect wrapper code generated when there's a + combination of overloading, parameters with a default value + and %newobject. Fixes https://sourceforge.net/p/swig/bugs/1350/ + 2017-10-09: olly Remove GCJ support. It isn't in a good state and doesn't seem to be used, and GCC7 dropped GCJ. Closes diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 2d177aa74..07937acfe 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -316,6 +316,7 @@ CPP_TEST_CASES += \ nested_template_base \ nested_workaround \ newobject1 \ + newobject3 \ null_pointer \ operator_overload \ operator_overload_break \ diff --git a/Examples/test-suite/newobject3.i b/Examples/test-suite/newobject3.i new file mode 100644 index 000000000..e408fade2 --- /dev/null +++ b/Examples/test-suite/newobject3.i @@ -0,0 +1,25 @@ +/** + * Regression test for PHP bug: https://sourceforge.net/p/swig/bugs/1350/ + */ + +%module newobject3 + +%newobject factory::create; +%inline %{ +class product {}; +class factory { +public: + product * create(short id, short type = 0); + product * create(const char * name, short type = 0); +}; +%} + +%{ +product * factory::create(short id, short type) { + return (id && type >= 0) ? new product : NULL; +} + +product * factory::create(const char * name, short type) { + return (name && type >= 0) ? new product : NULL; +} +%} diff --git a/Examples/test-suite/php/newobject3_runme.php b/Examples/test-suite/php/newobject3_runme.php new file mode 100644 index 000000000..a95b777d1 --- /dev/null +++ b/Examples/test-suite/php/newobject3_runme.php @@ -0,0 +1,18 @@ +create(7)); +check::classname("product", $factory->create(7, 6)); +check::classname("product", $factory->create("test")); +check::classname("product", $factory->create("test", 2)); + +check::isnull($factory->create(0), "create(0) should be NULL"); +check::isnull($factory->create(7, -1), "create(7, -1) should be NULL"); +check::isnull($factory->create(0, -1), "create(0, -1) should be NULL"); +check::isnull($factory->create("bad", -1), "create(\"bad\", -1) should be NULL"); + +?>