summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/ext
diff options
context:
space:
mode:
authorAndrew Konchin <[email protected]>2025-01-30 17:39:10 +0200
committerBenoit Daloze <[email protected]>2025-01-30 20:43:46 +0100
commitd7a5ad2a21f7d2c45e3fea674ff077bb0e2cadae ()
treed49629b969bb4d13b74fd1bfeebf15553cc3d5d2 /spec/ruby/optional/capi/ext
parentea2dd5b80e26036af83e7b37d722f4a106188555 (diff)
Update to ruby/spec@affef93
Notes: Merged: https://.com/ruby/ruby/pull/12679
-rw-r--r--spec/ruby/optional/capi/ext/finalizer_spec.c31
-rw-r--r--spec/ruby/optional/capi/ext/io_spec.c14
-rw-r--r--spec/ruby/optional/capi/ext/struct_spec.c28
3 files changed, 61 insertions, 12 deletions
@@ -0,0 +1,31 @@
@@ -377,16 +377,14 @@ static VALUE io_spec_rb_io_closed_p(VALUE self, VALUE io) {
}
static VALUE io_spec_rb_io_open_descriptor(VALUE self, VALUE klass, VALUE descriptor, VALUE mode, VALUE path, VALUE timeout, VALUE internal_encoding, VALUE external_encoding, VALUE ecflags, VALUE ecopts) {
- struct rb_io_encoding *io_encoding;
- io_encoding = (struct rb_io_encoding *) malloc(sizeof(struct rb_io_encoding));
- io_encoding->enc = rb_to_encoding(internal_encoding);
- io_encoding->enc2 = rb_to_encoding(external_encoding);
- io_encoding->ecflags = FIX2INT(ecflags);
- io_encoding->ecopts = ecopts;
-
- return rb_io_open_descriptor(klass, FIX2INT(descriptor), FIX2INT(mode), path, timeout, io_encoding);
}
static VALUE io_spec_rb_io_open_descriptor_without_encoding(VALUE self, VALUE klass, VALUE descriptor, VALUE mode, VALUE path, VALUE timeout) {
@@ -28,7 +28,7 @@ static VALUE struct_spec_rb_struct_aset(VALUE self, VALUE st, VALUE key, VALUE v
}
/* Only allow setting three attributes, should be sufficient for testing. */
-static VALUE struct_spec_struct_define(VALUE self, VALUE name,
VALUE attr1, VALUE attr2, VALUE attr3) {
const char *a1 = StringValuePtr(attr1);
@@ -42,7 +42,7 @@ static VALUE struct_spec_struct_define(VALUE self, VALUE name,
}
/* Only allow setting three attributes, should be sufficient for testing. */
-static VALUE struct_spec_struct_define_under(VALUE self, VALUE outer,
VALUE name, VALUE attr1, VALUE attr2, VALUE attr3) {
const char *nm = StringValuePtr(name);
@@ -62,6 +62,23 @@ static VALUE struct_spec_rb_struct_size(VALUE self, VALUE st) {
return rb_struct_size(st);
}
void Init_struct_spec(void) {
VALUE cls = rb_define_class("CApiStructSpecs", rb_cObject);
rb_define_method(cls, "rb_struct_aref", struct_spec_rb_struct_aref, 2);
@@ -69,10 +86,13 @@ void Init_struct_spec(void) {
rb_define_method(cls, "rb_struct_s_members", struct_spec_rb_struct_s_members, 1);
rb_define_method(cls, "rb_struct_members", struct_spec_rb_struct_members, 1);
rb_define_method(cls, "rb_struct_aset", struct_spec_rb_struct_aset, 3);
- rb_define_method(cls, "rb_struct_define", struct_spec_struct_define, 4);
- rb_define_method(cls, "rb_struct_define_under", struct_spec_struct_define_under, 5);
rb_define_method(cls, "rb_struct_new", struct_spec_rb_struct_new, 4);
rb_define_method(cls, "rb_struct_size", struct_spec_rb_struct_size, 1);
}
#ifdef __cplusplus