Search in sources :

Example 1 with XMLObject

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

the class ScriptRuntime method setObjectElem.

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

Example 2 with XMLObject

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

the class ScriptRuntime method setObjectProp.

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

Example 3 with XMLObject

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

the class ScriptRuntime method hasObjectElem.

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

Example 4 with XMLObject

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

the class ScriptRuntime method getObjectPropNoWarn.

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

Example 5 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)

Aggregations

XMLObject (org.mozilla.javascript.xml.XMLObject)16 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 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