In PHP 8.2 zend_operators.h contains inline code which triggers this
warning and our testsuite uses with option and -Werror.
I don't see a good way to only do this within our testsuite, but
disabling it globally like this shouldn't be problematic.
Under %feature("php:type", "compat") we don't generate return type
declaration for virtual methods if directors are enabled for that class.
However if a base class of the class has a method of the same name which
isn't directed this was still getting a return type declaration which
caused PHP to give an error when it tried to load the module.
Now we detect this situation and suppress the base class method's
return type declaration too.
Re-enable testcase director_redefined which now works again (it was
failing under PHP8 due to this issue).
See #2151
Encapsulate the code to generate arginfo in the PHPTypes class.
By itself this should result in no functional changes, but it's
a step towards being able to delay arginfo generation which I
think is necessary to address the incompatible overridden
method problem discussed in #2151.
If the same method name is implemented in a parent class then the
subclass can't have more required parameters than that or else we
get a compatibility error when the module is loaded.
The testsuite wasn't catching this problem because it was no longer
trying to load the modules for testcases without _runme.php, because
the mechanism to do that relied on there being a generated .php
wrapper, which we no longer have by default. Fix that to provide a
regression test for this fix.
See #2151
Otherwise can end up with a second PHP exception if the directorout
typemap doesn't accept PHP Null. `SWIG_fail` in this case results
in us returning to PHP which then propagates the pending exception.
This commit fixes a failure in smoketest.php in Xapian's PHP bindings,
but I've not managed to come up with a reproducer which works for
SWIG's testsuite.
I missed that this change breaks cpp_static, which seems to be to do
with handling the combined getter and setter we emit for static
member variables. Reverting while I figure out how to handle that.
This reverts commit a277748870.
Exit() is a wrapper for exit() by default, but SetExitHandler() allows
specifying a function to call instead.
This means that failures within DOH (e.g. Malloc() failing due to lack
of memory) will now perform cleanup such as removing output files.
This commit also cleans up exit statuses so SWIG should now reliably
exit with status 0 if the run was successful and status 1 if there was
an error (or a warning and -Werror was in effect).
Previously in some situations SWIG would try to exit with the status set
to the number of errors encountered, but that's problematic - for
example if there were 256 errors this would result in exit status 0 on
most platforms. Also some error statuses have special meanings e.g.
those defined by <sysexits.h>.
Also SWIG/Javascript tried to exit with status -1 in a few places (which
typically results in exit status 255).
Since the switch to wrapping classes using PHP's C API, we now
internally need to be able to tell if a PHP object is of or derived
from a class that is wrapped by SWIG so we know if we can offset the
zend_object pointer to get to the swig_object_wrapper. If we try to
do this to an object which isn't wrapped by SWIG then we invoke C/C++
undefined behaviour (and typically get a segmentation fault).
This check is implemented by having a SWIG\wrapped empty interface which
we make all SWIG-wrapped classes implement simply so we can test for it
to detect such classes.
Fixes#2125
Previously the zend_class_entry for Foo was named SWIGTYPE_Foo_ce, but
this can collide in some cases - e.g. if there's a class named p_Foo
then its zend_class entry will be SWIGTYPE_p_Foo_ce, but that's the same
as the swig_type_info for a class named p_Foo_ce.
Do more initialisation at module load time.
Use a shared set of handlers for cases when the C/C++ object is
destroyed with free().
Most of the code in the free_obj and create_object handlers is the
same for every wrapped class so factor that out into common functions.
`SWIG_ErrorCode()`, `SWIG_ErrorMsg()`, `SWIG_FAIL()` and `goto thrown;`
are no longer supported (these are really all internal implementation
details and none are documented aside from brief mentions in CHANGES
for the first three). I wasn't able to find any uses at least in FOSS
code via code search tools.
If you are using these:
Use `SWIG_PHP_Error(code,msg);` instead of `SWIG_ErrorCode(code);
SWIG_ErrorMsg(msg);` (which will throw a PHP exception in SWIG >= 4.1
and do the same as the individual calls in older SWIG).
`SWIG_FAIL();` and `goto thrown;` can typically be replaced with
`SWIG_fail;`. This will probably also work with older SWIG, but
please test with your wrappers if this is important to you.
Fixes#2014