class V8::Portal::Caller

Public Class Methods

new(portal) click to toggle source
# File lib/v8/portal/caller.rb, line 6
def initialize(portal)
  @portal = portal
end

Public Instance Methods

invoke(code, *args, &block) click to toggle source
# File lib/v8/portal/caller.rb, line 29
def invoke(code, *args, &block)
  protect do
    args = args.slice(0, code.arity) if code.arity >= 0
    code.call(*args, &block)
  end
end
protect(*args, &block) click to toggle source
# File lib/v8/portal/caller.rb, line 25
def protect(*args, &block)
  @portal.v8 raw(*args, &block)
end
raw() { || ... } click to toggle source
# File lib/v8/portal/caller.rb, line 10
def raw
  yield
rescue Exception => e
  case e
  when SystemExit, NoMemoryError
    raise e
  else
    error = V8::C::Exception::Error(V8::C::String::New(e.message))
    #TODO: This is almost certainly a crash here.
    #we need to hold onto `error` while it bubbles up the javascript stack.
    error.SetHiddenValue("TheRubyRacer::Cause", C::External::New(e))
    V8::C::ThrowException(error)
  end
end