2009-10-06 14:20:37 -04:00
|
|
|
|
|
|
|
module Rhino
|
2009-10-09 19:36:42 -04:00
|
|
|
module To
|
|
|
|
JS_UNDEF = [J::Scriptable::NOT_FOUND, J::Undefined]
|
|
|
|
|
2009-10-06 14:20:37 -04:00
|
|
|
def ruby(object)
|
|
|
|
case object
|
2009-11-09 10:45:23 -05:00
|
|
|
when *JS_UNDEF then nil
|
|
|
|
when J::Wrapper then object.unwrap
|
|
|
|
when J::Scriptable then NativeObject.new(object)
|
2009-10-06 14:20:37 -04:00
|
|
|
else object
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def javascript(object)
|
|
|
|
case object
|
|
|
|
when NativeObject then object.j
|
|
|
|
when J::Scriptable then object
|
2009-11-09 10:45:23 -05:00
|
|
|
else RubyObject.new(object)
|
2009-10-06 14:20:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module_function :ruby, :javascript
|
|
|
|
end
|
|
|
|
end
|