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

0.10.0 branch sees incompatible changes to lambda embeddings.

This commit is contained in:
Charles Lowell 2011-10-06 15:06:48 -05:00
parent ba8a9dd92a
commit 52df3776b0
5 changed files with 33 additions and 17 deletions

View file

@ -28,6 +28,7 @@ module V8
def invoke(code, *args, &block)
protect do
args = args.slice(0, code.arity) if code.arity >= 0
code.call(*args, &block)
end
end

View file

@ -6,7 +6,11 @@ module V8
def initialize(portal, code)
@portal = portal
@caller = code.respond_to?(:call) ? Call.new(portal) : BindAndCall.new(portal)
@caller = case code
when Method then BoundCall.new(portal)
when UnboundMethod then BindAndCall.new(portal)
else Call.new(portal)
end
@code = code
@template = V8::C::FunctionTemplate::New(@caller, @code)
end
@ -20,6 +24,17 @@ module V8
@portal = portal
end
def call(arguments)
proc = arguments.Data()
rbargs = [@portal.rb(arguments.This())]
for i in 0..arguments.Length() - 1
rbargs << @portal.rb(arguments[i])
end
@portal.caller.invoke(proc, *rbargs)
end
end
class BoundCall < Call
def call(arguments)
proc = arguments.Data()
rbargs = []

View file

@ -1,3 +1,3 @@
module V8
VERSION = "0.9.9"
VERSION = "0.10.0beta1"
end

View file

@ -42,7 +42,7 @@ describe C::Function do
it "is reflected properly" do
Context.new do |cxt|
cxt['say'] = lambda {|word, times| word * times}
cxt['say'] = lambda {|this, word, times| word * times}
cxt.eval('say("Hello", 3)').should == "HelloHelloHello"
end
end

@ -1 +1 @@
Subproject commit 5f0fb158e65d2723c32145891529ff9c3d2585e9
Subproject commit 1ebcd2a5766cec58f93d80308682ff7858320d3e