2012-06-12 07:06:25 -05:00
|
|
|
class V8::Function < V8::Object
|
2015-07-30 21:15:10 +03:00
|
|
|
#include V8::Error::Try
|
2012-06-20 13:20:13 -05:00
|
|
|
|
2012-06-12 07:06:25 -05:00
|
|
|
def initialize(native = nil)
|
|
|
|
super do
|
2012-06-14 08:40:33 -05:00
|
|
|
native || V8::C::FunctionTemplate::New().GetFunction()
|
2012-06-12 07:06:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def methodcall(this, *args)
|
|
|
|
@context.enter do
|
2012-06-20 13:20:13 -05:00
|
|
|
this ||= @context.native.Global()
|
2015-07-30 21:15:10 +03:00
|
|
|
@context.to_ruby native.Call(@context.to_v8(this), args.map {|a| @context.to_v8 a})
|
2012-06-12 07:06:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(*args)
|
|
|
|
@context.enter do
|
|
|
|
methodcall @context.native.Global(), *args
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def new(*args)
|
|
|
|
@context.enter do
|
2015-07-31 15:10:18 +03:00
|
|
|
@context.to_ruby native.NewInstance(args.map {|a| @context.to_v8 a})
|
2012-06-12 07:06:25 -05:00
|
|
|
end
|
|
|
|
end
|
2015-07-30 21:15:10 +03:00
|
|
|
end
|