Project

General

Profile

Feature #4893 » String_call_initialize_v2.diff

lazaridis.com (Lazaridis Ilias), 06/26/2011 08:06 PM

View differences:

"b/P:\\sand\\rubyi2\\sandbox\\rb192\\string.c"
return str;
}
static int str_call_initialize = FALSE;
VALUE
rb_str_call_initialize_get(VALUE self)
{
if (str_call_initialize == TRUE) return Qtrue;
return Qfalse;
}
VALUE
rb_str_call_initialize_set(VALUE self, VALUE val)
{
str_call_initialize = FALSE;
if (val == Qtrue) str_call_initialize = TRUE;
return self;
}
VALUE
rb_str_new(const char *ptr, long len)
{
return str_new(rb_cString, ptr, len);
VALUE str;
VALUE argv[1];
str = str_new(rb_cString, ptr, len);
if (str_call_initialize) {
argv[0] = (VALUE)str;
rb_obj_call_init((VALUE)str, 1, argv);
}
return str;
}
VALUE
......
rb_cString = rb_define_class("String", rb_cObject);
rb_include_module(rb_cString, rb_mComparable);
rb_define_alloc_func(rb_cString, str_alloc);
rb_define_singleton_method(rb_cString, "call_initialize", rb_str_call_initialize_get, 0);
rb_define_singleton_method(rb_cString, "call_initialize=", rb_str_call_initialize_set, 1);
rb_define_singleton_method(rb_cString, "try_convert", rb_str_s_try_convert, 1);
rb_define_method(rb_cString, "initialize", rb_str_init, -1);
rb_define_method(rb_cString, "initialize_copy", rb_str_replace, 1);
(5-5/13)