summaryrefslogtreecommitdiff
path: root/lib/prism/ffi.rb
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-05-29 10:12:51 -0400
committerKevin Newton <[email protected]>2024-05-30 15:18:20 -0400
commit72452f43871b8034bfa718ed823bc62b5b81d6f9 (patch)
tree1bd87295dfcf10d20bce7f6d18184644bb079387 /lib/prism/ffi.rb
parent1ab7c412d2e3880a7ad233c32e93961888f8145c (diff)
[ruby/prism] Tests overhaul
https://github.com/ruby/prism/commit/6f886be0a4
Diffstat (limited to 'lib/prism/ffi.rb')
-rw-r--r--lib/prism/ffi.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb
index df7e183310..6b48af43cc 100644
--- a/lib/prism/ffi.rb
+++ b/lib/prism/ffi.rb
@@ -200,8 +200,8 @@ module Prism
class << self
# Mirror the Prism.dump API by using the serialization API.
- def dump(code, **options)
- LibRubyParser::PrismString.with_string(code) { |string| dump_common(string, options) }
+ def dump(source, **options)
+ LibRubyParser::PrismString.with_string(source) { |string| dump_common(string, options) }
end
# Mirror the Prism.dump_file API by using the serialization API.
@@ -302,6 +302,27 @@ module Prism
!parse_file_success?(filepath, **options)
end
+ # Mirror the Prism.profile API by using the serialization API.
+ def profile(source, **options)
+ LibRubyParser::PrismString.with_string(source) do |string|
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
+ nil
+ end
+ end
+ end
+
+ # Mirror the Prism.profile_file API by using the serialization API.
+ def profile_file(filepath, **options)
+ LibRubyParser::PrismString.with_file(filepath) do |string|
+ LibRubyParser::PrismBuffer.with do |buffer|
+ options[:filepath] = filepath
+ LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
+ nil
+ end
+ end
+ end
+
private
def dump_common(string, options) # :nodoc: