Class: NameError::message

Inherits:
Data show all
Defined in:
error.c,
error.c

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._load(str) ⇒ Object

:nodoc:



1821
1822
1823
1824
1825
# File 'error.c', line 1821

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

Instance Method Details

#==(obj2) ⇒ Object

:nodoc:



1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
# File 'error.c', line 1741

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;
    }
    return Qtrue;
}

#_dump(limit) ⇒ Object

:nodoc:



1814
1815
1816
1817
1818
# File 'error.c', line 1814

static VALUE
name_err_mesg_dump(VALUE obj, VALUE limit)
{
    return name_err_mesg_to_str(obj);
}

#to_strObject

:nodoc:



1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
# File 'error.c', line 1761

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[NAME_ERR_MESG__MESG];
    if (NIL_P(mesg)) return Qnil;
    else {
	struct RString s_str, d_str;
	VALUE c, s, d = 0, args[4];
	int state = 0, singleton = 0;
	rb_encoding *usascii = rb_usascii_encoding();

#define FAKE_CSTR(v, str) rb_setup_fake_str((v), (str), rb_strlen_lit(str), usascii)
	obj = ptr[NAME_ERR_MESG__RECV];
	switch (obj) {
	  case Qnil:
	    d = FAKE_CSTR(&d_str, "nil");
	    break;
	  case Qtrue:
	    d = FAKE_CSTR(&d_str, "true");
	    break;
	  case Qfalse:
	    d = FAKE_CSTR(&d_str, "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);
	    }
	    singleton = (RSTRING_LEN(d) > 0 && RSTRING_PTR(d)[0] == '#');
	    break;
	}
	if (!singleton) {
	    s = FAKE_CSTR(&s_str, ":");
	    c = rb_class_name(CLASS_OF(obj));
	}
	else {
	    c = s = FAKE_CSTR(&s_str, "");
	}
        args[0] = rb_obj_as_string(ptr[NAME_ERR_MESG__NAME]);
	args[1] = d;
	args[2] = s;
	args[3] = c;
	mesg = rb_str_format(4, args, mesg);
    }
    return mesg;
}