|
|
@ -151,32 +151,30 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) { |
|
|
|
name_len--; |
|
|
|
name_len--; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check for a oneof name first.
|
|
|
|
// See if this name corresponds to either a oneof or field in this message.
|
|
|
|
o = upb_msgdef_ntoo(self->descriptor->msgdef, |
|
|
|
if (!upb_msgdef_lookupname(self->descriptor->msgdef, name, name_len, &f, |
|
|
|
name, name_len); |
|
|
|
&o)) { |
|
|
|
|
|
|
|
return rb_call_super(argc, argv); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (o != NULL) { |
|
|
|
if (o != NULL) { |
|
|
|
|
|
|
|
// This is a oneof -- return which field inside the oneof is set.
|
|
|
|
if (setter) { |
|
|
|
if (setter) { |
|
|
|
rb_raise(rb_eRuntimeError, "Oneof accessors are read-only."); |
|
|
|
rb_raise(rb_eRuntimeError, "Oneof accessors are read-only."); |
|
|
|
} |
|
|
|
} |
|
|
|
return which_oneof_field(self, o); |
|
|
|
return which_oneof_field(self, o); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, check for a field with that name.
|
|
|
|
|
|
|
|
f = upb_msgdef_ntof(self->descriptor->msgdef, |
|
|
|
|
|
|
|
name, name_len); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (f == NULL) { |
|
|
|
|
|
|
|
return rb_call_super(argc, argv); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (setter) { |
|
|
|
|
|
|
|
if (argc < 2) { |
|
|
|
|
|
|
|
rb_raise(rb_eArgError, "No value provided to setter."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
layout_set(self->descriptor->layout, Message_data(self), f, argv[1]); |
|
|
|
|
|
|
|
return Qnil; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return layout_get(self->descriptor->layout, Message_data(self), f); |
|
|
|
// This is a field -- get or set the field's value.
|
|
|
|
|
|
|
|
assert(f); |
|
|
|
|
|
|
|
if (setter) { |
|
|
|
|
|
|
|
if (argc < 2) { |
|
|
|
|
|
|
|
rb_raise(rb_eArgError, "No value provided to setter."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
layout_set(self->descriptor->layout, Message_data(self), f, argv[1]); |
|
|
|
|
|
|
|
return Qnil; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return layout_get(self->descriptor->layout, Message_data(self), f); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|