Sha256: 3e5f3a767b7d9e887a57b1b30c7026e9a168a8f4c8ac576fded154defa4d52cc

Contents?: true

Size: 873 Bytes

Versions: 8

Compression:

Stored size: 873 Bytes

Contents

module V8
  class Portal
    class Caller
      
      def initialize(portal)
        @portal = portal
      end
      
      def raw
        begin
          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
      end

      def protect(*args, &block)
        @portal.v8 raw(*args, &block)
      end

      def invoke(code, *args, &block)
        protect do
          code.call(*args, &block)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
therubyracer-0.9.4 lib/v8/portal/caller.rb
therubyracer-0.9.3 lib/v8/portal/caller.rb
therubyracer-0.9.3beta1 lib/v8/portal/caller.rb
therubyracer-0.9.2 lib/v8/portal/caller.rb
therubyracer-0.9.2beta1 lib/v8/portal/caller.rb
therubyracer-0.9.1 lib/v8/portal/caller.rb
therubyracer-0.9.1beta1 lib/v8/portal/caller.rb
therubyracer-0.9.0 lib/v8/portal/caller.rb