Skip to content

Commit 7d5f560

Browse files
committed
[GR-18163] Pass all Struct C-API specs
PullRequest: truffleruby/3483
2 parents 16c74eb + 483274e commit 7d5f560

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

lib/cext/ABI_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11
1+
12

lib/truffle/truffle/cext.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,10 @@ def rb_struct_aset(struct, index, value)
16251625
struct[index] = value
16261626
end
16271627

1628+
def rb_struct_getmember(struct, member)
1629+
struct[member]
1630+
end
1631+
16281632
def rb_struct_size(klass)
16291633
klass.members.size
16301634
end

spec/tags/optional/capi/struct_tags.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/c/cext/struct.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ VALUE rb_struct_aset(VALUE s, VALUE idx, VALUE val) {
1919
return RUBY_CEXT_INVOKE("rb_struct_aset", s, idx, val);
2020
}
2121

22+
VALUE rb_struct_getmember(VALUE s, ID member) {
23+
return RUBY_CEXT_INVOKE("rb_struct_getmember", s, ID2SYM(member));
24+
}
25+
2226
VALUE rb_struct_define(const char *name, ...) {
2327
VALUE rb_name = name == NULL ? Qnil : rb_str_new_cstr(name);
2428
VALUE ary = rb_ary_new();
@@ -65,11 +69,11 @@ VALUE rb_struct_new(VALUE klass, ...) {
6569
}
6670

6771
VALUE rb_struct_s_members(VALUE klass) {
68-
return RUBY_INVOKE(klass, "rb_struct_s_members");
72+
return RUBY_INVOKE(klass, "members");
6973
}
7074

7175
VALUE rb_struct_members(VALUE s) {
72-
return RUBY_INVOKE(s, "rb_struct_members");
76+
return RUBY_INVOKE(s, "members");
7377
}
7478

7579
VALUE rb_struct_size(VALUE s) {

0 commit comments

Comments
 (0)