2010-04-21 19:09:13 -04:00
|
|
|
module V8
|
|
|
|
class Function < V8::Object
|
2011-07-02 23:23:08 -04:00
|
|
|
|
2010-06-03 05:51:06 -04:00
|
|
|
def methodcall(thisObject, *args)
|
2010-05-26 12:54:56 -04:00
|
|
|
err = nil
|
|
|
|
return_value = nil
|
2011-07-02 23:23:08 -04:00
|
|
|
@portal.open do |to|
|
|
|
|
C::TryCatch.try do |try|
|
2010-08-28 14:44:33 -04:00
|
|
|
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()
|
2010-05-26 12:54:56 -04:00
|
|
|
end
|
2010-05-26 03:49:53 -04:00
|
|
|
end
|
2010-05-26 12:54:56 -04:00
|
|
|
raise err if err
|
|
|
|
return return_value
|
2010-04-21 19:09:13 -04:00
|
|
|
end
|
2011-07-02 23:23:08 -04:00
|
|
|
|
2010-06-03 05:51:06 -04:00
|
|
|
def call(*args)
|
2011-07-02 23:23:08 -04:00
|
|
|
@portal.open do
|
|
|
|
self.methodcall(@portal.context.native.Global(), *args)
|
|
|
|
end
|
2010-06-03 05:51:06 -04:00
|
|
|
end
|
2011-07-02 23:23:08 -04:00
|
|
|
|
2010-06-03 05:51:06 -04:00
|
|
|
def new(*args)
|
2010-08-28 14:44:33 -04:00
|
|
|
@portal.open do |to|
|
|
|
|
to.rb(@native.NewInstance(to.v8(args)))
|
2010-06-03 05:51:06 -04:00
|
|
|
end
|
|
|
|
end
|
2011-03-21 17:56:44 -04:00
|
|
|
|
|
|
|
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
|