Java Code Examples for jdk.nashorn.internal.runtime.ScriptObject#defineOwnProperty()

The following examples show how to use jdk.nashorn.internal.runtime.ScriptObject#defineOwnProperty() . 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 openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 5.2.3.7 Object.defineProperties ( O, Properties )
 *
 * @param self  self reference
 * @param obj   object in which to define properties
 * @param props properties
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object defineProperties(final Object self, final Object obj, final Object props) {
    Global.checkObject(obj);

    final ScriptObject sobj     = (ScriptObject)obj;
    final Object       propsObj = Global.toObject(props);

    if (propsObj instanceof ScriptObject) {
        final Object[] keys = ((ScriptObject)propsObj).getOwnKeys(false);
        for (final Object key : keys) {
            final String prop = JSType.toString(key);
            sobj.defineOwnProperty(prop, ((ScriptObject)propsObj).get(prop), true);
        }
    }
    return sobj;
}
 
Example 2
Source File: NativeObject.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 5.2.3.7 Object.defineProperties ( O, Properties )
 *
 * @param self  self reference
 * @param obj   object in which to define properties
 * @param props properties
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object defineProperties(final Object self, final Object obj, final Object props) {
    Global.checkObject(obj);

    final ScriptObject sobj     = (ScriptObject)obj;
    final Object       propsObj = Global.toObject(props);

    if (propsObj instanceof ScriptObject) {
        final Object[] keys = ((ScriptObject)propsObj).getOwnKeys(false);
        for (final Object key : keys) {
            final String prop = JSType.toString(key);
            sobj.defineOwnProperty(prop, ((ScriptObject)propsObj).get(prop), true);
        }
    }
    return sobj;
}
 
Example 3
Source File: NativeObject.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 5.2.3.7 Object.defineProperties ( O, Properties )
 *
 * @param self  self reference
 * @param obj   object in which to define properties
 * @param props properties
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperties(final Object self, final Object obj, final Object props) {
    final ScriptObject sobj     = Global.checkObject(obj);
    final Object       propsObj = Global.toObject(props);

    if (propsObj instanceof ScriptObject) {
        final Object[] keys = ((ScriptObject)propsObj).getOwnKeys(false);
        for (final Object key : keys) {
            final String prop = JSType.toString(key);
            sobj.defineOwnProperty(prop, ((ScriptObject)propsObj).get(prop), true);
        }
    }
    return sobj;
}
 
Example 4
Source File: NativeObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 5.2.3.7 Object.defineProperties ( O, Properties )
 *
 * @param self  self reference
 * @param obj   object in which to define properties
 * @param props properties
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperties(final Object self, final Object obj, final Object props) {
    final ScriptObject sobj     = Global.checkObject(obj);
    final Object       propsObj = Global.toObject(props);

    if (propsObj instanceof ScriptObject) {
        final Object[] keys = ((ScriptObject)propsObj).getOwnKeys(false);
        for (final Object key : keys) {
            final String prop = JSType.toString(key);
            sobj.defineOwnProperty(prop, ((ScriptObject)propsObj).get(prop), true);
        }
    }
    return sobj;
}
 
Example 5
Source File: NativeObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 5.2.3.7 Object.defineProperties ( O, Properties )
 *
 * @param self  self reference
 * @param obj   object in which to define properties
 * @param props properties
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperties(final Object self, final Object obj, final Object props) {
    final ScriptObject sobj     = Global.checkObject(obj);
    final Object       propsObj = Global.toObject(props);

    if (propsObj instanceof ScriptObject) {
        final Object[] keys = ((ScriptObject)propsObj).getOwnKeys(false);
        for (final Object key : keys) {
            final String prop = JSType.toString(key);
            sobj.defineOwnProperty(prop, ((ScriptObject)propsObj).get(prop), true);
        }
    }
    return sobj;
}
 
