mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
This patch fixes the bug when global With object was set to With
prototype and not With constructor, makes id for constructor property visible only in a prototype instance and removes the unused scopeInit function.
This commit is contained in:
parent
357263c927
commit
a388953fef
@ -43,10 +43,12 @@ import java.lang.reflect.Method;
|
||||
* It simply delegates every action to its prototype except
|
||||
* for operations on its parent.
|
||||
*/
|
||||
public class NativeWith implements Scriptable, IdFunctionMaster
|
||||
{
|
||||
public class NativeWith implements Scriptable, IdFunctionMaster {
|
||||
|
||||
public static void init(Context cx, Scriptable scope, boolean sealed) {
|
||||
NativeWith obj = new NativeWith();
|
||||
obj.prototypeFlag = true;
|
||||
|
||||
IdFunction ctor = new IdFunction(obj, "constructor", Id_constructor);
|
||||
ctor.initAsConstructor(scope, obj);
|
||||
if (sealed) { ctor.sealObject(); }
|
||||
@ -54,7 +56,7 @@ public class NativeWith implements Scriptable, IdFunctionMaster
|
||||
obj.setParentScope(ctor);
|
||||
obj.setPrototype(ScriptableObject.getObjectPrototype(scope));
|
||||
|
||||
ScriptableObject.defineProperty(scope, "With", obj,
|
||||
ScriptableObject.defineProperty(scope, "With", ctor,
|
||||
ScriptableObject.DONTENUM);
|
||||
}
|
||||
|
||||
@ -66,18 +68,6 @@ public class NativeWith implements Scriptable, IdFunctionMaster
|
||||
this.prototype = prototype;
|
||||
}
|
||||
|
||||
public void scopeInit(Context cx, Scriptable scope, boolean sealed) {
|
||||
IdFunction ctor = new IdFunction(this, "constructor", Id_constructor);
|
||||
ctor.initAsConstructor(scope, this);
|
||||
if (sealed) { ctor.sealObject(); }
|
||||
|
||||
setParentScope(ctor);
|
||||
setPrototype(ScriptableObject.getObjectPrototype(scope));
|
||||
|
||||
ScriptableObject.defineProperty(scope, getClassName(), this,
|
||||
ScriptableObject.DONTENUM);
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return "With";
|
||||
}
|
||||
@ -159,14 +149,19 @@ public class NativeWith implements Scriptable, IdFunctionMaster
|
||||
Object[] args)
|
||||
throws JavaScriptException
|
||||
{
|
||||
if (methodId == Id_constructor) {
|
||||
throw Context.reportRuntimeError1("msg.cant.call.indirect", "With");
|
||||
if (prototypeFlag) {
|
||||
if (methodId == Id_constructor) {
|
||||
throw Context.reportRuntimeError1
|
||||
("msg.cant.call.indirect", "With");
|
||||
}
|
||||
}
|
||||
throw IdFunction.onBadMethodId(this, methodId);
|
||||
}
|
||||
|
||||
public int methodArity(int methodId) {
|
||||
if (methodId == Id_constructor) { return 0; }
|
||||
if (prototypeFlag) {
|
||||
if (methodId == Id_constructor) { return 0; }
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -189,14 +184,12 @@ public class NativeWith implements Scriptable, IdFunctionMaster
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
protected int getMinimumId() { return 0; }
|
||||
protected int getMaximumId() { return MAX_ID; }
|
||||
|
||||
private static final int
|
||||
Id_constructor = 1,
|
||||
MAX_ID = 1;
|
||||
Id_constructor = 1;
|
||||
|
||||
private Scriptable prototype;
|
||||
private Scriptable parent;
|
||||
private Scriptable constructor;
|
||||
|
||||
private boolean prototypeFlag;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user