From f10f50a0f8f931aea210ab0099d169b9d799da8b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 18 Jan 2022 15:36:37 +1300 Subject: [perl] Require at least Perl 5.8.0 As discussed and agreed in #1629, it's become hard to test with Perl 5.6 or earlier, such old versions are no longer in active use, and 4.1.0 is an appropriate time to make such a change. I've dropped the compatibility code that was obvious to me, but there's probably more that can be cleaned up now. --- CHANGES.current | 3 ++ Doc/Manual/Perl5.html | 9 ++-- .../perl5/operator_overload_break_runme.pl | 11 +--- .../test-suite/perl5/operator_overload_runme.pl | 29 ++++------- Examples/test-suite/perl5/packageoption_runme.pl | 9 ---- Lib/perl5/perlhead.swg | 28 ++-------- Lib/perl5/perlinit.swg | 4 -- Lib/perl5/perlrun.swg | 60 ++++------------------ RELEASENOTES | 1 + Source/Modules/perl5.cxx | 7 --- configure.ac | 2 +- 11 files changed, 33 insertions(+), 130 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b6c21643b..5aa435e15 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-01-18: olly + [Perl] #1629 Perl 5.8.0 is now the oldest version we aim to support. + 2022-01-14: wsfulton [Python] Fix %callback and specifying the callback function as a static member function using Python staticmethod syntax, such as diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 9f2e08ba4..03dcfe6bb 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -91,10 +91,10 @@

This chapter describes SWIG's support of Perl5. Although the Perl5 module is one of the earliest SWIG modules, it has continued to evolve -and has been improved greatly with the help of SWIG users. For the -best results, it is recommended that SWIG be used with Perl 5.8 or -later. We're no longer testing regularly with older versions, but -Perl 5.6 seems to mostly work, while older versions don't. +and has been improved greatly with the help of SWIG users. As of SWIG +4.1.0, the minimum version of Perl we aim to support is Perl 5.8.0. +We can no longer easily test with older versions, and they no longer +seem to be in active use.

31.1 Overview

