1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

make embedded constructors per context. one more failing spec!!!

This commit is contained in:
Charles Lowell 2010-08-28 15:35:09 -05:00
parent 4353854671
commit e5bdf2b410
2 changed files with 24 additions and 26 deletions

View file

@ -1,6 +1,5 @@
require 'set'
module V8
class Access
def initialize(portal)
@classes = Hash.new do |h, cls|
@ -121,27 +120,4 @@ module V8
end
end
end
class Constructors < Access
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.rubysend(cls, :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
end
end

View file

@ -10,12 +10,34 @@ module V8
@named_property_query = nil
@named_property_deleter = nil
@named_property_enumerator = Interceptor(NamedPropertyEnumerator)
@indexed_property_getter = Interceptor(IndexedPropertyGetter)
@indexed_property_setter = Interceptor(IndexedPropertySetter)
@indexed_property_query = nil
@indexed_property_deleter = nil
@indexed_property_enumerator = Interceptor(IndexedPropertyEnumerator)
@constructors = Hash.new do |h, cls|
template = @context.access[cls]
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 << rb(arguments[i])
end
instance = rubysend(cls, :new, *rbargs)
wrap = C::External::New(instance)
end
arguments.This().tap do |this|
this.SetHiddenValue(C::String::NewSymbol("TheRubyRacer::RubyObject"), wrap)
end
end
h[cls] = template
end
end
def open
@ -69,7 +91,7 @@ module V8
when ::Time
C::Date::New(value)
when ::Class
Constructors[value].GetFunction().tap do |f|
@constructors[value].GetFunction().tap do |f|
f.SetHiddenValue(C::String::NewSymbol("TheRubyRacer::RubyObject"), C::External::New(value))
end
when nil,Numeric,TrueClass,FalseClass, C::Value