1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

truncate/fill arguments according to Ruby arity

This commit is contained in:
Charles Lowell 2012-06-11 16:20:42 -05:00
parent 1c9694a732
commit 4a8612f5c4

View file

@ -19,10 +19,13 @@ class V8::Conversion
context = V8::Context.current
proc = arguments.Data().Value()
length_of_given_args = arguments.Length()
args = ::Array.new(proc.arity < 0 ? length_of_given_args : [length_of_given_args, proc.arity].min)
args = ::Array.new(proc.arity < 0 ? length_of_given_args : proc.arity)
0.upto(args.length - 1) do |i|
args[i] = context.to_ruby arguments[i]
if i < length_of_given_args
args[i] = context.to_ruby arguments[i]
end
end
puts
context.to_v8 proc.call(*args)
rescue Exception => e
warn "unhandled exception in ruby #{e.class}: #{e.message}"