diff --git a/lib/v8/context.rb b/lib/v8/context.rb index de429e1..9f54e46 100644 --- a/lib/v8/context.rb +++ b/lib/v8/context.rb @@ -8,8 +8,9 @@ module V8 @to = Portal.new(self, @access) @native = opts[:with] ? C::Context::New(@to.rubytemplate) : C::Context::New() @native.enter do - @scope = @to.rb(@native.Global()) - @native.Global().SetHiddenValue(C::String::New("TheRubyRacer::RubyObject"), C::External::New(opts[:with])) if opts[:with] + @global = @native.Global() + @scope = @to.rb(@global) + @global.SetHiddenValue(C::String::New("TheRubyRacer::RubyObject"), C::External::New(opts[:with])) if opts[:with] end yield(self) if block_given? end diff --git a/lib/v8/error.rb b/lib/v8/error.rb index 0c00376..5efa480 100644 --- a/lib/v8/error.rb +++ b/lib/v8/error.rb @@ -107,9 +107,9 @@ module V8 #in the TryCatch. Is there a better way to detect a syntax error def syntax_error?(try) ex = try.Exception() - if ex && ex.kind_of?(V8::C::Object) - type = ex.Get("constructor") - type && type.kind_of?(V8::C::Function) && type.GetName().AsciiValue == "SyntaxError" + if ex && ex.kind_of?(V8::Object) + type = ex["constructor"] + type && type.kind_of?(V8::Function) && type.name == "SyntaxError" else false end diff --git a/lib/v8/portal.rb b/lib/v8/portal.rb index c603660..1c92190 100644 --- a/lib/v8/portal.rb +++ b/lib/v8/portal.rb @@ -186,7 +186,9 @@ module V8 if external && !external.IsEmpty() external.Value() else - yield.new(value, self) + yield.new(value, self).tap do |object| + value.SetHiddenValue(C::String::NewSymbol("TheRubyRacer::RubyObject"), C::External::New(object)) + end end end diff --git a/spec/redjs b/spec/redjs index 89c9609..88019dc 160000 --- a/spec/redjs +++ b/spec/redjs @@ -1 +1 @@ -Subproject commit 89c9609f1637f2a3505548313fe2d89c60048109 +Subproject commit 88019dcfd31f0cb1bc4c27ba8e4cbb359af1b804