From b37527a106050fc1aae687dae351de15313868a8 Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Mon, 1 Apr 2024 17:46:47 +0300 Subject: [PATCH] Add rb_class_get_superclass function --- lib/cext/ABI_check.txt | 2 +- lib/truffle/truffle/cext.rb | 4 ++++ src/main/c/cext/class.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cext/ABI_check.txt b/lib/cext/ABI_check.txt index b6a7d89c68e0..98d9bcb75a68 100644 --- a/lib/cext/ABI_check.txt +++ b/lib/cext/ABI_check.txt @@ -1 +1 @@ -16 +17 diff --git a/lib/truffle/truffle/cext.rb b/lib/truffle/truffle/cext.rb index 8cd2a3c01583..2b19e6332641 100644 --- a/lib/truffle/truffle/cext.rb +++ b/lib/truffle/truffle/cext.rb @@ -603,6 +603,10 @@ def rb_class_real(ruby_class) ruby_class end + def rb_class_get_superclass(ruby_class) + ruby_class.superclass || false + end + def rb_obj_respond_to(object, name, priv) object.respond_to?(name, priv != 0) end diff --git a/src/main/c/cext/class.c b/src/main/c/cext/class.c index ee23e0d1a8e3..33317b067878 100644 --- a/src/main/c/cext/class.c +++ b/src/main/c/cext/class.c @@ -51,6 +51,10 @@ VALUE rb_singleton_class(VALUE object) { return RUBY_CEXT_INVOKE("rb_singleton_class", object); } +VALUE rb_class_get_superclass(VALUE klass) { + return RUBY_CEXT_INVOKE("rb_class_get_superclass", klass); +} + VALUE rb_obj_alloc(VALUE ruby_class) { return RUBY_INVOKE(ruby_class, "__allocate__"); }