public static Object setDefaultNamespace(Object namespace, Context cx) { Scriptable scope = cx.currentActivationCall; if (scope == null) { scope = getTopCallScope(cx); } XMLLib xmlLib = currentXMLLib(cx); Object ns = xmlLib.toDefaultXmlNamespace(cx, namespace); // XXX : this should be in separated namesapce from Scriptable.get/put if (!scope.has(DEFAULT_NS_TAG, scope)) { // XXX: this is racy of cause ScriptableObject.defineProperty(scope, DEFAULT_NS_TAG, ns, ScriptableObject.PERMANENT | ScriptableObject.DONTENUM); } else { scope.put(DEFAULT_NS_TAG, scope, ns); } return Undefined.instance; }
private static XMLLib currentXMLLib(Context cx) { // Scripts should be running to access this if (cx.topCallScope == null) throw new IllegalStateException(); XMLLib xmlLib = cx.cachedXMLLib; if (xmlLib == null) { xmlLib = XMLLib.extractFromScope(cx.topCallScope); if (xmlLib == null) throw new IllegalStateException(); cx.cachedXMLLib = xmlLib; } return xmlLib; }
public static Ref nameRef(Object name, Context cx, Scriptable scope, int memberTypeFlags) { XMLLib xmlLib = currentXMLLib(cx); return xmlLib.nameRef(cx, name, scope, memberTypeFlags); }
public static Ref nameRef(Object namespace, Object name, Context cx, Scriptable scope, int memberTypeFlags) { XMLLib xmlLib = currentXMLLib(cx); return xmlLib.nameRef(cx, namespace, name, scope, memberTypeFlags); }