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:
parent
1c9694a732
commit
4a8612f5c4
1 changed files with 5 additions and 2 deletions
|
@ -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}"
|
||||
|
|
Loading…
Add table
Reference in a new issue