Commit graph

5,438 commits

Author SHA1 Message Date
Olly Betts
5da86a1413 Make some generated functions static 2021-12-17 09:38:44 +13:00
Olly Betts
6253583809 Rename php_fetch_object with swig_ prefix
We shouldn't be using symbols starting `php` as that risks collisions
with future symbols defined by PHP.
2021-12-17 09:37:00 +13:00
Olly Betts
9ffa15b307 Tweak source whitespace to match SWIG conventions 2021-12-15 19:40:06 +13:00
Olly Betts
6ef820acf9 [php] Simplify creating overload dispatch name 2021-12-15 19:30:17 +13:00
Olly Betts
98b8578731 [php] Tidy up code which processes in typemaps
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).
2021-12-13 16:02:12 +13:00
Olly Betts
4c7febfb80 Make DOH Char macro more robust
For example, `Char(foo)[0]` now works to get the first character
of DOH String `foo`.

Previously this gave a confusing error because it expanded to
`(char *) Data(foo)[0]` and the `[0]` binds more tightly
than the `(char *)`.
2021-12-13 09:33:26 +13:00
Olly Betts
48bb7e0e95 Simplify PHP backend code 2021-12-13 09:27:58 +13:00
Olly Betts
7d70402306 Update PHP source comment
We no longer wrap anything as a PHP resource.
2021-12-13 09:27:58 +13:00
Olly Betts
bf68b377e6 Remove unused code from PHP backend
These are leftovers from the work on wrapping using only PHP's C API.
2021-12-13 09:27:58 +13:00
Olly Betts
4467c94fe9 Fix removeNode() to really unset previousSibling
There was a typo in attribute name so we attempted to remove the
non-existent attribute prevSibling instead.
2021-12-10 18:34:21 +13:00
Olly Betts
fd013c344a [php] Remove unused variable
SWIG_module_entry hasn't actually been used for any of git history
which is over 19 years.
2021-12-10 17:10:35 +13:00
William S Fulton
be51cb6a6e Merge branch 'fix-crash-2101'
* fix-crash-2101:
  Added extern "C" block that was removed in previous commit.
  Fixed crashes when using embedded Python interpreters.
2021-12-02 09:01:18 +00:00
Olly Betts
c25df74807 [php7] Use destructor action if present
If there's a destructor, use its action instead of free(ptr)
(for C)/delete ptr (for C++).

Fixes #2108
2021-12-02 19:15:34 +13:00
John Senneker
ebe14e6e2a Fixed crashes when using embedded Python interpreters.
Fixes #2101. There are 3 related changes made here:
1. Move the SWIG_globals() singleton into pyrun from pyint so it
   is visible to SWIG_Python_DestroyModule(). The static globals
   varlink has been extracted out of the function so that it can
   be set to NULL in SWIG_Python_DestroyModule(), which fixes the
   issue described in #2101. (Now when the second interpreter
   starts up, the Swig_Globals_global pointer will be NULL, so it
   knows it has to create a new one.)
2. Remove a Py_DECREF on the globals varlink. The decrement is now
   performed by DestroyModule(), so there's no need to do it in
   SWIG_init().
3. Fixed similar issue with SWIG_Python_TypeCache().
2021-11-30 16:13:17 -05:00
Dimitris Apostolou
f586d920f7
Fix typos 2021-11-17 07:07:02 +02:00
William S Fulton
1c34be2d24 Fix nspace warning message 2021-11-11 18:59:25 +00:00
Vadim Zeitlin
26bf86322b Use SWIG-specific for non-overloaded synthesized functions too
This avoids conflicts between such functions, which are generated when
using %extend to add static methods to an existing class, and the actual
wrapper functions generated by the backend.

This shouldn't result in any user-visible changes.
2021-11-09 23:35:30 +01:00
Vadim Zeitlin
119222be77 Refactor code in Language::staticmemberfunctionHandler()
No real changes, just move the test for "code" to the outer scope to
facilitate the upcoming changes.

