Commit graph

22,131 commits

Author SHA1 Message Date
Olly Betts
84559bc441 Clean up code to generate magic property methods 2021-04-19 15:12:42 +12:00
Olly Betts
dbfe84651f [ci] Try -std=c++11 instead of -std=gnu++11 2021-04-19 14:25:03 +12:00
Olly Betts
8f0f2159d1 [ci] Set CPPSTD=c++11 for PHP
Otherwise SWIG defaults to forcing -std=c++98.
2021-04-19 13:43:35 +12:00
Olly Betts
d6f9f4b6c0 Make examples fail on any PHP diagnostic
Previously we called set_error_handler() in tests.php to do this, but
that only sets it for the test-suite.  Now we set it in on the PHP
command line, which works for both.
2021-04-19 13:40:46 +12:00
Olly Betts
e22dd47ff5 [ci] Run PHP tests on bionic
Seems the compiler in xenial doesn't support C++11 by default.
2021-04-19 12:05:18 +12:00
Olly Betts
3aa8b56a9a [ci] Fix edit mistake in previous commit 2021-04-19 11:55:00 +12:00
Olly Betts
3f7aed1a17 [ci] Specify --enable-cpp11-testing directly
Specifying CPP11=1 also passes -std=c++11 to the compiler, which is
really unhelpful here as that disables all GNU extensions which breaks
the PHP C API headers.
2021-04-19 11:41:42 +12:00
Olly Betts
ed86e68fe1 Remove variable which is set but never used 2021-04-19 11:37:21 +12:00
Olly Betts
09d06843d1 Fix PHP sync example
Mostly it was missing `%include <std_string.i>`
2021-04-19 11:26:32 +12:00
Olly Betts
a49cc60772 Adjust PHP sync example
Make it work with how globals are actually wrapped.  It looks like
this example has never been right, but nobody noticed before PHP 8
started warning about the use of unset variables.

