static void init(Scriptable scope, boolean sealed) { NativeObject obj = new NativeObject(); obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); }
private void setupDefaultPrototype() { NativeObject obj = new NativeObject(); final int attr = ScriptableObject.DONTENUM; obj.defineProperty("constructor", this, attr); // put the prototype property into the object now, then in the // wacky case of a user defining a function Object(), we don't // get an infinite loop trying to find the prototype. prototypeProperty = obj; Scriptable proto = getObjectPrototype(this); if (proto != obj) { // not the one we just made, it must remain grounded obj.setPrototype(proto); } }
/** * 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; }
ScriptableObject getPropertyDescriptor(Context cx, Scriptable scope) { ScriptableObject desc = new NativeObject(); ScriptRuntime.setObjectProtoAndParent(desc, scope); if (value != null) desc.defineProperty("value", value, EMPTY); desc.defineProperty("writable", (attributes & READONLY) == 0, EMPTY); desc.defineProperty("enumerable", (attributes & DONTENUM) == 0, EMPTY); desc.defineProperty("configurable", (attributes & PERMANENT) == 0, EMPTY); return desc; }
Scriptable delegee; if (args.length == 0) { delegee = new NativeObject(); } else { delegee = ScriptRuntime.toObject(cx, scope, args[0]);
/** * Creates a new event instance. * * @param target the event target * @param type the event type * @param state the state object */ public PopStateEvent(final EventTarget target, final String type, final Object state) { super(target, type); if (state instanceof NativeObject && getBrowserVersion().hasFeature(JS_POP_STATE_EVENT_CLONE_STATE)) { final NativeObject old = (NativeObject) state; final NativeObject newState = new NativeObject(); Context.enter(); try { for (final Object o : ScriptableObject.getPropertyIds(old)) { final String property = Context.toString(o); newState.defineProperty(property, ScriptableObject.getProperty(old, property), ScriptableObject.EMPTY); } } finally { Context.exit(); } state_ = newState; } else { state_ = state; } }
/** * Creates a new event instance. * * @param target the event target * @param type the event type * @param state the state object */ public PopStateEvent(final EventTarget target, final String type, final Object state) { super(target, type); if (state instanceof NativeObject && getBrowserVersion().hasFeature(JS_POP_STATE_EVENT_CLONE_STATE)) { final NativeObject old = (NativeObject) state; final NativeObject newState = new NativeObject(); Context.enter(); try { for (final Object o : ScriptableObject.getPropertyIds(old)) { final String property = Context.toString(o); newState.defineProperty(property, ScriptableObject.getProperty(old, property), ScriptableObject.EMPTY); } } finally { Context.exit(); } state_ = newState; } else { state_ = state; } }
NativeObject catchScopeObject = new NativeObject();
scope = new NativeObject();
|| args[0] == Undefined.instance) return new NativeObject(); Scriptable obj = ensureScriptable(arg); ScriptableObject newObject = new NativeObject(); newObject.setParentScope(this.getParentScope()); newObject.setPrototype(obj);