summaryrefslogtreecommitdiff
path: root/Source/Modules/php.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Parse storage class more flexiblyOlly Betts2023-05-111-7/+7
| | | | | | | | | | | | | | Previously we had a hard-coded list of allowed combinations in the grammar, but this suffers from combinatorial explosion, and results in a vague `Syntax error in input` error for invalid (and missing) combinations. This means we now support a number of cases which are valid C++ but weren't supported. Fixes #302 Fixes #2079 (friend constexpr) Fixes #2474 (virtual explicit)
* Removed unused default parameter valueOlly Betts2023-05-081-1/+1
|
* [PHP] Wrap method with both static and non-static overloadsOlly Betts2023-05-081-1/+18
| | | | | | | | | | | We now wrap this as a non-static method in PHP, which means the static form only callable via an object. Previously this case could end up wrapped as static or non-static in PHP. If it was wrapped as static, attempting to call non-static overloaded forms would crash with a segmentation fault. See #2544
* Remove remaining traces of PHP7 supportOlly Betts2023-04-201-13/+1
| | | | | The bulk of this was already removed in e3b112c69ceed5c39cb07fa45a3ba62b27712679.
* Remove support for PHP7Olly Betts2023-04-141-2/+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.
* Visual C++ warning fixesWilliam S Fulton2022-10-241-2/+2
|
* [php] Fix handling of multi-module casesOlly Betts2022-10-181-2/+7
| | | | | | | | | | | | | | | | 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-6/+6
| | | | | | | | | | | | | 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
* Use https for swig.org linksOlly Betts2022-10-061-1/+1
|
* [php] Fix emitted PHP type declarations in corner casesphp-type-declaration-fixesOlly Betts2022-10-041-83/+215
| | | | See #2151
* Prefer !Equal() to Cmp() != 0Olly Betts2022-10-031-5/+5
|
* [php] Add php:allowdynamicproperties featureOlly Betts2022-09-291-4/+13
| | | | | | | This follows PHP 8.2 deprecating dynamic features. The new feature also provides a clean way to fix the remaining PHP test case failure under PHP 8.2.
* [php] Suppress -Wdeclaration-after-statement in php.hOlly Betts2022-09-291-3/+22
| | | | | | | | 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.
* [php] Workaround PHP 8.2 header problemOlly Betts2022-09-281-0/+8
| | | | | We need to include php.h before stdio.h (and probably before most other libc headers).
* [php] Adapt swig_ptr_cast_object for PHP 8.2Olly Betts2022-09-281-0/+2
| | | | | The required return type has changed from int to an enum, which gives a compiler warning when we assign a function pointer.
* [php] Fix handling of friend functionsOlly Betts2022-07-291-6/+14
| | | | | We were incorrectly considering them as methods of the class they are a friend of for the purposes of calculate PHP type declarations.
* [php] Omit incompatible return type declaractionOlly Betts2022-07-131-10/+23
| | | | | | | | | | | | | | | | 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
* [php] Emit arginfo after all the codeOlly Betts2022-07-131-79/+115
| | | | | Another step in preparation for a fix for the incompatible overridden method problem discussed in #2151.
* php: Move ME and FE generation back out of PHPTypesOlly Betts2022-07-111-28/+29
| | | | | It's more natural to leave it where it was, and will work better when we delay the arginfo generation.
* php: Encapsulate arginfo generationOlly Betts2022-07-111-144/+147
| | | | | | | | 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.
* [php] Stop setting unused php:proxy attributeOlly Betts2022-07-111-5/+0
| | | | This is no longer used since we changed how classes are wrapped.
* Remove set but not used variablesOlly Betts2022-06-301-7/+0
| | | | | | Highlighted by clang-15 warnings such as: warning: variable 'index' set but not used [-Wunused-but-set-variable]
* [php] Adjust #required params for subclass methodsOlly Betts2022-06-141-4/+18
| | | | | | | | | | | | | | 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
* [php] Fix missing parameter type declarationsOlly Betts2022-06-121-28/+13
| | | | | | | In some cases of overloaded functions the parameter type information was missing for some or all parameters. See #2151
* [php] Skip directorout typemap if PHP exception pendingOlly Betts2022-06-101-4/+8
| | | | | | | | | | 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.
* Fix PHP parameter type declarations compatibilityOlly Betts2022-06-101-35/+78
| | | | | | | Ensure PHP parameter type declarations are compatible with those for the same method in any classes we inherit from. See #2151
* Revert "Fix PHP parameter type declarations compatibility"Olly Betts2022-06-091-77/+34
| | | | | | | | 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 a277748870199ccdc63b852369fcd07625bf0c20.
* Fix PHP parameter type declarations compatibilityOlly Betts2022-06-091-34/+77
| | | | | | | Ensure PHP parameter type declarations are compatible with those for the same method in any classes we inherit from. See #2151
* Rename zend_types to be clearerOlly Betts2022-06-091-8/+8
| | | | It's actually tracking pointer types which aren't wrapped as classes.
* [php] Eliminate sprintf to temp buffer to create ZVALOlly Betts2022-06-091-3/+1
| | | | | Use zend_strpprintf() which handles this more cleanly without risk of buffer overflow and without a fixed length limit.
* WIP: Refactor pararent class trackingOlly Betts2022-06-081-11/+14
|
* Header file tidyupWilliam S Fulton2022-05-071-1/+0
| | | | | Fix Visual C++ warning in scilab.cxx: warning C4996: 'strtok': This function or variable may be unsafe.
* Add DOH Exit() and SetExitHandler()Olly Betts2022-03-061-4/+4
| | | | | | | | | | | | | | | | | | | | | 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).
* [PHP] Fix cleanup code handling issuesOlly Betts2022-02-171-3/+6
| | | | | | | 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/
* [php] Make zend_function_entry arrays constOlly Betts2022-01-241-3/+3
|
* [php] Fix director upcall checkOlly Betts2022-01-221-4/+5
| | | | | This resolves an issue uncovered by adding a _runme.php for testcase director_alternating.
* [php] Make internal function wrappers staticOlly Betts2022-01-221-9/+9
|
* [php] Add type declarations for optional params tooOlly Betts2022-01-211-0/+4
| | | | See #2151
* [php] Actually generate parameter type declarationsOlly Betts2022-01-211-1/+1
|
* [php] Use -prefix setting in type declarationsOlly Betts2022-01-211-0/+1
|
* [php] Allow testing if an object is SWIG-wrappedOlly Betts2022-01-201-0/+13
| | | | | | | | | | | | | | | 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-201-91/+309
| | | | | We now automatically generate PHP type declarations for PHP >= 8.0. The generated code still compiles with PHP 7.x but without type declarations.
* Remove unused Printf parametersphp-codegen-improvementsOlly Betts2021-12-181-2/+2
|
* Make some generated variables staticOlly Betts2021-12-171-2/+2
|
* Improve naming of zend_class_entry structsOlly Betts2021-12-171-28/+29
| | | | | | | 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.
* Fix source code comment typoOlly Betts2021-12-171-1/+1
|
* Improve generated object handlersOlly Betts2021-12-171-69/+74
| | | | | | | | | | 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.
* Make some generated functions staticOlly Betts2021-12-171-4/+4
|
* Rename php_fetch_object with swig_ prefixOlly Betts2021-12-171-2/+2
| | | | | 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-69/+67
|