Example 6
Source File: NativeObject.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 5.2.3.7 Object.defineProperties ( O, Properties )
 *
 * @param self  self reference
 * @param obj   object in which to define properties
 * @param props properties
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperties(final Object self, final Object obj, final Object props) {
    final ScriptObject sobj     = Global.checkObject(obj);
    final Object       propsObj = Global.toObject(props);

    if (propsObj instanceof ScriptObject) {
        final Object[] keys = ((ScriptObject)propsObj).getOwnKeys(false);
        for (final Object key : keys) {
            final String prop = JSType.toString(key);
            sobj.defineOwnProperty(prop, ((ScriptObject)propsObj).get(prop), true);
        }
    }
    return sobj;
}
 
Example 7
Source File: NativeObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 5.2.3.7 Object.defineProperties ( O, Properties )
 *
 * @param self  self reference
 * @param obj   object in which to define properties
 * @param props properties
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperties(final Object self, final Object obj, final Object props) {
    final ScriptObject sobj     = Global.checkObject(obj);
    final Object       propsObj = Global.toObject(props);

    if (propsObj instanceof ScriptObject) {
        final Object[] keys = ((ScriptObject)propsObj).getOwnKeys(false);
        for (final Object key : keys) {
            final String prop = JSType.toString(key);
            sobj.defineOwnProperty(prop, ((ScriptObject)propsObj).get(prop), true);
        }
    }
    return sobj;
}
 
