Commit Graph

172 Commits

Author SHA1 Message Date
Olly Betts 9ddc9dceb7 Remove support for $source and $target
These were officially deprecated in 2001, and attempts to use them have
resulted in a warning (including a pointer to what to update them to)
for most if not all of that time.

Fixes #1984
2021-04-30 10:20:14 +12:00
Olly Betts 0bf846f56f Eliminate unused Printf args 2021-04-13 10:43:51 +12: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 2392f6146a Remove variables which are set but never used 2021-03-31 04:39:18 +13:00
Olly Betts b840911410 Remove outdated FIXME/TODO from php.cxx
See #1529
2021-03-26 11:18:07 +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 251d25346d Fix OUTPUT Typemap not having return statement bug in PHP wrapper. 2017-06-28 09:47:33 +12:00
Olly Betts 9a0180c56c Merge pull request #970 from nihal95/master
Adds pragma version directive for php5 and php7.  Fixes #360.
2017-05-16 17:47:35 +12:00
William S Fulton ebd37155a8 Fix potential use of uninitialized variables in directors 2017-05-13 22:40:59 +01:00
Nihal eb9e72f3b2 Add new pragma to specify version to PHP5 and PHP7 extensions.
See issue #360, feature request to have version in php5 and php7 extensions.
2017-05-08 11:43:38 +05:30
Christophe Duvernois 4777a0ad3c #526 : propagate c++11 noexcept to director classes 2017-04-27 23:37:15 +02:00
Olly Betts 0aac18b2a1 [PHP] destroy_globals function is empty, so drop
We can just pass NULL instead.
2016-12-30 16:02:01 +13:00
Olly Betts 36ee653d3b Omit module functions when there's no code
MSHUTDOWN, RINIT, RSHUTDOWN and MINFO are often empty, so check and
omit them if this is the case, and set the module structure entry to
NULL instead.  Reduces code size, number of external functions on the
module, and runtime overhead a little (RINIT and RSHUTDOWN are called
on every request when used with a webserver).
2016-12-30 15:36:08 +13:00
Olly Betts cf60bb8895 [php7] Drop special code for PHP < 5.4 2016-12-30 14:56:53 +13:00
Olly Betts 4a2ede0820 [PHP7] Remove lingering generated ZTS code
ZTS is gone in PHP7 so these are dead code.
2016-12-30 12:41:19 +13:00
Olly Betts 2b4c1cdd5e Fix "set but not used" warning 2016-12-13 11:40:45 +13:00
Olly Betts 2aa2219f28 Fix reference example under PHP 7.1
PHP 7.1 no longer supports calling methods with fewer parameters
than declared, so we need to generate __construct() with default
values for all but the first parameter.
2016-12-06 11:01:55 +13:00
Olly Betts da1dd2ffd2 [PHP] Pick a default dtor which can't collide 2016-12-01 15:09:53 +13:00
Olly Betts 76a98b0b1a [PHP] Emit at most one copy of the default dtor
Can reduce the wrapper source size significantly, though at least
with recent GCC the stripped compiled size seems unchanged.
2016-12-01 14:21:29 +13:00
Olly Betts 659116a1b2 Fix memory leaks introduced by previous commit 2016-12-01 14:04:10 +13:00
Olly Betts 4993991d28 [PHP] Only emit one copy of each distinct arginfo
Previously we emitted a separate one for every wrapped function,
but typically many functions have the same number of parameters
and combinations of parameters passed by reference or not.

This change significantly reduces both the size of the generated
wrapper, and of the compiled PHP extension module (e.g. by ~6% for
the stripped extension module for Xapian's PHP7 bindings).
2016-12-01 13:05:41 +13:00
Olly Betts 75a00cd15e [PHP7] Make default C++ extension .cxx
This is SWIG's default for every language except PHP, and now is a
good time to make this change so that once we drop PHP5 support, we'll
have the same default everywhere.  It's easy to override the default
with -cppext cxx to get the PHP5 behaviour.
2016-11-30 13:27:13 +13:00
Olly Betts 1169874f59 [PHP] Add support for PHP7.
PHP5's C extension API has changed substantially so you need to use
-php7 to specify you want PHP7 compatible wrappers.
Fixes https://github.com/swig/swig/issues/571
2016-11-30 13:05:59 +13:00
Olly Betts 1adfe2f537 [PHP] Fix code generated for feature("director:except")
Previously the return value of call_user_function() was ignored and we
checked an uninitialised value instead.  Fixes #627.  Based on patch
from Sergey Seroshtan.
2016-09-25 14:42:04 +13:00
Olly Betts 26bbc96d58 Arrange to return after calling zend_throw_exception()
Fixes github issue#240.
2016-09-16 17:54:02 +12:00
William S Fulton ac495d5c66 Merge branch 'char-escaping'
* char-escaping:
  Add missing string_constant.i testcase
  changes file update for char wrappers
  C# char wrappers fixes for enum values, static const member char values and %csconst
  D testing added for %dmanifestconst and char constants
  Fix wrapping D constants using %dmanifestconst
  Php fix for enum value of '\0'
  Fix static const char member variables wrappers with %javaconst(1).
  Expand char testing in enums and %constant
  Java char changes file update
  Java enum and static member variable escaping fix for chars
  Add tests for enum values and static const member variables chars containing escape sequences
  Minor documentation tweak

Conflicts:
	CHANGES.current
2016-03-12 23:27:51 +00:00
William S Fulton 539aca58a5 Php fix for enum value of '\0' 2016-03-12 00:26:49 +00:00
William S Fulton 21ee09fc19 Multiple inheritance warning wording tweak 2016-03-06 10:45:39 +00:00
Petre Eftime 0a07cd4c30 Prevent redefinition warnings when compiling with SWIG<module> defined
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
2015-12-22 14:33:21 +02:00
William S Fulton 6a61f8271f Php fix for -Wmissing-field-initializers warning
Use ZEND_FE_END (introduced sometime around 5.2) to obtain the correct
number of arguments for zend_function_entry. Fallback to the original
3 argument initializer if not defined, however, this will not fix the
initializer warning though for some older versions of PHP.
2015-12-19 16:21:23 +00:00
William S Fulton edcdaaec16 Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
Nils Gladitz 925cec3a82 Add a space between literal and string macro
In C++11 a space between a literal and string macro is required.
2015-07-03 20:59:23 +01:00
Olly Betts 7ba0652677 Create director_common.swg for language-indep code
Move -DSWIG_DIRECTOR_STATIC handling there, so this is now supported for
all languages with director support, not just Python and PHP.
2015-03-12 19:51:11 +13:00
Olly Betts b3003f1f9f [PHP] When wrapping a returned resource as an object, check if all
cases wrap it in the same class, and if so eliminate the pointless
switch statement wrapper we previously generated.
2015-01-23 13:56:13 +13:00
Olly Betts 0dd685bad2 Fix PHP crash in director_finalizer 2015-01-14 15:38:55 +13:00
Olly Betts ea5be4e508 Fix PHP backend for default_args testcase 2015-01-14 10:44:54 +13:00