Commit graph

4,126 commits

Author SHA1 Message Date
tytan652
fa2f9dc5da [lua] Fix maybe-uninitialized warning in generated code 2021-12-15 09:31:13 +13:00
Olly Betts
94ad89284d [php] Remove redundant in typemap for bool
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.
2021-12-13 09:31:11 +13:00
Olly Betts
c0c7a8dba0 [php] Fix two incorrect PHP 8 conditionals
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.
2021-12-08 13:10:38 +13:00
William S Fulton
7246cfa6c6
Merge pull request #2116 from vstinner/python311
Add Python 3.11 support: use Py_SET_TYPE()
2021-12-07 20:32:31 +00:00
Victor Stinner
e902ab5160 Add Python 3.11 support: use Py_SET_TYPE()
On Python 3.9 and newer, SwigPyBuiltin_SetMetaType() now calls
Py_SET_TYPE(). Py_TYPE() can no longer be usd as an l-value on
Python 3.11:

* https://docs.python.org/dev/c-api/structures.html#c.Py_SET_TYPE
* https://docs.python.org/dev/whatsnew/3.11.html#c-api-changes
2021-12-06 23:17:33 +01:00
Robert Fries
983b91694f Additional changes due to name changes in octave-6 * is_map to isstruct, is_object to isobject 2021-12-05 22:19:46 +00:00
Robert Fries
81f9e6600f Octave module lets examples and tests work with Octave-6 * Try-catch replacement for check of error_state * Add execute method in addition to call * Replace oct_mach_info with octave::mach_info * Call from interpreter: global_varval global_assign * Assign a global name requires locating the stack which requires interpreter to tree evaluator to callStack * Do not use discard_error_messages or discard_warning_messages 2021-12-05 22:19:46 +00:00
Robert Fries
852eab7db3 Allow swig wrapped modules to compile with -Bsymbolic 2021-12-05 22:19:40 +00: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
7c97bd5ab3 [js] Remove code to handle v8 < 5.0
We require at least node v6 which means v8 5.0, so code to handle
older v8 is no longer useful.
2021-12-02 14:04:25 +13:00
John Senneker
160b8c5da3 Added extern "C" block that was removed in previous commit. 2021-12-01 15:15:24 -05:00
William S Fulton
f17b6bda93 Merge branch 'fix_SWIG_V8_VERSION'
* fix_SWIG_V8_VERSION:
  [javascript][v8] SWIG_V8_VERSION generation method corrected.
2021-12-01 18:22:29 +00: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
606491326e Scilab compilation fix when wrapping C++11 enum classes 2021-11-15 20:19:12 +00:00
William S Fulton
01eb2e0aa9 Lua int ref typemap improvements
Fixes complex typedefs to const int& and const unsigned int&.
Fixes cpp11_type_aliasing testcase
2021-11-12 19:30:53 +00:00
William S Fulton
ada739b4a8 Fix mismatched new char[] and free() - Javascript
Javascript - v8 and node only.
When wrapping C code char arrays.
Now calloc is now used instead of new char[] in SWIG_AsCharPtrAndSize.
Fixes gcc-11 warning -Wmismatched-new-delete in arrays and
memberin_extend testcases.
2021-11-12 19:00:20 +00:00
Anthony Heading
6c59cae799 Avoid gcc 11 misleading indentation warning in generated code
Closes https://github.com/swig/swig/pull/2074
2021-10-03 17:18:58 +02: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
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
8fb25b6a38 php: SWIG_exception now maps code to exception class
This now determines the class of the exception object where a
suitable pre-defined PHP exception class exists - for example,
SWIG_TypeError -> PHP exception class TypeError.

Exception codes which don't naturally map to a pre-defined PHP
exception class are thrown as PHP class Exception (like all
PHP exceptions raised by SWIG_exception were before this change.)
2021-05-25 16:33:01 +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
Andrew Rogers
448e8d57bd Further leak fixes 2021-05-18 13:07:48 +01:00
Andrew Rogers
16123466f4 Update tests for failing Python API calls to all use '!= 0' 2021-05-18 13:05:51 +01:00
Andrew Rogers
4f453e0cde Tidy up handling of OOM exceptions - Py*_New will call PyErr_NoMemory() internally, so there is no need to call it again here, just correctly handle the NULL return value 2021-05-17 22:50:52 +01:00
Andrew Rogers
04a0b526eb Merge remote-tracking branch 'upstream/master' into memleak
# Conflicts:
#	CHANGES.current
2021-05-17 22:44:56 +01: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
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
Andrew Rogers
84ff84f4fb [Python] Fix memory leaks. 2021-05-12 23:42:32 +01: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
b671a37e89 [php] Fix reserved class names TRUE, FALSE, NULL
PHPCN(x) does a string compare of x with the lower-cased class name,
so x needs to be in lowercase or else the entry has no effect.  The
entries for TRUE, FALSE and NULL weren't working as a result.
2021-05-12 16:45:42 +12:00
Olly Betts
853c511057 [php] Update keyword list
Add some missing entries, remove some long obsolete entries (from
the "ming" extension for generating SWF files, which was split
out from PHP core in 2008), and entry for "static" as a reserved class
name (`static::` is used for late static bindings, but attempting to
name a PHP class `static` fails because `static` is a keyword and we
also list it as such).
2021-05-12 16:43:32 +12:00
Olly Betts
542f6ca440 Fix uses of uninitialised zval
SWIG_SetPointerZval() now checks if the passed zval is an object,
so use ZVAL_UNDEF() before in cases where we create a zval to pass.
2021-05-05 11:55:07 +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
82b244c1d3 [php] Remove redundant conditional include
We always include zend_exceptions.h via phprun.swg.
2021-05-05 09:35:52 +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
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
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
Hirokazu MORIKAWA
3fe47b4b46 [javascript][v8] SWIG_V8_VERSION generation method corrected.
"SWIG_V8_VERSION" generation method was incorrectly fixed.

Signed-off-by: Hirokazu MORIKAWA <morikw2@gmail.com>
2021-05-01 09:25:03 +09:00
William S Fulton
429288fa1c Fix Java %interface family of macros
when returning by const pointer reference

Closes #1987
2021-04-27 23:37:18 +01:00
William S Fulton
13158bda9a Member function pointer typemap tweaks
Use sizeof variable name rather than variable type.
Workaround Visual C++ unable to parse some complex C++11 types, such as
  sizeof(short (Funcs::*)(bool) const &&)
2021-04-26 22:32:52 +01:00
Olly Betts
837dfa1e7e Fix directorout SWIGTYPE typemaps 2021-04-22 17:51:14 +12:00
Olly Betts
a6a52f2f79 Eliminate remaining use of $needNewFlow 2021-04-22 15:14:38 +12:00
Olly Betts
50426aae20 Make PHP directors work more like other languages
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).
2021-04-22 14:40:21 +12:00