From 08fa873638fc3d1a0169da8583ae492f765d3a5b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Jul 2015 18:27:43 +0200 Subject: [PATCH 1/2] Make callback unit test pass for PHP backend. Deprecated %callback(1) doesn't work with PHP, use "%s" to give the same name to the callback as to the C function explicitly instead. --- Examples/test-suite/callback.i | 10 +++++++++- Examples/test-suite/php/Makefile.in | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/callback.i index 8e28dad06..c92994898 100644 --- a/Examples/test-suite/callback.i +++ b/Examples/test-suite/callback.i @@ -1,10 +1,18 @@ %module callback +// Not specifying the callback name is only possible in Python. +#ifdef SWIGPYTHON %callback(1) foo; %callback(1) foof; %callback(1) A::bar; %callback(1) A::foom; -%callback("%s_Cb_Ptr") foo_T; // old style, still works. +#else +%callback("%s") foo; +%callback("%s") foof; +%callback("%s") A::bar; +%callback("%s") A::foom; +#endif +%callback("%s_Cb_Ptr") foo_T; // this works in Python too %inline %{ diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index c3f8af5cb..c365d01c3 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -10,6 +10,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ + callback \ php_iterator \ php_namewarn_rename \ From a4b319ce8eba4fe971235f611fd656148f6f3ed5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Jul 2015 16:08:05 +0200 Subject: [PATCH 2/2] Remove callback function from autodoc unit test. It doesn't seem to belong there at all, there is a dedicated callback unit test for it and it was added to the initial version of autodoc.i back in 124253d69828b4323f939bf118254ee96aefcdc7 without any explanation, so just remove it. As this callback was used in a PHP test, perform this test for callback.i now and use "%(uppercase)s" construct inside %callback to test that this works. --- Examples/test-suite/autodoc.i | 6 ------ Examples/test-suite/callback.i | 2 +- Examples/test-suite/php/autodoc_runme.php | 9 --------- Examples/test-suite/php/callback_runme.php | 9 +++++++++ 4 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 Examples/test-suite/php/autodoc_runme.php create mode 100644 Examples/test-suite/php/callback_runme.php diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index d85899756..07afa5794 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -114,12 +114,6 @@ } %} -%callback("%(uppercase)s_CALLBACK") func_cb; - -%inline { - int func_cb(int c, int d) { return c; } -} - // Bug 3310528 %feature("autodoc","1") banana; // names + types %inline %{ diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/callback.i index c92994898..4db63353b 100644 --- a/Examples/test-suite/callback.i +++ b/Examples/test-suite/callback.i @@ -12,7 +12,7 @@ %callback("%s") A::bar; %callback("%s") A::foom; #endif -%callback("%s_Cb_Ptr") foo_T; // this works in Python too +%callback("%(uppercase)s_Cb_Ptr") foo_T; // this works in Python too %inline %{ diff --git a/Examples/test-suite/php/autodoc_runme.php b/Examples/test-suite/php/autodoc_runme.php deleted file mode 100644 index f2e19d3cb..000000000 --- a/Examples/test-suite/php/autodoc_runme.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/Examples/test-suite/php/callback_runme.php b/Examples/test-suite/php/callback_runme.php new file mode 100644 index 000000000..392d5e598 --- /dev/null +++ b/Examples/test-suite/php/callback_runme.php @@ -0,0 +1,9 @@ + not a resource\n"); + +check::done(); +?>