From 1b5ea69f67175e0289c036f0379c77d223050744 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 5 Aug 2010 11:37:49 -0500 Subject: [PATCH] allow default ruby access property interceptors to specify which properties they do *not* intercept. --- lib/v8/access.rb | 27 ++++++++++++++++++++------- lib/v8/function.rb | 8 ++++---- spec/redjs | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/v8/access.rb b/lib/v8/access.rb index b9a87a6..5f223ee 100644 --- a/lib/v8/access.rb +++ b/lib/v8/access.rb @@ -122,7 +122,11 @@ module V8 To.v8(method) end elsif obj.respond_to?(:[]) - Function.rubysend(obj, :[], name) + intercepts = true + result = Function.rubysend(obj, :[], name) do + intercepts = false + end + intercepts ? result : C::Empty else C::Empty end @@ -140,8 +144,11 @@ module V8 Function.rubysend(obj, setter, To.rb(value)) value elsif obj.respond_to?(:[]=) - Function.rubysend(obj, :[]=, name, To.rb(value)) - value + intercepts = true + Function.rubysend(obj, :[]=, name, To.rb(value)) do + intercepts = false + end + intercepts ? value : C::Empty else C::Empty end @@ -165,7 +172,11 @@ module V8 def self.call(index, info) obj = To.rb(info.This()) if obj.respond_to?(:[]) - Function.rubysend(obj, :[], index) + intercepts = true + value = Function.rubysend(obj, :[], index) do + intercepts = false + end + intercepts ? value : C::Empty else C::Empty end @@ -176,8 +187,11 @@ module V8 def self.call(index, value, info) obj = To.rb(info.This()) if obj.respond_to?(:[]=) - Function.rubysend(obj, :[]=, index, To.rb(value)) - value + intercepts = true + Function.rubysend(obj, :[]=, index, To.rb(value)) do + intercepts = false + end + intercepts ? value : C::Empty else C::Empty end @@ -190,7 +204,6 @@ module V8 if obj.respond_to?(:length) C::Array::New(obj.length).tap do |indices| for index in 0..obj.length - 1 - rputs "index: #{index}" indices.Set(index,index) end end diff --git a/lib/v8/function.rb b/lib/v8/function.rb index 1e62fb3..2c4beed 100644 --- a/lib/v8/function.rb +++ b/lib/v8/function.rb @@ -40,15 +40,15 @@ module V8 end end - def self.rubycall(rubycode, *args) + def self.rubycall(rubycode, *args, &block) rubyprotect do - rubycode.call(*args) + rubycode.call(*args, &block) end end - def self.rubysend(obj, message, *args) + def self.rubysend(obj, message, *args, &block) rubyprotect do - obj.send(message, *args) + obj.send(message, *args, &block) end end end diff --git a/spec/redjs b/spec/redjs index 9c6563d..baabf41 160000 --- a/spec/redjs +++ b/spec/redjs @@ -1 +1 @@ -Subproject commit 9c6563d8c3838ace05936990b11e0366db6c5564 +Subproject commit baabf41cdcc1f19ddc2cdf392b92e836989b0ad7