Пример #1
0
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);
}
Пример #2
0
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);
}
Пример #3
0
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);
}
Пример #4
0
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;
}
Пример #5
0
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;
}
Пример #6
0
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));
}
Пример #7
0
VALUE
rb_struct_iv_get(VALUE c, const char *name)
{
    return struct_ivar_get(c, rb_intern(name));
}