Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Apr 22, 2024
1 parent 028dbfa commit 51e5532
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ext/ripper/ripper_init.c.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
VALUE sourcefile_string;
const char *sourcefile;
int sourceline;
rb_parser_input_data input;

p = ripper_parser_params(self, false);
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
Expand All @@ -342,18 +343,21 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
gets = ripper_lex_io_get;
r->type = lex_type_io;
r->data.val = src;
input = (rb_parser_input_data)src;
}
else if (rb_respond_to(src, id_gets)) {
gets = ripper_lex_get_generic;
r->type = lex_type_generic;
r->data.val = src;
input = (rb_parser_input_data)src;
}
else {
StringValue(src);
gets = ripper_lex_get_str;
r->type = lex_type_str;
r->data.ptr_str.str = src;
r->data.ptr_str.ptr = 0;
input = (rb_parser_input_data)&r->data.ptr_str;
}
if (NIL_P(fname)) {
fname = STR_NEW2("(ripper)");
Expand All @@ -369,7 +373,7 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
sourcefile = RSTRING_PTR(fname);
sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;

rb_ruby_parser_ripper_initialize(p, gets, (rb_parser_input_data)&r->data, sourcefile_string, sourcefile, sourceline);
rb_ruby_parser_ripper_initialize(p, gets, input, sourcefile_string, sourcefile, sourceline);

return Qnil;
}
Expand Down

0 comments on commit 51e5532

Please sign in to comment.