Class: V8::Constructors

Inherits:
Access show all
Defined in:
lib/v8/access.rb

Class Method Summary collapse

Methods inherited from Access

#[], #initialize, rubyobject, #template

Constructor Details

This class inherits a constructor from V8::Access

Class Method Details

.[](cls) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/v8/access.rb', line 71

def self.[](cls)
  Access[cls].tap do |template|
    template.SetCallHandler() do |arguments|
      wrap = nil
      if arguments.Length() > 0 && arguments[0].kind_of?(C::External)
        wrap = arguments[0]
      else
        rbargs = []
        for i in 0..arguments.Length() - 1
          rbargs << To.rb(arguments[i])
        end
        instance = V8::Function.rubycall(cls.method(:new), *rbargs)
        wrap = C::External::New(instance)
      end
      arguments.This().tap do |this|
        this.SetHiddenValue(C::String::NewSymbol("TheRubyRacer::RubyObject"), wrap)
      end
    end
  end
end