1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2018-06-19 02:46:10 +00:00
parent 8b3902b28c
commit 61391616f4
3 changed files with 1 additions and 13 deletions

View file

@ -101,12 +101,6 @@ VALUE sws_typed_wrap_struct(VALUE self, VALUE val) {
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) {
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);

View file

@ -29,11 +29,6 @@ describe "CApiWrappedTypedStruct" do
@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)

View file

@ -47,7 +47,7 @@ rb_obj_hidden_p(VALUE obj)
}
}
#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))