summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/ext
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-06-07 14:15:05 +0900
committerNobuyoshi Nakada <[email protected]>2024-06-07 14:15:05 +0900
commit5f6a4ed5074eda4b4b1bd2d6dd29aaf3b8ef879d ()
tree0b29f76b2711d674544aed40e1ba02bb3ba32fe4 /spec/ruby/optional/capi/ext
parenta279463d0ebb2fe1d4021ddd4675141deead514b (diff)
Remove the old untyped Data API in spec/ruby
-rw-r--r--spec/ruby/optional/capi/ext/data_spec.c4
-rw-r--r--spec/ruby/optional/capi/ext/rubyspec.h4
-rw-r--r--spec/ruby/optional/capi/ext/typed_data_spec.c2
3 files changed, 10 insertions, 0 deletions
@@ -3,6 +3,7 @@
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -70,8 +71,10 @@ VALUE sws_rb_check_type(VALUE self, VALUE obj, VALUE other) {
rb_check_type(obj, TYPE(other));
return Qtrue;
}
void Init_data_spec(void) {
VALUE cls = rb_define_class("CApiAllocSpecs", rb_cObject);
rb_define_alloc_func(cls, sdaf_alloc_func);
rb_define_method(cls, "wrapped_data", sdaf_get_struct, 0);
@@ -82,6 +85,7 @@ void Init_data_spec(void) {
rb_define_method(cls, "get_struct_data_ptr", sws_get_struct_data_ptr, 1);
rb_define_method(cls, "change_struct", sws_change_struct, 2);
rb_define_method(cls, "rb_check_type", sws_rb_check_type, 2);
}
#ifdef __cplusplus
@@ -46,6 +46,10 @@
(RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR == (minor) && RUBY_VERSION_TEENY < (teeny)))
#define RUBY_VERSION_SINCE(major,minor,teeny) (!RUBY_VERSION_BEFORE(major, minor, teeny))
#if RUBY_VERSION_SINCE(3, 3, 0)
#define RUBY_VERSION_IS_3_3
#endif
@@ -106,6 +106,8 @@ VALUE sws_typed_wrap_struct(VALUE self, VALUE val) {
return TypedData_Wrap_Struct(rb_cObject, &sample_typed_wrapped_struct_data_type, bar);
}
VALUE sws_untyped_wrap_struct(VALUE self, VALUE val) {
int* data = (int*) malloc(sizeof(int));
*data = FIX2INT(val);