We are converting from spidermonkey to rhino and it appears that the
name property for the constructor function returns "constructor" for
all builtin types.  Spidermonkey would return "Date" or "Array" or
whatever.  Is there a workaround?  This code needs to work with both
interpreters.

Here is an example of the rhino behavior:

js> var i=new Date;
js> i.constructor.name
constructor
js> Date.name
constructor
js> function bob(){}
js> bob.name
bob
js> var i = new Array();
js> i.constructor.name
constructor
js>
This commit is contained in:
nboyd%atg.com 2002-01-04 14:04:01 +00:00
Родитель bbb7be562e
Коммит 4476a490b1
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -419,7 +419,7 @@ public abstract class IdScriptable extends ScriptableObject
throw new RuntimeException("No id for constructor property");
}
IdFunction ctor = newIdFunction(constructorId);
IdFunction ctor = newIdFunction(getClassName(), constructorId);
ctor.initAsConstructor(scope, this);
fillConstructorProperties(cx, ctor, sealed);
if (sealed) {
@ -484,7 +484,11 @@ public abstract class IdScriptable extends ScriptableObject
}
protected IdFunction newIdFunction(int id) {
IdFunction f = new IdFunction(this, getIdName(id), id);
return newIdFunction(getIdName(id), id);
}
protected IdFunction newIdFunction(String name, int id) {
IdFunction f = new IdFunction(this, name, id);
if (0 != (setupFlags & SEAL_FUNCTIONS_FLAG)) { f.sealObject(); }
return f;
}