This commit is best viewed ignoring whitespace-only changes.
2021-11-09 23:35:28 +01:00
Olly Betts
561a1d843d Fix ODR violations
Detected by compiling with GCC flags `-flto -Wodr`.
2021-09-20 15:04:51 +12:00
Ian Lance Taylor
45ebd33698 swig -go: improve _cgo_panic implementation 2021-09-16 10:29:48 -07:00
Ian Lance Taylor
6ca5d5d722 swig -go: don't use crosscall2 for panicking
Instead rely only on documented and exported interfaces.
2021-09-15 17:56:01 -07:00
Ian Lance Taylor
4461c443cf remove Go -no-cgo option
It only worked for Go versions before 1.5, which is more than five
years ago and long-unsupported.
2021-09-14 13:59:21 -07:00
Lindley French
112f9d59ea Also expose in proxyClassFunctionHandler 2021-06-24 15:49:49 -07:00
Lindley French
46ec93785a Expose to javaout typemaps. 2021-06-23 00:00:37 -07:00
Olly Betts
17a294cec4 Replace remaining PHP errors with PHP exceptions
`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
2021-05-26 09:39:43 +12:00
Olly Betts
cdc69f9843 php: Throw exceptions instead of using errors
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.
2021-05-25 16:42:12 +12:00
Olly Betts
3c168ef332 Map known PHP interfaces to zend_class_entry*
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
2021-05-25 16:28:44 +12:00
Olly Betts
02ae5168d7 Remove details of long-removed directories
These were removed a decade or two ago!
2021-05-16 08:42:39 +12:00
Olly Betts
a54d62b22e [UFFI] Remove code for Common Lisp UFFI
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
b7a99f22f5 [S-EXP] Remove code for Common Lisp S-Exp
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
11bb422bd3 [Pike] Remove code for Pike
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
12f3a85916 [Modula3] Remove code for Modula3
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
f3ba54c3bb [CLISP] Remove code for GNU Common Lisp
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
5f38f9cc78 [Chicken] Remove code for Chicken
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
3f78ea64c0 Remove bogus reference to allegrocl:old-sym:name
It'll never be set under -cffi.  Looking at the history it looks like
this is just a remnant from this file being originally created by
copying allegrocl.cxx.
2021-05-13 10:41:01 +12:00
Olly Betts
353baebfcf [Allegrocl] Remove code for Allegro Common Lisp
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-13 10:38:40 +12:00
Olly Betts
8dadbcc744 [php] Simplify naming of overloaded method wrappers
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).
2021-05-12 15:05:09 +12:00
Olly Betts
ead90be779 [php] Fix -prefix when there are subclasses
The calls to the parent class' magic __get, __set and __isset methods
weren't getting the prefix.
2021-05-12 15:04:31 +12:00
Olly Betts
20fd344e86 Fix comment typo 2021-05-05 16:01:51 +12:00
Olly Betts
228b04974d Clean up includes of PHP API headers
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.
2021-05-05 10:58:07 +12:00
Olly Betts
e59d34481d Improve comment 2021-05-05 10:34:20 +12:00
Olly Betts
32283991c5 Don't generate a .php wrapper file by default
It's now only generated if something to put in it is specified via:

%pragma(php) include=...

or

%pragma(php) code=...
2021-05-04 14:14:56 +12:00
Olly Betts
6e6d720d88 Fix segfault in exception class creation
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.
2021-05-04 13:12:15 +12:00
Olly Betts
592f230295 Remove CG(active_class_entry) = NULL;
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.
2021-05-04 11:36:24 +12:00
Olly Betts
586eb24efe php: Stop using dl()
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.
2021-05-03 18:42:28 +12:00
Olly Betts
1eabe1b29b Fix type in SWIG_DIRECTOR_CAST 2021-05-03 16:51:18 +12:00
Olly Betts
c87047fd39 Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-05-03 16:17:02 +12:00
Olly Betts
04bacf689b Implement director-disown for PHP 2021-05-03 16:00:30 +12:00
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
William S Fulton
8a21922f1a bool performance warning fix 2021-04-26 22:32:52 +01:00