From 11d0e9760b6cc948ff81b5f2f26bc7e7e6c13b86 Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Tue, 25 Feb 2003 09:17:43 +0000 Subject: [PATCH] Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=96270 : proper implementation of Scriptable.has in ImporterTopLevel and NativeJavaPackages --- .../src/org/mozilla/javascript/ImporterTopLevel.java | 11 +++++++++++ .../src/org/mozilla/javascript/NativeJavaPackage.java | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java b/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java index 0301d34d8db4..af173828f8d8 100644 --- a/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java +++ b/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java @@ -97,10 +97,21 @@ public class ImporterTopLevel extends ScriptableObject { return "global"; } + public boolean has(String name, Scriptable start) { + return super.has(name, start) + || getPackageProperty(name, start) != NOT_FOUND; + } + public Object get(String name, Scriptable start) { Object result = super.get(name, start); if (result != NOT_FOUND) return result; + result = getPackageProperty(name, start); + return result; + } + + private Object getPackageProperty(String name, Scriptable start) { + Object result= NOT_FOUND; if (name.equals("_packages_")) return result; Object plist = ScriptableObject.getProperty(start,"_packages_"); diff --git a/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java b/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java index e5317116dff9..210347f6694b 100644 --- a/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java +++ b/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java @@ -178,10 +178,14 @@ public class NativeJavaPackage extends ScriptableObject { return "JavaPackage"; } - public boolean has(String id, int index, Scriptable start) { + public boolean has(String id, Scriptable start) { return true; } + public boolean has(int index, Scriptable start) { + return false; + } + public void put(String id, Scriptable start, Object value) { // Can't add properties to Java packages. Sorry. }