Java Code Examples for jdk.nashorn.internal.runtime.ScriptObject#setProto()
The following examples show how to use
jdk.nashorn.internal.runtime.ScriptObject#setProto() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeObject.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 2
Source File: NativeObject.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 3
Source File: NativeObject.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 4
Source File: NativeObject.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 5
Source File: NativeObject.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 6
Source File: NativeObject.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 7
Source File: NativeObject.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 8
Source File: NativeObject.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 9
Source File: NativeObject.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 10
Source File: NativeObject.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * ECMA 15.2.3.5 Object.create ( O [, Properties] ) * * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); } // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } return newObj; }
Example 11
Source File: Global.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private ScriptFunction initErrorSubtype(final String name, final ScriptObject errorProto) { final ScriptObject cons = initConstructor(name); final ScriptObject prototype = ScriptFunction.getPrototype(cons); prototype.set(NativeError.NAME, name, false); prototype.set(NativeError.MESSAGE, "", false); prototype.setProto(errorProto); return (ScriptFunction)cons; }
Example 12
Source File: Global.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * These classes are generated by nasgen tool and so we have to use * reflection to load and create new instance of these classes. */ private ScriptObject initConstructor(final String name) { try { // Assuming class name pattern for built-in JS constructors. final StringBuilder sb = new StringBuilder("jdk.nashorn.internal.objects."); sb.append("Native"); sb.append(name); sb.append("$Constructor"); final Class<?> funcClass = Class.forName(sb.toString()); final ScriptObject res = (ScriptObject)funcClass.newInstance(); if (res instanceof ScriptFunction) { // All global constructor prototypes are not-writable, // not-enumerable and not-configurable. final ScriptFunction func = (ScriptFunction)res; func.modifyOwnProperty(func.getProperty("prototype"), Attribute.NON_ENUMERABLE_CONSTANT); } if (res.getProto() == null) { res.setProto(getObjectPrototype()); } return res; } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } }
Example 13
Source File: Global.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private ScriptFunction initErrorSubtype(final String name, final ScriptObject errorProto) { final ScriptObject cons = initConstructor(name); final ScriptObject prototype = ScriptFunction.getPrototype(cons); prototype.set(NativeError.NAME, name, false); prototype.set(NativeError.MESSAGE, "", false); prototype.setProto(errorProto); return (ScriptFunction)cons; }
Example 14
Source File: Global.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * These classes are generated by nasgen tool and so we have to use * reflection to load and create new instance of these classes. */ private ScriptObject initConstructor(final String name) { try { // Assuming class name pattern for built-in JS constructors. final StringBuilder sb = new StringBuilder("jdk.nashorn.internal.objects."); sb.append("Native"); sb.append(name); sb.append("$Constructor"); final Class<?> funcClass = Class.forName(sb.toString()); final ScriptObject res = (ScriptObject)funcClass.newInstance(); if (res instanceof ScriptFunction) { // All global constructor prototypes are not-writable, // not-enumerable and not-configurable. final ScriptFunction func = (ScriptFunction)res; func.modifyOwnProperty(func.getProperty("prototype"), Attribute.NON_ENUMERABLE_CONSTANT); } if (res.getProto() == null) { res.setProto(getObjectPrototype()); } return res; } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } }
Example 15
Source File: Global.java From nashorn with GNU General Public License v2.0 | 5 votes |
private ScriptFunction initErrorSubtype(final String name, final ScriptObject errorProto) { final ScriptObject cons = initConstructor(name); final ScriptObject prototype = ScriptFunction.getPrototype(cons); prototype.set(NativeError.NAME, name, false); prototype.set(NativeError.MESSAGE, "", false); prototype.setProto(errorProto); return (ScriptFunction)cons; }
Example 16
Source File: Global.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * These classes are generated by nasgen tool and so we have to use * reflection to load and create new instance of these classes. */ private ScriptObject initConstructor(final String name) { try { // Assuming class name pattern for built-in JS constructors. final StringBuilder sb = new StringBuilder("jdk.nashorn.internal.objects."); sb.append("Native"); sb.append(name); sb.append("$Constructor"); final Class<?> funcClass = Class.forName(sb.toString()); final ScriptObject res = (ScriptObject)funcClass.newInstance(); if (res instanceof ScriptFunction) { // All global constructor prototypes are not-writable, // not-enumerable and not-configurable. final ScriptFunction func = (ScriptFunction)res; func.modifyOwnProperty(func.getProperty("prototype"), Attribute.NON_ENUMERABLE_CONSTANT); } if (res.getProto() == null) { res.setProto(getObjectPrototype()); } return res; } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } }