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