Commit graph

335 commits

Author SHA1 Message Date
Olly Betts
a0174ea7fe php: Fix testcase li_boost_shared_ptr_bits 2021-04-04 18:58:24 +12:00
Olly Betts
40da8bcbb6 php: Wrap classes using only swig_object_wrapper
We no longer use PHP resources to wrap classes, and the proxy classes no
longer has a _cPtr property.
2021-04-04 07:45:20 +12:00
Olly Betts
0267ee374b Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-04-02 08:13:10 +13:00
Olly Betts
18bc3e287b php: Avoid double underscore in generated code
These are reserved by the C++ standard, but we were generating them
in the le_swig__... names.
2021-04-02 08:07:44 +13:00
Olly Betts
d2a0956766 Remove NULL check which can never be NULL
A pointer to a struct member can't be NULL!
2021-04-02 07:59:35 +13:00
Olly Betts
a1abc692d3 Eliminate per-class dtor function
These are all the same, and the NULL check performed is done inside
zend_objects_destroy_object() anyway, so we can just set the dtor
to zend_objects_destroy_object (which is what in-tree PHP extensions
do.)
2021-04-02 07:58:08 +13:00
Olly Betts
c467a66668 Remove debug code 2021-04-01 14:40:32 +13:00
Olly Betts
5838f10aa0 wrap fake class constants via C API 2021-04-01 14:40:32 +13:00
Olly Betts
43457690ac Eliminate another global variable 2021-03-31 11:10:34 +13:00
Olly Betts
46ef0eb9a1 Fix value of $source typemap parameter
This is only present for ancient compatibility so nothing actually
tests it works.
2021-03-31 10:57:34 +13:00
Olly Betts
3b1cc00566 Eliminate 3 List variables
Rather than building up lists of classes and details about them to
generate from at the end, just generate into a new String variable as we
go along.
2021-03-31 10:55:26 +13:00
Olly Betts
d24e09c57d Remove now-unused variables and code to set them 2021-03-31 05:02:13 +13:00
Olly Betts
904f5a65d8 Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-03-31 04:53:40 +13:00
Olly Betts
2392f6146a Remove variables which are set but never used 2021-03-31 04:39:18 +13:00
Olly Betts
c863ca8b1f Use zstring access macros
These are likely to be more future-proof than accessing struct members
directly.
2021-03-29 18:18:37 +13:00
Olly Betts
5156ad4f7b Remove unnecessary NULL check
SWIG_remove() calls either free() or delete, both of which handle
a NULL pointer.
2021-03-29 17:45:03 +13:00
Olly Betts
979d48b0b4 Remove obsolete FIXME
We no longer have the PHP code wrappers.
2021-03-29 17:41:01 +13:00
Olly Betts
3f1286ba4f Use standard SWIG overload dispatch
Instead of having a slightly modified PHP-specific variant of
Swig_overload_dispatch we now advance the ParmList over the this
pointer.
2021-03-29 17:41:01 +13:00
Olly Betts
7142acbf93 Fix whitespace oddities 2021-03-29 17:29:59 +13:00
Olly Betts
0e7d6a4c8d More PHP8 compatibility fixes 2021-03-29 09:37:44 +13:00
Olly Betts
73a149200f Remove more code which is no longer used 2021-03-28 19:47:16 +13:00
Olly Betts
1c5573d0d0 Remove code which is no longer used 2021-03-28 08:54:24 +13:00
Olly Betts
c58149bc45 Simplify printing code a little
Remove unused Printf parameter, and use Printv where it's more readable.
2021-03-27 19:59:30 +13:00
Olly Betts
dfa5353f27 Eliminate extras hash table
This was used to store custom properties, but we can just ask the PHP
object to store them like it normally would, after checking for our
custom pseudo-properties.
2021-03-27 19:57:37 +13:00
Olly Betts
799cb68a8a Use ZEND_THIS instead of getThis()
getThis(z) checks that z is a PHP object and returns ZEND_THIS if it
is, and NULL otherwise.  In all our uses we know that z is a PHP object
(and we'd try to dereference NULL if it were returned!)
2021-03-27 19:51:24 +13:00
Olly Betts
232308b494 Drop unnecessary casts to swig_object_wrapper* 2021-03-27 19:49:49 +13:00
Olly Betts
c03679acef Improve how we allocate swig_object_wrapper
Use zend_object_alloc() and put the zend_object member last so that
Zend can put object properties after it.
2021-03-26 17:15:34 +13:00
Olly Betts
4aff93942a Improve arginfo generation
Fixes some failing examples and testcases.
2021-03-26 15:34:29 +13:00
Olly Betts
f77113ea71 php: Eliminate SWIG_ZEND_NAMED_FE
It existed to work around const-correctness issues in older versions of
PHP's C API.  It's conceivable user code might be using it, but unlikely
and the switch to creating classes via the API is a natural time for a
compatibility break.
2021-03-26 13:58:02 +13:00
Olly Betts
2ba0f82720 Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-03-26 12:00:59 +13:00
Olly Betts
b840911410 Remove outdated FIXME/TODO from php.cxx
See #1529
2021-03-26 11:18:07 +13:00
Olly Betts
8ded9d8dae Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-03-25 17:45:17 +13:00
Olly Betts
d15fe23c5f Merge branch 'gsoc2017-php7-classes-via-c-api' of https://github.com/nihal95/swig into gsoc2017-php7-classes-via-c-api 2021-03-25 16:25:33 +13:00
Olly Betts
786efd0ae0 Eliminate irrelevant formatting differences from master 2021-03-24 11:59:25 +13:00
Olly Betts
3584c7d49c Add initial support for PHP8
Testcase director_overload2 is failing, but the rest of the testsuite
passes.
2021-03-19 19:30:27 +13:00
Olly Betts
2e7da86b2c php: Fix overloaded directed methods with non-void return
We were treating  such methods like constructors and assigning to the
internal _cPtr, which just seems bizarrely wrong.

Fixes #1900
2021-03-18 10:58:44 +13:00
William S Fulton
2cf075558c Replace all exit() with SWIG_exit()
For consistent cleanup on error
2019-07-31 00:08:49 +01:00
Frederik Schubert
b3a3c4f09e Don't add a closing php-tag
This PR removes the closing `?>` PHP tag from generated files. [PSR-2](https://www.php-fig.org/psr/psr-2/) states:

> The closing `?>` tag MUST be omitted from files containing only PHP.

A problem might occur if files with any character after the closing tag are used with `include` or `require`. It might trigger an output and disallow HTTP header manipulation. See the popular [_headers already sent_](https://stackoverflow.com/a/8028987/1847340) debate on SO.
2019-05-22 11:35:08 +12:00
Olly Betts
950473d77e [php] Whitespace improvements in generated C/C++ code 2019-02-12 10:14:25 +13:00
Olly Betts
123eabf200 [PHP] Wrap renamed constructor as static method
Previously it was wrapped as a non-static method, which results in
a diagnostic from PHP if called as a static method.
2019-02-09 12:51:45 +13:00
Olly Betts
3f9ebb31b9 [PHP] Don't generate code referencing undefined $r
This could happen in overloaded methods which returned void and took at
least one const std::string& parameter.
2019-02-08 18:09:52 +13:00
William S Fulton
df86ec5af6 Consistent use of target language version of options
If a version number is supported by the target language prefer to show it in the -help.
For example, -perl5 instead of -perl.
2019-02-05 19:18:46 +00:00
William S Fulton
29d30bd319 Consistent implementation for disabled languages
The deprecated php4 and php5 use the new Disabled language handling
recently implemented for a consistent implementation
2019-02-05 19:04:59 +00:00
Olly Betts
d7ac8581b1 [php] Drop support for long-deprecated %pragma(php4)
Finally removed support for %pragma(php4) which was deprecated back in
2008.  The replacement is %pragma(php), which has been supported since
at least 2005.
2018-06-07 18:09:14 +12:00
Olly Betts
d6d5db122b Remove support for PHP5
PHP5 is no longer actively supported by the PHP developers and security
support for it ends completely at the end of 2018, so it doesn't make
sense to include support for it in the upcoming SWIG 4.0.0 release.

See #701.
2018-06-07 18:09:03 +12:00
Olly Betts
224bb9e023 [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals
This should make the generated code work with PHP 7.2.0.
2017-12-08 15:50:14 +13:00
William S Fulton
ae044c1c2f Generation of director method declarations fixes
- Fixes generation of director method declarations containing C++11 ref-qualifiers.
- Fixes generation of director method declarations returning more complex types such
  as const ref pointers.
- Rewrite Swig_method_call to use more up to date code in the core.
2017-10-23 18:55:14 +01:00
William S Fulton
3f8b8fe734 Enhancements for directorin typemaps
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }

The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
2017-10-16 19:28:27 +01:00
Olly Betts
0c56d0cb72 [PHP] Fix incorrect wrapper code generation
Fix 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 10:40:27 +13:00
Nihal
6c3f5155b2 Refactor declarations inside if-else block.
- This is to support C90
2017-09-23 12:13:20 +05:30