summaryrefslogtreecommitdiff
path: root/Lib/php
Commit message (Collapse)AuthorAgeFilesLines
* Initial support for std::string_viewOlly Betts2023-05-081-0/+69
| | | | | | | So far C#, Java, Lua and PHP are supported. Closes: #2540 See #1567
* [php] Add throws typemaps for string* + const string*Olly Betts2023-04-241-0/+5
|
* [php] Support INPUT,INOUT,OUTPUT for std::string&Olly Betts2023-04-211-9/+37
| | | | | | | By default SWIG/PHP wraps std::string& as a pass-by-reference PHP string parameter, but sometimes such a parameter is only for input or only for output, so add support for the named typemaps that other target languages support.
* Remove remaining traces of PHP7 supportOlly Betts2023-04-201-4/+2
| | | | | The bulk of this was already removed in e3b112c69ceed5c39cb07fa45a3ba62b27712679.
* [php] Remove unused exception.i includeOlly Betts2023-04-201-2/+0
|
* Make string& consistent in PHP's std_string.iOlly Betts2023-04-201-6/+6
|
* Remove support for PHP7Olly Betts2023-04-142-66/+3
| | | | | PHP7 security support ended 2022-11-28 so it doesn't make sense to include support for it in the SWIG 4.2.x release series.
* [php] Fix handling of multi-module casesOlly Betts2022-10-181-1/+1
| | | | | | | | | | | | | | | | Look up unknown base classes using SWIG_MangledTypeQueryModule(). Revert to using SWIG_TypeCheck() instead of SWIG_TypeCheckStruct() as the latter doesn't seem to work for this case (at least for PHP right now). Add mod_runme.php as a regression test for this. Adjust the PHP test harness not to set up reflection for the module unless it's actually needed for a testcase. Currently the approach to find the module name doesn't work for multi-module testcases. See #2126
* Cleanup SWIG_VERSION definitionWilliam S Fulton2022-10-131-2/+0
| | | | | | | | | | | | | Add Swig_obligatory_macros which must be called by each target language to define SWIG_VERSION correctly in the generated code, as well as the language specific macro SWIGXXX where XXX is the target language name. Drop the #ifdef SWIGXXX that was previously generated - I can't see the point of this and if users are defining this macro somehow, then users will need to change this Closes #1050
* Fix compile error when using directorsWilliam S Fulton2022-10-101-1/+1
| | | | | | | | Fix when using templates with more than one template parameter and used as an input parameter in a virtual method in a director class (problem affecting most of the scripting languages). Fixes #2160
* Sort out predefined SWIG-specific macrosOlly Betts2022-10-051-0/+2
| | | | | | | | | | | | | | | | | | | Ensure that SWIG_VERSION is defined both at SWIG-time and in the generated C/C++ wrapper code (it was only defined in the wrapper for some target languages previously). SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers to match behaviour for all other target languages. Stop defining SWIGVERSION in the wrapper. This only happened as a side-effect of how SWIG_VERSION was defined but was never documented and is redundant. The new testcase also checks that SWIG is defined at SWIG-time but not in the generated wrapper, and that exactly one of a list of target-language specific macros is defined. Fixes #1050
* [php] Fix testcase segfaults with PHP 8.0Olly Betts2022-09-291-0/+4
| | | | | | | | | | | | | | | | | | | | | | | These testcases were segfaulting: prefix director_using_member_scopes virtual_poly The fix here is admittedly a hack - we perform the initialisation of EG(class_table) from CG(class_table) which PHP will do, but hasn't yet. PHP doesn't seem to clearly document which API calls are actually valid in minit or other initialisation contexts, but the code we're generating works with all PHP 7.x and PHP 8.x versions aside from PHP 8.0 so it seems this is a bug in PHP 8.0 rather than that we're doing something invalid, and we need to work with existing PHP 8.0 releases so this hack seems a necessary evil. It will at least have a limited life as PHP 8.0 is only in active support until 2022-11-26, with security support ending a year later. Fixes #2383.
* [php] Workaround PHP 8.2 header problemOlly Betts2022-09-281-2/+0
| | | | | We need to include php.h before stdio.h (and probably before most other libc headers).
* Add missing typecheck typemaps for std::auto_ptr and std::unique_ptrWilliam S Fulton2022-09-172-0/+12
| | | | To fix overloading when using these types.
* Provide SWIGTYPE MOVE typemaps in swigmove.iWilliam S Fulton2022-09-161-0/+24
| | | | | | | | | | | | For implementing full move semantics when passing parameters by value. Based on SWIGTYPE && and std::unique_ptr typemaps which implement move semantics. Added for all languages, but untested for: Go, Ocaml, R, Scilab (and unlikely to be fully functional for same reasons as for std::unique_ptr support). Issue #999
* SWIGTYPE && input typemaps now assume object has been movedWilliam S Fulton2022-08-313-6/+23
| | | | | | | | | | | | | | | | | | | | Replicated Java implementation. Fully implemented for: - C# - D - Guile - Javascript (UTL) - Lua - MzScheme - Octave (UTL) - Perl (UTL) - PHP - Python (UTL) - Ruby (UTL) - Tcl (UTL) PHP std::auto_ptr std::unique_ptr minor tweaks and testcase corrections
* Cosmetic stray semi-colon removal after %typemap using quotesWilliam S Fulton2022-08-314-10/+10
|
* Add PHP support for std::unique_ptr and std::auto_ptrWilliam S Fulton2022-08-063-3/+83
| | | | Equivalent to Python/Ruby implementations.
* [php] Add parentheses around $value when castingOlly Betts2022-07-271-6/+6
| | | | | In some cases $value can be an expression without parentheses around it, and we want to cast the result of the whole expression.
* More move semantics improvementsWilliam S Fulton2022-07-041-1/+1
| | | | | More removal of casts in the out typemaps when copying objects to enable C++ compilers to possibly make use of move semantics.
* Performance optimisation for directors for classes passed by valueWilliam S Fulton2022-07-041-1/+1
| | | | | | | The directorin typemaps in the director methods now use std::move on the input parameter when copying the object from the stack to the heap prior to the callback into the target language, thereby taking advantage of move semantics if available.
* Movable and move-only types supported in "out" typemaps.William S Fulton2022-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enhance SWIGTYPE "out" typemaps to use std::move when copying objects, thereby making use of move semantics when wrapping a function returning by value if the returned type supports move semantics. Wrapping functions that return move only types 'by value' now work out the box without having to provide custom typemaps. The implementation removed all casts in the "out" typemaps to allow the compiler to appropriately choose calling a move constructor, where possible, otherwise a copy constructor. The implementation alsoand required modifying SwigValueWrapper to change a cast operator from: SwigValueWrapper::operator T&() const; to #if __cplusplus >=201103L SwigValueWrapper::operator T&&() const; #else SwigValueWrapper::operator T&() const; #endif This is not backwards compatible for C++11 and later when using the valuewrapper feature if a cast is explicitly being made in user supplied "out" typemaps. Suggested change in custom "out" typemaps for C++11 and later code: 1. Try remove the cast altogether to let the compiler use an appropriate implicit cast. 2. Change the cast, for example, from static_cast<X &> to static_cast<X &&>, using the __cplusplus macro if all versions of C++ need to be supported. Issue #999 Closes #1044 More about the commit: Added some missing "varout" typemaps for Ocaml which was falling back to use "out" typemaps as they were missing. Ruby std::set fix for SwigValueWrapper C++11 changes.
* [php] Eliminate sprintf to temp buffer to create ZVALOlly Betts2022-06-092-30/+10
| | | | | Use zend_strpprintf() which handles this more cleanly without risk of buffer overflow and without a fixed length limit.
* argcargv.i cosmetic updatesWilliam S Fulton2022-05-151-1/+1
|
* Typemaps for (int ARGC, char **ARGV) fixupWilliam S Fulton2022-05-151-4/+0
| | | | | The default typemap should not be in this library file - this is for users to add in if they want C default argument support.
* Fix argcargv.i in Perl5, Tcl, PHPErez Geva2022-05-111-0/+4
| | | | | | | Add missing type map for type check. Add testing of argcargv.i for Perl5, Tcl, PHP and Ruby. Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
* Add argcargv.i to more languages: Perl 5, Tcl, PHPErez Geva2022-05-061-0/+40
| | | | Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
* [PHP] Fix cleanup code handling issuesOlly Betts2022-02-172-5/+5
| | | | | | | Fix to call cleanup code in exception situations and not to invoke the freearg typemap twice in certain situations. Fixes https://sourceforge.net/p/swig/bugs/1211/
* Merge pull request #2197 from swig-fortran/rename-warnOlly Betts2022-02-101-3/+3
|\ | | | | Print rename warnings except anonymous template methods
| * Renames performed by `%namewarn` with `rename=` are printed in warning messageSeth R Johnson2022-02-061-3/+3
| | | | | | | | | | | | This is necessary for regex-like renames (where you can't use the #define trick as is done in many of the %keywordwarn directives). It's now unnecessary to print the "renaming to '`x`'" code explicitly by the kw.swg files.
* | Fix typosDimitris Apostolou2022-02-101-1/+1
|/
* Fix -Wstrict-prototypes warning in generated PHP wrappersOlly Betts2022-02-031-1/+1
|
* [php] Initialise zval in directorin typemapsOlly Betts2022-01-241-0/+2
| | | | | | | | | SWIG_SetPointerZval() requires the zval structure passed to be initialised (so it can handle the constructor case where the zval is already initialised as a PHP object. I couldn't think of a suitable regression test for this, but it fixes 2 issues detected by running director_basic under valgrind.
* [php] Fix director upcall checkOlly Betts2022-01-221-7/+2
| | | | | This resolves an issue uncovered by adding a _runme.php for testcase director_alternating.
* [php] Fix long long handling on 32 bit platformsOlly Betts2022-01-221-2/+2
| | | | | | | | The typemaps for long long and unsigned long long didn't handle a string input correctly, and long_long_runme.php had a flawed test in this case. Fixes #2155
* [php] Provide zend_class_implements_interface() for 7.xOlly Betts2022-01-211-6/+18
| | | | | | | | | It seems instanceof_function_ex() isn't a viable option for PHP 7.3 and earlier - the implementation is strangely wrong. So let's just provide a compatibility implementation which does what zend_class_implements_interface() does in 8.x and use that for all 7.x so there are fewer variants to worry about testing.
* [php] Fix minor version testOlly Betts2022-01-211-1/+1
|
* Fix unterminated comment in previous commitOlly Betts2022-01-211-1/+1
| | | | | I'm an idiot - I noticed I'd used a // comment after testing, but failed to retest after fixing that.
* [php] Fix zend_class_implements_interface() compatOlly Betts2022-01-211-1/+6
| | | | | | The sense of parameter 3 of instanceof_function_ex() appears to have changed in PHP 7.4 and we need to pass 0 for older versions and 1 for PHP 7.4. Words fail me.
* [php] Allow testing if an object is SWIG-wrappedOlly Betts2022-01-201-1/+18
| | | | | | | | | | | | | | | 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
* [php] Generate PHP type declarationsOlly Betts2022-01-207-94/+136
| | | | | We now automatically generate PHP type declarations for PHP >= 8.0. The generated code still compiles with PHP 7.x but without type declarations.
* [php] Use SWIG_TypeCheckStruct to check typesOlly Betts2021-12-191-37/+17
| | | | | | | We have the swig_type_info available and SWIG_TypeCheckStruct is more efficient because it uses a pointer comparison instead of the string comparison SWIG_TypeCheck uses (this change speeds up `make check-php-test-suite` by about 10%).
* [PHP] Add new PHP 8.1 keywordOlly Betts2021-12-181-0/+9
| | | | | | Add PHP keyword 'readonly' (added in 8.1) to the list SWIG knows to automatically rename. This keyword is special in that PHP allows it to be used as a function (or method) name.
* Improve naming of zend_class_entry structsOlly Betts2021-12-171-6/+6
| | | | | | | 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.
* Improve generated object handlersOlly Betts2021-12-171-0/+21
| | | | | | | | | | 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.
* Rename php_fetch_object with swig_ prefixOlly Betts2021-12-171-3/+3
| | | | | We shouldn't be using symbols starting `php` as that risks collisions with future symbols defined by PHP.
* Tweak source whitespace to match SWIG conventionsOlly Betts2021-12-151-0/+1
|
* [php] Remove redundant in typemap for boolOlly Betts2021-12-131-1/+0
| | | | | | This typemap which would wrap C++ bool as PHP int is later overridden by another which wraps it as PHP bool. The current result is what we want so just remove the redundant one.
* [php] Fix two incorrect PHP 8 conditionalsOlly Betts2021-12-081-1/+1
| | | | | | | | The correct macro to test is PHP_MAJOR_VERSION so these two PHP 8 cases weren't ever used, which hid that the PHP8 version of the code was broken in one of them. Highlighted in #2113.
* Replace remaining PHP errors with PHP exceptionsOlly Betts2021-05-264-11/+8
| | | | | | | | | | | | | | | | | | | | `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