Sha256: 4dc1d42c61e6d3600cae5fc1b5e6d2758d4e1dbae4249349b42ed019acb3f40b

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

module V8
  class Function < V8::Object
    
    def methodcall(thisObject, *args)
      err = nil
      return_value = nil
      C::TryCatch.try do |try|
        @context.enter do
          this = To.v8(thisObject)
          return_value = To.ruby(@native.Call(this, To.v8(args)))
          err = JavascriptError.new(try) if try.HasCaught()
        end
      end
      raise err if err
      return return_value
    end
    
    def call(*args)
      self.methodcall(@context.Global(), *args)
    end
    
    def new(*args)
      @context.enter do
        To.rb(@native.NewInstance(To.v8(args)))
      end
    end

    def self.rubycall(rubycode, *args)
      begin
        To.v8(rubycode.call(*args))
      rescue StandardError => e
        V8::C::ThrowException(V8::C::Exception::Error(V8::C::String::New(e.message)))
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
therubyracer-0.7.1 lib/v8/function.rb
therubyracer-0.7.1.pre lib/v8/function.rb