@@ -680,7 +680,6 @@ files(s) field". installation under "Additional include directories".
  • Define the symbols WIN32 and MSWIN32 under preprocessor options. -If using the ActiveWare port, also define the symbol PERL_OBJECT. Note that all extensions to the ActiveWare port must be compiled with the C++ compiler since Perl has been encapsulated in a C++ class. diff --git a/Examples/test-suite/perl5/operator_overload_break_runme.pl b/Examples/test-suite/perl5/operator_overload_break_runme.pl index fd3fe3303..c692dfac7 100644 --- a/Examples/test-suite/perl5/operator_overload_break_runme.pl +++ b/Examples/test-suite/perl5/operator_overload_break_runme.pl @@ -4,15 +4,6 @@ use Test::More tests => 9; use operator_overload_break; -# Workaround for -# ok( not (expression) , "test description" ); -# does not working in older versions of Perl, eg 5.004_04 -sub ok_not ($;$) { - my($test, $name) = @_; - $test = not $test; - ok($test, $name); -} - pass("loaded"); my $op = operator_overload_break::Op->new(5); @@ -32,7 +23,7 @@ $op->{k} = 22; ok((10 == (32 - $op)), "reversed subtraction"); -ok_not((3 == $op), +ok(not(3 == $op), 'not equal'); $op->{k} = 3; diff --git a/Examples/test-suite/perl5/operator_overload_runme.pl b/Examples/test-suite/perl5/operator_overload_runme.pl index ba3f33a64..43a77a961 100644 --- a/Examples/test-suite/perl5/operator_overload_runme.pl +++ b/Examples/test-suite/perl5/operator_overload_runme.pl @@ -4,15 +4,6 @@ use Test::More tests => 39; use operator_overload; -# Workaround for -# ok( not (expression) , "test description" ); -# does not working in older versions of Perl, eg 5.004_04 -sub ok_not ($;$) { - my($test, $name) = @_; - $test = not $test; - ok($test, $name); -} - pass("loaded"); # first check all the operators are implemented correctly from pure C++ code @@ -30,7 +21,7 @@ isa_ok($op2, "operator_overload::Op"); $op->{i} = 5; $op2->{i} = 3; -ok_not(($op == $op2), "operator equal: not equal"); +ok(not($op == $op2), "operator equal: not equal"); $op->{i} = 3; ok(($op == $op2), "operator equal: equal"); @@ -42,7 +33,7 @@ $op2->{i} = 3; ok(($op != $op2), "operator not equal: not equal"); $op->{i} = 3; -ok_not(($op != $op2), "operator not equal: equal"); +ok(not($op != $op2), "operator not equal: equal"); # stringify operator $op->{i} = 3; @@ -99,16 +90,16 @@ is($op3->{i}, 2, "operator modulus"); $op->{i} = 8; $op2->{i} = 3; ok($op > $op2, "operator greater than"); -ok_not(($op2 > $op), "operator greater than"); +ok(not($op2 > $op), "operator greater than"); $op->{i} = 3; -ok_not(($op2 > $op), "operator greater than"); -ok_not(($op > $op2), "operator greater than"); +ok(not($op2 > $op), "operator greater than"); +ok(not($op > $op2), "operator greater than"); # greater than or equal operator $op->{i} = 8; $op2->{i} = 3; ok($op >= $op2, "operator greater than or equal"); -ok_not(($op2 >= $op), "operator greater than or equal"); +ok(not($op2 >= $op), "operator greater than or equal"); $op->{i} = 3; ok(($op2 >= $op), "operator greater than or equal"); ok(($op >= $op2), "operator greater than or equal"); @@ -117,16 +108,16 @@ ok(($op >= $op2), "operator greater than or equal"); $op2->{i} = 8; $op->{i} = 3; ok($op < $op2, "operator lesser than"); -ok_not(($op2 < $op), "operator lesser than"); +ok(not($op2 < $op), "operator lesser than"); $op2->{i} = 3; -ok_not(($op2 < $op), "operator lesser than"); -ok_not(($op < $op2), "operator lesser than"); +ok(not($op2 < $op), "operator lesser than"); +ok(not($op < $op2), "operator lesser than"); # less than or equal operator $op2->{i} = 8; $op->{i} = 3; ok($op <= $op2, "operator lesser than or equal"); -ok_not(($op2 <= $op), "operator lesser than or equal"); +ok(not($op2 <= $op), "operator lesser than or equal"); $op2->{i} = 3; ok(($op2 <= $op), "operator less than or equal"); ok(($op <= $op2), "operator less than or equal"); diff --git a/Examples/test-suite/perl5/packageoption_runme.pl b/Examples/test-suite/perl5/packageoption_runme.pl index d94a7a1fd..02e95f7a8 100644 --- a/Examples/test-suite/perl5/packageoption_runme.pl +++ b/Examples/test-suite/perl5/packageoption_runme.pl @@ -5,15 +5,6 @@ use Test::More tests => 4; BEGIN { use_ok('packageoption_a'); } BEGIN { use_ok('packageoption_b'); } -# Workaround for -# ok( not (expression) , "test description" ); -# does not working in older versions of Perl, eg 5.004_04 -sub ok_not ($;$) { - my($test, $name) = @_; - $test = not $test; - ok($test, $name); -} - my $a = CommonPackage::A->new(); isa_ok($a, 'CommonPackage::A'); diff --git a/Lib/perl5/perlhead.swg b/Lib/perl5/perlhead.swg index 5437af5a5..bb7c1741d 100644 --- a/Lib/perl5/perlhead.swg +++ b/Lib/perl5/perlhead.swg @@ -8,22 +8,9 @@ extern "C" { #include "perl.h" #include "XSUB.h" -/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ - -/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ -#ifndef PERL_REVISION -# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) -# define PERL_PATCHLEVEL_H_IMPLICIT -# include -# endif -# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) -# include -# endif -# ifndef PERL_REVISION -# define PERL_REVISION (5) -# define PERL_VERSION PATCHLEVEL -# define PERL_SUBVERSION SUBVERSION -# endif +/* PERL_REVISION was added in Perl 5.6. */ +#if !defined PERL_REVISION || (PERL_REVISION-0 == 5 && PERL_VERSION-0 < 8) +# error SWIG requires Perl >= 5.8.0 #endif #if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) @@ -38,15 +25,6 @@ extern "C" { # define SvUOK(sv) SvIOK_UV(sv) #endif -#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) -# define PL_sv_undef sv_undef -# define PL_na na -# define PL_errgv errgv -# define PL_sv_no sv_no -# define PL_sv_yes sv_yes -# define PL_markstack_ptr markstack_ptr -#endif - #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE diff --git a/Lib/perl5/perlinit.swg b/Lib/perl5/perlinit.swg index b49040d26..c26b93fad 100644 --- a/Lib/perl5/perlinit.swg +++ b/Lib/perl5/perlinit.swg @@ -4,15 +4,11 @@ #ifdef __cplusplus extern "C" #endif -#ifndef PERL_OBJECT #ifndef MULTIPLICITY SWIGEXPORT void SWIG_init (CV* cv); #else SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); #endif -#else -SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); -#endif %} /* Module initialization function */ diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index b04002f5d..28703d1a6 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -6,13 +6,8 @@ * type checking. * ----------------------------------------------------------------------------- */ -#ifdef PERL_OBJECT -#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), -#define SWIG_PERL_OBJECT_CALL pPerl, -#else #define SWIG_PERL_OBJECT_DECL #define SWIG_PERL_OBJECT_CALL -#endif /* Common SWIG API */ @@ -88,32 +83,12 @@ extern "C" { #endif /* Macro to call an XS function */ -#ifdef PERL_OBJECT -# define SWIG_CALLXS(_name) _name(cv,pPerl) -#else -# ifndef MULTIPLICITY -# define SWIG_CALLXS(_name) _name(cv) -# else -# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) -# endif -#endif - -#ifdef PERL_OBJECT -#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; - -#ifdef __cplusplus -extern "C" { -#endif -typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); -#ifdef __cplusplus -} +#ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +#else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) #endif -#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) -#define SWIGCLASS_STATIC - -#else /* PERL_OBJECT */ - #define MAGIC_PPERL #define SWIGCLASS_STATIC static SWIGUNUSED @@ -141,24 +116,14 @@ typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); #endif #endif /* MULTIPLICITY */ -#endif /* PERL_OBJECT */ -# ifdef PERL_OBJECT -# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) -static void SWIGUNUSED SWIG_Perl_croak_null(CPerlObj *pPerl) -# else static void SWIGUNUSED SWIG_croak_null() -# endif { SV *err = get_sv("@", GV_ADD); -# if (PERL_VERSION < 6) - croak("%_", err); -# else if (sv_isobject(err)) croak(0); else croak("%s", SvPV_nolen(err)); -# endif } @@ -462,20 +427,15 @@ typedef struct { } swig_variable_info; /* Magic variable code */ -#ifndef PERL_OBJECT -# ifdef __cplusplus +#ifdef __cplusplus # define swig_create_magic(s,a,b,c) _swig_create_magic(s,const_cast(a),b,c) -# else +#else # define swig_create_magic(s,a,b,c) _swig_create_magic(s,(char*)(a),b,c) -# endif -# ifndef MULTIPLICITY -SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) -# else -SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) -# endif +#endif +#ifndef MULTIPLICITY +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) #else -# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) -SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) #endif { MAGIC *mg; diff --git a/RELEASENOTES b/RELEASENOTES index c05ccc4ec..3a596dd46 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -10,6 +10,7 @@ published on the SWIG web site at http://swig.org/release.html. SWIG-4.1.0 summary: - Add PHP 8 support. - PHP wrapping is now done entirely via PHP's C API - no more .php wrapper. +- Perl 5.8.0 is now the oldest version SWIG supports. - GitHub Actions is now used instead of Travis CI for continuous integration. SWIG-4.0.2 summary: diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index e87f9f310..459d403bf 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -445,13 +445,7 @@ public: Printv(magic, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n", - "#ifdef PERL_OBJECT\n", - "#define MAGIC_CLASS _wrap_", underscore_module, "_var::\n", - "class _wrap_", underscore_module, "_var : public CPerlObj {\n", - "public:\n", - "#else\n", "#define MAGIC_CLASS\n", - "#endif\n", "SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) {\n", tab4, "MAGIC_PPERL\n", tab4, "croak(\"Value is read-only.\");\n", tab4, "return 0;\n", "}\n", NIL); @@ -470,7 +464,6 @@ public: /* Dump out variable wrappers */ - Printv(magic, "\n\n#ifdef PERL_OBJECT\n", "};\n", "#endif\n", NIL); Printv(magic, "\n#ifdef __cplusplus\n}\n#endif\n", NIL); Printf(f_header, "%s\n", magic); diff --git a/configure.ac b/configure.ac index 8073bfdb3..ed836205f 100644 --- a/configure.ac +++ b/configure.ac @@ -983,7 +983,7 @@ else # First figure out what the name of Perl5 is if test "x$PERLBIN" = xyes; then -AC_CHECK_PROGS(PERL, perl perl5.6.1 perl5.6.0 perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl) +AC_CHECK_PROGS(PERL, perl perl5) else PERL="$PERLBIN" fi -- cgit v1.2.1