From c7b01f8cea1731cf159378b3c002409237754e07 Mon Sep 17 00:00:00 2001 From: "rogerl%netscape.com" Date: Wed, 19 Apr 2000 22:32:50 +0000 Subject: [PATCH] Added hasOwnProperty, propertyIsEnumerable, isPrototypeOf to Object. git-svn-id: svn://10.0.0.236/trunk@66471 18797224-902f-48f8-a5cc-f745e15eee43 --- .../org/mozilla/javascript/NativeObject.java | 42 +++++++++++++++++++ .../org/mozilla/javascript/NativeObject.java | 42 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java b/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java index 76510eaae56..56dc36ab781 100644 --- a/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java +++ b/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java @@ -141,6 +141,48 @@ public class NativeObject extends ScriptableObject { { return thisObj; } + + public static Object jsFunction_hasOwnProperty(Context cx, + Scriptable thisObj, + Object[] args, + Function funObj) + { + if (args.length != 0) + if (thisObj.has(ScriptRuntime.toString(args[0]), null)) + return Boolean.TRUE; + return Boolean.FALSE; + } + + public static Object jsFunction_propertyIsEnumerable(Context cx, + Scriptable thisObj, + Object[] args, + Function funObj) + { + try { + if (args.length != 0) { + String name = ScriptRuntime.toString(args[0]); + if (thisObj.has(name, null)) + if ((((ScriptableObject)thisObj).getAttributes(name, null) + & ScriptableObject.DONTENUM) == 0) + return Boolean.TRUE; + } + } + catch (PropertyException x) { + } + catch (ClassCastException x) { + } + return Boolean.FALSE; + } + + public static Object jsFunction_isPrototypeOf(Context cx, Scriptable thisObj, + Object[] args, Function funObj) + { + if (args.length != 0) + if (args[0] instanceof Scriptable) + if (thisObj == (Scriptable)args[0].getPrototype()) + return Boolean.TRUE; + return Boolean.FALSE; + } } diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java b/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java index 76510eaae56..56dc36ab781 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java @@ -141,6 +141,48 @@ public class NativeObject extends ScriptableObject { { return thisObj; } + + public static Object jsFunction_hasOwnProperty(Context cx, + Scriptable thisObj, + Object[] args, + Function funObj) + { + if (args.length != 0) + if (thisObj.has(ScriptRuntime.toString(args[0]), null)) + return Boolean.TRUE; + return Boolean.FALSE; + } + + public static Object jsFunction_propertyIsEnumerable(Context cx, + Scriptable thisObj, + Object[] args, + Function funObj) + { + try { + if (args.length != 0) { + String name = ScriptRuntime.toString(args[0]); + if (thisObj.has(name, null)) + if ((((ScriptableObject)thisObj).getAttributes(name, null) + & ScriptableObject.DONTENUM) == 0) + return Boolean.TRUE; + } + } + catch (PropertyException x) { + } + catch (ClassCastException x) { + } + return Boolean.FALSE; + } + + public static Object jsFunction_isPrototypeOf(Context cx, Scriptable thisObj, + Object[] args, Function funObj) + { + if (args.length != 0) + if (args[0] instanceof Scriptable) + if (thisObj == (Scriptable)args[0].getPrototype()) + return Boolean.TRUE; + return Boolean.FALSE; + } }