private void putProperty(String name, Object value) { ScriptableObject.putProperty(global, name, value); }
private void putProperty(String name, Object value) { ScriptableObject.putProperty(global, name, value); }
static void init(Scriptable scope, boolean sealed) { NativeError obj = new NativeError(); ScriptableObject.putProperty(obj, "name", "Error"); ScriptableObject.putProperty(obj, "message", ""); ScriptableObject.putProperty(obj, "fileName", ""); ScriptableObject.putProperty(obj, "lineNumber", Integer.valueOf(0)); obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); }
public static Object setObjectIndex(Scriptable obj, int index, Object value, Context cx) { if (obj instanceof XMLObject) { XMLObject xmlObject = (XMLObject)obj; xmlObject.ecmaPut(cx, Integer.valueOf(index), value); } else { ScriptableObject.putProperty(obj, index, value); } return value; }
public static Object setObjectProp(Scriptable obj, String property, Object value, Context cx) { if (obj instanceof XMLObject) { XMLObject xmlObject = (XMLObject)obj; xmlObject.ecmaPut(cx, property, value); } else { ScriptableObject.putProperty(obj, property, value); } return value; }
public void putJsonProperty(String name, String json) { ScriptableObject.putProperty(global, name, NativeJSON.parse(cx, global, json, (context, scope, holdable, objects) -> objects[1])); }
public void putJsonProperty(String name, String json) { ScriptableObject.putProperty(global, name, NativeJSON.parse(cx, global, json, (context, scope, holdable, objects) -> objects[1])); }
public static Object setObjectElem(Scriptable obj, Object elem, Object value, Context cx) { if (obj instanceof XMLObject) { XMLObject xmlObject = (XMLObject)obj; xmlObject.ecmaPut(cx, elem, value); return value; } String s = toStringIdOrIndex(cx, elem); if (s == null) { int index = lastIndexResult(cx); ScriptableObject.putProperty(obj, index, value); } else { ScriptableObject.putProperty(obj, s, value); } return value; }
ScriptableObject.putProperty(obj, "message", ScriptRuntime.toString(args[0])); if (arglen >= 2) { ScriptableObject.putProperty(obj, "fileName", args[1]); if (arglen >= 3) { int line = ScriptRuntime.toInt32(args[2]); ScriptableObject.putProperty(obj, "lineNumber", Integer.valueOf(line)); ScriptableObject.putProperty(obj, "lineNumber", Integer.valueOf(linep[0])); if(arglen < 2) { ScriptableObject.putProperty(obj, "fileName", fileName); ScriptableObject.putProperty(obj,"at", obj.new NativeErrorException()); return obj;
specialRef(object, (String)id, cx).set(cx, value); } else { ScriptableObject.putProperty(object, (String)id, value); ScriptableObject.putProperty(object, index, value);
/** * Install the wrapper in place of the native toString function on Function's prototype. * @param window the scope * @param browserVersion the simulated browser */ static void installFix(final Scriptable window, final BrowserVersion browserVersion) { if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_NEW_LINE)) { final ScriptableObject fnPrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Function"); final Function originalToString = (Function) ScriptableObject.getProperty(fnPrototype, "toString"); final Function newToString = new NativeFunctionToStringFunction(originalToString); ScriptableObject.putProperty(fnPrototype, "toString", newToString); } else if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_COMPACT)) { final ScriptableObject fnPrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Function"); final Function originalToString = (Function) ScriptableObject.getProperty(fnPrototype, "toString"); final Function newToString = new NativeFunctionToStringFunctionChrome(originalToString); ScriptableObject.putProperty(fnPrototype, "toString", newToString); } else if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_NL)) { final ScriptableObject fnPrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Function"); final Function originalToString = (Function) ScriptableObject.getProperty(fnPrototype, "toString"); final Function newToString = new NativeFunctionToStringFunctionFF(originalToString); ScriptableObject.putProperty(fnPrototype, "toString", newToString); } }
/** * Install the wrapper in place of the native toString function on Function's prototype. * @param window the scope * @param browserVersion the simulated browser */ static void installFix(final Scriptable window, final BrowserVersion browserVersion) { if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_NEW_LINE)) { final ScriptableObject fnPrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Function"); final Function originalToString = (Function) ScriptableObject.getProperty(fnPrototype, "toString"); final Function newToString = new NativeFunctionToStringFunction(originalToString); ScriptableObject.putProperty(fnPrototype, "toString", newToString); } else if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_COMPACT)) { final ScriptableObject fnPrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Function"); final Function originalToString = (Function) ScriptableObject.getProperty(fnPrototype, "toString"); final Function newToString = new NativeFunctionToStringFunctionChrome(originalToString); ScriptableObject.putProperty(fnPrototype, "toString", newToString); } else if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_NL)) { final ScriptableObject fnPrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Function"); final Function originalToString = (Function) ScriptableObject.getProperty(fnPrototype, "toString"); final Function newToString = new NativeFunctionToStringFunctionFF(originalToString); ScriptableObject.putProperty(fnPrototype, "toString", newToString); } }
/** * Triggers the {@code onerror} handler, if one has been set. * @param e the error that needs to be reported */ public void triggerOnError(final ScriptException e) { final Object o = getOnerror(); if (o instanceof Function) { final Function f = (Function) o; String msg = e.getMessage(); final String url = e.getPage().getUrl().toExternalForm(); final int line = e.getFailingLineNumber(); final int column = e.getFailingColumnNumber(); Object jsError = e.getMessage(); if (e.getCause() instanceof JavaScriptException) { msg = "uncaught exception: " + e.getCause().getMessage(); jsError = ((JavaScriptException) e.getCause()).getValue(); } else if (e.getCause() instanceof EcmaError) { msg = "uncaught " + e.getCause().getMessage(); final EcmaError ecmaError = (EcmaError) e.getCause(); final Scriptable err = Context.getCurrentContext().newObject(this, "Error"); ScriptableObject.putProperty(err, "message", ecmaError.getMessage()); ScriptableObject.putProperty(err, "fileName", ecmaError.sourceName()); ScriptableObject.putProperty(err, "lineNumber", Integer.valueOf(ecmaError.lineNumber())); jsError = err; } final Object[] args = new Object[] {msg, url, Integer.valueOf(line), Integer.valueOf(column), jsError}; f.call(Context.getCurrentContext(), this, this, args); } }
/** * Triggers the {@code onerror} handler, if one has been set. * @param e the error that needs to be reported */ public void triggerOnError(final ScriptException e) { final Object o = getOnerror(); if (o instanceof Function) { final Function f = (Function) o; String msg = e.getMessage(); final String url = e.getPage().getUrl().toExternalForm(); final int line = e.getFailingLineNumber(); final int column = e.getFailingColumnNumber(); Object jsError = e.getMessage(); if (e.getCause() instanceof JavaScriptException) { msg = "uncaught exception: " + e.getCause().getMessage(); jsError = ((JavaScriptException) e.getCause()).getValue(); } else if (e.getCause() instanceof EcmaError) { msg = "uncaught " + e.getCause().getMessage(); final EcmaError ecmaError = (EcmaError) e.getCause(); final Scriptable err = Context.getCurrentContext().newObject(this, "Error"); ScriptableObject.putProperty(err, "message", ecmaError.getMessage()); ScriptableObject.putProperty(err, "fileName", ecmaError.sourceName()); ScriptableObject.putProperty(err, "lineNumber", Integer.valueOf(ecmaError.lineNumber())); jsError = err; } final Object[] args = new Object[] {msg, url, Integer.valueOf(line), Integer.valueOf(column), jsError}; f.call(Context.getCurrentContext(), this, this, args); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = htmlSelect_.getScriptableObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * <p>See {@link #getWithFallback(String)} for the corresponding getter behavior.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = (HTMLSelectElement) htmlSelect_.getScriptObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = htmlSelect_.getScriptableObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * <p>See {@link #getWithFallback(String)} for the corresponding getter behavior.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = (HTMLSelectElement) htmlSelect_.getScriptObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * <p>See {@link #getWithFallback(String)} for the corresponding getter behavior.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = (HTMLSelectElement) htmlSelect_.getScriptObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
public static Object setName(Scriptable bound, Object value, Context cx, Scriptable scope, String id) { if (bound != null) { if (bound instanceof XMLObject) { XMLObject xmlObject = (XMLObject)bound; xmlObject.ecmaPut(cx, id, value); } else { ScriptableObject.putProperty(bound, id, value); } } else { // "newname = 7;", where 'newname' has not yet // been defined, creates a new property in the // top scope unless strict mode is specified. if (cx.hasFeature(Context.FEATURE_STRICT_MODE) || cx.hasFeature(Context.FEATURE_STRICT_VARS)) { Context.reportWarning( ScriptRuntime.getMessage1("msg.assn.create.strict", id)); } // Find the top scope by walking up the scope chain. bound = ScriptableObject.getTopLevelScope(scope); if (cx.useDynamicScope) { bound = checkDynamicScope(cx.topCallScope, bound); } bound.put(id, bound, value); } return value; }