ruby-changes:51484
From: ko1 <ko1@a...>
Date: Tue, 19 Jun 2018 11:46:15 +0900 (JST)
Subject: [ruby-changes:51484] ko1:r63694 (trunk): NULL class Data_Wrap_Struct is not allowed.
ko1 2018-06-19 11:46:10 +0900 (Tue, 19 Jun 2018) New Revision: 63694 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63694 Log: NULL class Data_Wrap_Struct is not allowed. * spec/ruby/optional/capi/typed_data_spec.rb: same as r63692. * spec/ruby/optional/capi/ext/typed_data_spec.c: ditto. * vm_insnhelper.h (PUSH): re-enable assertion to check hidden objects. Modified files: trunk/spec/ruby/optional/capi/ext/typed_data_spec.c trunk/spec/ruby/optional/capi/typed_data_spec.rb trunk/vm_insnhelper.h Index: spec/ruby/optional/capi/typed_data_spec.rb =================================================================== --- spec/ruby/optional/capi/typed_data_spec.rb (revision 63693) +++ spec/ruby/optional/capi/typed_data_spec.rb (revision 63694) @@ -29,11 +29,6 @@ describe "CApiWrappedTypedStruct" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/typed_data_spec.rb#L29 @s.typed_get_struct_parent(a).should == 1024 end - it "allows for using NULL as the klass for Data_Wrap_Struct" do - a = @s.typed_wrap_struct_null(1024) - @s.typed_get_struct(a).should == 1024 - end - describe "RTYPEDATA" do it "returns the struct data" do a = @s.typed_wrap_struct(1024) Index: spec/ruby/optional/capi/ext/typed_data_spec.c =================================================================== --- spec/ruby/optional/capi/ext/typed_data_spec.c (revision 63693) +++ spec/ruby/optional/capi/ext/typed_data_spec.c (revision 63694) @@ -101,12 +101,6 @@ VALUE sws_typed_wrap_struct(VALUE self, https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/typed_data_spec.c#L101 return TypedData_Wrap_Struct(rb_cObject, &sample_typed_wrapped_struct_data_type, bar); } -VALUE sws_typed_wrap_struct_null(VALUE self, VALUE val) { - struct sample_typed_wrapped_struct* bar = (struct sample_typed_wrapped_struct *)malloc(sizeof(struct sample_typed_wrapped_struct)); - bar->foo = FIX2INT(val); - return TypedData_Wrap_Struct(0, &sample_typed_wrapped_struct_data_type, bar); -} - VALUE sws_typed_get_struct(VALUE self, VALUE obj) { struct sample_typed_wrapped_struct* bar; TypedData_Get_Struct(obj, struct sample_typed_wrapped_struct, &sample_typed_wrapped_struct_data_type, bar); @@ -161,7 +155,6 @@ void Init_typed_data_spec(void) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/typed_data_spec.c#L155 cls = rb_define_class("CApiWrappedTypedStructSpecs", rb_cObject); rb_define_method(cls, "typed_wrap_struct", sws_typed_wrap_struct, 1); - rb_define_method(cls, "typed_wrap_struct_null", sws_typed_wrap_struct_null, 1); rb_define_method(cls, "typed_get_struct", sws_typed_get_struct, 1); rb_define_method(cls, "typed_get_struct_other", sws_typed_get_struct_different_type, 1); rb_define_method(cls, "typed_get_struct_parent", sws_typed_get_struct_parent_type, 1); Index: vm_insnhelper.h =================================================================== --- vm_insnhelper.h (revision 63693) +++ vm_insnhelper.h (revision 63694) @@ -47,7 +47,7 @@ rb_obj_hidden_p(VALUE obj) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L47 } } -#define PUSH(x) (SET_SV(x), INC_SP(1)) +#define PUSH(x) (VM_ASSERT(!rb_obj_hidden_p(x)), SET_SV(x), INC_SP(1)) #define TOPN(n) (*(GET_SP()-(n)-1)) #define POPN(n) (DEC_SP(n)) #define POP() (DEC_SP(1)) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/