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
# File 'lib/v8/function.rb', line 18

def call(*args)
  self.methodcall(@portal.context.native.Global(), *args)
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
  C::TryCatch.try do |try|
    @portal.open do |to|
      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



28
29
30
31
32
# File 'lib/v8/function.rb', line 28

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

#name=(name) ⇒ Object



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

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

#new(*args) ⇒ Object



22
23
24
25
26
# File 'lib/v8/function.rb', line 22

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