Search in sources :

Example 6 with XMLObject

use of org.mozilla.javascript.xml.XMLObject in project hackpad by dropbox.

the class ScriptRuntime method setName.

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 {
        // 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;
}
Also used : XMLObject(org.mozilla.javascript.xml.XMLObject)

Example 7 with XMLObject

use of org.mozilla.javascript.xml.XMLObject in project hackpad by dropbox.

the class ScriptRuntime method setConst.

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;
}
Also used : XMLObject(org.mozilla.javascript.xml.XMLObject)

Example 8 with XMLObject

use of org.mozilla.javascript.xml.XMLObject in project hackpad by dropbox.

the class ScriptRuntime method strictSetName.

public static Object strictSetName(Scriptable bound, Object value, Context cx, Scriptable scope, String id) {
    if (bound != null) {
        // 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);
    }
}
Also used : XMLObject(org.mozilla.javascript.xml.XMLObject)

Example 9 with XMLObject

use of org.mozilla.javascript.xml.XMLObject in project hackpad by dropbox.

the class ScriptRuntime method setObjectIndex.

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;
}
Also used : XMLObject(org.mozilla.javascript.xml.XMLObject)

Example 10 with XMLObject

use of org.mozilla.javascript.xml.XMLObject in project hackpad by dropbox.

the class ScriptRuntime method getObjectElem.

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;
}
Also used : XMLObject(org.mozilla.javascript.xml.XMLObject) XMLObject(org.mozilla.javascript.xml.XMLObject)

Aggregations

XMLObject (org.mozilla.javascript.xml.XMLObject)17 StringReader (java.io.StringReader)2 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)2 StringWriter (java.io.StringWriter)1 Date (java.util.Date)1 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Abdera (org.apache.abdera.Abdera)1 Factory (org.apache.abdera.factory.Factory)1 IRISyntaxException (org.apache.abdera.i18n.iri.IRISyntaxException)1 LogFactory (org.apache.commons.logging.LogFactory)1 FileHostObject (org.jaggeryjs.hostobjects.file.FileHostObject)1 Context (org.mozilla.javascript.Context)1 Scriptable (org.mozilla.javascript.Scriptable)1 Wrapper (org.mozilla.javascript.Wrapper)1 Node (org.w3c.dom.Node)1