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.core;
021 
022 import java.util.Iterator;
023 
024 import js.*;
025 import js.core.*;
026 
027 final class JscBoolean extends JsBoolean implements
028     Iterable<JsBoolean.Mid>, Like<Boolean>, LikeObject, Unwrappable<JscObject>
029 {
030     public JscBoolean(JscObject var) {
031         super((Object)var);
032     }
033     public JscBoolean(Boolean var, ObjectLike objectLike) {
034         this(new JscObject(var, objectLike));
035     }
036     public JscBoolean(Boolean var) {
037         this(var, Js.object());
038     }
039 
040     public final JscObject unwrap() {
041         return (JscObject)var;
042     }
043 
044     public final Boolean like() {
045         return (Boolean)unwrap().like();
046     }
047 
048     public final ObjectLike likeObject() {
049         return unwrap().likeObject();
050     }
051 
052     @Override
053     public final JscBoolean var() {
054         return this;
055     }
056 
057     public final Iterator<Mid> iterator() {
058         return unwrap().iterator();
059     }
060 
061     @Override
062     public final String typeof() {
063         return undefined() ? "undefined" : "object";
064     }
065 
066     @Override
067     public final String toString() {
068         return toString.with(this).call(this);
069     }
070 
071     @Override
072     public final Boolean valueOf() {
073         return valueOf.with(this).call(this);
074     }
075 
076     @Override
077     public final boolean undefined() {
078         return unwrap().undefined();
079     }
080 
081     @Override
082     public final boolean delete() {
083         return unwrap().delete();
084     }
085 
086     @Override
087     public final boolean delete(Mid mid) {
088         return unwrap().delete();
089     }
090 
091     @Override
092     public final Object var(Mid mid) {
093         return unwrap().var(mid);
094     }
095     @Override
096     public final <S> S var(Mid mid, S v) {
097         return unwrap().var(mid, v);
098     }
099 
100     @Override
101     protected final <T> T call(JsFunction.Member<T> member) {
102         return member.with(this).call(this);
103     }
104     @Override
105     protected final <T> T call(JsFunction.Member<T> member, Object arg) {
106         return member.with(this).call(this, arg);
107     }
108     @Override
109     protected final <T> T call(JsFunction.Member<T> member, Vars<?> args) {
110         return member.with(this).call(this, args);
111     }
112 }