always use RGSS method of checking private data

This commit is contained in:
Inori 2019-12-21 04:51:54 -05:00
parent 7f08ce1b36
commit 0888ab6750

View file

@ -180,13 +180,12 @@ getPrivateDataCheck(VALUE self, const rb_data_type_t &type)
getPrivateDataCheck(VALUE self, const char *type) getPrivateDataCheck(VALUE self, const char *type)
#endif #endif
{ {
#ifndef OLD_RUBY rb_check_type(self, T_DATA);
void *obj = Check_TypedStruct(self, &type); #ifdef OLD_RUBY
#else // RGSS1 works in a more permissive way than the above, VALUE otherObj = rb_const_get(rb_cObject, rb_intern(type));
// See the function at ram:10012AB0 in RGSS104E for an example #else
// This isn't an exact replica, but should have pretty much the same result VALUE otherObj = rb_const_get(rb_cObject, rb_intern(type.wrap_struct_name));
rb_check_type(self, T_DATA); #endif
VALUE otherObj = rb_const_get(rb_cObject, rb_intern(type));
const char *ownname, *othername; const char *ownname, *othername;
if (!rb_obj_is_kind_of(self, otherObj)) if (!rb_obj_is_kind_of(self, otherObj))
{ {
@ -194,9 +193,8 @@ getPrivateDataCheck(VALUE self, const char *type)
othername = rb_obj_classname(otherObj); othername = rb_obj_classname(otherObj);
rb_raise(rb_eTypeError, "Can't convert %s into %s", othername, ownname); rb_raise(rb_eTypeError, "Can't convert %s into %s", othername, ownname);
} }
void *obj = DATA_PTR(self); void *obj = DATA_PTR(self);
#endif
return static_cast<C*>(obj); return static_cast<C*>(obj);
} }