summaryrefslogtreecommitdiff
path: root/ext/ffi_c/MappedType.c
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2023-05-08 13:21:33 +0200
committerLars Kanis <lars@greiz-reinsdorf.de>2023-05-08 13:21:33 +0200
commitc6b7139d0394638ef51b451b81dcd2ffefb94160 (patch)
treef1513b0afc5ef798382100a53c3191ff52e66d3e /ext/ffi_c/MappedType.c
parentc1e6a14476e210efeac79aa260c2eb2d1d98a580 (diff)
parent938b5d8590361acf871fddb9149fe725f65d781f (diff)
downloadffi-c6b7139d0394638ef51b451b81dcd2ffefb94160.tar.gz
Merge branch 'ractor'
Diffstat (limited to 'ext/ffi_c/MappedType.c')
-rw-r--r--ext/ffi_c/MappedType.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/ext/ffi_c/MappedType.c b/ext/ffi_c/MappedType.c
index b1532e1..2e506f2 100644
--- a/ext/ffi_c/MappedType.c
+++ b/ext/ffi_c/MappedType.c
@@ -57,7 +57,7 @@ static const rb_data_type_t mapped_type_data_type = {
.parent = &rbffi_type_data_type,
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
// macro to update VALUE references, as to trigger write barriers.
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
};
@@ -110,6 +110,8 @@ mapped_initialize(VALUE self, VALUE rbConverter)
TypedData_Get_Struct(m->rbType, Type, &rbffi_type_data_type, m->type);
m->base.ffiType = m->type->ffiType;
+ rb_obj_freeze(self);
+
return self;
}
@@ -175,6 +177,15 @@ mapped_from_native(int argc, VALUE* argv, VALUE self)
return rb_funcall2(m->rbConverter, id_from_native, argc, argv);
}
+static VALUE
+mapped_converter(VALUE self)
+{
+ MappedType*m = NULL;
+ TypedData_Get_Struct(self, MappedType, &mapped_type_data_type, m);
+
+ return m->rbConverter;
+}
+
void
rbffi_MappedType_Init(VALUE moduleFFI)
{
@@ -195,5 +206,6 @@ rbffi_MappedType_Init(VALUE moduleFFI)
rb_define_method(rbffi_MappedTypeClass, "native_type", mapped_native_type, 0);
rb_define_method(rbffi_MappedTypeClass, "to_native", mapped_to_native, -1);
rb_define_method(rbffi_MappedTypeClass, "from_native", mapped_from_native, -1);
+ rb_define_method(rbffi_MappedTypeClass, "converter", mapped_converter, 0);
}