Merge pull request #8523 from blue-devil/master

swig rebuild
This commit is contained in:
Blue DeviL
2020-05-19 00:31:27 +03:00
committed by GitHub
7 changed files with 2971 additions and 11 deletions
+7 -2
View File
@@ -4,21 +4,26 @@
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt
from pisi.actionsapi import get
from pisi.actionsapi import autotools
from pisi.actionsapi import pisitools
from pisi.actionsapi import shelltools
from pisi.actionsapi import get
def setup():
shelltools.system("sed -i 's/\$(PERL5_SCRIPT/-I. &/' Examples/Makefile.in")
shelltools.system("sed -i 's/\$command 2/-I. &/' Examples/test-suite/perl5/run-perl-test.pl")
autotools.configure("--without-clisp \
--without-maximum-compile-warnings")
#autotools.configure("--prefix=/usr")
def build():
autotools.make()
# too much dependency to test
#def check():
# shelltools.system("make check || warning 'Tests failed'")
def install():
autotools.rawInstall("DESTDIR=%s" % get.installDIR())
pisitools.dodoc("ANNOUNCE", "CHANGES*", "LICENSE", "README", "TODO")
pisitools.dodoc("LICENSE*", "README")
@@ -0,0 +1,453 @@
From 00e291b319bd6b58bf061feee3721a58c9c6be32 Mon Sep 17 00:00:00 2001
From: Thomas Reitmayr <treitmayr@devbase.at>
Date: Mon, 30 Dec 2019 20:11:03 +0100
Subject: [PATCH 1/3] Add support for Ruby 2.7
This commit fixes the signatures of various callback methods
and cleans up the macro definitions used for casting callbacks.
Note that the transparent version of the macro RUBY_METHOD_FUNC
is currently masked behind RUBY_DEVEL, see commit
https://github.com/ruby/ruby/commit/1d91feaf13e0ffe04b2dabc6e77e4101b6d0bb07
In order to still support strict signature checking and prevent
nasty deprecation warnings, the use of RUBY_METHOD_FUNC had to
be replaced with VALUEFUNC.
---
Lib/ruby/rubyclasses.swg | 14 +++++++-------
Lib/ruby/rubyhead.swg | 26 +++++++++-----------------
Lib/ruby/rubyprimtypes.swg | 15 ++++++++-------
Lib/ruby/rubytracking.swg | 10 +++++-----
Source/Modules/ruby.cxx | 22 +++++++++-------------
5 files changed, 38 insertions(+), 49 deletions(-)
diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg
index f7b51bdcc5..b345fcebeb 100644
--- a/Lib/ruby/rubyclasses.swg
+++ b/Lib/ruby/rubyclasses.swg
@@ -174,7 +174,7 @@ namespace swig {
return rb_inspect(_obj);
}
- static VALUE swig_rescue_swallow(VALUE)
+ static VALUE swig_rescue_swallow(VALUE, VALUE)
{
/*
VALUE errstr = rb_obj_as_string(rb_errinfo());
@@ -203,8 +203,8 @@ namespace swig {
args.id = op_id;
args.nargs = 1;
args.target = VALUE(other);
- ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
- (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
+ ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args),
+ (VALUEFUNC(swig_rescue_swallow)), Qnil);
}
if (ret == Qnil) {
VALUE a = rb_funcall( _obj, hash_id, 0 );
@@ -243,8 +243,8 @@ namespace swig {
args.id = op_id;
args.nargs = 0;
args.target = Qnil;
- ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
- (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
+ ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args),
+ (VALUEFUNC(swig_rescue_swallow)), Qnil);
SWIG_RUBY_THREAD_END_BLOCK;
return ret;
}
@@ -262,8 +262,8 @@ namespace swig {
args.id = op_id;
args.nargs = 1;
args.target = VALUE(other);
- ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
- (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
+ ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args),
+ (VALUEFUNC(swig_rescue_swallow)), Qnil);
SWIG_RUBY_THREAD_END_BLOCK;
return GC_VALUE(ret);
}
diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg
index 90f07cf683..9a0400eea9 100644
--- a/Lib/ruby/rubyhead.swg
+++ b/Lib/ruby/rubyhead.swg
@@ -110,26 +110,18 @@
* can be passed as an argument to API functions like Data_Wrap_Struct()
* and Data_Make_Struct().
*/
-
-#ifdef __cplusplus
-# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
-# define PROTECTFUNC(f) ((VALUE (*)()) f)
-# define VALUEFUNC(f) ((VALUE (*)()) f)
-# define VOIDFUNC(f) ((void (*)()) f)
-# else
-# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
-# define PROTECTFUNC(f) ((VALUE (*)()) f)
-# define VALUEFUNC(f) ((VALUE (*)()) f)
-# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
-# else /* These definitions should work for Ruby 1.7+ */
-# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
-# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
-# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
-# endif
-# endif
+#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL)
+# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
+# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
+# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
+# define VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f))
+# define INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f))
#else
+# define PROTECTFUNC(f) (f)
# define VALUEFUNC(f) (f)
# define VOIDFUNC(f) (f)
+# define VOID_ANYARGS_FUNC(f) (f)
+# define INT_ANYARGS_FUNC(f) (f)
#endif
/* Don't use for expressions have side effect */
diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg
index 3a848191cd..4b078deea0 100644
--- a/Lib/ruby/rubyprimtypes.swg
+++ b/Lib/ruby/rubyprimtypes.swg
@@ -10,15 +10,16 @@
%fragment("SWIG_ruby_failed","header")
{
SWIGINTERN VALUE
-SWIG_ruby_failed(void)
+SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
{
return Qnil;
}
}
%define %ruby_aux_method(Type, Method, Action)
-SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args)
+SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE arg)
{
+ VALUE *args = (VALUE *)arg;
VALUE obj = args[0];
VALUE type = TYPE(obj);
Type *res = (Type *)(args[1]);
@@ -79,7 +80,7 @@ SWIG_AsVal_dec(long)(VALUE obj, long* val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -111,7 +112,7 @@ SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -149,7 +150,7 @@ SWIG_AsVal_dec(long long)(VALUE obj, long long *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -187,7 +188,7 @@ SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -215,7 +216,7 @@ SWIG_AsVal_dec(double)(VALUE obj, double *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2DBL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg
index b9fb249d80..221a681939 100644
--- a/Lib/ruby/rubytracking.swg
+++ b/Lib/ruby/rubytracking.swg
@@ -32,7 +32,7 @@ extern "C" {
*/
static st_table* swig_ruby_trackings = NULL;
-static VALUE swig_ruby_trackings_count(ANYARGS) {
+static VALUE swig_ruby_trackings_count(ID id, VALUE *var) {
return SWIG2NUM(swig_ruby_trackings->num_entries);
}
@@ -69,7 +69,7 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value);
}
- rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL);
+ rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", VALUEFUNC(swig_ruby_trackings_count), VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
}
/* Add a Tracking from a C/C++ struct to a Ruby object */
@@ -118,13 +118,13 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
to the passed callback function. */
/* Proxy method to abstract the internal trackings datatype */
-static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) {
- (*meth)(ptr, obj);
+static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) {
+ ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj);
return ST_CONTINUE;
}
SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) {
- st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth);
+ st_foreach(swig_ruby_trackings, INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), (st_data_t)meth);
}
#ifdef __cplusplus
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index c8f582679b..01b75befa5 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2191,6 +2191,7 @@ class RUBY:public Language {
String *tm;
String *getfname, *setfname;
Wrapper *getf, *setf;
+ const int assignable = is_assignable(n);
// Determine whether virtual global variables shall be used
// which have different getter and setter signatures,
@@ -2206,7 +2207,7 @@ class RUBY:public Language {
getfname = Swig_name_wrapper(getname);
Setattr(n, "wrap:name", getfname);
Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL);
- Printf(getf->def, (use_virtual_var) ? "ID id" : "VALUE self");
+ Printf(getf->def, (use_virtual_var) ? "ID id, VALUE *data" : "VALUE self");
Printf(getf->def, ") {");
Wrapper_add_local(getf, "_val", "VALUE _val");
@@ -2229,8 +2230,8 @@ class RUBY:public Language {
Wrapper_print(getf, f_wrappers);
- if (!is_assignable(n)) {
- setfname = NewString("NULL");
+ if (!assignable) {
+ setfname = NewString("(rb_gvar_setter_t *)NULL");
} else {
/* create setter */
String* docs = docstring(n, AUTODOC_SETTER);
@@ -2242,7 +2243,7 @@ class RUBY:public Language {
Setattr(n, "wrap:name", setfname);
Printf(setf->def, "SWIGINTERN ");
if (use_virtual_var) {
- Printv(setf->def, "void\n", setfname, "(VALUE _val, ID id) {", NIL);
+ Printv(setf->def, "void\n", setfname, "(VALUE _val, ID id, VALUE *data) {", NIL);
} else {
Printv(setf->def, "VALUE\n", setfname, "(VALUE self, VALUE _val) {", NIL);
}
@@ -2273,7 +2274,7 @@ class RUBY:public Language {
if (CPlusPlus) {
Insert(getfname, 0, "VALUEFUNC(");
Append(getfname, ")");
- Insert(setfname, 0, (use_virtual_var) ? "(void (*)(ANYARGS))(" : "VALUEFUNC(");
+ Insert(setfname, 0, (use_virtual_var) ? "VOID_ANYARGS_FUNC(" : "VALUEFUNC(");
Append(setfname, ")");
}
@@ -2282,7 +2283,7 @@ class RUBY:public Language {
case STATIC_VAR:
/* C++ class variable */
Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"", klass->strip(iname), "\", ", getfname, ", 0);\n", NIL);
- if (!GetFlag(n, "feature:immutable")) {
+ if (assignable) {
Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"", klass->strip(iname), "=\", ", setfname, ", 1);\n", NIL);
}
Printv(klass->init, s, NIL);
@@ -2293,16 +2294,11 @@ class RUBY:public Language {
assert(current == NO_CPP);
if (!useGlobalModule) {
Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "\", ", getfname, ", 0);\n", NIL);
- if (!GetFlag(n, "feature:immutable")) {
+ if (assignable) {
Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "=\", ", setfname, ", 1);\n", NIL);
}
} else {
- Printv(s, tab4, "rb_define_virtual_variable(\"$", iname, "\", ", getfname, ", ", NIL);
- if (GetFlag(n, "feature:immutable")) {
- Printv(s, tab4, "0);\n", NIL);
- } else {
- Printv(s, tab4, setfname, ");\n", NIL);
- }
+ Printv(s, tab4, "rb_define_virtual_variable(\"$", iname, "\", ", getfname, ", ", setfname, ");\n", NIL);
}
Printv(f_init, s, NIL);
Delete(s);
From 5542cc228ad10bdc5c91107afb77c808c43bf2a4 Mon Sep 17 00:00:00 2001
From: Thomas Reitmayr <treitmayr@devbase.at>
Date: Fri, 3 Jan 2020 21:45:53 +0100
Subject: [PATCH 2/3] Move new macros for Ruby to their dedicated namespace
---
Lib/ruby/rubyhead.swg | 8 ++++----
Lib/ruby/rubytracking.swg | 8 ++++++--
Source/Modules/ruby.cxx | 2 +-
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg
index 9a0400eea9..89d6f14662 100644
--- a/Lib/ruby/rubyhead.swg
+++ b/Lib/ruby/rubyhead.swg
@@ -114,14 +114,14 @@
# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
-# define VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f))
-# define INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f))
+# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f))
+# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f))
#else
# define PROTECTFUNC(f) (f)
# define VALUEFUNC(f) (f)
# define VOIDFUNC(f) (f)
-# define VOID_ANYARGS_FUNC(f) (f)
-# define INT_ANYARGS_FUNC(f) (f)
+# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f)
+# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f)
#endif
/* Don't use for expressions have side effect */
diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg
index 221a681939..1edcc56819 100644
--- a/Lib/ruby/rubytracking.swg
+++ b/Lib/ruby/rubytracking.swg
@@ -69,7 +69,9 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value);
}
- rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", VALUEFUNC(swig_ruby_trackings_count), VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
+ rb_define_virtual_variable("SWIG_TRACKINGS_COUNT",
+ VALUEFUNC(swig_ruby_trackings_count),
+ SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
}
/* Add a Tracking from a C/C++ struct to a Ruby object */
@@ -124,7 +126,9 @@ static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_
}
SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) {
- st_foreach(swig_ruby_trackings, INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), (st_data_t)meth);
+ st_foreach(swig_ruby_trackings,
+ SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback),
+ (st_data_t)meth);
}
#ifdef __cplusplus
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index 01b75befa5..fcbcb7a5c1 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2274,7 +2274,7 @@ class RUBY:public Language {
if (CPlusPlus) {
Insert(getfname, 0, "VALUEFUNC(");
Append(getfname, ")");
- Insert(setfname, 0, (use_virtual_var) ? "VOID_ANYARGS_FUNC(" : "VALUEFUNC(");
+ Insert(setfname, 0, (use_virtual_var) ? "SWIG_RUBY_VOID_ANYARGS_FUNC(" : "VALUEFUNC(");
Append(setfname, ")");
}
From f5908eca7638b786acda58306ba96ff70094e98b Mon Sep 17 00:00:00 2001
From: Thomas Reitmayr <treitmayr@devbase.at>
Date: Sat, 4 Jan 2020 18:21:10 +0100
Subject: [PATCH 3/3] Improve description of cast macros for Ruby
The macros for casting function pointers are now fully described and also
clarify why the macros act transparently for C even before Ruby 2.7.
In addition, an "if (CPlusPlus)" was removed in the code generator for
global variables in order to keep the distinction between C and C++ in
one place, which is at the definition of said macros.
---
Lib/ruby/rubyhead.swg | 32 ++++++++++++++++++++++++--------
Source/Modules/ruby.cxx | 12 +++++-------
2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg
index 89d6f14662..bf4e36248e 100644
--- a/Lib/ruby/rubyhead.swg
+++ b/Lib/ruby/rubyhead.swg
@@ -98,17 +98,33 @@
/*
- * Need to be very careful about how these macros are defined, especially
- * when compiling C++ code or C code with an ANSI C compiler.
+ * The following macros are used for providing the correct type of a
+ * function pointer to the Ruby C API.
+ * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being
+ * defined) these macros act transparently due to Ruby's moving away from
+ * ANYARGS and instead employing strict function signatures.
*
- * VALUEFUNC(f) is a macro used to typecast a C function that implements
- * a Ruby method so that it can be passed as an argument to API functions
- * like rb_define_method() and rb_define_singleton_method().
+ * Note: In case of C (not C++) the macros are transparent even before
+ * Ruby 2.7 due to the fact that the Ruby C API used function declarators
+ * with empty parentheses, which allows for an unspecified number of
+ * arguments.
*
- * VOIDFUNC(f) is a macro used to typecast a C function that implements
- * either the "mark" or "free" stuff for a Ruby Data object, so that it
- * can be passed as an argument to API functions like Data_Wrap_Struct()
+ * PROTECTFUNC(f) is used for the function pointer argument of the Ruby
+ * C API function rb_protect().
+ *
+ * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API
+ * functions like rb_define_method() and rb_define_singleton_method().
+ *
+ * VOIDFUNC(f) is used to typecast a C function that implements either
+ * the "mark" or "free" stuff for a Ruby Data object, so that it can be
+ * passed as an argument to Ruby C API functions like Data_Wrap_Struct()
* and Data_Make_Struct().
+ *
+ * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer
+ * argument(s) of Ruby C API functions like rb_define_virtual_variable().
+ *
+ * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer
+ * argument(s) of Ruby C API functions like st_foreach().
*/
#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL)
# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index fcbcb7a5c1..48b0efab36 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2270,13 +2270,11 @@ class RUBY:public Language {
Delete(setname);
}
- /* define accessor method */
- if (CPlusPlus) {
- Insert(getfname, 0, "VALUEFUNC(");
- Append(getfname, ")");
- Insert(setfname, 0, (use_virtual_var) ? "SWIG_RUBY_VOID_ANYARGS_FUNC(" : "VALUEFUNC(");
- Append(setfname, ")");
- }
+ /* define accessor methods */
+ Insert(getfname, 0, "VALUEFUNC(");
+ Append(getfname, ")");
+ Insert(setfname, 0, (use_virtual_var) ? "SWIG_RUBY_VOID_ANYARGS_FUNC(" : "VALUEFUNC(");
+ Append(setfname, ")");
String *s = NewString("");
switch (current) {
@@ -0,0 +1,531 @@
From 18a3ef391121d7c4d819448c929721fd1708b40b Mon Sep 17 00:00:00 2001
From: Thomas Reitmayr <treitmayr@devbase.at>
Date: Sun, 27 Oct 2019 21:41:03 +0100
Subject: [PATCH] Fix code generated for Ruby global variables
This commit fixes swig#1653 by creating a Ruby virtual variable
for a C/c++ global variable when SWIG is invoked with the
-globalmodule option.
---
Doc/Manual/Ruby.html | 18 +++++++
Examples/test-suite/common.mk | 2 +
Examples/test-suite/global_immutable_vars.i | 24 +++++++++
.../test-suite/global_immutable_vars_cpp.i | 24 +++++++++
Examples/test-suite/ruby/Makefile.in | 4 ++
.../ruby/global_immutable_vars_cpp_runme.rb | 47 +++++++++++++++++
.../ruby/global_immutable_vars_runme.rb | 51 +++++++++++++++++++
.../ruby_global_immutable_vars_cpp_runme.rb | 47 +++++++++++++++++
.../ruby/ruby_global_immutable_vars_runme.rb | 51 +++++++++++++++++++
.../test-suite/ruby_global_immutable_vars.i | 25 +++++++++
.../ruby_global_immutable_vars_cpp.i | 23 +++++++++
Source/Modules/ruby.cxx | 36 +++++++++----
12 files changed, 342 insertions(+), 10 deletions(-)
create mode 100644 Examples/test-suite/global_immutable_vars.i
create mode 100644 Examples/test-suite/global_immutable_vars_cpp.i
create mode 100644 Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb
create mode 100644 Examples/test-suite/ruby/global_immutable_vars_runme.rb
create mode 100644 Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb
create mode 100644 Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb
create mode 100644 Examples/test-suite/ruby_global_immutable_vars.i
create mode 100644 Examples/test-suite/ruby_global_immutable_vars_cpp.i
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index 3cfd1292ca..6939a8a186 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -615,6 +615,24 @@ <H3><a name="Ruby_nn14">34.3.3 Variable Linking</a></H3>
effect until it is explicitly disabled using <tt>%mutable</tt>.
</p>
+<p>Note: When SWIG is invoked with the <tt>-globalmodule</tt> option in
+effect, the C/C++ global variables will be translated into Ruby global
+variables. Type-checking and the optional read-only characteristic are
+available in the same way as described above. However the example would
+then have to be modified and executed in the following way:
+
+<div class="code targetlang">
+<pre>$ <b>irb</b>
+irb(main):001:0&gt; <b>require 'Example'</b>
+true
+irb(main):002:0&gt; <b>$variable1 = 2</b>
+2
+irb(main):003:0&gt; <b>$Variable2 = 4 * 10.3</b>
+41.2
+irb(main):004:0&gt; <b>$Variable2</b>
+41.2</pre>
+</div>
+
<H3><a name="Ruby_nn15">34.3.4 Constants</a></H3>
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 5f77928102..008916a561 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -250,6 +250,7 @@ CPP_TEST_CASES += \
funcptr_cpp \
functors \
fvirtual \
+ global_immutable_vars_cpp \
global_namespace \
global_ns_arg \
global_scope_types \
@@ -689,6 +690,7 @@ C_TEST_CASES += \
funcptr \
function_typedef \
global_functions \
+ global_immutable_vars \
immutable_values \
inctest \
infinity \
diff --git a/Examples/test-suite/global_immutable_vars.i b/Examples/test-suite/global_immutable_vars.i
new file mode 100644
index 0000000000..cd8cb184ba
--- /dev/null
+++ b/Examples/test-suite/global_immutable_vars.i
@@ -0,0 +1,24 @@
+%module global_immutable_vars
+
+// Test immutable and mutable global variables,
+// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+%}
+
diff --git a/Examples/test-suite/global_immutable_vars_cpp.i b/Examples/test-suite/global_immutable_vars_cpp.i
new file mode 100644
index 0000000000..66eb8545d2
--- /dev/null
+++ b/Examples/test-suite/global_immutable_vars_cpp.i
@@ -0,0 +1,24 @@
+%module global_immutable_vars_cpp
+
+// Test immutable and mutable global variables,
+// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+%}
+
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index d75cdb0587..2c59029ec0 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -23,6 +23,7 @@ CPP_TEST_CASES = \
li_std_wstring_inherit \
primitive_types \
ruby_alias_method \
+ ruby_global_immutable_vars_cpp \
ruby_keywords \
ruby_minherit_shared_ptr \
ruby_naming \
@@ -48,6 +49,7 @@ C_TEST_CASES += \
li_cstring \
ruby_alias_global_function \
ruby_alias_module_function \
+ ruby_global_immutable_vars \
ruby_manual_proxy \
include $(srcdir)/../common.mk
@@ -57,6 +59,8 @@ SWIGOPT += -w801 -noautorename -features autodoc=4
# Custom tests - tests with additional commandline options
ruby_alias_global_function.ctest: SWIGOPT += -globalmodule
+ruby_global_immutable_vars.ctest: SWIGOPT += -globalmodule
+ruby_global_immutable_vars_cpp.cpptest: SWIGOPT += -globalmodule
ruby_naming.cpptest: SWIGOPT += -autorename
# Rules for the different types of tests
diff --git a/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb
new file mode 100644
index 0000000000..c40896a867
--- /dev/null
+++ b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+#
+# C++ version of global_immutable_vars_runme.rb
+#
+
+require 'swig_assert'
+
+require 'global_immutable_vars_cpp'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+Global_immutable_vars_cpp::default_mutable_var == 40
+Global_immutable_vars_cpp::global_immutable_var == 41
+Global_immutable_vars_cpp::specific_mutable_var == 42
+Global_immutable_vars_cpp::global_mutable_var == 43
+Global_immutable_vars_cpp::specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+Global_immutable_vars_cpp::default_mutable_var = 80
+Global_immutable_vars_cpp::default_mutable_var == 80
+Global_immutable_vars_cpp::specific_mutable_var = 82
+Global_immutable_vars_cpp::specific_mutable_var == 82
+Global_immutable_vars_cpp::global_mutable_var = 83
+Global_immutable_vars_cpp::global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ Global_immutable_vars_cpp::global_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars_cpp::global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ Global_immutable_vars_cpp::specific_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars_cpp::specific_immutable_var is writable (expected to be immutable)")
+
diff --git a/Examples/test-suite/ruby/global_immutable_vars_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_runme.rb
new file mode 100644
index 0000000000..af55cfeb34
--- /dev/null
+++ b/Examples/test-suite/ruby/global_immutable_vars_runme.rb
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+#
+# Here the proper generation of mutable and immutable variables is tested
+# in the target language.
+# Immutable variables do not have "<var>=" methods generated by SWIG,
+# therefore trying to assign these variables shall throw a NoMethodError
+# exception.
+#
+
+require 'swig_assert'
+
+require 'global_immutable_vars'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+Global_immutable_vars::default_mutable_var == 40
+Global_immutable_vars::global_immutable_var == 41
+Global_immutable_vars::specific_mutable_var == 42
+Global_immutable_vars::global_mutable_var == 43
+Global_immutable_vars::specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+Global_immutable_vars::default_mutable_var = 80
+Global_immutable_vars::default_mutable_var == 80
+Global_immutable_vars::specific_mutable_var = 82
+Global_immutable_vars::specific_mutable_var == 82
+Global_immutable_vars::global_mutable_var = 83
+Global_immutable_vars::global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ Global_immutable_vars::global_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars::global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ Global_immutable_vars::specific_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars::specific_immutable_var is writable (expected to be immutable)")
+
diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb
new file mode 100644
index 0000000000..8453254eb3
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+#
+# C++ version of ruby_global_immutable_vars_runme.rb.
+#
+
+require 'swig_assert'
+
+require 'ruby_global_immutable_vars_cpp'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+$default_mutable_var == 40
+$global_immutable_var == 41
+$specific_mutable_var == 42
+$global_mutable_var == 43
+$specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+$default_mutable_var = 80
+$default_mutable_var == 80
+$specific_mutable_var = 82
+$specific_mutable_var == 82
+$global_mutable_var = 83
+$global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ $global_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ $specific_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$specific_immutable_var is writable (expected to be immutable)")
+
diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb
new file mode 100644
index 0000000000..fda1ccf0f0
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+#
+# This test program is similar to global_immutable_vars_runme.rb
+# with the difference that the global variables to check are also
+# Ruby global variables (SWIG Ruby option "-globalmodule").
+#
+# Immutable global variables shall throw a NameError exception.
+#
+
+require 'swig_assert'
+
+require 'ruby_global_immutable_vars'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+$default_mutable_var == 40
+$global_immutable_var == 41
+$specific_mutable_var == 42
+$global_mutable_var == 43
+$specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+$default_mutable_var = 80
+$default_mutable_var == 80
+$specific_mutable_var = 82
+$specific_mutable_var == 82
+$global_mutable_var = 83
+$global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ $global_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ $specific_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$specific_immutable_var is writable (expected to be immutable)")
+
diff --git a/Examples/test-suite/ruby_global_immutable_vars.i b/Examples/test-suite/ruby_global_immutable_vars.i
new file mode 100644
index 0000000000..dc49cd9467
--- /dev/null
+++ b/Examples/test-suite/ruby_global_immutable_vars.i
@@ -0,0 +1,25 @@
+%module ruby_global_immutable_vars
+
+// This copy of global_immutable_vars.i shall be compiled with the
+// SWIG Ruby option "-globalmodule" in order to check the code path
+// for registering global methods (in contrast to module methods).
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+%}
+
diff --git a/Examples/test-suite/ruby_global_immutable_vars_cpp.i b/Examples/test-suite/ruby_global_immutable_vars_cpp.i
new file mode 100644
index 0000000000..cf3145e801
--- /dev/null
+++ b/Examples/test-suite/ruby_global_immutable_vars_cpp.i
@@ -0,0 +1,23 @@
+%module ruby_global_immutable_vars_cpp
+
+// C++ version of ruby_global_immutable_vars.i
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+%}
+
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index 6a1e16d5da..c8f582679b 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2192,6 +2192,11 @@ class RUBY:public Language {
String *getfname, *setfname;
Wrapper *getf, *setf;
+ // Determine whether virtual global variables shall be used
+ // which have different getter and setter signatures,
+ // see https://docs.ruby-lang.org/en/2.6.0/extension_rdoc.html#label-Global+Variables+Shared+Between+C+and+Ruby
+ const bool use_virtual_var = (current == NO_CPP && useGlobalModule);
+
getf = NewWrapper();
setf = NewWrapper();
@@ -2201,7 +2206,7 @@ class RUBY:public Language {
getfname = Swig_name_wrapper(getname);
Setattr(n, "wrap:name", getfname);
Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL);
- Printf(getf->def, "VALUE self");
+ Printf(getf->def, (use_virtual_var) ? "ID id" : "VALUE self");
Printf(getf->def, ") {");
Wrapper_add_local(getf, "_val", "VALUE _val");
@@ -2235,8 +2240,12 @@ class RUBY:public Language {
String *setname = Swig_name_set(NSPACE_TODO, iname);
setfname = Swig_name_wrapper(setname);
Setattr(n, "wrap:name", setfname);
- Printv(setf->def, "SWIGINTERN VALUE\n", setfname, "(VALUE self, ", NIL);
- Printf(setf->def, "VALUE _val) {");
+ Printf(setf->def, "SWIGINTERN ");
+ if (use_virtual_var) {
+ Printv(setf->def, "void\n", setfname, "(VALUE _val, ID id) {", NIL);
+ } else {
+ Printv(setf->def, "VALUE\n", setfname, "(VALUE self, VALUE _val) {", NIL);
+ }
tm = Swig_typemap_lookup("varin", n, name, 0);
if (tm) {
Replaceall(tm, "$input", "_val");
@@ -2247,9 +2256,14 @@ class RUBY:public Language {
} else {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s\n", SwigType_str(t, 0));
}
- Printv(setf->code, tab4, "return _val;\n", NIL);
- Printf(setf->code, "fail:\n");
- Printv(setf->code, tab4, "return Qnil;\n", NIL);
+ if (use_virtual_var) {
+ Printf(setf->code, "fail:\n");
+ Printv(setf->code, tab4, "return;\n", NIL);
+ } else {
+ Printv(setf->code, tab4, "return _val;\n", NIL);
+ Printf(setf->code, "fail:\n");
+ Printv(setf->code, tab4, "return Qnil;\n", NIL);
+ }
Printf(setf->code, "}\n");
Wrapper_print(setf, f_wrappers);
Delete(setname);
@@ -2259,7 +2273,7 @@ class RUBY:public Language {
if (CPlusPlus) {
Insert(getfname, 0, "VALUEFUNC(");
Append(getfname, ")");
- Insert(setfname, 0, "VALUEFUNC(");
+ Insert(setfname, 0, (use_virtual_var) ? "(void (*)(ANYARGS))(" : "VALUEFUNC(");
Append(setfname, ")");
}
@@ -2283,9 +2297,11 @@ class RUBY:public Language {
Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "=\", ", setfname, ", 1);\n", NIL);
}
} else {
- Printv(s, tab4, "rb_define_global_method(\"", iname, "\", ", getfname, ", 0);\n", NIL);
- if (!GetFlag(n, "feature:immutable")) {
- Printv(s, tab4, "rb_define_global_method(\"", iname, "=\", ", setfname, ", 1);\n", NIL);
+ Printv(s, tab4, "rb_define_virtual_variable(\"$", iname, "\", ", getfname, ", ", NIL);
+ if (GetFlag(n, "feature:immutable")) {
+ Printv(s, tab4, "0);\n", NIL);
+ } else {
+ Printv(s, tab4, setfname, ");\n", NIL);
}
}
Printv(f_init, s, NIL);
@@ -0,0 +1,88 @@
From e14532ce52a654768cc4010e9e18e1a0a4d965db Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vz-swig@zeitlins.org>
Date: Sat, 25 Jan 2020 17:06:20 +0100
Subject: [PATCH] Fix crash in Python backend when using empty docstrings
Due to confusion in build_combined_docstring(), we could call
DohDelete() on the "feature:docstring" string, which resulted in a crash
when trying to use it later.
Fix this and simplify the code at the same time by ensuring that we
always use a copy of "feature:docstring" if it's not empty or don't use
it at all if it's empty -- like this we don't have to check for its
length each time before using it.
Closes #1648.
---
Examples/test-suite/autodoc.i | 9 +++++++++
Examples/test-suite/python/autodoc_runme.py | 2 ++
Source/Modules/python.cxx | 15 +++++++++++----
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i
index 9f4365ee1c..efc7201553 100644
--- a/Examples/test-suite/autodoc.i
+++ b/Examples/test-suite/autodoc.i
@@ -183,3 +183,12 @@ const int PROCESS_DEFAULT_VALUE = 17;
typedef long int some_type;
int process_complex_defval(int val = PROCESS_DEFAULT_VALUE, int factor = some_type(-1)) { return val*factor; }
%}
+
+// Test for empty docstring, which should be ignored.
+%feature("docstring") ""
+
+%inline %{
+struct a_structure{
+ char my_array[1];
+};
+%}
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index 6002d49fec..7bc918644d 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -279,3 +279,5 @@ def check(got, expected, expected_builtin=None, skip=False):
check(inspect.getdoc(process4), "process4(int _from=0, int _in=1, int var=2) -> int")
check(inspect.getdoc(process_complex_defval), "process_complex_defval(val=PROCESS_DEFAULT_VALUE, factor=some_type(-1)) -> int")
+
+check(inspect.getdoc(a_structure.__init__), "__init__(a_structure self) -> a_structure", None, skip)
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 1dbedad26a..f6b47be244 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -1484,8 +1484,15 @@ class PYTHON:public Language {
String *build_combined_docstring(Node *n, autodoc_t ad_type, const String *indent = "", bool low_level = false) {
String *docstr = Getattr(n, "feature:docstring");
- if (docstr && Len(docstr)) {
- docstr = Copy(docstr);
+ if (docstr) {
+ // Simplify the code below by just ignoring empty docstrings.
+ if (!Len(docstr))
+ docstr = NULL;
+ else
+ docstr = Copy(docstr);
+ }
+
+ if (docstr) {
char *t = Char(docstr);
if (*t == '{') {
Delitem(docstr, 0);
@@ -1496,7 +1503,7 @@ class PYTHON:public Language {
if (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) {
String *autodoc = make_autodoc(n, ad_type, low_level);
if (autodoc && Len(autodoc) > 0) {
- if (docstr && Len(docstr)) {
+ if (docstr) {
Append(autodoc, "\n");
Append(autodoc, docstr);
}
@@ -1509,7 +1516,7 @@ class PYTHON:public Language {
Delete(autodoc);
}
- if (!docstr || !Len(docstr)) {
+ if (!docstr) {
if (doxygen) {
docstr = Getattr(n, "python:docstring");
if (!docstr && doxygenTranslator->hasDocumentation(n)) {
File diff suppressed because it is too large Load Diff
+28 -8
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<!DOCTYPE PISI SYSTEM "https://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
<Source>
<Name>swig</Name>
@@ -8,39 +8,59 @@
<Name>PisiLinux Community</Name>
<Email>admins@pisilinux.org</Email>
</Packager>
<PartOf>programming.library</PartOf>
<License>GPLv3+</License>
<License>BSD</License>
<IsA>app:console</IsA>
<IsA>library</IsA>
<Summary>Connects C/C++/Objective C to some high-level programming languages</Summary>
<Description>Simplified Wrapper and Interface Generator, SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of languages including common scripting languages such as Perl, PHP, Python, Tcl, Ruby and PHP</Description>
<Archive sha1sum="3915d3ab537c171d6d086a8e93bfc545cebf6172" type="targz">mirrors://sourceforge/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz</Archive>
<BuildDependencies>
<Dependency>python3-devel</Dependency>
<Dependency>boost-devel</Dependency>
<Dependency>ruby-devel</Dependency>
<Dependency>libpcre-devel</Dependency>
<Dependency>zlib-devel</Dependency>
<Dependency>perl</Dependency>
<Dependency>zlib-devel</Dependency>
<Dependency>ruby-devel</Dependency>
<Dependency>boost-devel</Dependency>
<Dependency>libpcre-devel</Dependency>
<Dependency>python3-devel</Dependency>
</BuildDependencies>
<Patches>
<!-- Fix code generated for Ruby global variables https://github.com/swig/swig/issues/1668 -->
<Patch>swig-4.0.1-Fix-code-generated-for-Ruby-global-variables.patch</Patch>
<!-- Add support for Ruby 2.7 https://github.com/swig/swig/pull/1692 -->
<Patch>swig-4.0.1-Add-support-for-Ruby-2.7.patch</Patch>
<!-- Fix crash in Python backend when using empty docstrings https://github.com/swig/swig/pull/1710 -->
<Patch>swig-4.0.1-Fix-crash-in-Python-backend-when-using-empty-docstrings.patch</Patch>
<!-- Upgrade SWIG to support NodeJS v12 / V8 v7.6, v8 v7.8 runtime https://github.com/swig/swig/pull/1702 -->
<Patch>swig-Upgrade-to-support-newer-NodeJS.patch</Patch>
</Patches>
</Source>
<Package>
<Name>swig</Name>
<Summary>Connects C/C++/Objective C to some high-level programming languages</Summary>
<RuntimeDependencies>
<Dependency>zlib</Dependency>
<Dependency>libgcc</Dependency>
<Dependency>libpcre</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="executable">/usr/bin</Path>
<Path fileType="library">/usr/lib</Path>
<Path fileType="data">/usr/share/swig</Path>
<Path fileType="doc">/usr/share/doc</Path>
<Path fileType="man">/usr/share/man</Path>
<Path fileType="executable">/usr/bin</Path>
<Path fileType="data">/usr/share/swig</Path>
</Files>
</Package>
<History>
<Update release="7">
<Date>2020-05-18</Date>
<Version>4.0.1</Version>
<Comment>Rebuild due to new ruby version</Comment>
<Name>Blue Devil</Name>
<Email>bluedevil@sctzine.com</Email>
</Update>
<Update release="6">
<Date>2020-01-09</Date>
<Version>4.0.1</Version>
+1 -1
View File
@@ -6,4 +6,4 @@
<Description xml:lang="tr">SWIG, C ve C++ ile yazılmış uygulamaları çeşitli üst düzey programlama dilleri ile bağlayan bir yazılım geliştirme aracıdır. SWIG, genel betik dilleri olan Perl, PHP, Python, Tcl, Ruby gibi farklı diller ile kullanılır.</Description>
<Description xml:lang="fr">Simplified Wrapper and Interface Generator (Générateur d'interface de scripts d'enrobage simplifié), SWIG est un outil de développement qui connecte des programmes écrits en C et C++ avec divers langages de programmation de haut niveau. SWIG est utilisé avec différents type de langages incluant les langages de script habituels tels que Perl, PHP, Python, Tcl, Ruby.</Description>
</Source>
</PISI>
</PISI>