/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#setParentScope */ public void setParentScope(Scriptable parent) { obj.setParentScope(parent); } /**
void initAsConstructor(Scriptable scope, Scriptable prototype) { ScriptRuntime.setFunctionProtoAndParent(this, scope); setImmunePrototypeProperty(prototype); prototype.setParentScope(this); defineProperty(prototype, "constructor", this, ScriptableObject.DONTENUM | ScriptableObject.PERMANENT | ScriptableObject.READONLY); setParentScope(scope); }
/** * Creates new script object. * The default implementation of {@link #construct} uses the method to * to get the value for <tt>thisObj</tt> argument when invoking * {@link #call}. * The methos is allowed to return <tt>null</tt> to indicate that * {@link #call} will create a new object itself. In this case * {@link #construct} will set scope and prototype on the result * {@link #call} unless they are already set. */ public Scriptable createObject(Context cx, Scriptable scope) { Scriptable newInstance = new NativeObject(); newInstance.setPrototype(getClassPrototype()); newInstance.setParentScope(getParentScope()); return newInstance; }
/** * Return new {@link Scriptable} instance using the default * constructor for the class of the underlying Java method. * Return null to indicate that the call method should be used to create * new objects. */ @Override public Scriptable createObject(Context cx, Scriptable scope) { if (member.isCtor() || parmsLength == VARARGS_CTOR) { return null; } Scriptable result; try { result = (Scriptable) member.getDeclaringClass().newInstance(); } catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); } result.setPrototype(getClassPrototype()); result.setParentScope(getParentScope()); return result; }
public Scriptable construct(Context cx, Scriptable scope, Object[] args) { Scriptable result = createObject(cx, scope); if (result != null) { Object val = call(cx, scope, result, args); if (val instanceof Scriptable) { result = (Scriptable)val; } } else { Object val = call(cx, scope, null, args); if (!(val instanceof Scriptable)) { // It is program error not to return Scriptable from // the call method if createObject returns null. throw new IllegalStateException( "Bad implementaion of call as constructor, name=" +getFunctionName()+" in "+getClass().getName()); } result = (Scriptable)val; if (result.getPrototype() == null) { result.setPrototype(getClassPrototype()); } if (result.getParentScope() == null) { Scriptable parent = getParentScope(); if (result != parent) { result.setParentScope(parent); } } } return result; }
/** * {@inheritDoc} */ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { final Object object = super.call(cx, scope, thisObj, args); if (object instanceof Scriptable) { final Scriptable result = (Scriptable) object; if (result.getPrototype() == null) { final Scriptable proto = getClassPrototype(); if (result != proto) { result.setPrototype(proto); } } if (result.getParentScope() == null) { final Scriptable parent = getParentScope(); if (result != parent) { result.setParentScope(parent); } } } return object; } }
/** * {@inheritDoc} */ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { final Object object = super.call(cx, scope, thisObj, args); if (object instanceof Scriptable) { final Scriptable result = (Scriptable) object; if (result.getPrototype() == null) { final Scriptable proto = getClassPrototype(); if (result != proto) { result.setPrototype(proto); } } if (result.getParentScope() == null) { final Scriptable parent = getParentScope(); if (result != parent) { result.setParentScope(parent); } } } return object; } }
try { wrappedActiveX_ = new ActiveXObjectImpl(classid); wrappedActiveX_.setParentScope(getParentScope());
try { wrappedActiveX_ = new ActiveXObjectImpl(classid); wrappedActiveX_.setParentScope(getParentScope());
target.setPrototype(obj); } else { target.setParentScope(obj);