This reveals that handling of std::string properties needs fixing.
2021-04-18 10:00:34 +12:00
Olly Betts
3b63ef27fe [ci] Enable --enable-cpp11-testing for PHP 2021-04-18 08:15:55 +12:00
Olly Betts
f8c7dbb676 [ci] Reduce appveyor to one MSVC Python build
Building once with a different compiler on a different platform is
useful, but running multiple builds for languages I'm not working
on is a waste of donated CPU time, and having CI reported as failing
because the Python builds on cygwin aren't currently working is
downright unhelpful.
2021-04-18 08:07:20 +12:00
Olly Betts
0a437cddcc Simplify magic property methods 2021-04-17 19:01:32 +12:00
Olly Betts
db358d1e42 Expand li_std_string_runme.php
Re-enable a disabled check and implement more checks based on those
in perl5/li_std_string_runme.pl.
2021-04-17 18:53:50 +12:00
Olly Betts
e76308be92 Simplify globalvariableHandler() further 2021-04-17 07:39:41 +12:00
Olly Betts
3e4b7b3368 Drop special case for PHP in allowexcept.i
Now the varinit typemaps are gone we no longer take the address of
the variable in the generated code.
2021-04-17 07:38:23 +12:00
Olly Betts
14edc26c8d Add PHP run test for global_vars 2021-04-17 06:11:49 +12:00
Olly Betts
2629764e3f Remove remnants of attempts to wrap to PHP global vars
This isn't really workable since PHP doesn't support intercepting
accesses to global variables (nor to static class properties, so
we can't wrap C/C++ global variables that way either).

The _get() and _set() function wrappers actually work and have
been generated for a very long time.
2021-04-17 05:59:18 +12:00
Olly Betts
a51a5c77f2 Modernise checks for PHP NULL and resources 2021-04-17 05:36:13 +12:00
Olly Betts
12bcd36923 Filter less in check::functions()
Stop filtering /^new_/ - we no longer generate these for classes, so
only the li_carrays and li_carrays_cpp testcases generate new_* flat
functions, and it's helpful to check those are generated.

Stop filtering /_(alter|get)_newobject$/' - we no longer generate
these, as they weren't used or documented.
2021-04-17 04:14:33 +12:00
Olly Betts
7ccf3b81df Drop support for long obsolete typemap vars
These were deprecated nearly 20 years ago and attempts to use them
have generated a deprecation warning for most of that time.

Addresses #1984 for PHP.
2021-04-16 16:33:51 +12:00
Olly Betts
4eb666d648 Remove set but not used variable 2021-04-16 16:33:25 +12:00
Olly Betts
54a879d2cc Remove unused typemap variable $classFlag 2021-04-16 15:52:21 +12:00
Olly Betts
dcdaaba7ba Eliminate $zend_obj typemap variable
We can just get the zend_class_entry from the swig_type_info when
we need it.
2021-04-16 13:13:24 +12:00
Olly Betts
c4ff1ed7cb Remove <module>_{alter,get}_newobject functions
These were added as part of the changes to add director support for
PHP, but have never actually been used by anything SWIG generates,
and they aren't documented so shouldn't be used externally.

Removing these exposed a bug in the arginfo generation where we emitted
a ZEND_ARG_INFO for a varargs "parameter", which this commit also fixes.
2021-04-16 09:42:27 +12:00
Olly Betts
97733543e2 Fix directorout typemap for const TYPE &
Previous we were returning a pointer or reference to a local
variable.
2021-04-15 12:50:32 +12:00
Olly Betts
451998f27b Fix in typemap for void** and void*&
Mark the parameter as "byref" and write back through the reference
after the call.

Adjust testcase argout to uncomment the part that's meant to test this,
and to remove lingering traces of PHP's old call-time pass-by-reference
(which was completely removed before PHP 7).

Fixes #1457
2021-04-14 17:05:19 +12:00
Olly Betts
a80dad0369 Revert to call_user_function() for PHP 7
zend_call_known_instance_method() was new in PHP 8.0.
2021-04-14 17:01:43 +12:00
Olly Betts
5bd38004c9 Fix calling of protected director methods
Use zend_call_known_instance_method() instead of call_user_function(),
since this way PHP seems to know that context of the call is from within
the same object.

Fixes testcases director_nested and director_protected which were giving
errors for PHP 8 and warnings for PHP 7.
2021-04-14 16:14:10 +12:00
Olly Betts
b430832a08 Restore checks for flat functions in php testcases 2021-04-14 12:44:48 +12:00
Olly Betts
8cb0c185ac Restore checks for globals in php testcases 2021-04-14 11:15:43 +12:00
Olly Betts
50f92dca08 Mark wrapped abstract classes
This allows restoring reflection checks in testcase director_abstract.
2021-04-14 10:59:12 +12:00
Olly Betts
40906ae856 Reenable check::classes() and check::classmethods() 2021-04-14 10:05:20 +12:00
Olly Betts
836258b9d3 Fix some cases of converting PHP NULL to C++ NULL
Fixes testcase overload_null for PHP 8.0
2021-04-13 16:53:52 +12:00
Olly Betts
37f575b7b4 Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-04-13 15:15:09 +12:00
Olly Betts
3912c572ff php: Make typemap formatting more consistent 2021-04-13 14:50:33 +12:00
Olly Betts
2da0127f5f php: Merge two identical typemaps 2021-04-13 14:47:06 +12:00
Olly Betts
623dd7a394 Eliminate CALL_METHOD and CALL_METHOD_PARAM_1 macros
These names lack a "SWIG_" prefix to help prevent collisions with code
being wrapped, but they're each only used in one place so just inline
them there.
2021-04-13 14:42:33 +12:00
Olly Betts
3b43a7bf9b Refactor to eliminate SWIG_ConvertResourcePtr() 2021-04-13 13:22:03 +12:00
Olly Betts
a216f6ca3c Stop generating unused Zend resource destructors
These aren't used since we stopped using PHP resources to wrap classes.
2021-04-13 13:13:24 +12:00
Olly Betts
09b968474d Removed unused #define-s in generated code 2021-04-13 12:43:02 +12:00
Olly Betts
d2542eadf6 Remove redundant cast 2021-04-13 11:16:59 +12:00
Olly Betts
0bf846f56f Eliminate unused Printf args 2021-04-13 10:43:51 +12:00
Olly Betts
762a309373 Fix typemap formatting incosistencies 2021-04-13 10:31:22 +12:00
Olly Betts
0a72bfc630 Eliminate tempPointer variable 2021-04-13 10:18:47 +12:00
Olly Betts
93a288c85a Fix memory leak in SWIG tool 2021-04-13 10:14:29 +12:00
Olly Betts
60e7deda2c Eliminate non-standard $lower_param typemap variable 2021-04-13 10:03:03 +12:00
Olly Betts
d2eb06fbc0 Merge 2 functionally identical typemaps
The only difference is code formatting.
2021-04-13 09:53:14 +12:00
Olly Betts
5161acdd24 Eliminate direct reference to c_result in typemap
Typemaps should use $result.
2021-04-13 09:07:31 +12:00
Olly Betts
9987d7168a Implement type-checking of wrapped objects
The testsuite now all passes (with PHP 7.4 at least)
2021-04-12 17:29:39 +12:00