public void put(String id, Scriptable start, Object value) { if (start == this) start = prototype; prototype.put(id, start, value); }
/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#put(String, Scriptable, Object) */ public void put(String name, Scriptable start, Object value) { obj.put(name,start,value); } /**
public void put(int index, Scriptable start, Object value) { if (start == this) start = prototype; prototype.put(index, start, value); }
/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#put(int, Scriptable, Object) */ public void put(int index, Scriptable start, Object value) { obj.put(index,start,value); } /**
/** * Utility method to add properties to arbitrary Scriptable object. * If destination is instance of ScriptableObject, calls * defineProperty there, otherwise calls put in destination * ignoring attributes */ public static void defineProperty(Scriptable destination, String propertyName, Object value, int attributes) { if (!(destination instanceof ScriptableObject)) { destination.put(propertyName, destination, value); return; } ScriptableObject so = (ScriptableObject)destination; so.defineProperty(propertyName, value, attributes); }
/** * Puts an indexed property in an object or in an object in its prototype chain. * <p> * Searches for the indexed property in the prototype chain. If it is found, * the value of the property in <code>obj</code> is changed through a call * to {@link Scriptable#put(int, Scriptable, Object)} on the prototype * passing <code>obj</code> as the <code>start</code> argument. This allows * the prototype to veto the property setting in case the prototype defines * the property with [[ReadOnly]] attribute. If the property is not found, * it is added in <code>obj</code>. * @param obj a JavaScript object * @param index a property index * @param value any JavaScript value accepted by Scriptable.put * @since 1.5R2 */ public static void putProperty(Scriptable obj, int index, Object value) { Scriptable base = getBase(obj, index); if (base == null) base = obj; base.put(index, obj, value); }
final void set(int id, Scriptable start, Object value) { if (value == NOT_FOUND) throw new IllegalArgumentException(); ensureId(id); int attr = attributeArray[id - 1]; if ((attr & READONLY) == 0) { if (start == obj) { if (value == null) { value = UniqueTag.NULL_VALUE; } int valueSlot = (id - 1) * SLOT_SPAN + VALUE_SLOT; synchronized (this) { valueArray[valueSlot] = value; } } else { int nameSlot = (id - 1) * SLOT_SPAN + NAME_SLOT; String name = (String)valueArray[nameSlot]; start.put(name, start, value); } } }
/** * Puts a named property in an object or in an object in its prototype chain. * <p> * Searches for the named property in the prototype chain. If it is found, * the value of the property in <code>obj</code> is changed through a call * to {@link Scriptable#put(String, Scriptable, Object)} on the * prototype passing <code>obj</code> as the <code>start</code> argument. * This allows the prototype to veto the property setting in case the * prototype defines the property with [[ReadOnly]] attribute. If the * property is not found, it is added in <code>obj</code>. * @param obj a JavaScript object * @param name a property name * @param value any JavaScript value accepted by Scriptable.put * @since 1.5R2 */ public static void putProperty(Scriptable obj, String name, Object value) { Scriptable base = getBase(obj, name); if (base == null) base = obj; base.put(name, obj, value); }
public void put(String name, Scriptable start, Object value) { // We could be asked to modify the value of a property in the // prototype. Since we can't add a property to a Java object, // we modify it in the prototype rather than copy it down. if (prototype == null || members.has(name, false)) members.put(this, name, javaObject, value, false); else prototype.put(name, prototype, value); }
/** * {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { // for java mocks do a bit more, we have handle unknown properties // ourself if (wrappedActiveX_ instanceof NativeJavaObject) { if (wrappedActiveX_.has(name, start)) { wrappedActiveX_.put(name, start, value); } else { super.put(name, start, value); } return; } if (wrappedActiveX_ != null) { wrappedActiveX_.put(name, start, value); return; } super.put(name, start, value); }
/** * Sets the value of the indexed property, creating it if need be. * * @param index the numeric index for the property * @param start the object whose property is being set * @param value value to set the property to */ public void put(int index, Scriptable start, Object value) { if (putImpl(null, index, start, value, EMPTY)) return; if (start == this) throw Kit.codeBug(); start.put(index, start, value); }
/** * {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { // for java mocks do a bit more, we have handle unknown properties // ourself if (wrappedActiveX_ instanceof NativeJavaObject) { if (wrappedActiveX_.has(name, start)) { wrappedActiveX_.put(name, start, value); } else { super.put(name, start, value); } return; } if (wrappedActiveX_ != null) { wrappedActiveX_.put(name, start, value); return; } super.put(name, start, value); }
@Test public void run() throws RhinoException { try { final Scriptable scope = getScope(); final Map<String, Object> implicitObjects = getImplicitObjects(); for (Entry<String, Object> entry : implicitObjects.entrySet()) { scope.put(entry.getKey(), scope, entry.getValue()); } for (Script compiledScript : this.compiledScripts) { compiledScript.exec(context, scope); } } catch (JavaScriptException jsex) { throw jsex; } }
private static void match_glob(GlobData mdata, Context cx, Scriptable scope, int count, RegExpImpl reImpl) { if (mdata.arrayobj == null) { Scriptable s = ScriptableObject.getTopLevelScope(scope); mdata.arrayobj = ScriptRuntime.newObject(cx, s, "Array", null); } SubString matchsub = reImpl.lastMatch; String matchstr = matchsub.toString(); mdata.arrayobj.put(count, mdata.arrayobj, matchstr); }
/** * Sets the value of the named property, creating it if need be. * * If the property was created using defineProperty, the * appropriate setter method is called. <p> * * If the property's attributes include READONLY, no action is * taken. * This method will actually set the property in the start * object. * * @param name the name of the property * @param start the object whose property is being set * @param value value to set the property to */ public void put(String name, Scriptable start, Object value) { if (putImpl(name, 0, start, value, EMPTY)) return; if (start == this) throw Kit.codeBug(); start.put(name, start, value); }
/** * Sets the value of the named const property, creating it if need be. * * If the property was created using defineProperty, the * appropriate setter method is called. <p> * * If the property's attributes include READONLY, no action is * taken. * This method will actually set the property in the start * object. * * @param name the name of the property * @param start the object whose property is being set * @param value value to set the property to */ public void putConst(String name, Scriptable start, Object value) { if (putImpl(name, 0, start, value, READONLY)) return; if (start == this) throw Kit.codeBug(); if (start instanceof ConstProperties) ((ConstProperties)start).putConst(name, start, value); else start.put(name, start, value); }
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; }
public static Object propIncrDecr(Object obj, String id, Context cx, int incrDecrMask) { Scriptable start = toObjectOrNull(cx, obj); if (start == null) { throw undefReadError(obj, id); } Scriptable target = start; Object value; search: { do { value = target.get(id, start); if (value != Scriptable.NOT_FOUND) { break search; } target = target.getPrototype(); } while (target != null); start.put(id, start, NaNobj); return NaNobj; } return doScriptableIncrDecr(target, id, start, value, incrDecrMask); }
@Override public void put(final String name, final Scriptable start, final Object value) { if (this != start) { super.put(name, start, value); return; } final Scriptable prototype = getPrototype(); if (prototype != null && !"constructor".equals(name) && prototype.get(name, start) != Scriptable.NOT_FOUND) { prototype.put(name, start, value); return; } if (getDomNodeOrNull() != null) { // check if prototype or not final Definition style = StyleAttributes.getDefinition(name, getBrowserVersion()); if (style != null) { final String stringValue = Context.toString(value); setStyleAttribute(style.getAttributeName(), stringValue); return; } } super.put(name, start, value); }
@Override public void put(final String name, final Scriptable start, final Object value) { if (this != start) { super.put(name, start, value); return; } final Scriptable prototype = getPrototype(); if (prototype != null && !"constructor".equals(name) && prototype.get(name, start) != Scriptable.NOT_FOUND) { prototype.put(name, start, value); return; } if (getDomNodeOrNull() != null) { // check if prototype or not final Definition style = StyleAttributes.getDefinition(name, getBrowserVersion()); if (style != null) { final String stringValue = Context.toString(value); setStyleAttribute(style.getAttributeName(), stringValue); return; } } super.put(name, start, value); }