Class: NameError::message
Overview
:nodoc:
Class Method Summary collapse
-
._load(str) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#==(obj2) ⇒ Object
:nodoc:.
-
#_dump(limit) ⇒ Object
:nodoc:.
-
#initialize_copy(obj2) ⇒ Object
:nodoc:.
-
#to_str ⇒ Object
:nodoc:.
Class Method Details
._load(str) ⇒ Object
:nodoc:
1987 1988 1989 1990 1991 |
# File 'error.c', line 1987
static VALUE
name_err_mesg_load(VALUE klass, VALUE str)
{
return str;
}
|
Instance Method Details
#==(obj2) ⇒ Object
:nodoc:
1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 |
# File 'error.c', line 1892
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:
1980 1981 1982 1983 1984 |
# File 'error.c', line 1980
static VALUE
name_err_mesg_dump(VALUE obj, VALUE limit)
{
return name_err_mesg_to_str(obj);
}
|
#initialize_copy(obj2) ⇒ Object
:nodoc:
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 |
# File 'error.c', line 1877
static VALUE
name_err_mesg_init_copy(VALUE obj1, VALUE obj2)
{
VALUE *ptr1, *ptr2;
if (obj1 == obj2) return obj1;
rb_obj_init_copy(obj1, obj2);
TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1);
TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2);
MEMCPY(ptr1, ptr2, VALUE, NAME_ERR_MESG_COUNT);
return obj1;
}
|
#to_str ⇒ Object
:nodoc:
1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 |
# File 'error.c', line 1923
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(name_err_mesg_receiver_name, obj, &state);
if (state || d == Qundef || d == Qnil)
d = rb_protect(rb_inspect, obj, &state);
if (state) {
rb_set_errinfo(Qnil);
}
d = rb_check_string_type(d);
if (NIL_P(d)) {
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;
}
|