Example 8
Source File: NativeArray.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ECMA 15.4.4.12 Array.prototype.splice ( start, deleteCount [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return result of splice
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object splice(final Object self, final Object... args) {
    final Object obj = Global.toObject(self);

    if (!(obj instanceof ScriptObject)) {
        return ScriptRuntime.UNDEFINED;
    }

    final Object start = args.length > 0 ? args[0] : ScriptRuntime.UNDEFINED;
    final Object deleteCount = args.length > 1 ? args[1] : ScriptRuntime.UNDEFINED;

    Object[] items;

    if (args.length > 2) {
        items = new Object[args.length - 2];
        System.arraycopy(args, 2, items, 0, items.length);
    } else {
        items = ScriptRuntime.EMPTY_ARRAY;
    }

    final ScriptObject sobj                = (ScriptObject)obj;
    final long         len                 = JSType.toUint32(sobj.getLength());
    final long         relativeStart       = JSType.toLong(start);

    final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
    final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart);

    NativeArray returnValue;

    if (actualStart <= Integer.MAX_VALUE && actualDeleteCount <= Integer.MAX_VALUE && bulkable(sobj)) {
        try {
            returnValue =  new NativeArray(sobj.getArray().fastSplice((int)actualStart, (int)actualDeleteCount, items.length));

            // Since this is a dense bulkable array we can use faster defineOwnProperty to copy new elements
            int k = (int) actualStart;
            for (int i = 0; i < items.length; i++, k++) {
                sobj.defineOwnProperty(k, items[i]);
            }
        } catch (final UnsupportedOperationException uoe) {
            returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
        }
    } else {
        returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
    }

    return returnValue;
}
 
Example 9
Source File: NativeArray.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ECMA 15.4.4.12 Array.prototype.splice ( start, deleteCount [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return result of splice
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object splice(final Object self, final Object... args) {
    final Object obj = Global.toObject(self);

    if (!(obj instanceof ScriptObject)) {
        return ScriptRuntime.UNDEFINED;
    }

    final Object start = args.length > 0 ? args[0] : ScriptRuntime.UNDEFINED;
    final Object deleteCount = args.length > 1 ? args[1] : ScriptRuntime.UNDEFINED;

    Object[] items;

    if (args.length > 2) {
        items = new Object[args.length - 2];
        System.arraycopy(args, 2, items, 0, items.length);
    } else {
        items = ScriptRuntime.EMPTY_ARRAY;
    }

    final ScriptObject sobj                = (ScriptObject)obj;
    final long         len                 = JSType.toUint32(sobj.getLength());
    final long         relativeStart       = JSType.toLong(start);

    final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
    final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart);

    NativeArray returnValue;

    if (actualStart <= Integer.MAX_VALUE && actualDeleteCount <= Integer.MAX_VALUE && bulkable(sobj)) {
        try {
            returnValue =  new NativeArray(sobj.getArray().fastSplice((int)actualStart, (int)actualDeleteCount, items.length));

            // Since this is a dense bulkable array we can use faster defineOwnProperty to copy new elements
            int k = (int) actualStart;
            for (int i = 0; i < items.length; i++, k++) {
                sobj.defineOwnProperty(k, items[i]);
            }
        } catch (final UnsupportedOperationException uoe) {
            returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
        }
    } else {
        returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
    }

    return returnValue;
}
 
Example 10
Source File: NativeArray.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ECMA 15.4.4.12 Array.prototype.splice ( start, deleteCount [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return result of splice
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object splice(final Object self, final Object... args) {
    final Object obj = Global.toObject(self);

    if (!(obj instanceof ScriptObject)) {
        return ScriptRuntime.UNDEFINED;
    }

    final Object start = (args.length > 0) ? args[0] : ScriptRuntime.UNDEFINED;
    final Object deleteCount = (args.length > 1) ? args[1] : ScriptRuntime.UNDEFINED;

    Object[] items;

    if (args.length > 2) {
        items = new Object[args.length - 2];
        System.arraycopy(args, 2, items, 0, items.length);
    } else {
        items = ScriptRuntime.EMPTY_ARRAY;
    }

    final ScriptObject sobj                = (ScriptObject)obj;
    final long         len                 = JSType.toUint32(sobj.getLength());
    final long         relativeStart       = JSType.toLong(start);

    final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
    final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart);

    NativeArray returnValue;

    if (actualStart <= Integer.MAX_VALUE && actualDeleteCount <= Integer.MAX_VALUE && bulkable(sobj)) {
        try {
            returnValue =  new NativeArray(sobj.getArray().fastSplice((int)actualStart, (int)actualDeleteCount, items.length));

            // Since this is a dense bulkable array we can use faster defineOwnProperty to copy new elements
            int k = (int) actualStart;
            for (int i = 0; i < items.length; i++, k++) {
                sobj.defineOwnProperty(k, items[i]);
            }
        } catch (UnsupportedOperationException uoe) {
            returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
        }
    } else {
        returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
    }

    return returnValue;
}
 
Example 11
Source File: NativeArray.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ECMA 15.4.4.12 Array.prototype.splice ( start, deleteCount [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return result of splice
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object splice(final Object self, final Object... args) {
    final Object obj = Global.toObject(self);

    if (!(obj instanceof ScriptObject)) {
        return ScriptRuntime.UNDEFINED;
    }

    final Object start = args.length > 0 ? args[0] : ScriptRuntime.UNDEFINED;
    final Object deleteCount = args.length > 1 ? args[1] : ScriptRuntime.UNDEFINED;

    Object[] items;

    if (args.length > 2) {
        items = new Object[args.length - 2];
        System.arraycopy(args, 2, items, 0, items.length);
    } else {
        items = ScriptRuntime.EMPTY_ARRAY;
    }

    final ScriptObject sobj                = (ScriptObject)obj;
    final long         len                 = JSType.toUint32(sobj.getLength());
    final long         relativeStart       = JSType.toLong(start);

    final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
    final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart);

    NativeArray returnValue;

    if (actualStart <= Integer.MAX_VALUE && actualDeleteCount <= Integer.MAX_VALUE && bulkable(sobj)) {
        try {
            returnValue =  new NativeArray(sobj.getArray().fastSplice((int)actualStart, (int)actualDeleteCount, items.length));

            // Since this is a dense bulkable array we can use faster defineOwnProperty to copy new elements
            int k = (int) actualStart;
            for (int i = 0; i < items.length; i++, k++) {
                sobj.defineOwnProperty(k, items[i]);
            }
        } catch (final UnsupportedOperationException uoe) {
            returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
        }
    } else {
        returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
    }

    return returnValue;
}
 
Example 12
Source File: NativeArray.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ECMA 15.4.4.12 Array.prototype.splice ( start, deleteCount [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return result of splice
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object splice(final Object self, final Object... args) {
    final Object obj = Global.toObject(self);

    if (!(obj instanceof ScriptObject)) {
        return ScriptRuntime.UNDEFINED;
    }

    final Object start = args.length > 0 ? args[0] : ScriptRuntime.UNDEFINED;
    final Object deleteCount = args.length > 1 ? args[1] : ScriptRuntime.UNDEFINED;

    Object[] items;

    if (args.length > 2) {
        items = new Object[args.length - 2];
        System.arraycopy(args, 2, items, 0, items.length);
    } else {
        items = ScriptRuntime.EMPTY_ARRAY;
    }

    final ScriptObject sobj                = (ScriptObject)obj;
    final long         len                 = JSType.toUint32(sobj.getLength());
    final long         relativeStart       = JSType.toLong(start);

    final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
    final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart);

    NativeArray returnValue;

    if (actualStart <= Integer.MAX_VALUE && actualDeleteCount <= Integer.MAX_VALUE && bulkable(sobj)) {
        try {
            returnValue =  new NativeArray(sobj.getArray().fastSplice((int)actualStart, (int)actualDeleteCount, items.length));

            // Since this is a dense bulkable array we can use faster defineOwnProperty to copy new elements
            int k = (int) actualStart;
            for (int i = 0; i < items.length; i++, k++) {
                sobj.defineOwnProperty(k, items[i]);
            }
        } catch (final UnsupportedOperationException uoe) {
            returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
        }
    } else {
        returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
    }

    return returnValue;
}
 
Example 13
Source File: NativeArray.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ECMA 15.4.4.12 Array.prototype.splice ( start, deleteCount [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return result of splice
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object splice(final Object self, final Object... args) {
    final Object obj = Global.toObject(self);

    if (!(obj instanceof ScriptObject)) {
        return ScriptRuntime.UNDEFINED;
    }

    final ScriptObject sobj          = (ScriptObject)obj;
    final long         len           = JSType.toUint32(sobj.getLength());
    final long         relativeStart = JSType.toLong(args.length > 0 ? args[0] : ScriptRuntime.UNDEFINED);

    final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
    final long actualDeleteCount;
    Object[] items = ScriptRuntime.EMPTY_ARRAY;

    if (args.length == 0) {
        actualDeleteCount = 0;
    } else if (args.length == 1) {
        actualDeleteCount = len - actualStart;
    } else {
        actualDeleteCount = Math.min(Math.max(JSType.toLong(args[1]), 0), len - actualStart);
        if (args.length > 2) {
            items = new Object[args.length - 2];
            System.arraycopy(args, 2, items, 0, items.length);
        }
    }

    NativeArray returnValue;

    if (actualStart <= Integer.MAX_VALUE && actualDeleteCount <= Integer.MAX_VALUE && bulkable(sobj)) {
        try {
            returnValue = new NativeArray(sobj.getArray().fastSplice((int)actualStart, (int)actualDeleteCount, items.length));

            // Since this is a dense bulkable array we can use faster defineOwnProperty to copy new elements
            int k = (int) actualStart;
            for (int i = 0; i < items.length; i++, k++) {
                sobj.defineOwnProperty(k, items[i]);
            }
        } catch (final UnsupportedOperationException uoe) {
            returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
        }
    } else {
        returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
    }

    return returnValue;
}
 
Example 14
Source File: NativeArray.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ECMA 15.4.4.12 Array.prototype.splice ( start, deleteCount [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return result of splice
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object splice(final Object self, final Object... args) {
    final Object obj = Global.toObject(self);

    if (!(obj instanceof ScriptObject)) {
        return ScriptRuntime.UNDEFINED;
    }

    final Object start = args.length > 0 ? args[0] : ScriptRuntime.UNDEFINED;
    final Object deleteCount = args.length > 1 ? args[1] : ScriptRuntime.UNDEFINED;

    Object[] items;

    if (args.length > 2) {
        items = new Object[args.length - 2];
        System.arraycopy(args, 2, items, 0, items.length);
    } else {
        items = ScriptRuntime.EMPTY_ARRAY;
    }

    final ScriptObject sobj                = (ScriptObject)obj;
    final long         len                 = JSType.toUint32(sobj.getLength());
    final long         relativeStart       = JSType.toLong(start);

    final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);
    final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart);

    NativeArray returnValue;

    if (actualStart <= Integer.MAX_VALUE && actualDeleteCount <= Integer.MAX_VALUE && bulkable(sobj)) {
        try {
            returnValue =  new NativeArray(sobj.getArray().fastSplice((int)actualStart, (int)actualDeleteCount, items.length));

            // Since this is a dense bulkable array we can use faster defineOwnProperty to copy new elements
            int k = (int) actualStart;
            for (int i = 0; i < items.length; i++, k++) {
                sobj.defineOwnProperty(k, items[i]);
            }
        } catch (final UnsupportedOperationException uoe) {
            returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
        }
    } else {
        returnValue = slowSplice(sobj, actualStart, actualDeleteCount, items, len);
    }

    return returnValue;
}
 
Example 15
Source File: NativeObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * ECMA 15.2.3.6 Object.defineProperty ( O, P, Attributes )
 *
 * @param self self reference
 * @param obj  object in which to define a property
 * @param prop property to define
 * @param attr attributes for property descriptor
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
    final ScriptObject sobj = Global.checkObject(obj);
    sobj.defineOwnProperty(JSType.toString(prop), attr, true);
    return sobj;
}
 
Example 16
Source File: NativeObject.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * ECMA 15.2.3.6 Object.defineProperty ( O, P, Attributes )
 *
 * @param self self reference
 * @param obj  object in which to define a property
 * @param prop property to define
 * @param attr attributes for property descriptor
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
    final ScriptObject sobj = Global.checkObject(obj);
    sobj.defineOwnProperty(JSType.toString(prop), attr, true);
    return sobj;
}
 
Example 17
Source File: NativeObject.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * ECMA 15.2.3.6 Object.defineProperty ( O, P, Attributes )
 *
 * @param self self reference
 * @param obj  object in which to define a property
 * @param prop property to define
 * @param attr attributes for property descriptor
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
    final ScriptObject sobj = Global.checkObject(obj);
    sobj.defineOwnProperty(JSType.toPropertyKey(prop), attr, true);
    return sobj;
}
 
Example 18
Source File: NativeObject.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * ECMA 15.2.3.6 Object.defineProperty ( O, P, Attributes )
 *
 * @param self self reference
 * @param obj  object in which to define a property
 * @param prop property to define
 * @param attr attributes for property descriptor
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
    final ScriptObject sobj = Global.checkObject(obj);
    sobj.defineOwnProperty(JSType.toString(prop), attr, true);
    return sobj;
}
 
Example 19
Source File: NativeObject.java    From jdk8u_nashorn with GNU General Public License v2.0 3 votes vote down vote up
/**
 * ECMA 15.2.3.6 Object.defineProperty ( O, P, Attributes )
 *
 * @param self self reference
 * @param obj  object in which to define a property
 * @param prop property to define
 * @param attr attributes for property descriptor
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
    final ScriptObject sobj = Global.checkObject(obj);
    sobj.defineOwnProperty(JSType.toString(prop), attr, true);
    return sobj;
}
 
Example 20
Source File: NativeObject.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * ECMA 15.2.3.6 Object.defineProperty ( O, P, Attributes )
 *
 * @param self self reference
 * @param obj  object in which to define a property
 * @param prop property to define
 * @param attr attributes for property descriptor
 * @return object
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
    final ScriptObject sobj = Global.checkObject(obj);
    sobj.defineOwnProperty(JSType.toString(prop), attr, true);
    return sobj;
}