summaryrefslogtreecommitdiff
path: root/Source/Modules/php.cxx
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* [php] Simplify creating overload dispatch nameOlly Betts2021-12-151-8/+2
|
* [php] Tidy up code which processes in typemapsOlly Betts2021-12-131-23/+21
| | | | | | The only functional change is that we now recover after WARN_TYPEMAP_IN_UNDEF better (or at least like most of the other SWIG backends do).
* Simplify PHP backend codeOlly Betts2021-12-131-13/+1
|
* Update PHP source commentOlly Betts2021-12-131-1/+1
| | | | We no longer wrap anything as a PHP resource.
* Remove unused code from PHP backendOlly Betts2021-12-131-47/+0
| | | | These are leftovers from the work on wrapping using only PHP's C API.
* [php] Remove unused variableOlly Betts2021-12-101-2/+1
| | | | | SWIG_module_entry hasn't actually been used for any of git history which is over 19 years.
* [php7] Use destructor action if presentOlly Betts2021-12-021-9/+26
| | | | | | | If there's a destructor, use its action instead of free(ptr) (for C)/delete ptr (for C++). Fixes #2108
* Replace remaining PHP errors with PHP exceptionsOlly Betts2021-05-261-52/+6
| | | | | | | | | | | | | | | | | | | | `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
* php: Throw exceptions instead of using errorsOlly Betts2021-05-251-8/+19
| | | | | | | | Parameter type errors and some other cases in SWIG-generated wrappers now throw a PHP exception, which is how PHP's native parameter handling deals with similar situations. See #2014, but not closing yet as there may be more cases to convert.
* Map known PHP interfaces to zend_class_entry*Olly Betts2021-05-251-19/+57
| | | | | | | | | | | Most pre-defined interfaces are accessible via zend_class_entry* variables declared in the PHP C API - we can use these to add an interface at MINIT time (rather than having to wait until RINIT to look up by name) by having a mapping from PHP interface name to them. This will also be a little faster than looking up by name. Closes #2013
* [php] Simplify naming of overloaded method wrappersOlly Betts2021-05-121-12/+2
| | | | | | The underlying wrapper function is now always named using ZEND_NAMED_FUNCTION even if it's a method (in PHP a function and a method only differ in how they're used).
* [php] Fix -prefix when there are subclassesOlly Betts2021-05-121-3/+3
| | | | | The calls to the parent class' magic __get, __set and __isset methods weren't getting the prefix.
* Clean up includes of PHP API headersOlly Betts2021-05-051-1/+0
| | | | | | | | Eliminate redundant and unused includes. Only include the minimum headers needed before the PHP_MAJOR_VERSION check in case future PHP versions remove some of the headers we include.
* Improve commentOlly Betts2021-05-051-1/+3
|
* Don't generate a .php wrapper file by defaultOlly Betts2021-05-041-18/+24
| | | | | | | | | | It's now only generated if something to put in it is specified via: %pragma(php) include=... or %pragma(php) code=...
* Fix segfault in exception class creationOlly Betts2021-05-041-49/+40
| | | | | We can't safely lookup the Exception class entry at MINIT time, but we can just use zend_ce_exception instead, which will be a bit faster too.
* Remove CG(active_class_entry) = NULL;Olly Betts2021-05-041-2/+0
| | | | | | | This has been in the code for a really long time, and doesn't seem to be required now. It's not documented by PHP as something we need to do, and the value seems to always be NULL at this point already.
* php: Stop using dl()Olly Betts2021-05-031-18/+21
| | | | | | | | With modern PHP it only works with the CLI version of PHP, so it's better to direct users to load the extension via "extension=" in php.ini. Suggested by ferdynator in #1529.
* Fix type in SWIG_DIRECTOR_CASTOlly Betts2021-05-031-1/+1
|
* Merge branch 'master' into gsoc2017-php7-classes-via-c-apiOlly Betts2021-05-031-2/+0
|\
| * Remove support for $source and $targetOlly Betts2021-04-301-13/+0
| | | | | | | | | | | | | | | | 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
* | Implement director-disown for PHPOlly Betts2021-05-031-7/+21
| |
* | Only emit custom free_obj handler if neededOlly Betts2021-04-221-12/+14
| | | | | | | | | | If has_destructor isn't set then the default zend_object_std_dtor does everything necessary.
* | Eliminate remaining use of $needNewFlowOlly Betts2021-04-221-1/+0
| |
* | Make PHP directors work more like other languagesOlly Betts2021-04-221-43/+13
| | | | | | | | | | | | A PHP exception now gets translated to a C++ exception to skips over C++ code to get back to PHP, avoiding the need to gate every directorout typemap on EG(exception).
* | Whitespace tweaksOlly Betts2021-04-221-3/+3
| |
* | Pass NULL instead of an empty zend_function_entryOlly Betts2021-04-211-5/+1
| |
* | Just call the internal class entry internal_ceOlly Betts2021-04-211-11/+11
| | | | | | | | | | It's just a local variable, so no need to carefully name it after the class.
* | Use PTR instead of zv for SWIG_remove() parameterOlly Betts2021-04-211-2/+2
| | | | | | | | The parameter is a general pointer, not necessarily a zval.
* | Eliminate SWIG_SetZval()Olly Betts2021-04-211-1/+0
| | | | | | | | | | $needNewFlow is now only used for a different hack in a directorout typemap.
* | Remove bogus zend_string_release() in magic methodsOlly Betts2021-04-211-3/+0
| | | | | | | | We shouldn't be freeing the property name here.
* | Eliminate unused code in generated __isset methodsOlly Betts2021-04-211-5/+2
| |
* | Use PHP objects instead of resources to wrap pointersOlly Betts2021-04-211-47/+69
| | | | | | | | Pointer to member is currently still wrapped as a resource.
* | Fix -prefix to prefix PHP class namesOlly Betts2021-04-201-15/+15
| |
* | Generate list of string compares for __isset()Olly Betts2021-04-191-9/+16
| | | | | | | | | | | | Previously we checked for a <varname>_get() method instead, but that will misfire for an method actually called foo_get() in the C++ API being wrapped.
* | Clean up code to generate magic property methodsOlly Betts2021-04-191-154/+137
| |
* | Remove variable which is set but never usedOlly Betts2021-04-191-5/+0
| |
* | Simplify magic property methodsOlly Betts2021-04-171-19/+9
| |
* | Simplify globalvariableHandler() furtherOlly Betts2021-04-171-26/+7
| |
* | Remove remnants of attempts to wrap to PHP global varsOlly Betts2021-04-171-66/+12
| | | | | | | | | | | | | | | | | | 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.
* | Drop support for long obsolete typemap varsOlly Betts2021-04-161-14/+0
| | | | | | | | | | | | | | 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.
* | Remove set but not used variableOlly Betts2021-04-161-2/+0
| |