|
7 | 7 | require "rbconfig" |
8 | 8 | require "ffi" |
9 | 9 |
|
10 | | -# We want to eagerly load this file if there are Ractors so that it does not get |
11 | | -# autoloaded from within a non-main Ractor. |
12 | | -require "prism/serialize" if defined?(Ractor) |
13 | | - |
14 | 10 | module Prism |
15 | 11 | module LibRubyParser # :nodoc: |
16 | 12 | extend FFI::Library |
@@ -163,9 +159,6 @@ def self.with |
163 | 159 | class PrismString # :nodoc: |
164 | 160 | SIZEOF = LibRubyParser.pm_string_sizeof |
165 | 161 |
|
166 | | - PLATFORM_EXPECTS_UTF8 = |
167 | | - RbConfig::CONFIG["host_os"].match?(/bccwin|cygwin|djgpp|mingw|mswin|wince|darwin/i) |
168 | | - |
169 | 162 | attr_reader :pointer, :length |
170 | 163 |
|
171 | 164 | def initialize(pointer, length, from_string) |
@@ -200,7 +193,8 @@ def self.with_file(filepath) |
200 | 193 | # On Windows and Mac, it's expected that filepaths will be encoded in |
201 | 194 | # UTF-8. If they are not, we need to convert them to UTF-8 before |
202 | 195 | # passing them into pm_string_mapped_init. |
203 | | - if PLATFORM_EXPECTS_UTF8 && (encoding = filepath.encoding) != Encoding::ASCII_8BIT && encoding != Encoding::UTF_8 |
| 196 | + if RbConfig::CONFIG["host_os"].match?(/bccwin|cygwin|djgpp|mingw|mswin|wince|darwin/i) && |
| 197 | + (encoding = filepath.encoding) != Encoding::ASCII_8BIT && encoding != Encoding::UTF_8 |
204 | 198 | filepath = filepath.encode(Encoding::UTF_8) |
205 | 199 | end |
206 | 200 |
|
@@ -229,7 +223,7 @@ def self.with_file(filepath) |
229 | 223 | private_constant :LibRubyParser |
230 | 224 |
|
231 | 225 | # The version constant is set by reading the result of calling pm_version. |
232 | | - VERSION = LibRubyParser.pm_version.read_string.freeze |
| 226 | + VERSION = LibRubyParser.pm_version.read_string |
233 | 227 |
|
234 | 228 | class << self |
235 | 229 | # Mirror the Prism.dump API by using the serialization API. |
|
0 commit comments