diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2023-05-08 13:21:33 +0200 |
---|---|---|
committer | Lars Kanis <lars@greiz-reinsdorf.de> | 2023-05-08 13:21:33 +0200 |
commit | c6b7139d0394638ef51b451b81dcd2ffefb94160 (patch) | |
tree | f1513b0afc5ef798382100a53c3191ff52e66d3e /ext/ffi_c/Variadic.c | |
parent | c1e6a14476e210efeac79aa260c2eb2d1d98a580 (diff) | |
parent | 938b5d8590361acf871fddb9149fe725f65d781f (diff) | |
download | ffi-c6b7139d0394638ef51b451b81dcd2ffefb94160.tar.gz |
Merge branch 'ractor'
Diffstat (limited to 'ext/ffi_c/Variadic.c')
-rw-r--r-- | ext/ffi_c/Variadic.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/ffi_c/Variadic.c b/ext/ffi_c/Variadic.c index a255969..09d7ce8 100644 --- a/ext/ffi_c/Variadic.c +++ b/ext/ffi_c/Variadic.c @@ -36,6 +36,9 @@ #include <stdint.h> #include <stdbool.h> #include <ruby.h> +#if HAVE_RB_EXT_RACTOR_SAFE +#include <ruby/ractor.h> +#endif #include <ffi.h> #include "rbffi.h" @@ -81,7 +84,7 @@ static const rb_data_type_t variadic_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 }; @@ -180,7 +183,7 @@ variadic_initialize(VALUE self, VALUE rbFunction, VALUE rbParameterTypes, VALUE /* * @fixed and @type_map are used by the parameter mangling ruby code */ - rb_iv_set(self, "@fixed", fixed); + rb_iv_set(self, "@fixed", rb_obj_freeze(fixed)); rb_iv_set(self, "@type_map", rb_hash_aref(options, ID2SYM(rb_intern("type_map")))); return retval; @@ -318,6 +321,14 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues) return rbffi_NativeValue_ToRuby(invoker->returnType, invoker->rbReturnType, retval); } +static VALUE +variadic_return_type(VALUE self) +{ + VariadicInvoker* invoker; + + TypedData_Get_Struct(self, VariadicInvoker, &variadic_data_type, invoker); + return invoker->rbReturnType; +} void rbffi_Variadic_Init(VALUE moduleFFI) @@ -329,5 +340,6 @@ rbffi_Variadic_Init(VALUE moduleFFI) rb_define_method(classVariadicInvoker, "initialize", variadic_initialize, 4); rb_define_method(classVariadicInvoker, "invoke", variadic_invoke, 2); + rb_define_method(classVariadicInvoker, "return_type", variadic_return_type, 0); } |