mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Check -1 arity for C++
This commit is contained in:
parent
f9d20a1bf1
commit
a93d0a4e62
4 changed files with 24 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -171,7 +171,7 @@ lcov*.info
|
|||
/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
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
$(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)
|
||||
|
|
|
@ -23,6 +23,9 @@ end
|
|||
|
||||
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
|
||||
|
|
13
ext/-test-/cxxanyargs/failurem1.cpp
Normal file
13
ext/-test-/cxxanyargs/failurem1.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#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);
|
||||
}
|
Loading…
Reference in a new issue