From 167e089722b5fe74502eaf9478e4ab3ed41e4151 Mon Sep 17 00:00:00 2001 From: kares Date: Fri, 9 Dec 2011 19:02:08 +0100 Subject: [PATCH] fix NativeObject#[]= JS constant resolution + change getCurrentContext when converting scoped values --- lib/rhino/rhino_ext.rb | 2 ++ lib/rhino/wormhole.rb | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rhino/rhino_ext.rb b/lib/rhino/rhino_ext.rb index d46ae4d..65d3b8b 100644 --- a/lib/rhino/rhino_ext.rb +++ b/lib/rhino/rhino_ext.rb @@ -98,6 +98,8 @@ end class Java::OrgMozillaJavascript::NativeObject + import "org.mozilla.javascript" + # re-implement Map#put def []=(key, value) scope = self diff --git a/lib/rhino/wormhole.rb b/lib/rhino/wormhole.rb index 5fde794..1441562 100644 --- a/lib/rhino/wormhole.rb +++ b/lib/rhino/wormhole.rb @@ -40,8 +40,7 @@ module Rhino end def array_to_javascript(rb_array, scope = nil) - if scope - raise "no current context" unless context = JS::Context.getCurrentContext + if scope && context = JS::Context.getCurrentContext context.newArray(scope, rb_array.to_java) else JS::NativeArray.new(rb_array.to_java) @@ -50,8 +49,7 @@ module Rhino def hash_to_javascript(rb_hash, scope = nil) js_object = - if scope - raise "no current context" unless context = JS::Context.getCurrentContext + if scope && context = JS::Context.getCurrentContext context.newObject(scope) else JS::NativeObject.new