Class: NameError::message

Inherits:
Data show all
Defined in:
error.c

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.!Object

:nodoc:


# File 'error.c'

VALUE
rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method)
{
    VALUE *ptr = ALLOC_N(VALUE, NAME_ERR_MESG_COUNT);
    VALUE result;

    ptr[0] = mesg;
    ptr[1] = recv;
    ptr[2] = method;
    result = TypedData_Wrap_Struct(rb_cNameErrorMesg, &name_err_mesg_data_type, ptr);
    RB_GC_GUARD(mesg);
    RB_GC_GUARD(recv);
    RB_GC_GUARD(method);
    return result;
}

._loadObject

:nodoc:


# File 'error.c'

static VALUE
name_err_mesg_load(VALUE klass, VALUE str)
{
    return str;
}

Instance Method Details

#==Object

:nodoc:


# File 'error.c'

static VALUE
name_err_mesg_equal(VALUE obj1, VALUE obj2)
{
VALUE *ptr1, *ptr2;
int i;

if (obj1 == obj2) return Qtrue;
if (rb_obj_class(obj2) != rb_cNameErrorMesg)
return Qfalse;

TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1);
TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2);
for (i=0; i<NAME_ERR_MESG_COUNT; i++) {
if (!rb_equal(ptr1[i], ptr2[i]))
    return Qfalse;
}

#_dumpObject

:nodoc:


# File 'error.c'

static VALUE
name_err_mesg_to_str(VALUE obj)
{
    VALUE *ptr, mesg;
    TypedData_Get_Struct(obj, VALUE, &name_err_mesg_data_type, ptr);

    mesg = ptr[0];
    if (NIL_P(mesg)) return Qnil;
    else {
    const char *desc = 0;
    VALUE d = 0, args[NAME_ERR_MESG_COUNT];
    int state = 0;

    obj = ptr[1];
    switch (TYPE(obj)) {
      case T_NIL:
desc = "nil";
break;
      case T_TRUE:
desc = "true";
break;
      case T_FALSE:
desc = "false";
break;
      default:
d = rb_protect(rb_inspect, obj, &state);
if (state)
rb_set_errinfo(Qnil);
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
d = rb_any_to_s(obj);
}

#to_strObject

:nodoc:


# File 'error.c'

static VALUE
name_err_mesg_to_str(VALUE obj)
{
    VALUE *ptr, mesg;
    TypedData_Get_Struct(obj, VALUE, &name_err_mesg_data_type, ptr);

    mesg = ptr[0];
    if (NIL_P(mesg)) return Qnil;
    else {
    const char *desc = 0;
    VALUE d = 0, args[NAME_ERR_MESG_COUNT];
    int state = 0;

    obj = ptr[1];
    switch (TYPE(obj)) {
      case T_NIL:
desc = "nil";
break;
      case T_TRUE:
desc = "true";
break;
      case T_FALSE:
desc = "false";
break;
      default:
d = rb_protect(rb_inspect, obj, &state);
if (state)
rb_set_errinfo(Qnil);
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
d = rb_any_to_s(obj);
}