[前][次][番号順一覧][スレッド一覧]

ruby-changes:57794

From: Nobuyoshi <ko1@a...>
Date: Thu, 19 Sep 2019 00:11:33 +0900 (JST)
Subject: [ruby-changes:57794] 842f600a93 (master): Look up the language module

https://git.ruby-lang.org/ruby.git/commit/?id=842f600a93

From 842f600a93deca71e908ef5bb16e4e6aed519890 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 18 Sep 2019 23:31:53 +0900
Subject: Look up the language module

Look up language module with `MakeMakefile.[]`, insted of a
accessing constant under that module directly, to get rid of
expose the constant to the toplevel inadvertently.

diff --git a/ext/-test-/cxxanyargs/extconf.rb b/ext/-test-/cxxanyargs/extconf.rb
index c1823a4..7e2449a 100644
--- a/ext/-test-/cxxanyargs/extconf.rb
+++ b/ext/-test-/cxxanyargs/extconf.rb
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/extconf.rb#L1
 # frozen_string_literal: false
 
-cxx = MakeMakefile::CXX
+cxx = MakeMakefile["C++"]
 
 ok = cxx.try_compile(<<~'begin', "") do |x|
   #include "ruby/config.h"
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 8df6e9a..ce72668 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -2776,7 +2776,17 @@ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L2776
 realclean: distclean
 "
 
-  module CXX
+  @lang = Hash.new(self)
+
+  def self.[](name)
+    @lang.fetch(name)
+  end
+
+  def self.[]=(name, mod)
+    @lang[name] = mod
+  end
+
+  self["C++"] = Module.new do
     include MakeMakefile
     extend self
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]