Java 类org.mozilla.javascript.xml.XMLObject 实例源码

项目:HL4A    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuilder rv = new StringBuilder();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{
    if (obj instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)obj;
        return xmlObject.ecmaGet(cx, elem);
    }

    Object result;

    String s = toStringIdOrIndex(cx, elem);
    if (s == null) {
        int index = lastIndexResult(cx);
        result = ScriptableObject.getProperty(obj, index);
    } else {
        result = ScriptableObject.getProperty(obj, s);
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object getObjectProp(Scriptable obj, String property,
                                   Context cx)
{
    if (obj instanceof XMLObject) {
        // TODO: Change XMLObject to just use Scriptable interface
        // to avoid paying cost of instanceof check on *every property
        // lookup* !
        XMLObject xmlObject = (XMLObject)obj;
        return xmlObject.ecmaGet(cx, property);
    }

    Object result = ScriptableObject.getProperty(obj, property);
    if (result == Scriptable.NOT_FOUND) {
        if (cx.hasFeature(Context.FEATURE_STRICT_MODE)) {
            Context.reportWarning(ScriptRuntime.getMessage1(
                "msg.ref.undefined.prop", property));
        }
        result = Undefined.instance;
    }

    return result;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object getObjectPropNoWarn(Object obj, String property,
                                         Context cx)
{
    Scriptable sobj = toObjectOrNull(cx, obj);
    if (sobj == null) {
        throw undefReadError(obj, property);
    }
    if (obj instanceof XMLObject) {
        // TODO: fix as mentioned in note in method above
        getObjectProp(sobj, property, cx);
    }
    Object result = ScriptableObject.getProperty(sobj, property);
    if (result == Scriptable.NOT_FOUND) {
      return Undefined.instance;
    }
    return result;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)obj;
        xmlObject.ecmaPut(cx, elem, value);
        return value;
    }

    String s = toStringIdOrIndex(cx, elem);
    if (s == null) {
        int index = lastIndexResult(cx);
        ScriptableObject.putProperty(obj, index, value);
    } else {
        ScriptableObject.putProperty(obj, s, value);
    }

    return value;
}
项目:whackpad    文件:ScriptRuntime.java   
public static boolean deleteObjectElem(Scriptable target, Object elem,
                                       Context cx)
{
    boolean result;
    if (target instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)target;
        result = xmlObject.ecmaDelete(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            target.delete(index);
            return !target.has(index, target);
        } else {
            target.delete(s);
            return !target.has(s, target);
        }
    }
    return result;
}
项目:whackpad    文件:ScriptRuntime.java   
public static boolean hasObjectElem(Scriptable target, Object elem,
                                    Context cx)
{
    boolean result;

    if (target instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)target;
        result = xmlObject.ecmaHas(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.hasProperty(target, index);
        } else {
            result = ScriptableObject.hasProperty(target, s);
        }
    }

    return result;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object strictSetName(Scriptable bound, Object value,
        Context cx, Scriptable scope, String id) {
    if (bound != null) {
        // TODO: The LeftHandSide also may not be a reference to a
        // data property with the attribute value {[[Writable]]:false},
        // to an accessor property with the attribute value
        // {[[Put]]:undefined}, nor to a non-existent property of an
        // object whose [[Extensible]] internal property has the value
        // false. In these cases a TypeError exception is thrown (11.13.1).
        if (bound instanceof XMLObject) {
            XMLObject xmlObject = (XMLObject) bound;
            xmlObject.ecmaPut(cx, id, value);
        } else {
            ScriptableObject.putProperty(bound, id, value);
        }
        return value;
    } else {
        // See ES5 8.7.2
        String msg = "Assignment to undefined \"" + id + "\" in strict mode";
        throw constructError("ReferenceError", msg);
    }
}
项目:whackpad    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuffer rv = new StringBuffer();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:TaleCraft    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:TaleCraft    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:code404    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:code404    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:code404    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuffer rv = new StringBuffer();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:rhino-jscover    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:rhino-jscover    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:rhino-jscover    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuffer rv = new StringBuffer();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:LoboEvolution    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else if (isSymbol(elem)) {
        result = ScriptableObject.getProperty(obj, (Symbol)elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:LoboEvolution    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else if (isSymbol(elem)) {
        ScriptableObject.putProperty(obj, (Symbol)elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:astor    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:astor    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:astor    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuffer rv = new StringBuffer();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:wso2-axis2    文件:JSOMElementConvertor.java   
public OMElement fromScript(Object o) {
    if (!(o instanceof XMLObject)) {
        return super.fromScript(o);
    }

    // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost. See Mozilla bugzilla 361722
    Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) o, "copy", new Object[0]);
    Wrapper wrapper = (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new Object[0]);
    XmlObject xmlObject = (XmlObject)wrapper.unwrap();
    try {

        StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
        OMElement omElement = builder.getDocumentElement();

        return omElement;

    } catch (XMLStreamException e) {
        throw new RuntimeException(e);
    }
}
项目:Rhino-Prov-Mod    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:Rhino-Prov-Mod    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:Rhino-Prov-Mod    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuffer rv = new StringBuffer();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:android-js    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:android-js    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:closure-compiler-old    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:closure-compiler-old    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:closure-compiler-old    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuffer rv = new StringBuffer();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:closure-compiler-copy    文件:ScriptRuntime.java   
public static Object getObjectElem(Scriptable obj, Object elem,
                                   Context cx)
{

    Object result;

    if (obj instanceof XMLObject) {
        result = ((XMLObject)obj).get(cx, elem);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            result = ScriptableObject.getProperty(obj, index);
        } else {
            result = ScriptableObject.getProperty(obj, s);
        }
    }

    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:closure-compiler-copy    文件:ScriptRuntime.java   
public static Object setObjectElem(Scriptable obj, Object elem,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        ((XMLObject)obj).put(cx, elem, value);
    } else {
        String s = toStringIdOrIndex(cx, elem);
        if (s == null) {
            int index = lastIndexResult(cx);
            ScriptableObject.putProperty(obj, index, value);
        } else {
            ScriptableObject.putProperty(obj, s, value);
        }
    }

    return value;
}
项目:closure-compiler-copy    文件:XML.java   
private String ecmaToString() {
    //    See ECMA357 10.1.1
    if (isAttribute() || isText()) {
        return ecmaValue();
    }
    if (this.hasSimpleContent()) {
        StringBuffer rv = new StringBuffer();
        for (int i=0; i < this.node.getChildCount(); i++) {
            XmlNode child = this.node.getChild(i);
            if (!child.isProcessingInstructionType() &&
                !child.isCommentType())
            {
                // TODO: Probably inefficient; taking clean non-optimized
                // solution for now
                XML x = new XML(getLib(), getParentScope(),
                                (XMLObject)getPrototype(), child);
                rv.append(x.toString());
            }
        }
        return rv.toString();
    }
    return toXMLString();
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object getObjectIndex(Scriptable obj, int index,
                                    Context cx)
{
    if (obj instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)obj;
        return xmlObject.ecmaGet(cx, Integer.valueOf(index));
    }

    Object result = ScriptableObject.getProperty(obj, index);
    if (result == Scriptable.NOT_FOUND) {
        result = Undefined.instance;
    }

    return result;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object setObjectProp(Scriptable obj, String property,
                                   Object value, Context cx)
{
    if (obj instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)obj;
        xmlObject.ecmaPut(cx, property, value);
    } else {
        ScriptableObject.putProperty(obj, property, value);
    }
    return value;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object setObjectIndex(Scriptable obj, int index, Object value,
                                    Context cx)
{
    if (obj instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)obj;
        xmlObject.ecmaPut(cx, Integer.valueOf(index), value);
    } else {
        ScriptableObject.putProperty(obj, index, value);
    }
    return value;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object setName(Scriptable bound, Object value,
                             Context cx, Scriptable scope, String id)
{
    if (bound != null) {
        if (bound instanceof XMLObject) {
            XMLObject xmlObject = (XMLObject)bound;
            xmlObject.ecmaPut(cx, id, value);
        } else {
            ScriptableObject.putProperty(bound, id, value);
        }
    } else {
        // "newname = 7;", where 'newname' has not yet
        // been defined, creates a new property in the
        // top scope unless strict mode is specified.
        if (cx.hasFeature(Context.FEATURE_STRICT_MODE) ||
            cx.hasFeature(Context.FEATURE_STRICT_VARS))
        {
            Context.reportWarning(
                ScriptRuntime.getMessage1("msg.assn.create.strict", id));
        }
        // Find the top scope by walking up the scope chain.
        bound = ScriptableObject.getTopLevelScope(scope);
        if (cx.useDynamicScope) {
            bound = checkDynamicScope(cx.topCallScope, bound);
        }
        bound.put(id, bound, value);
    }
    return value;
}
项目:whackpad    文件:ScriptRuntime.java   
public static Object setConst(Scriptable bound, Object value,
                             Context cx, String id)
{
    if (bound instanceof XMLObject) {
        XMLObject xmlObject = (XMLObject)bound;
        xmlObject.ecmaPut(cx, id, value);
    } else {
        ScriptableObject.putConstProperty(bound, id, value);
    }
    return value;
}
项目:whackpad    文件:ScriptRuntime.java   
/**
 * Prepare for calling obj[id](...): return function corresponding to
 * obj[id] and make obj properly converted to Scriptable available
 * as ScriptRuntime.lastStoredScriptable() for consumption as thisObj.
 * The caller must call ScriptRuntime.lastStoredScriptable() immediately
 * after calling this method.
 */
public static Callable getElemFunctionAndThis(Object obj,
                                              Object elem,
                                              Context cx)
{
    String s = toStringIdOrIndex(cx, elem);
    if (s != null) {
        return getPropFunctionAndThis(obj, s, cx);
    }
    int index = lastIndexResult(cx);

    Scriptable thisObj = toObjectOrNull(cx, obj);
    if (thisObj == null) {
        throw undefCallError(obj, String.valueOf(index));
    }

    Object value;
    for (;;) {
        // Ignore XML lookup as required by ECMA 357, 11.2.2.1
        value = ScriptableObject.getProperty(thisObj, index);
        if (value != Scriptable.NOT_FOUND) {
            break;
        }
        if (!(thisObj instanceof XMLObject)) {
            break;
        }
        XMLObject xmlObject = (XMLObject)thisObj;
        Scriptable extra = xmlObject.getExtraMethodSource(cx);
        if (extra == null) {
            break;
        }
        thisObj = extra;
    }
    if (!(value instanceof Callable)) {
        throw notFunctionError(value, elem);
    }

    storeScriptable(cx, thisObj);
    return (Callable)value;
}