pry / pry-doc

Provide MRI Core documentation and source code for the Pry REPL
https://github.com/pry/pry-doc
Other
175 stars 26 forks source link

Allow show-source to return MRI C source #82

Closed banister closed 6 years ago

banister commented 6 years ago

This PR decorates the standard show-source command with extra powers allowing it to extract and display MRI C source on the fly.

It also downloads and sets up the correct Ruby source for the current RUBY_VERSION lazily and stores it in ~/.pry.d/ruby-#{version}

TODO:

498: VALUE
 499: (rb_ary_new_from_args)(long n, ...)
 500: {
 501:     va_list ar;
 502:     VALUE ary;
 503:     long i;
 504:
 505:     ary = rb_ary_new2(n);
 506:
 507:     va_start(ar, n);
 508:     for (i=0; i<n; i++) {
 509:   ARY_SET(ary, i, va_arg(ar, VALUE));
 510:     }
 511:     va_end(ar);
 512:
 513:     ARY_SET_LEN(ary, n);
 514:     return ary;
 515: }

currently. Rewrite symbol extraction code so this mess doesn't happen

img

kyrylo commented 6 years ago

What if the rb_ary_dup method is defined in the Ruby context? How do you handle this case?

banister commented 6 years ago

@kyrylo with the -c (or --c-source) switch, it prioritizes C symbols over ruby

https://github.com/pry/pry-doc/blob/fbf26084851488858d415172cc133ce6d0a7f8eb/lib/pry-doc/pry_ext/show_source_with_c_internals.rb#L23-L25

banister commented 6 years ago

@kyrylo i added some specs and refactored a bit. review when you get a chance bb