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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations