001 
002 /*
003  *  JScripter Simulation 1.0 - For Java To Script
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package org.jscripter.sim.client;
021 
022 import netscape.javascript.JSObject;
023 
024 import js.Vars;
025 import js.core.*;
026 
027 final class JseArray extends JsArray implements Unwrappable<JseObject>, Live
028 {
029     public JseArray(JseObject var) {
030         super((Object)var);
031     }
032 
033     @Override
034     public final JseArray var() {
035         return this;
036     }
037     public final JseObject unwrap() {
038         return (JseObject)var;
039     }
040     public final JSObject getJSObject() {
041         return unwrap().getJSObject();
042     }
043 
044     @Override
045     public final String toString() {
046         return var == null ? "undefined" : unwrap().toString();
047     }
048 
049     @Override
050     public final boolean undefined() {
051         return var == null || unwrap().undefined();
052     }
053 
054     @Override
055     public final boolean delete() {
056         if (undefined()) return false;
057         return unwrap().delete();
058     }
059 
060     @Override
061     public final boolean delete(Mid mid) {
062         return undefined() ? false : unwrap().delete(mid);
063     }
064 
065     public final boolean in(Object o) {
066         return true;
067     }
068 
069     @Override
070     public Object get(int i) {
071         return unwrap().getSlot(i);
072     }
073 
074     @Override
075     public Object set(int i, Object v) {
076         unwrap().setSlot(i, v);
077         return v;
078     }
079 
080     @Override
081     public final Object var(Mid mid) {
082         return unwrap().var(mid);
083     }
084     @Override
085     public final <S> S var(Mid mid, S v) {
086         return unwrap().var(mid, v);
087     }
088 
089     @Override
090     protected final <S> S call(JsFunction.Member<S> member) {
091         return unwrap().call(member);
092     }
093     @Override
094     protected final <S> S call(JsFunction.Member<S> member, Object arg) {
095         return unwrap().call(member, arg);
096     }
097     @Override
098     protected final <S> S call(JsFunction.Member<S> member, Vars<?> args) {
099         return unwrap().call(member, args);
100     }
101 }