From cd70bea9a0d686686d21960d08011a2db3fd9675 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 29 Jun 2021 23:32:36 +0200 Subject: [PATCH] Basic enabling of Ruby 3 --- src/klayout.pri | 3 +++ src/rba/rba/rbaConvert.cc | 2 +- testdata/ruby/basic_testcore.rb | 20 ++++++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/klayout.pri b/src/klayout.pri index 550c0cba7..b03d5f7ea 100644 --- a/src/klayout.pri +++ b/src/klayout.pri @@ -154,6 +154,9 @@ msvc { # because we use unordered_map/unordered_set: QMAKE_CXXFLAGS += -std=c++0x + # needed for Ruby 3.0 + QMAKE_CXXFLAGS += -fdeclspec + win32 { QMAKE_LFLAGS += -Wl,--exclude-all-symbols } else { diff --git a/src/rba/rba/rbaConvert.cc b/src/rba/rba/rbaConvert.cc index 6ac1a7877..17673a91a 100644 --- a/src/rba/rba/rbaConvert.cc +++ b/src/rba/rba/rbaConvert.cc @@ -224,7 +224,7 @@ object_to_ruby (void *obj, Proxy *self, const gsi::ClassBase *cls, bool pass_obj // a Ruby object. If it already has, we simply return a reference to this. ret = rba_data->self (); -#if HAVE_RUBY_VERSION_CODE >= 20200 +#if HAVE_RUBY_VERSION_CODE >= 20200 && HAVE_RUBY_VERSION_CODE < 30000 // Mark the returned object - the original one may have been already // scheduled for sweeping. This happens at least for Ruby 2.3 which // has a two-phase GC (mark and sweep in separate steps). If by chance diff --git a/testdata/ruby/basic_testcore.rb b/testdata/ruby/basic_testcore.rb index 008a064d7..ab32c9156 100644 --- a/testdata/ruby/basic_testcore.rb +++ b/testdata/ruby/basic_testcore.rb @@ -894,8 +894,10 @@ class Basic_TestClass < TestBase end - # TODO: this class is going to be deprecated - class X < Data + if RUBY_VERSION < "3.0.0" + # TODO: this class is going to be deprecated + class X < Data + end end class Y < Object end @@ -907,12 +909,14 @@ class Basic_TestClass < TestBase end # Test, if this throws an error (object of class X passed to A argument): - begin - b = RBA::B.new - assert_equal( b.b4( X.new ), "b4_result: -6" ) - assert_equal( false, true ) # this must never hit - rescue - assert_equal( $!.to_s(), "allocator undefined for Basic_TestClass::X" ); + if RUBY_VERSION < "3.0.0" + begin + b = RBA::B.new + assert_equal( b.b4( X.new ), "b4_result: -6" ) + assert_equal( false, true ) # this must never hit + rescue + assert_equal( $!.to_s(), "allocator undefined for Basic_TestClass::X" ); + end end # Test, if this throws an error (object of class X passed to A argument):