new(p1, p2 = v2, p3 = v3)
public
Show source
static VALUE
ripper_initialize(int argc, VALUE *argv, VALUE self)
{
struct parser_params *p;
VALUE src, fname, lineno;
TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
if (RB_TYPE_P(src, T_FILE)) {
p->lex.gets = ripper_lex_io_get;
}
else if (rb_respond_to(src, id_gets)) {
p->lex.gets = ripper_lex_get_generic;
}
else {
StringValue(src);
p->lex.gets = lex_get_str;
}
p->lex.input = src;
p->eofp = 0;
if (NIL_P(fname)) {
fname = STR_NEW2("(ripper)");
OBJ_FREEZE(fname);
}
else {
StringValueCStr(fname);
fname = rb_str_new_frozen(fname);
}
parser_initialize(p);
p->ruby_sourcefile_string = fname;
p->ruby_sourcefile = RSTRING_PTR(fname);
p->ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
return Qnil;
}