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 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; } }
catchScopeObject.defineProperty( exceptionName, obj, ScriptableObject.PERMANENT); catchScopeObject.defineProperty( "__exception__", Context.javaToJS(t, scope), ScriptableObject.PERMANENT|ScriptableObject.DONTENUM);