static long num_members(VALUE klass) { VALUE members; members = struct_ivar_get(klass, id_members); if (!RB_TYPE_P(members, T_ARRAY)) { rb_raise(rb_eTypeError, "broken members"); } return RARRAY_LEN(members); }
static int num_members(mrb_state *mrb, struct RClass *klass) { mrb_value members; members = struct_ivar_get(mrb, mrb_obj_value(klass), mrb_intern(mrb, "__members__")); if (mrb_type(members) != MRB_TT_ARRAY) { mrb_raise(mrb, E_TYPE_ERROR, "broken members"); } return RARRAY_LEN(members); }
static int num_members(mrb_state *mrb, struct RClass *klass) { mrb_value members; members = struct_ivar_get(mrb, mrb_obj_value(klass), mrb_intern_lit(mrb, "__members__")); if (!mrb_array_p(members)) { mrb_raise(mrb, E_TYPE_ERROR, "broken members"); } return RARRAY_LEN(members); }
mrb_value mrb_struct_s_members(mrb_state *mrb, mrb_value klass) { mrb_value members = struct_ivar_get(mrb, klass, mrb_intern_lit(mrb, "__members__")); if (mrb_nil_p(members)) { mrb_raise(mrb, E_TYPE_ERROR, "uninitialized struct"); } if (!mrb_array_p(members)) { mrb_raise(mrb, E_TYPE_ERROR, "corrupted struct"); } return members; }
VALUE rb_struct_s_members(VALUE klass) { VALUE members = struct_ivar_get(klass, id_members); if (NIL_P(members)) { rb_raise(rb_eTypeError, "uninitialized struct"); } if (TYPE(members) != T_ARRAY) { rb_raise(rb_eTypeError, "corrupted struct"); } return members; }
mrb_value mrb_struct_iv_get(mrb_state *mrb, mrb_value c, const char *name) { return struct_ivar_get(mrb, c, mrb_intern_cstr(mrb, name)); }
VALUE rb_struct_iv_get(VALUE c, const char *name) { return struct_ivar_get(c, rb_intern(name)); }