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

42 lines
868 B
Ruby
Raw Normal View History

2010-04-21 19:09:13 -04:00
module V8
class Function < V8::Object
def methodcall(thisObject, *args)
err = nil
return_value = nil
C::TryCatch.try do |try|
@portal.open do |to|
this = to.v8(thisObject)
return_value = to.rb(@native.Call(this, to.v8(args)))
2010-08-28 15:04:51 -04:00
err = JSError.new(try, to) if try.HasCaught()
end
end
raise err if err
return return_value
2010-04-21 19:09:13 -04:00
end
def call(*args)
self.methodcall(@portal.context.native.Global(), *args)
end
def new(*args)
@portal.open do |to|
to.rb(@native.NewInstance(to.v8(args)))
end
end
def name
@portal.open do |to|
to.rb(@native.GetName())
end
end
def name=(name)
name.tap do
@portal.open do |to|
@native.SetName(to.v8(name))
end
end
end
2010-04-21 19:09:13 -04:00
end
end