Added hasOwnProperty, propertyIsEnumerable, isPrototypeOf to Object.

git-svn-id: svn://10.0.0.236/trunk@66471 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com
2000-04-19 22:32:50 +00:00
parent ebfb917075
commit c7b01f8cea
2 changed files with 84 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}