Class: V8::Function

Inherits:
Object show all
Defined in:
lib/v8/function.rb

Instance Method Summary collapse

Methods inherited from Object

#[], #[]=, #each, #initialize, #method_missing, #respond_to?, #to_s

Constructor Details

This class inherits a constructor from V8::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class V8::Object

Instance Method Details

#call(*args) ⇒ Object



18
19
20
21
22
# File 'lib/v8/function.rb', line 18

def call(*args)
  @portal.open do
    self.methodcall(@portal.context.native.Global(), *args)
  end
end

#methodcall(thisObject, *args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/v8/function.rb', line 4

def methodcall(thisObject, *args)
  err = nil
  return_value = nil
  @portal.open do |to|
    C::TryCatch.try do |try|
      this = to.v8(thisObject)
      return_value = to.rb(@native.Call(this, to.v8(args)))
      err = JSError.new(try, to) if try.HasCaught()
    end
  end
  raise err if err
  return return_value
end

#nameObject



30
31
32
33
34
# File 'lib/v8/function.rb', line 30

def name
  @portal.open do |to|
    to.rb(@native.GetName())
  end
end

#name=(name) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/v8/function.rb', line 36

def name=(name)
  name.tap do
    @portal.open do |to|
      @native.SetName(to.v8(name))
    end
  end
end

#new(*args) ⇒ Object



24
25
26
27
28
# File 'lib/v8/function.rb', line 24

def new(*args)
  @portal.open do |to|
    to.rb(@native.NewInstance(to.v8(args)))
  end
end