protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
protected final XMLLib bindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new IllegalStateException(); } return (XMLLib)so.associateValue(XML_LIB_KEY, this); }
/** * Associate ClassCache object with the given top-level scope. * The ClassCache object can only be associated with the given scope once. * * @param topScope scope to associate this ClassCache object with. * @return true if no previous ClassCache objects were embedded into * the scope and this ClassCache were successfully associated * or false otherwise. * * @see #get(Scriptable scope) */ public boolean associate(ScriptableObject topScope) { if (topScope.getParentScope() != null) { // Can only associate cache with top level scope throw new IllegalArgumentException(); } if (this == topScope.associateValue(AKEY, this)) { return true; } return false; }
@JSFunction @SuppressWarnings("unused") public static Object createDocument(Context cx, Scriptable thisObj, Object[] args, Function funObj) { ensureArg(args, 0); XmlWrapImpl self = (XmlWrapImpl)thisObj; Source src = self.getSource(cx, args[0]); ScriptableObject ret = (ScriptableObject)cx.newObject(thisObj); ret.associateValue("document", src); return ret; }
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) { // XXX: Currently only instances of ScriptableObject are // supported since the resulting interface proxies should // be reused next time conversion is made and generic // Callable has no storage for it. Weak references can // address it but for now use this restriction. Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type); Object old = so.getAssociatedValue(key); if (old != null) { // Function was already wrapped return old; } Context cx = Context.getContext(); Object glue = InterfaceAdapter.create(cx, type, so); // Store for later retrieval glue = so.associateValue(key, glue); return glue; }
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) { // XXX: Currently only instances of ScriptableObject are // supported since the resulting interface proxies should // be reused next time conversion is made and generic // Callable has no storage for it. Weak references can // address it but for now use this restriction. Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type); Object old = so.getAssociatedValue(key); if (old != null) { // Function was already wrapped return old; } Context cx = Context.getContext(); Object glue = InterfaceAdapter.create(cx, type, so); // Store for later retrieval glue = so.associateValue(key, glue); return glue; }
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) { // XXX: Currently only instances of ScriptableObject are // supported since the resulting interface proxies should // be reused next time conversion is made and generic // Callable has no storage for it. Weak references can // address it but for now use this restriction. Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type); Object old = so.getAssociatedValue(key); if (old != null) { // Function was already wrapped return old; } Context cx = Context.getContext(); Object glue = InterfaceAdapter.create(cx, type, so); // Store for later retrieval glue = so.associateValue(key, glue); return glue; }
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) { // XXX: Currently only instances of ScriptableObject are // supported since the resulting interface proxies should // be reused next time conversion is made and generic // Callable has no storage for it. Weak references can // address it but for now use this restriction. Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type); Object old = so.getAssociatedValue(key); if (old != null) { // Function was already wrapped return old; } Context cx = Context.getContext(); Object glue = InterfaceAdapter.create(cx, type, so); // Store for later retrieval glue = so.associateValue(key, glue); return glue; }
@JSFunction @SuppressWarnings("unused") public static Object createStylesheet(Context cx, Scriptable thisObj, Object[] args, Function funObj) { ensureArg(args, 0); XmlWrapImpl self = (XmlWrapImpl)thisObj; Source src = self.getSource(cx, args[0]); try { // Keep in mind that we are in Node.js and the factory will be single-threaded. // Set the error listener to prevent stuff being written to standard error. Err errs = new Err(); self.transFactory.setErrorListener(errs); Templates tmpl = self.transFactory.newTemplates(src); ScriptableObject ret = (ScriptableObject)cx.newObject(thisObj); ret.associateValue("template", tmpl); return ret; } catch (TransformerConfigurationException e) { throw Utils.makeError(cx, thisObj, "XSLT transformer exception: " + e); } }
static NativeGenerator init(ScriptableObject scope, boolean sealed) { // Generator // Can't use "NativeGenerator().exportAsJSClass" since we don't want // to define "Generator" as a constructor in the top-level scope. NativeGenerator prototype = new NativeGenerator(); if (scope != null) { prototype.setParentScope(scope); prototype.setPrototype(getObjectPrototype(scope)); } prototype.activatePrototypeMap(MAX_PROTOTYPE_ID); if (sealed) { prototype.sealObject(); } // Need to access Generator prototype when constructing // Generator instances, but don't have a generator constructor // to use to find the prototype. Use the "associateValue" // approach instead. if (scope != null) { scope.associateValue(GENERATOR_TAG, prototype); } return prototype; }
static NativeGenerator init(ScriptableObject scope, boolean sealed) { // Generator // Can't use "NativeGenerator().exportAsJSClass" since we don't want // to define "Generator" as a constructor in the top-level scope. NativeGenerator prototype = new NativeGenerator(); if (scope != null) { prototype.setParentScope(scope); prototype.setPrototype(getObjectPrototype(scope)); } prototype.activatePrototypeMap(MAX_PROTOTYPE_ID); if (sealed) { prototype.sealObject(); } // Need to access Generator prototype when constructing // Generator instances, but don't have a generator constructor // to use to find the prototype. Use the "associateValue" // approach instead. if (scope != null) { scope.associateValue(GENERATOR_TAG, prototype); } return prototype; }
static void init(ScriptableObject scope, boolean sealed) { // Iterator NativeIterator iterator = new NativeIterator(); iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); // Generator NativeGenerator.init(scope, sealed); // StopIteration NativeObject obj = new StopIteration(); obj.setPrototype(getObjectPrototype(scope)); obj.setParentScope(scope); if (sealed) { obj.sealObject(); } ScriptableObject.defineProperty(scope, STOP_ITERATION, obj, ScriptableObject.DONTENUM); // Use "associateValue" so that generators can continue to // throw StopIteration even if the property of the global // scope is replaced or deleted. scope.associateValue(ITERATOR_TAG, obj); }
static void init(ScriptableObject scope, boolean sealed) { // Iterator NativeIterator iterator = new NativeIterator(); iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); // Generator NativeGenerator.init(scope, sealed); // StopIteration NativeObject obj = new StopIteration(); obj.setPrototype(getObjectPrototype(scope)); obj.setParentScope(scope); if (sealed) { obj.sealObject(); } ScriptableObject.defineProperty(scope, STOP_ITERATION, obj, ScriptableObject.DONTENUM); // Use "associateValue" so that generators can continue to // throw StopIteration even if the property of the global // scope is replaced or deleted. scope.associateValue(ITERATOR_TAG, obj); }
static void init(ScriptableObject scope, boolean sealed) { // Iterator NativeIterator iterator = new NativeIterator(); iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); // Generator NativeGenerator.init(scope, sealed); // StopIteration NativeObject obj = new StopIteration(); obj.setPrototype(getObjectPrototype(scope)); obj.setParentScope(scope); if (sealed) { obj.sealObject(); } ScriptableObject.defineProperty(scope, STOP_ITERATION, obj, ScriptableObject.DONTENUM); // Use "associateValue" so that generators can continue to // throw StopIteration even if the property of the global // scope is replaced or deleted. scope.associateValue(ITERATOR_TAG, obj); }
static void init(ScriptableObject scope, boolean sealed) { // Iterator NativeIterator iterator = new NativeIterator(); iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); // Generator NativeGenerator.init(scope, sealed); // StopIteration NativeObject obj = new StopIteration(); obj.setPrototype(getObjectPrototype(scope)); obj.setParentScope(scope); if (sealed) { obj.sealObject(); } ScriptableObject.defineProperty(scope, STOP_ITERATION, obj, ScriptableObject.DONTENUM); // Use "associateValue" so that generators can continue to // throw StopIteration even if the property of the global // scope is replaced or deleted. scope.associateValue(ITERATOR_TAG, obj); }
static void init(ScriptableObject scope, boolean sealed) { // Iterator NativeIterator iterator = new NativeIterator(); iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); // Generator NativeGenerator.init(scope, sealed); // StopIteration NativeObject obj = new StopIteration(); obj.setPrototype(getObjectPrototype(scope)); obj.setParentScope(scope); if (sealed) { obj.sealObject(); } ScriptableObject.defineProperty(scope, STOP_ITERATION, obj, ScriptableObject.DONTENUM); // Use "associateValue" so that generators can continue to // throw StopIteration even if the property of the global // scope is replaced or deleted. scope.associateValue(ITERATOR_TAG, obj); }