summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml81
-rw-r--r--CHANGES.current14
-rw-r--r--Doc/Manual/Php.html94
-rw-r--r--Doc/Manual/SWIG.html2
-rw-r--r--Examples/scilab/matrix2/example.c30
-rw-r--r--Examples/scilab/matrix2/example.i4
-rw-r--r--Examples/scilab/matrix2/runme.sci8
-rw-r--r--Examples/test-suite/php/default_args_runme.php17
-rw-r--r--Examples/test-suite/php/director_classes_runme.php8
-rw-r--r--Examples/test-suite/php/director_thread_runme.php2
-rw-r--r--Lib/php/const.i2
-rw-r--r--Lib/php/phprun.swg67
-rw-r--r--Lib/ruby/rubyrun.swg2
-rw-r--r--Lib/scilab/scidouble.swg14
-rw-r--r--Lib/scilab/sciint.swg5
-rw-r--r--Lib/scilab/scimatrixdouble.swg12
-rw-r--r--Lib/scilab/scimatrixint.swg12
-rw-r--r--RELEASENOTES3
-rw-r--r--Source/Modules/php.cxx5
-rw-r--r--Source/Modules/swigmain.cxx2
-rw-r--r--Tools/CI-linux-environment.sh6
-rw-r--r--Tools/CI-linux-install.sh45
-rw-r--r--configure.ac10
23 files changed, 203 insertions, 242 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 35c6d31cb..f7f059d25 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -75,21 +75,21 @@ jobs:
- SWIGLANG: guile
VER: '3.0'
- SWIGLANG: java
- - SWIGLANG: javascript
- ENGINE: node
- VER: '6'
- CPPSTD: c++11
- os: ubuntu-18.04
- - SWIGLANG: javascript
- ENGINE: node
- VER: '8'
- CPPSTD: c++11
- os: ubuntu-18.04
- - SWIGLANG: javascript
- ENGINE: node
- VER: '10'
- CPPSTD: c++11
- os: ubuntu-18.04
+ #- SWIGLANG: javascript
+ # ENGINE: node
+ # VER: '6'
+ # CPPSTD: c++11
+ # os: ubuntu-18.04
+ #- SWIGLANG: javascript
+ # ENGINE: node
+ # VER: '8'
+ # CPPSTD: c++11
+ # os: ubuntu-18.04
+ #- SWIGLANG: javascript
+ # ENGINE: node
+ # VER: '10'
+ # CPPSTD: c++11
+ # os: ubuntu-18.04
- SWIGLANG: javascript
ENGINE: node
VER: '12'
@@ -108,16 +108,6 @@ jobs:
CPPSTD: c++11
- SWIGLANG: perl5
- SWIGLANG: php
- VER: '7.0'
- - SWIGLANG: php
- VER: '7.1'
- - SWIGLANG: php
- VER: '7.2'
- - SWIGLANG: php
- VER: '7.3'
- - SWIGLANG: php
- VER: '7.4'
- - SWIGLANG: php
VER: '8.0'
- SWIGLANG: php
VER: '8.1'
@@ -125,12 +115,12 @@ jobs:
VER: '8.2'
- SWIGLANG: python
PY2: 2
- - SWIGLANG: python
- VER: '3.3'
- os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- - SWIGLANG: python
- VER: '3.4'
- os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
+ #- SWIGLANG: python
+ # VER: '3.3'
+ # os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
+ #- SWIGLANG: python
+ # VER: '3.4'
+ # os: ubuntu-18.04 # Python < 3.5 not available for 20.04.
- SWIGLANG: python
VER: '3.5'
- SWIGLANG: python
@@ -156,21 +146,18 @@ jobs:
- SWIGLANG: python
SWIG_FEATURES: -builtin -O
- SWIGLANG: r
- - SWIGLANG: ruby
- VER: '1.9'
- os: ubuntu-18.04
+ # rvm fails to install Ruby 1.9 on ubuntu-20.04
+ #- SWIGLANG: ruby
+ # VER: '1.9'
+ # os: ubuntu-18.04
- SWIGLANG: ruby
VER: '2.0'
- os: ubuntu-18.04
- SWIGLANG: ruby
VER: '2.1'
- os: ubuntu-18.04
- SWIGLANG: ruby
VER: '2.2'
- os: ubuntu-18.04
- SWIGLANG: ruby
VER: '2.3'
- os: ubuntu-18.04
- SWIGLANG: ruby
VER: '2.4'
- SWIGLANG: ruby
@@ -185,11 +172,13 @@ jobs:
- SWIGLANG: ruby
VER: '3.1'
CPPSTD: c++11
+ - SWIGLANG: ruby
+ CPPSTD: c++11
+ VER: '3.2'
- SWIGLANG: scilab
VER: '5.5.2'
- SWIGLANG: scilab
- os: ubuntu-18.04 # scilab 6.0
- - SWIGLANG: scilab
+ VER: '6.0.2'
- SWIGLANG: tcl
# c++11 testing
- SWIGLANG: csharp
@@ -319,11 +308,11 @@ jobs:
# Experimental languages (these are allowed to fail)
- SWIGLANG: mzscheme
continue-on-error: true
- - SWIGLANG: ocaml
- CPPSTD: c++17
- GCC: 11
- continue-on-error: true
- os: ubuntu-18.04 # ocaml-4.08 in ubuntu-20.04 not yet working
+ #- SWIGLANG: ocaml
+ # CPPSTD: c++17
+ # GCC: 11
+ # continue-on-error: true
+ # os: ubuntu-18.04 # ocaml-4.08 in ubuntu-20.04 not yet working
# Run all of them, as opposed to aborting when one fails
fail-fast: false
@@ -340,7 +329,7 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
submodules: recursive
diff --git a/CHANGES.current b/CHANGES.current
index 254c2c5ab..cbfe89da9 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -13,6 +13,20 @@ Version 4.2.0 (in progress)
takes parameters from the input following the original macro
expansion.
+2023-04-19: wildmaples
+ [Ruby] #2527 Fix "undefining the allocator of T_DATA" warning seen
+ with Ruby 3.2.
+
+2023-04-18: davidcl
+ [Scilab] #894 extract values with ":" for typemap (int* IN, int IN_SIZE)
+
+2023-04-14: olly
+ [PHP7] Support for PHP7 has been removed. 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.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
2023-03-25: alatina
[Octave] #2512 Add support for Octave 8.1.
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index fad7f6a2f..815d99dce 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -51,12 +51,13 @@
<p>
-In this chapter, we discuss SWIG's support of PHP. Currently any PHP7 or PHP8
+In this chapter, we discuss SWIG's support of PHP. Currently any PHP8
release should work.
</p>
<p>
-Support for PHP7 was added in SWIG 3.0.11 and for PHP8 in 4.1.0.
+Support for PHP8 was added in SWIG 4.1.0.
+Support for PHP7 was added in SWIG 3.0.11 and removed in 4.2.0.
Support for PHP5 was removed in SWIG 4.0.0 and support for PHP4 was removed in
SWIG 1.3.37. There never was a PHP6 release.
</p>
@@ -76,13 +77,14 @@ available.
<p>
-To build a PHP extension, run swig using the <tt>-php7</tt> option as follows
-(<tt>-php</tt> is also supported and currently is an alias for <tt>-php7</tt>
-but prior to SWIG 4.0.0 it was an alias for <tt>-php5</tt>):
+To build a PHP extension, run swig using the <tt>-php</tt> option
+(you can also use <tt>-php7</tt> - PHP7 and PHP8 have a largely compatible C
+extension API, hence the same option name has been used for both). For
+example:
</p>
<div class="code"><pre>
-swig -php7 example.i
+swig -php example.i
</pre></div>
<p>
@@ -146,9 +148,9 @@ least work for Linux though):
<p>
To test the extension from a PHP script, you first need to tell PHP to
-load it. Assuming you're using PHP 7.2 or higher, the recommended (and
-simplest!) way to do this is to copy it to PHP's default extension directory
-and add a line like this to the <tt>[PHP]</tt> section of <tt>php.ini</tt>:
+load it. The recommended (and simplest!) way to do this is to copy it to
+PHP's default extension directory and add a line like this to the
+<tt>[PHP]</tt> section of <tt>php.ini</tt>:
</p>
<div class="code"><pre>
@@ -156,10 +158,9 @@ and add a line like this to the <tt>[PHP]</tt> section of <tt>php.ini</tt>:
</pre></div>
<p>
-PHP &lt; 7.2 doesn't support loading by just the module name, so you need
-to specify the filename of the module to be specified, which varies
-between platforms. And for any PHP version, if the module is not in PHP's
-default extension directory, you also need to specify the path, for example:
+If the module is not in PHP's default extension directory, you also need to
+specify the path, in which case you'll also need to deal with platform-specific
+naming - for example, on Linux:
</p>
<div class="code"><pre>
@@ -167,6 +168,14 @@ default extension directory, you also need to specify the path, for example:
</pre></div>
<p>
+but on Microsoft Windows you'd need to use:
+</p>
+
+<div class="code"><pre>
+ extension=/path/to/php_modulename.dll
+</pre></div>
+
+<p>
If you're using the PHP CLI SAPI it's possible (but not recommended) to use the
<a href="https://www.php.net/manual/en/function.dl.php">dl() function</a> to
load an extension at run time, by adding a line like this to the start of each
@@ -174,15 +183,17 @@ PHP script which uses your extension:
</p>
<div class="code"><pre>
- dl("/path/to/modulename.so"); // Load the module
+ dl("modulename"); // Load the module
</pre></div>
<p>
-But to do this portably you need to take into account that pathnames and the
-filename extension vary by platform, and for security reasons PHP no longer
-supports <tt>dl()</tt> when running PHP through a webserver. Overall it's
-better to instead use <tt>extension</tt> in <tt>php.ini</tt> as described
-above.
+Again, if the module isn't in PHP's default extension directory you'll also
+need to specify the path and deal with that varying by platform.
+</p>
+
+<p>
+For security reasons PHP no longer supports <tt>dl()</tt> when running PHP
+through a webserver, so this isn't an option there.
</p>
<H2><a name="Php_nn2">32.2 Basic PHP interface</a></H2>
@@ -227,47 +238,6 @@ echo "E = " . E . "\n";
</pre>
</div>
-<p>
-There's one peculiarity of how constants work in PHP prior to PHP 8
-which it is useful to note (this is not specific to SWIG though) - if you try
-to use an undeclared constant, PHP will emit a warning (or a notice in PHP 7.1
-and earlier) and then expand the constant to a string version of the constant's
-name. Unfortunately it is easy to miss the warning message if you're using PHP
-in a webserver as it will probably end up in error.log or similar. PHP 8.0
-made this an error.
-</p>
-
-<p>
-For example,
-</p>
-
-<div class="code"><pre>
-%module example
-
-#define EASY_TO_MISPELL 0
-</pre>
-</div>
-
-<p>
-accessed incorrectly in PHP,
-</p>
-
-<div class="code">
-<pre>
-if(EASY_TO_MISPEL) {
- ...
-} else {
- ...
-}
-
-</pre>
-</div>
-
-<p>
-The mis-spelled constant will become the string 'EASY_TO_MISPEL', which
-is treated as true by the if test, when the value of the intended constant
-would be treated as false!
-</p>
<H3><a name="Php_nn2_2">32.2.2 Global Variables</a></H3>
@@ -346,9 +316,7 @@ $c = bar(3.5); # Use default argument for 2nd parameter
<p>
SWIG generates PHP type declarations for function parameters and return
-types for PHP 8 and later (we don't try to support PHP 7's more limited type
-declarations and the generated wrappers compiled for PHP 7 will not have any
-type declarations).
+types for PHP 8 and later.
</p>
<p>
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 3fb41e522..cc01d9e6c 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -128,7 +128,7 @@ Supported Target Language Options
-lua - Generate Lua wrappers
-octave - Generate Octave wrappers
-perl5 - Generate Perl 5 wrappers
- -php7 - Generate PHP 7 or later wrappers
+ -php7 - Generate PHP 8 or later wrappers
-python - Generate Python wrappers
-r - Generate R (aka GNU S) wrappers
-ruby - Generate Ruby wrappers
diff --git a/Examples/scilab/matrix2/example.c b/Examples/scilab/matrix2/example.c
index 476067df9..232c88824 100644
--- a/Examples/scilab/matrix2/example.c
+++ b/Examples/scilab/matrix2/example.c
@@ -29,12 +29,12 @@ void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double** resu
}
}
-void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes)
+void getDoubleMatrix(int nbRow, int nbCol, double **resultMatrix, int *nbRowRes, int *nbColRes)
{
int i;
int size;
- *nbRowRes = 5;
- *nbColRes = 3;
+ *nbRowRes = nbRow;
+ *nbColRes = nbCol;
size = (*nbRowRes) * (*nbColRes);
*resultMatrix = (double*) malloc(size * sizeof(double));
for (i=0; i<size; i++)
@@ -43,6 +43,30 @@ void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes)
}
}
+void extractDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, int* indexes, int nbIndexes, double **resultMatrix, int *nbRowRes, int *nbColRes)
+{
+ if (nbIndexes < 0)
+ {
+ int sz = nbRow * nbCol;
+ *nbRowRes = sz;
+ *nbColRes = 1;
+
+ *resultMatrix = malloc(sz * sizeof(double));
+ memcpy(*resultMatrix, inputMatrix, sz * sizeof(double));
+ } else {
+ int i;
+
+ *nbRowRes = nbIndexes;
+ *nbColRes = 1;
+
+ *resultMatrix = malloc(nbIndexes * sizeof(double));
+ for (i = 0; i < nbIndexes; i++)
+ {
+ (*resultMatrix)[i] = inputMatrix[indexes[i]];
+ }
+ }
+}
+
// Integer matrix functions
int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol)
diff --git a/Examples/scilab/matrix2/example.i b/Examples/scilab/matrix2/example.i
index e37cd116c..1584691cc 100644
--- a/Examples/scilab/matrix2/example.i
+++ b/Examples/scilab/matrix2/example.i
@@ -4,6 +4,7 @@
%apply (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (double *inputMatrix, int nbRow, int nbCol) }
%apply (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (double **resultMatrix, int *nbRowRes, int *nbColRes) }
+%apply (int *IN, int IN_SIZE) { (int* indexes, int nbIndexes) }
%apply (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (int *inputMatrix, int nbRow, int nbCol) }
%apply (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (int **resultMatrix, int *nbRowRes, int *nbColRes) }
@@ -14,7 +15,8 @@
%inline %{
extern double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol);
extern void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double **resultMatrix, int *nbRowRes, int *nbColRes);
- extern void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes);
+ extern void getDoubleMatrix(int nbRow, int nbCol,double **resultMatrix, int *nbRowRes, int *nbColRes);
+ extern void extractDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, int* indexes, int nbIndexes, double **resultMatrix, int *nbRowRes, int *nbColRes);
extern int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol);
extern void squareIntegerMatrix(int *inputMatrix, int nbRow, int nbCol, int **resultMatrix, int *nbRowRes, int *nbColRes);
diff --git a/Examples/scilab/matrix2/runme.sci b/Examples/scilab/matrix2/runme.sci
index 0af7df4e7..4264991e8 100644
--- a/Examples/scilab/matrix2/runme.sci
+++ b/Examples/scilab/matrix2/runme.sci
@@ -8,7 +8,7 @@ end
// Test lib double matrix functions
disp("Call lib function getDoubleMatrix()");
-doubleMatrix = getDoubleMatrix();
+doubleMatrix = getDoubleMatrix(5, 3);
disp(doubleMatrix);
disp("Call lib function sumDoubleMatrix()");
@@ -19,6 +19,12 @@ disp("Call lib function squareDoubleMatrix()");
sqrd = squareDoubleMatrix(doubleMatrix);
disp(sqrd);
+disp("Extract various indexes");
+disp(extractDoubleMatrix(doubleMatrix, 2));
+disp(extractDoubleMatrix(doubleMatrix, 2:5));
+disp(extractDoubleMatrix(doubleMatrix, :));
+
+
// Test lib integer matrix functions
diff --git a/Examples/test-suite/php/default_args_runme.php b/Examples/test-suite/php/default_args_runme.php
index 59350644f..31cbe0ff4 100644
--- a/Examples/test-suite/php/default_args_runme.php
+++ b/Examples/test-suite/php/default_args_runme.php
@@ -42,19 +42,6 @@ check::equal($f->double_if_void_ptr_is_null(6, Null), 12, "\$f->double_if_void_p
check::equal($f->double_if_void_ptr_is_null(7), 14, "\$f->double_if_void_ptr_is_null(7)");
-# For the testcases below, PHP 7 emits an error, while PHP 8 throws an
-# exception. To simplify the testcases we install an error handler function
-# for PHP7 which throws an ArgumentCountError exception (which we have to
-# define ourselves for PHP 7.0).
-
-if (PHP_MAJOR_VERSION == 7) {
- if (PHP_MINOR_VERSION == 0) {
- # ArgumentCountError was added in PHP 7.1.
- class ArgumentCountError extends Error {}
- }
- $old_error_handler = set_error_handler(function($n,$s,$f,$l){throw preg_match('/^Wrong parameter count/', $s) ? new ArgumentCountError($s) : new Error($s);});
-}
-
try {
$f = new Foo(1);
check::fail("Foo::Foo ignore is not working");
@@ -91,10 +78,6 @@ try {
} catch (Error $e) {
}
-if (PHP_MAJOR_VERSION == 7) {
- set_error_handler($old_error_handler);
-}
-
check::equal(Klass::inc(100, new Klass(22))->val, 122, "Klass::inc failed");
check::equal(klass::inc(100)->val, 99, "klass::inc failed");
diff --git a/Examples/test-suite/php/director_classes_runme.php b/Examples/test-suite/php/director_classes_runme.php
index d187ed82e..937d0db3f 100644
--- a/Examples/test-suite/php/director_classes_runme.php
+++ b/Examples/test-suite/php/director_classes_runme.php
@@ -41,12 +41,8 @@ if (PHP_MAJOR_VERSION < 8) {
class PHPDerived extends Base {
function Val(DoubleHolder $x) { return $x; }
function Ref(DoubleHolder $x) { return $x; }
- // PHP 7.0 fails to parse the `?` - revert once we drop 7.0 support:
- // function Ptr(?DoubleHolder $x) { return $x; }
- function Ptr($x) { return $x; }
- // PHP 7.0 fails to parse the `?` - revert once we drop 7.0 support:
- // function ConstPtrRef(?DoubleHolder $x) { return $x; }
- function ConstPtrRef($x) { return $x; }
+ function Ptr(?DoubleHolder $x) { return $x; }
+ function ConstPtrRef(?DoubleHolder $x) { return $x; }
function FullyOverloaded($x) {
$rv = parent::FullyOverloaded($x);
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
diff --git a/Examples/test-suite/php/director_thread_runme.php b/Examples/test-suite/php/director_thread_runme.php
index 190dbad71..e4eb3684a 100644
--- a/Examples/test-suite/php/director_thread_runme.php
+++ b/Examples/test-suite/php/director_thread_runme.php
@@ -3,7 +3,7 @@
require "tests.php";
# Fails in a ZTS-build of PHP5 - see: https://github.com/swig/swig/pull/155
-# FIXME: Does this still fail in a threaded build of PHP7?
+# FIXME: Does this still fail in a threaded build of PHP8?
exit(0);
// New functions
diff --git a/Lib/php/const.i b/Lib/php/const.i
index a74af0d78..1e1fe9cad 100644
--- a/Lib/php/const.i
+++ b/Lib/php/const.i
@@ -95,7 +95,7 @@
SWIG_SetPointerZval(&c.value, (void*)($value), $1_descriptor, 0);
zval_copy_ctor(&c.value);
c.name = zend_string_init("$symname", sizeof("$symname") - 1, 0);
- SWIG_ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
+ ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
zend_register_constant(&c);
}
diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
index d3ad0d26a..588701f9b 100644
--- a/Lib/php/phprun.swg
+++ b/Lib/php/phprun.swg
@@ -10,35 +10,14 @@
extern "C" {
#endif
-#if PHP_MAJOR_VERSION < 7
-# error These bindings need PHP 7 or later - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
+#if PHP_MAJOR_VERSION < 8
+# error These bindings need PHP 8 or later - to generate PHP7 bindings use SWIG < 4.1.0; to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
#endif
#include "zend_inheritance.h"
#include "zend_exceptions.h"
#include "zend_inheritance.h"
-#if PHP_MAJOR_VERSION == 7
-/* These macros were new in PHP 8.0. For PHP 7.x we define them to give the
- * same result except without any type declarations. PHP 7.x supports type
- * declarations, but not for the return type, and alternate types aren't
- * supported, so we don't try to support these.
- */
-# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(name, byref, num_req, classes, types) \
- ZEND_BEGIN_ARG_INFO_EX(name, 0, byref, num_req)
-# define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, byref, num_req, types) \
- ZEND_BEGIN_ARG_INFO_EX(name, 0, byref, num_req)
-
-/* NB We can just ignore `default` here we currently always pass NULL for it
- * (this mechanism for specifying default parameter values was new in PHP 8.0
- * so it's not useful while we still want to support PHP7 too).
- */
-# define ZEND_ARG_OBJ_TYPE_MASK(byref, name, classes, types, default) \
- ZEND_ARG_INFO(byref, name)
-# define ZEND_ARG_TYPE_MASK(byref, name, types, default) \
- ZEND_ARG_INFO(byref, name)
-#endif
-
#include <stdlib.h> /* for abort(), used in generated code. */
#define SWIG_BOOL_CONSTANT(N, V) REGISTER_BOOL_CONSTANT(#N, V, CONST_CS | CONST_PERSISTENT)
@@ -50,27 +29,6 @@ extern "C" {
REGISTER_STRINGL_CONSTANT(#N, &swig_char, 1, CONST_CS | CONST_PERSISTENT);\
} while (0)
-/* ZEND_CONSTANT_SET_FLAGS was new in PHP 7.3. */
-#ifdef ZEND_CONSTANT_SET_FLAGS
-# define SWIG_ZEND_CONSTANT_SET_FLAGS ZEND_CONSTANT_SET_FLAGS
-#else
-# define SWIG_ZEND_CONSTANT_SET_FLAGS(C, F, N) do { (C)->flags = (F); (C)->module_number = (N); } while (0)
-#endif
-
-/* zend_object_alloc was new in PHP 7.3. */
-#if PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3
-static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
- void *obj = emalloc(obj_size + zend_object_properties_size(ce));
- memset(obj, 0, obj_size - sizeof(zval));
- return obj;
-}
-#endif
-
-/* ZEND_THIS was new in PHP 7.4. */
-#ifndef ZEND_THIS
-# define ZEND_THIS &EX(This)
-#endif
-
#ifdef __cplusplus
}
#endif
@@ -93,27 +51,6 @@ static int default_error_code = E_ERROR;
static zend_class_entry SWIG_Php_swig_wrapped_interface_ce;
-#if PHP_MAJOR_VERSION == 7
-/* zend_class_implements_interface() was new in PHP 8.0.
- *
- * We could use instanceof_function_ex(C, I, 1) here for 7.4, but for 7.3
- * and earlier that doesn't work, so instead we 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.
- */
-static int zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce) {
- uint32_t i;
- if (class_ce->num_interfaces) {
- for (i = 0; i < class_ce->num_interfaces; i++) {
- if (class_ce->interfaces[i] == interface_ce) {
- return 1;
- }
- }
- }
- return 0;
-}
-#endif
-
/* used to wrap returned objects in so we know whether they are newobject
and need freeing, or not */
typedef struct {
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index 6cac4626a..885292481 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -157,7 +157,7 @@ SWIG_Ruby_define_class(swig_type_info *type)
_cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
}
- rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
+ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer));
free((void *) klass_name);
}
diff --git a/Lib/scilab/scidouble.swg b/Lib/scilab/scidouble.swg
index 1b8263306..e14c84647 100644
--- a/Lib/scilab/scidouble.swg
+++ b/Lib/scilab/scidouble.swg
@@ -56,6 +56,7 @@ SWIG_SciDouble_FromDouble(void *pvApiCtx, int iVarOut, double dblValue, char *fn
SWIGINTERN int
SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, double **pdValue, char *fname) {
SciErr sciErr;
+ int iType = 0;
int *piAddrVar = NULL;
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
@@ -64,13 +65,24 @@ SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *i
return SWIG_ERROR;
}
- if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix && !isVarComplex(pvApiCtx, piAddrVar)) {
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, pdValue);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
}
+ else if (iType == sci_implicit_poly) {
+ *iRows = -1;
+ *iCols = 0;
+ *pdValue = NULL;
+ }
else {
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
return SWIG_ERROR;
diff --git a/Lib/scilab/sciint.swg b/Lib/scilab/sciint.swg
index 2d6993569..b7b2563e8 100644
--- a/Lib/scilab/sciint.swg
+++ b/Lib/scilab/sciint.swg
@@ -157,6 +157,11 @@ SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, in
return SWIG_ERROR;
}
}
+ else if (iType == sci_implicit_poly) {
+ *iRows = -1;
+ *iCols = 0;
+ *piValue = NULL;
+ }
else {
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar);
return SWIG_ERROR;
diff --git a/Lib/scilab/scimatrixdouble.swg b/Lib/scilab/scimatrixdouble.swg
index 9444a8078..bb9403edd 100644
--- a/Lib/scilab/scimatrixdouble.swg
+++ b/Lib/scilab/scimatrixdouble.swg
@@ -28,7 +28,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_SIZE) (int rowCount, int colCount)
{
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
- $2 = rowCount * colCount;
+ if (rowCount < 0) {
+ $2 = rowCount;
+ } else {
+ $2 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
@@ -40,7 +44,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_SIZE, double *IN) (int rowCount, int colCount)
{
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
- $1 = rowCount * colCount;
+ if (rowCount < 0) {
+ $1 = rowCount;
+ } else {
+ $1 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
diff --git a/Lib/scilab/scimatrixint.swg b/Lib/scilab/scimatrixint.swg
index e304d4f64..057710725 100644
--- a/Lib/scilab/scimatrixint.swg
+++ b/Lib/scilab/scimatrixint.swg
@@ -30,7 +30,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_SIZE) (int rowCount, int colCount)
{
if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
- $2 = rowCount * colCount;
+ if (rowCount < 0) {
+ $2 = rowCount;
+ } else {
+ $2 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
@@ -43,7 +47,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_SIZE, int *IN) (int rowCount, int colCount)
{
if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
- $1 = rowCount * colCount;
+ if (rowCount < 0) {
+ $1 = rowCount;
+ } else {
+ $1 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
diff --git a/RELEASENOTES b/RELEASENOTES
index 493f19954..300e79c09 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -7,6 +7,9 @@ Release Notes
Detailed release notes are available with the release and are also
published on the SWIG web site at https://swig.org/release.html.
+SWIG-4.2.0 summary:
+- PHP7 support removed, PHP8 is now the supported PHP version.
+
SWIG-4.1.1 summary:
- Couple of stability fixes.
- Stability fix in ccache-swig when calculating hashes of inputs.
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index c8cc9212b..6f326c15b 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -784,8 +784,9 @@ public:
Printf(s_init, "#ifdef __cplusplus\n");
Printf(s_init, "extern \"C\" {\n");
Printf(s_init, "#endif\n");
- // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE
- // in PHP7 has "extern "C" { ... }" around it so we can't do that.
+ // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but the definition
+ // of ZEND_GET_MODULE has "extern "C" { ... }" around it so we can't do
+ // that.
Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module);
Printf(s_init, "#ifdef __cplusplus\n");
Printf(s_init, "}\n");
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index d553fe893..1d1b2946c 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -70,7 +70,7 @@ static TargetLanguageModule modules[] = {
{"-perl5", swig_perl5, "Perl 5", Supported},
{"-php", swig_php, NULL, Supported},
{"-php5", NULL, "PHP 5", Disabled},
- {"-php7", swig_php, "PHP 7 or later", Supported},
+ {"-php7", swig_php, "PHP 8 or later", Supported},
{"-pike", NULL, "Pike", Disabled},
{"-python", swig_python, "Python", Supported},
{"-r", swig_r, "R (aka GNU S)", Supported},
diff --git a/Tools/CI-linux-environment.sh b/Tools/CI-linux-environment.sh
index e854c5b0e..3655108be 100644
--- a/Tools/CI-linux-environment.sh
+++ b/Tools/CI-linux-environment.sh
@@ -25,7 +25,11 @@ case "$SWIGLANG" in
"ruby")
if ! command -v rvm; then
set +x
- source $HOME/.rvm/scripts/rvm
+ if [ -f /etc/profile.d/rvm.sh ] ; then
+ source /etc/profile.d/rvm.sh
+ elif [ -f $HOME/.rvm/scripts/rvm ] ; then
+ source $HOME/.rvm/scripts/rvm
+ fi
set -x
fi
;;
diff --git a/Tools/CI-linux-install.sh b/Tools/CI-linux-install.sh
index 456f5bc42..93bb46412 100644
--- a/Tools/CI-linux-install.sh
+++ b/Tools/CI-linux-install.sh
@@ -117,32 +117,35 @@ case "$SWIGLANG" in
$RETRY sudo apt-get -qq install r-base
;;
"ruby")
- if ! command -v rvm; then
+ if [[ "$VER" ]]; then
case "$VER" in
- 1.9 | 2.0 | 2.1 | 2.2 | 2.3 )
- $RETRY sudo apt-get -qq install libgdbm-dev libncurses5-dev libyaml-dev libssl1.0-dev
+ 3.1 | 3.2 )
+ # Ruby 3.1+ support is currently only rvm master (2023-04-19)
+ # YOLO
+ curl -sSL https://rvm.io/mpapis.asc | gpg --import -
+ curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
+ curl -sSL https://get.rvm.io | bash -s stable
+ set +x
+ source $HOME/.rvm/scripts/rvm
+ $RETRY rvm get master
+ rvm reload
+ rvm list known
+ set -x
+ ;;
+ * )
+ # Install from PPA as that also contains packages needed for the build.
+ sudo apt-add-repository -y ppa:rael-gc/rvm
+ sudo apt-get update
+ sudo apt-get install rvm
+ sudo usermod -a -G rvm $USER
+ set +x
+ source /etc/profile.d/rvm.sh
+ set -x
;;
esac
- # YOLO
- curl -sSL https://rvm.io/mpapis.asc | gpg --import -
- curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
- curl -sSL https://get.rvm.io | bash -s stable
set +x
- source $HOME/.rvm/scripts/rvm
- set -x
- fi
- case "$VER" in
- 2.7 | 3.0 | 3.1 )
- # Ruby 2.7+ support is currently only rvm master (30 Dec 2019)
- set +x
- $RETRY rvm get master
- rvm reload
- rvm list known
- set -x
- ;;
- esac
- if [[ "$VER" ]]; then
$RETRY rvm install $VER
+ set -x
fi
;;
"scilab")
diff --git a/configure.ac b/configure.ac
index 830214a74..c0f57571f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1851,17 +1851,15 @@ if test x"${PHPBIN}" = xno; then
PHP=
else
if test "x$PHPBIN" = xyes; then
- AC_CHECK_PROGS(PHP, [php8.2 php8.1 php8.0 php7.4 php7.3 php7.2 php7.1 php7.0 php])
+ AC_CHECK_PROGS(PHP, [php8.2 php8.1 php8.0 php])
else
PHP=$PHPBIN
fi
if test -n "$PHP"; then
AC_MSG_CHECKING(for PHP header files)
- dnl /usr/bin/php7.0 -> /usr/bin/php-config7.0
+ dnl /usr/bin/php8.0 -> /usr/bin/php-config8.0
case $PHP in
- *7.*)
- PHPCONFIG=`echo "$PHP"|sed 's/7\...*$/-config&/'` ;;
*8.*)
PHPCONFIG=`echo "$PHP"|sed 's/8\...*$/-config&/'` ;;
*)
@@ -1869,7 +1867,7 @@ else
esac
php_version=`$PHPCONFIG --version 2>/dev/null`
case $php_version in
- 7.*|8.*)
+ 8.*)
PHPINC=`$PHPCONFIG --includes 2>/dev/null`
if test -n "$PHPINC"; then
AC_MSG_RESULT($PHPINC)
@@ -1880,7 +1878,7 @@ else
"")
AC_MSG_RESULT([could not find $PHPCONFIG or obtain PHP version from it]) ;;
*)
- AC_MSG_RESULT([found PHP $php_version - not PHP 7 or 8]) ;;
+ AC_MSG_RESULT([found PHP $php_version - not PHP 8]) ;;
esac
fi
fi