Fix implementation of OBJ_INIT_COPY for Ruby < 1.9

This commit is contained in:
刘皓 2025-03-18 18:41:28 -04:00
parent fd08583edd
commit cb302d2475
No known key found for this signature in database
GPG key ID: 7901753DB465B711

View file

@ -166,7 +166,7 @@ DEF_TYPE_CUSTOMNAME_AND_FREE(Klass, Name, freeInstance<Klass>)
BUILTIN_TYPE(obj) == (type))) BUILTIN_TYPE(obj) == (type)))
#endif #endif
#define OBJ_INIT_COPY(a, b) rb_obj_init_copy(a, b) #define OBJ_INIT_COPY(a, b) (a != b && (rb_obj_init_copy(a, b), 1))
#define DEF_ALLOCFUNC_CUSTOMFREE(type, free) \ #define DEF_ALLOCFUNC_CUSTOMFREE(type, free) \
static VALUE type##Allocate(VALUE klass) { \ static VALUE type##Allocate(VALUE klass) { \
@ -505,7 +505,7 @@ RB_METHOD_GUARD(Typ##Load) { return objectLoad<Typ>(argc, argv, self); } RB_METH
RB_METHOD_GUARD(Klass##InitializeCopy) { \ RB_METHOD_GUARD(Klass##InitializeCopy) { \
VALUE origObj; \ VALUE origObj; \
rb_get_args(argc, argv, "o", &origObj RB_ARG_END); \ rb_get_args(argc, argv, "o", &origObj RB_ARG_END); \
if (!OBJ_INIT_COPY(self, origObj)) /* When would this fail??*/ \ if (!OBJ_INIT_COPY(self, origObj)) \
return self; \ return self; \
Klass *orig = getPrivateData<Klass>(origObj); \ Klass *orig = getPrivateData<Klass>(origObj); \
Klass *k = 0; \ Klass *k = 0; \