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

Move Get,Set,Constructor and friends out of Class

Even though they had been moved into the
`ClassAction` module, that module still had the
potential for conflict. Instead, we'll just put 
evenything in the Conversion namespace. That way
we need not worry.
This commit is contained in:
Charles Lowell 2012-07-24 23:25:04 +03:00
parent 7f3a8cb91f
commit c5b13ea115
3 changed files with 99 additions and 110 deletions

View file

@ -4,10 +4,10 @@ class V8::Conversion
def to_template
weakcell(:constructor) do
template = V8::C::FunctionTemplate::New(V8::Conversion::ClassActions::Constructor.new(self))
template = V8::C::FunctionTemplate::New(V8::Conversion::Constructor.new(self))
prototype = template.InstanceTemplate()
prototype.SetNamedPropertyHandler(V8::Conversion::ClassActions::Get, V8::Conversion::ClassActions::Set)
prototype.SetIndexedPropertyHandler(V8::Conversion::ClassActions::IGet, V8::Conversion::ClassActions::ISet)
prototype.SetNamedPropertyHandler(V8::Conversion::Get, V8::Conversion::Set)
prototype.SetIndexedPropertyHandler(V8::Conversion::IGet, V8::Conversion::ISet)
if self != ::Object && superclass != ::Object && superclass != ::Class
template.Inherit(superclass.to_template)
end
@ -16,7 +16,6 @@ class V8::Conversion
end
end
module ClassActions
class Constructor
include V8::Error::Protect
@ -118,4 +117,3 @@ class V8::Conversion
end
end
end
end

View file

@ -1,21 +0,0 @@
require 'spec_helper'
# NOTE: This was written to reproduce a bug where V8::Conversion would load the wrong class
# when inside of an eigen class scope.
# We use Set because ::Set is a existing class and V8::Conversion::Class::Set also exists
require "set"
describe "Class scope" do
it "doesn't try to use V8::Conversion::Class::* as root objects" do
klass = Class.new do
class << self
def test
Set.new
end
end
end
klass.test.should be_instance_of(::Set)
end
end

View file

@ -6,4 +6,16 @@ describe V8::Conversion do
cxt['big'] = BigDecimal.new('1.1')
cxt['big'].should eql BigDecimal.new('1.1')
end
it "doesn't try to use V8::Conversion::Class::* as root objects" do
klass = Class.new do
class << self
def test
Set.new
end
end
end
klass.test.should be_instance_of(::Set)
end
end