Skip to content

Commit 13e12d3

Browse files
committed
[GR-19220] Implement rb_define_class_id, rb_module_new and rb_define_module_id (#1876).
PullRequest: truffleruby/1235
2 parents 1505aee + e7501ce commit 13e12d3

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Compatibility:
7575
* Include the major kernel version in `RUBY_PLATFORM` on macOS like MRI (#1860, @eightbitraptor).
7676
* Implemented `Enumerator::Chain`, `Enumerator#+`, and `Enumerable#chain` (#1859, #1858).
7777
* Implemented `Thread#backtrace_locations` and `Exception#backtrace_locations` (#1556).
78+
* Implemented `rb_module_new`, `rb_define_class_id`, `rb_define_module_id`, (#1876, @chrisseaton).
7879

7980
Performance:
8081

lib/truffle/truffle/cext.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,10 @@ def rb_block_call(object, method, args, func, data)
15241524
end
15251525
end
15261526

1527+
def rb_module_new
1528+
Module.new
1529+
end
1530+
15271531
def rb_ensure(b_proc, data1, e_proc, data2)
15281532
begin
15291533
TrufflePrimitive.cext_unwrap(TrufflePrimitive.call_with_c_mutex(b_proc, [data1]))

src/main/c/cext/ruby.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3532,15 +3532,20 @@ VALUE rb_class_inherited(VALUE super, VALUE klass) {
35323532
}
35333533

35343534
VALUE rb_define_class_id(ID id, VALUE super) {
3535-
rb_tr_error("rb_define_class_id not implemented");
3535+
// id is deliberately ignored - see MRI
3536+
if (super == NULL) {
3537+
super = rb_cObject;
3538+
}
3539+
return rb_class_new(super);
35363540
}
35373541

35383542
VALUE rb_module_new(void) {
3539-
rb_tr_error("rb_module_new not implemented");
3543+
return RUBY_CEXT_INVOKE("rb_module_new");
35403544
}
35413545

35423546
VALUE rb_define_module_id(ID id) {
3543-
rb_tr_error("rb_define_module_id not implemented");
3547+
// id is deliberately ignored - see MRI
3548+
return rb_module_new();
35443549
}
35453550

35463551
VALUE rb_define_module_id_under(VALUE outer, ID id) {

0 commit comments

Comments
 (0)