aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Marc-Antoine Perennou <Marc-Antoine@Perennou.com> 2021-02-15 10:31:20 +0100
committerAvatar Heiko Becker <heirecka@exherbo.org> 2021-06-16 20:46:02 +0000
commit0a26d11172817958eb3b5180aa00b714d3744db4 (patch)
treeba1be510ed37ef14eae90ba5afcc5dec1972f486
parent243b1c1c59c08b460342e30f409e18010b421802 (diff)
downloadpaludis-0a26d11172817958eb3b5180aa00b714d3744db4.tar.gz
paludis-0a26d11172817958eb3b5180aa00b714d3744db4.tar.xz
ruby: fix namespace clash with ruby 3.0
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
-rw-r--r--ruby/paludis_ruby.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 2b243d053..fcd585a73 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -42,6 +42,17 @@
#include <paludis/util/hashes.hh>
#include <ruby.h>
+#include <ruby/version.h>
+
+#if RUBY_API_VERSION_CODE >= 30000
+// Ruby 3.0 uses "ruby" instead of "::ruby" which clashes with our ruby namespace
+#undef rb_define_method
+#define rb_define_method(klass, mid, func, arity) ::ruby::backward::cxxanyargs::define_method::rb_define_method::specific<arity>::define(klass, mid, func)
+#undef rb_define_singleton_method
+#define rb_define_singleton_method(klass, mid, func, arity) ::ruby::backward::cxxanyargs::define_method::rb_define_singleton_method::specific<arity>::define(klass, mid, func)
+#undef rb_define_module_function
+#define rb_define_module_function(klass, mid, func, arity) ::ruby::backward::cxxanyargs::define_method::rb_define_module_function::specific<arity>::define(klass, mid, func)
+#endif
#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
#define RDOC_IS_STUPID(x, y) RUBY_FUNC_CAST((y))