Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search subclasses from constants #4209

Merged
merged 1 commit into from Feb 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions win32/mkexports.rb
Expand Up @@ -9,14 +9,11 @@ module RbConfig
class Exports
PrivateNames = /(?:Init_|InitVM_|ruby_static_id_|threadptr|_ec_|DllMain\b)/

@@subclass = []
def self.inherited(klass)
@@subclass << [/#{klass.name.sub(/.*::/, '').downcase}/i, klass]
end

def self.create(*args, &block)
platform = RUBY_PLATFORM
pat, klass = @@subclass.find {|p, k| p =~ platform}
klass = constants.find do |p|
break const_get(p) if platform.include?(p.to_s.downcase)
end
unless klass
raise ArgumentError, "unsupported platform: #{platform}"
end
Expand Down