diff --git a/Gemfile b/Gemfile index 79bdb4e..c3fef7f 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,4 @@ source 'http://rubygems.org' gemspec gem 'redjs', :git => 'https://github.com/cowboyd/redjs.git' -gem 'libv8', "~> 3.10.8" +gem 'libv8', "~> 3.11.8" diff --git a/ext/v8/build.rb b/ext/v8/build.rb index 279ae74..943645e 100644 --- a/ext/v8/build.rb +++ b/ext/v8/build.rb @@ -1,5 +1,5 @@ -LIBV8_COMPATIBILITY = '~> 3.10.8' +LIBV8_COMPATIBILITY = '~> 3.11.8' def have_rubygem_libv8? gem 'libv8', LIBV8_COMPATIBILITY diff --git a/lib/v8/context.rb b/lib/v8/context.rb index 001825c..c5401a1 100644 --- a/lib/v8/context.rb +++ b/lib/v8/context.rb @@ -8,16 +8,11 @@ module V8 @conversion = Conversion.new @access = Access.new if global = options[:with] - V8::C::Locker() do - V8::C::HandleScope() do - tmp = V8::C::Context::New() - tmp.Enter() - global_template = global.to_v8_template - tmp.Exit() - @native = V8::C::Context::New(nil, global_template) - enter { link global, @native.Global() } - end + Context.new.enter do + global_template = global.class.to_v8_template.InstanceTemplate() + @native = V8::C::Context::New(nil, global_template) end + enter {link global, @native.Global()} else @native = V8::C::Context::New() end diff --git a/lib/v8/conversion/class.rb b/lib/v8/conversion/class.rb index c9fcbad..ca2077e 100644 --- a/lib/v8/conversion/class.rb +++ b/lib/v8/conversion/class.rb @@ -34,6 +34,7 @@ class V8::Conversion arguments.construct @class end end + return arguments.This() end module Args diff --git a/lib/v8/conversion/object.rb b/lib/v8/conversion/object.rb index 203ce18..d70a9ea 100644 --- a/lib/v8/conversion/object.rb +++ b/lib/v8/conversion/object.rb @@ -9,72 +9,9 @@ class V8::Conversion return object end - def to_v8_template - weakcell(:v8_template) do - V8::C::ObjectTemplate::New().tap do |template| - data = V8::C::External::New(self) - template.SetNamedPropertyHandler(Get, Set, nil, nil, nil, data) - template.SetIndexedPropertyHandler(IGet, ISet, nil, nil, nil, data) - end - end - end - def to_ruby self end - - module Accessor - include V8::Error::Protect - def intercept(info, key, &block) - context = V8::Context.current - access = context.access - object = info.Data().Value() - handles_property = true - dontintercept = proc do - handles_property = false - end - protect do - result = block.call(context, access, object, context.to_ruby(key), dontintercept) - handles_property ? context.to_v8(result) : V8::C::Value::Empty - end - end - end - - class Get - extend Accessor - def self.call(property, info) - intercept(info, property) do |context, access, object, key, dontintercept| - access.get(object, key, &dontintercept) - end - end - end - - class Set - extend Accessor - def self.call(property, value, info) - intercept(info, property) do |context, access, object, key, dontintercept| - access.set(object, key, context.to_ruby(value), &dontintercept) - end - end - end - - class IGet - extend Accessor - def self.call(property, info) - intercept(info, property) do |context, access, object, key, dontintercept| - access.iget(object, key, &dontintercept) - end - end - end - - class ISet - extend Accessor - def self.call(property, value, info) - intercept(info, property) do |context, access, object, key, dontintercept| - access.iset(object, key, context.to_ruby(value), &dontintercept) - end - end - end end module NativeObject