static Hash imageToNameMap = new Hash();
/** the empty object, used for get-traps */
- private static Array emptyobj = new Array();
+ private static JS.Array emptyobj = new JS.Array();
// Instance Data: Templates ////////////////////////////////////////////////////////
/** a trivial private class to serve as the box.indexof function object */
private class IndexOf extends JS.Callable {
public IndexOf() { this.setSeal(true); }
- public Object call(Array args) throws JS.Exn {
+ public Object call(JS.Array args) throws JS.Exn {
if (args.length() != 1 || args.elementAt(0) == null || !(args.elementAt(0) instanceof Box)) return new Integer(-1);
Box b = (Box)args.elementAt(0);
if (b.getParent() != Box.this) {
if (clear && callback != null) {
clear = false;
ThreadMessage.newthread(new JS.Callable() {
- public Object call(Array args_) throws JS.Exn {
+ public Object call(JS.Array args_) throws JS.Exn {
try {
- Array args = new Array();
+ JS.Array args = new JS.Array();
args.addElement(new Double(bytesDownloaded));
args.addElement(new Double(contentLength));
callback.call(args);
public Object get(int i) {
if (redirect == null) return null;
if (redirect != this) return redirect.get(i);
- return i >= numChildren() ? null : getChild(i);
+ return i >= numChildren() || i < 0 ? null : getChild(i);
}
/**
* WARNING: O(n) runtime, unless i == numChildren()
*/
public void put(int i, Object value) {
+ if (i < 0) return;
if (value != null && !(value instanceof Box)) {
if (Log.on) Log.log(this, "attempt to set a numerical property on a box to anything other than a box at " + Context.getCurrentSourceNameAndLine());
public Object[] keys() {
Object[] ret = new Object[numChildren()];
- for(int i=0; i<ret.length; i++) ret[i] = get(i);
+ for(int i=0; i<ret.length; i++) ret[i] = new Integer(i);
return ret;
}
if (!ignoretraps && traps != null) {
Trap t = (Trap)traps.get(name);
if (t != null) {
- Array arg = new Array();
+ JS.Array arg = new JS.Array();
arg.addElement(value);
t.perform(arg);
arg.setElementAt(null, 0);
if (name.charAt(0) == '_') {
if (value != null && !(value instanceof JS.Callable)) {
- if (Log.on) Log.log(this, "attempt to put a non-function value (" + value + ") to " +
+ if (Log.on) Log.log(this, "attempt to put a non function value (" + value + ") to " +
+ name + " at " + Context.getCurrentSourceNameAndLine());
+ } else if (value != null && !(value instanceof JS.CompiledFunction)) {
+ if (Log.on) Log.log(this, "attempt to put a non-compiled function value (" + value + ") to " +
name + " at " + Context.getCurrentSourceNameAndLine());
} else if (name.charAt(1) == '_') {
name = name.substring(2).intern();
Trap t = Trap.getTrap(this, name);
if (t != null) t.delete();
- if (value != null) Trap.addTrap(this, name, ((CompiledFunction)value), true, rp);
+ if (value != null) Trap.addTrap(this, name, ((JS.CompiledFunction)value), true, rp);
} else {
name = name.substring(1).intern();
Trap t = Trap.getTrap(this, name);
if (t != null) t.delete();
- if (value != null) Trap.addTrap(this, name, ((CompiledFunction)value), false, rp);
+ if (value != null) Trap.addTrap(this, name, ((JS.CompiledFunction)value), false, rp);
}
return;
}