Skip to content

Commit cef7fe0

Browse files
XrXrchrisseaton
authored andcommitted
Implement rb_define_class_id, rb_module_new and rb_define_module_id
No specs cause these are fairly trivial.
1 parent f0c3d6a commit cef7fe0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3524,15 +3524,18 @@ VALUE rb_class_inherited(VALUE super, VALUE klass) {
35243524
}
35253525

35263526
VALUE rb_define_class_id(ID id, VALUE super) {
3527-
rb_tr_error("rb_define_class_id not implemented");
3527+
if (super == NULL) {
3528+
super = rb_cObject;
3529+
}
3530+
return rb_class_new(super);
35283531
}
35293532

35303533
VALUE rb_module_new(void) {
3531-
rb_tr_error("rb_module_new not implemented");
3534+
return RUBY_CEXT_INVOKE("rb_module_new");
35323535
}
35333536

35343537
VALUE rb_define_module_id(ID id) {
3535-
rb_tr_error("rb_define_module_id not implemented");
3538+
return rb_module_new();
35363539
}
35373540

35383541
VALUE rb_define_module_id_under(VALUE outer, ID id) {

0 commit comments

Comments
 (0)