summaryrefslogtreecommitdiff
path: root/spec/rubyspec/optional/capi/ext/data_spec.c
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 20:18:52 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 20:18:52 +0000
commit1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch)
treea3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/rubyspec/optional/capi/ext/data_spec.c
parent75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff)
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/optional/capi/ext/data_spec.c')
-rw-r--r--spec/rubyspec/optional/capi/ext/data_spec.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/spec/rubyspec/optional/capi/ext/data_spec.c b/spec/rubyspec/optional/capi/ext/data_spec.c
deleted file mode 100644
index ed79497897..0000000000
--- a/spec/rubyspec/optional/capi/ext/data_spec.c
+++ /dev/null
@@ -1,97 +0,0 @@
-#include "ruby.h"
-#include "rubyspec.h"
-
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(HAVE_RDATA) && defined(HAVE_DATA_WRAP_STRUCT)
-struct sample_wrapped_struct {
- int foo;
-};
-
-void sample_wrapped_struct_free(void* st) {
- free(st);
-}
-
-void sample_wrapped_struct_mark(void* st) {
-}
-
-VALUE sdaf_alloc_func(VALUE klass) {
- struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
- bar->foo = 42;
- return Data_Wrap_Struct(klass, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
-}
-
-VALUE sdaf_get_struct(VALUE self) {
- struct sample_wrapped_struct* bar;
- Data_Get_Struct(self, struct sample_wrapped_struct, bar);
-
- return INT2FIX((*bar).foo);
-}
-
-VALUE sws_wrap_struct(VALUE self, VALUE val) {
- struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
- bar->foo = FIX2INT(val);
- return Data_Wrap_Struct(rb_cObject, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
-}
-
-VALUE sws_wrap_struct_null(VALUE self, VALUE val) {
- struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
- bar->foo = FIX2INT(val);
- return Data_Wrap_Struct(0, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
-}
-
-VALUE sws_get_struct(VALUE self, VALUE obj) {
- struct sample_wrapped_struct* bar;
- Data_Get_Struct(obj, struct sample_wrapped_struct, bar);
-
- return INT2FIX((*bar).foo);
-}
-
-VALUE sws_get_struct_rdata(VALUE self, VALUE obj) {
- struct sample_wrapped_struct* bar;
- bar = (struct sample_wrapped_struct*) RDATA(obj)->data;
- return INT2FIX(bar->foo);
-}
-
-VALUE sws_get_struct_data_ptr(VALUE self, VALUE obj) {
- struct sample_wrapped_struct* bar;
- bar = (struct sample_wrapped_struct*) DATA_PTR(obj);
- return INT2FIX(bar->foo);
-}
-
-VALUE sws_change_struct(VALUE self, VALUE obj, VALUE new_val) {
- struct sample_wrapped_struct *old_struct, *new_struct;
- new_struct = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
- new_struct->foo = FIX2INT(new_val);
- old_struct = RDATA(obj)->data;
- free(old_struct);
- RDATA(obj)->data = new_struct;
- return Qnil;
-}
-#endif
-
-void Init_data_spec(void) {
- VALUE cls;
- cls = rb_define_class("CApiAllocSpecs", rb_cObject);
-
-#if defined(HAVE_RDATA) && defined(HAVE_DATA_WRAP_STRUCT)
- rb_define_alloc_func(cls, sdaf_alloc_func);
- rb_define_method(cls, "wrapped_data", sdaf_get_struct, 0);
-
- cls = rb_define_class("CApiWrappedStructSpecs", rb_cObject);
- rb_define_method(cls, "wrap_struct", sws_wrap_struct, 1);
- rb_define_method(cls, "wrap_struct_null", sws_wrap_struct_null, 1);
- rb_define_method(cls, "get_struct", sws_get_struct, 1);
- rb_define_method(cls, "get_struct_rdata", sws_get_struct_rdata, 1);
- rb_define_method(cls, "get_struct_data_ptr", sws_get_struct_data_ptr, 1);
- rb_define_method(cls, "change_struct", sws_change_struct, 2);
-#endif
-}
-
-#ifdef __cplusplus
-}
-#endif