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

ruby-changes:58881

From: Nobuyoshi <ko1@a...>
Date: Fri, 22 Nov 2019 18:43:15 +0900 (JST)
Subject: [ruby-changes:58881] a93d0a4e62 (master): Check -1 arity for C++

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

From a93d0a4e62c50a53ccdc3b2bc114f75a25bfc40f Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 22 Nov 2019 18:39:39 +0900
Subject: Check -1 arity for C++


diff --git a/.gitignore b/.gitignore
index 35f5d3e..487af95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -171,7 +171,7 @@ lcov*.info https://github.com/ruby/ruby/blob/trunk/.gitignore#L171
 /ext/*/exts.mk
 
 # /ext/-test-/cxxanyargs
-/ext/-test-/cxxanyargs/failure.failed
+/ext/-test-/cxxanyargs/failure*.failed
 
 # /ext/-test-/win32/dln/
 /ext/-test-/win32/dln/dlntest.dll
diff --git a/ext/-test-/cxxanyargs/depend b/ext/-test-/cxxanyargs/depend
index ad8260a..02113b6c 100644
--- a/ext/-test-/cxxanyargs/depend
+++ b/ext/-test-/cxxanyargs/depend
@@ -1,11 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/depend#L1
-$(TARGET_SO) $(STATIC_LIB): failure.failed
+$(TARGET_SO) $(STATIC_LIB): $(FAILURES:.cpp=.failed)
 
-failure.failed: failure.cpp cxxanyargs.o
+.SUFFIXES: .failed
+
+.cpp.failed:
 	$(Q)$(RUBY) -rfileutils \
 	  -e "t = ARGV.shift" \
 	  -e "err = IO.popen(ARGV, err:[:child, :out], &:read)" \
 	  -e "abort err unless /rb_define_method/ =~ err" \
-	  -e "FileUtils.touch(t)" $@ $(MAKE) failure.o
+	  -e "File.write(t, err)" $@ $(MAKE) $(*F).o
 
 # AUTOGENERATED DEPENDENCIES START
 cxxanyargs.o: $(RUBY_EXTCONF_H)
diff --git a/ext/-test-/cxxanyargs/extconf.rb b/ext/-test-/cxxanyargs/extconf.rb
index b3f4547..d2a740b 100644
--- a/ext/-test-/cxxanyargs/extconf.rb
+++ b/ext/-test-/cxxanyargs/extconf.rb
@@ -23,6 +23,9 @@ end https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/extconf.rb#L23
 
 if ok
   $srcs = %w[cxxanyargs.cpp]
-  $cleanfiles << "failure.failed"
-  create_makefile("-test-/cxxanyargs")
+  failures = Dir.glob($srcdir + "/failure*.cpp").map {|n| File.basename(n)}
+  $cleanfiles << "$(FAILURES:.cpp=.failed)"
+  create_makefile("-test-/cxxanyargs") do |mk|
+    mk << "FAILURES #{['=', failures].join(' ')}\n"
+  end
 end
diff --git a/ext/-test-/cxxanyargs/failurem1.cpp b/ext/-test-/cxxanyargs/failurem1.cpp
new file mode 100644
index 0000000..e58a0f4
--- /dev/null
+++ b/ext/-test-/cxxanyargs/failurem1.cpp
@@ -0,0 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/failurem1.cpp#L1
+#include <ruby/ruby.h>
+
+static VALUE
+func_argm1(int argc, VALUE *argv, VALUE self)
+{
+    return argc > 0 ? argv[0] : Qnil;
+}
+
+extern "C" void
+Init_failure(void)
+{
+    rb_define_method(rb_cObject, "argm1", func_argm1, 0);
+}
-- 
cgit v0.10.2


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

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