|
|
|
@ -294,8 +294,17 @@ VALUE native_slot_get(upb_fieldtype_t type, |
|
|
|
|
return DEREF(memory, int8_t) ? Qtrue : Qfalse; |
|
|
|
|
case UPB_TYPE_STRING: |
|
|
|
|
case UPB_TYPE_BYTES: |
|
|
|
|
case UPB_TYPE_MESSAGE: |
|
|
|
|
return DEREF(memory, VALUE); |
|
|
|
|
case UPB_TYPE_MESSAGE: { |
|
|
|
|
VALUE val = DEREF(memory, VALUE); |
|
|
|
|
int type = TYPE(val); |
|
|
|
|
if (type != T_DATA && type != T_NIL) { |
|
|
|
|
// This must be a wrapper type.
|
|
|
|
|
val = ruby_wrapper_type(type_class, val); |
|
|
|
|
DEREF(memory, VALUE) = val; |
|
|
|
|
} |
|
|
|
|
return val; |
|
|
|
|
} |
|
|
|
|
case UPB_TYPE_ENUM: { |
|
|
|
|
int32_t val = DEREF(memory, int32_t); |
|
|
|
|
VALUE symbol = enum_lookup(type_class, INT2NUM(val)); |
|
|
|
@ -392,13 +401,14 @@ void native_slot_deep_copy(upb_fieldtype_t type, void* to, void* from) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool native_slot_eq(upb_fieldtype_t type, void* mem1, void* mem2) { |
|
|
|
|
bool native_slot_eq(upb_fieldtype_t type, VALUE type_class, void* mem1, |
|
|
|
|
void* mem2) { |
|
|
|
|
switch (type) { |
|
|
|
|
case UPB_TYPE_STRING: |
|
|
|
|
case UPB_TYPE_BYTES: |
|
|
|
|
case UPB_TYPE_MESSAGE: { |
|
|
|
|
VALUE val1 = DEREF(mem1, VALUE); |
|
|
|
|
VALUE val2 = DEREF(mem2, VALUE); |
|
|
|
|
VALUE val1 = native_slot_get(type, type_class, mem1); |
|
|
|
|
VALUE val2 = native_slot_get(type, type_class, mem2); |
|
|
|
|
VALUE ret = rb_funcall(val1, rb_intern("=="), 1, val2); |
|
|
|
|
return ret == Qtrue; |
|
|
|
|
} |
|
|
|
@ -843,15 +853,8 @@ VALUE layout_get(MessageLayout* layout, |
|
|
|
|
} else if (!field_set) { |
|
|
|
|
return layout_get_default(field); |
|
|
|
|
} else { |
|
|
|
|
VALUE type_class = field_type_class(layout, field); |
|
|
|
|
VALUE val = native_slot_get(upb_fielddef_type(field), type_class, memory); |
|
|
|
|
int type = TYPE(val); |
|
|
|
|
if (type != T_DATA && type != T_NIL && is_wrapper_type_field(field)) { |
|
|
|
|
val = ruby_wrapper_type(layout, field, val); |
|
|
|
|
native_slot_set(upb_fielddef_name(field), upb_fielddef_type(field), |
|
|
|
|
type_class, memory, val); |
|
|
|
|
} |
|
|
|
|
return val; |
|
|
|
|
return native_slot_get(upb_fielddef_type(field), |
|
|
|
|
field_type_class(layout, field), memory); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1068,7 +1071,8 @@ VALUE layout_eq(MessageLayout* layout, void* msg1, void* msg2) { |
|
|
|
|
if (*msg1_oneof_case != *msg2_oneof_case || |
|
|
|
|
(slot_read_oneof_case(layout, msg1, oneof) == |
|
|
|
|
upb_fielddef_number(field) && |
|
|
|
|
!native_slot_eq(upb_fielddef_type(field), msg1_memory, |
|
|
|
|
!native_slot_eq(upb_fielddef_type(field), |
|
|
|
|
field_type_class(layout, field), msg1_memory, |
|
|
|
|
msg2_memory))) { |
|
|
|
|
return Qfalse; |
|
|
|
|
} |
|
|
|
@ -1085,7 +1089,9 @@ VALUE layout_eq(MessageLayout* layout, void* msg1, void* msg2) { |
|
|
|
|
} else { |
|
|
|
|
if (slot_is_hasbit_set(layout, msg1, field) != |
|
|
|
|
slot_is_hasbit_set(layout, msg2, field) || |
|
|
|
|
!native_slot_eq(upb_fielddef_type(field), msg1_memory, msg2_memory)) { |
|
|
|
|
!native_slot_eq(upb_fielddef_type(field), |
|
|
|
|
field_type_class(layout, field), msg1_memory, |
|
|
|
|
msg2_memory)) { |
|
|
|
|
return Qfalse; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|