< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java

Print this page

        

*** 146,156 **** * @param self self reference * @param obj object whose index properties are backed by buffer * @param buf external buffer - should be a nio ByteBuffer * @return the 'obj' object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject setIndexedPropertiesToExternalArrayData(final Object self, final Object obj, final Object buf) { Global.checkObject(obj); final ScriptObject sobj = (ScriptObject)obj; if (buf instanceof ByteBuffer) { sobj.setArray(ArrayData.allocate((ByteBuffer)buf)); --- 146,157 ---- * @param self self reference * @param obj object whose index properties are backed by buffer * @param buf external buffer - should be a nio ByteBuffer * @return the 'obj' object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "sets ByteBuffer to hold indexed data (nashorn extension)") public static ScriptObject setIndexedPropertiesToExternalArrayData(final Object self, final Object obj, final Object buf) { Global.checkObject(obj); final ScriptObject sobj = (ScriptObject)obj; if (buf instanceof ByteBuffer) { sobj.setArray(ArrayData.allocate((ByteBuffer)buf));
*** 166,176 **** * * @param self self reference * @param obj object to get prototype from * @return the prototype of an object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object getPrototypeOf(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).getProto(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).getProto(); --- 167,178 ---- * * @param self self reference * @param obj object to get prototype from * @return the prototype of an object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "returns the prototype of the specified object") public static Object getPrototypeOf(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).getProto(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).getProto();
*** 193,203 **** * @param self self reference * @param obj object to set prototype for * @param proto prototype object to be used * @return object whose prototype is set */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object setPrototypeOf(final Object self, final Object obj, final Object proto) { if (obj instanceof ScriptObject) { ((ScriptObject)obj).setPrototypeOf(proto); return obj; } else if (obj instanceof ScriptObjectMirror) { --- 195,206 ---- * @param self self reference * @param obj object to set prototype for * @param proto prototype object to be used * @return object whose prototype is set */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "sets the prototype of the given object (ES6)") public static Object setPrototypeOf(final Object self, final Object obj, final Object proto) { if (obj instanceof ScriptObject) { ((ScriptObject)obj).setPrototypeOf(proto); return obj; } else if (obj instanceof ScriptObjectMirror) {
*** 214,224 **** * @param self self reference * @param obj object from which to get property descriptor for {@code ToString(prop)} * @param prop property descriptor * @return property descriptor */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object getOwnPropertyDescriptor(final Object self, final Object obj, final Object prop) { if (obj instanceof ScriptObject) { final String key = JSType.toString(prop); final ScriptObject sobj = (ScriptObject)obj; --- 217,228 ---- * @param self self reference * @param obj object from which to get property descriptor for {@code ToString(prop)} * @param prop property descriptor * @return property descriptor */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "returns a property descriptor for an own property (not inherited property)") public static Object getOwnPropertyDescriptor(final Object self, final Object obj, final Object prop) { if (obj instanceof ScriptObject) { final String key = JSType.toString(prop); final ScriptObject sobj = (ScriptObject)obj;
*** 238,248 **** * * @param self self reference * @param obj object to query for property names * @return array of property names */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject getOwnPropertyNames(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return new NativeArray(((ScriptObject)obj).getOwnKeys(true)); } else if (obj instanceof ScriptObjectMirror) { return new NativeArray(((ScriptObjectMirror)obj).getOwnKeys(true)); --- 242,253 ---- * * @param self self reference * @param obj object to query for property names * @return array of property names */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "returns an array of all properties (enumerable or not) found directly on the given object") public static ScriptObject getOwnPropertyNames(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return new NativeArray(((ScriptObject)obj).getOwnKeys(true)); } else if (obj instanceof ScriptObjectMirror) { return new NativeArray(((ScriptObjectMirror)obj).getOwnKeys(true));
*** 256,266 **** * * @param self self reference * @param obj object to query for property names * @return array of property names */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject getOwnPropertySymbols(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return new NativeArray(((ScriptObject)obj).getOwnSymbols(true)); } else { // TODO: we don't support this on ScriptObjectMirror objects yet --- 261,272 ---- * * @param self self reference * @param obj object to query for property names * @return array of property names */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "returns an array of all symbol properties found directly on the given object (ES6)") public static ScriptObject getOwnPropertySymbols(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return new NativeArray(((ScriptObject)obj).getOwnSymbols(true)); } else { // TODO: we don't support this on ScriptObjectMirror objects yet
*** 274,284 **** * @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); } --- 280,291 ---- * @param self self reference * @param proto prototype object * @param props properties to define * @return object created */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "creates a new object with the specified prototype object and properties") public static ScriptObject create(final Object self, final Object proto, final Object props) { if (proto != null) { Global.checkObject(proto); }
*** 300,310 **** * @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; } --- 307,318 ---- * @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, ! documentation = "adds an own property and/or update the attributes of an existing own property of an object") 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; }
*** 315,325 **** * @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) { --- 323,334 ---- * @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, ! documentation = "defines new or modifies existing properties directly on the given object") 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) {
*** 337,347 **** * * @param self self reference * @param obj object to seal * @return sealed object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object seal(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).seal(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).seal(); --- 346,357 ---- * * @param self self reference * @param obj object to seal * @return sealed object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "prevents new properties from being added to the given object and marks existing properties as non-configurable") public static Object seal(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).seal(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).seal();
*** 356,366 **** * * @param self self reference * @param obj object to freeze * @return frozen object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object freeze(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).freeze(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).freeze(); --- 366,377 ---- * * @param self self reference * @param obj object to freeze * @return frozen object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "prevents new properties from being added to the given object and prevents existing properties from being removed or re-configured") public static Object freeze(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).freeze(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).freeze();
*** 374,384 **** * * @param self self reference * @param obj object, for which to set the internal extensible property to false * @return object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object preventExtensions(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).preventExtensions(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).preventExtensions(); --- 385,396 ---- * * @param self self reference * @param obj object, for which to set the internal extensible property to false * @return object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "prevents new properties from ever being added to the given object") public static Object preventExtensions(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).preventExtensions(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).preventExtensions();
*** 392,402 **** * * @param self self reference * @param obj check whether an object is sealed * @return true if sealed, false otherwise */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static boolean isSealed(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).isSealed(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).isSealed(); --- 404,415 ---- * * @param self self reference * @param obj check whether an object is sealed * @return true if sealed, false otherwise */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "tells if an object is sealed or not") public static boolean isSealed(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).isSealed(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).isSealed();
*** 410,420 **** * * @param self self reference * @param obj check whether an object * @return true if object is frozen, false otherwise */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static boolean isFrozen(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).isFrozen(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).isFrozen(); --- 423,434 ---- * * @param self self reference * @param obj check whether an object * @return true if object is frozen, false otherwise */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "tells if an object is fronzen or not") public static boolean isFrozen(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).isFrozen(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).isFrozen();
*** 428,438 **** * * @param self self reference * @param obj check whether an object is extensible * @return true if object is extensible, false otherwise */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static boolean isExtensible(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).isExtensible(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).isExtensible(); --- 442,453 ---- * * @param self self reference * @param obj check whether an object is extensible * @return true if object is extensible, false otherwise */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "tells if an object is extensible or not") public static boolean isExtensible(final Object self, final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).isExtensible(); } else if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).isExtensible();
*** 446,456 **** * * @param self self reference * @param obj object from which to extract keys * @return array of keys in object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static ScriptObject keys(final Object self, final Object obj) { if (obj instanceof ScriptObject) { final ScriptObject sobj = (ScriptObject)obj; return new NativeArray(sobj.getOwnKeys(false)); } else if (obj instanceof ScriptObjectMirror) { --- 461,472 ---- * * @param self self reference * @param obj object from which to extract keys * @return array of keys in object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "returns an array of the given object's own enumerable properties") public static ScriptObject keys(final Object self, final Object obj) { if (obj instanceof ScriptObject) { final ScriptObject sobj = (ScriptObject)obj; return new NativeArray(sobj.getOwnKeys(false)); } else if (obj instanceof ScriptObjectMirror) {
*** 469,479 **** * @param newObj is the new object instantiated with the new operator * @param self self reference * @param value value of object to be instantiated * @return the new NativeObject */ ! @Constructor public static Object construct(final boolean newObj, final Object self, final Object value) { final JSType type = JSType.ofNoFunction(value); // Object(null), Object(undefined), Object() are same as "new Object()" --- 485,495 ---- * @param newObj is the new object instantiated with the new operator * @param self self reference * @param value value of object to be instantiated * @return the new NativeObject */ ! @Constructor(documentation = "creates a new script object or converts given value as a script object") public static Object construct(final boolean newObj, final Object self, final Object value) { final JSType type = JSType.ofNoFunction(value); // Object(null), Object(undefined), Object() are same as "new Object()"
*** 503,513 **** * ECMA 15.2.4.2 Object.prototype.toString ( ) * * @param self self reference * @return ToString of object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE) public static String toString(final Object self) { return ScriptRuntime.builtinObjectToString(self); } /** --- 519,530 ---- * ECMA 15.2.4.2 Object.prototype.toString ( ) * * @param self self reference * @return ToString of object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, ! documentation = "returns a string representing of this object") public static String toString(final Object self) { return ScriptRuntime.builtinObjectToString(self); } /**
*** 556,566 **** * * @param self self reference * @param v property to check for * @return true if property exists in object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE) public static boolean hasOwnProperty(final Object self, final Object v) { // Convert ScriptObjects to primitive with String.class hint // but no need to convert other primitives to string. final Object key = JSType.toPrimitive(v, String.class); final Object obj = Global.toObject(self); --- 573,584 ---- * * @param self self reference * @param v property to check for * @return true if property exists in object */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, ! documentation = "tells whether this object has the specified property or not") public static boolean hasOwnProperty(final Object self, final Object v) { // Convert ScriptObjects to primitive with String.class hint // but no need to convert other primitives to string. final Object key = JSType.toPrimitive(v, String.class); final Object obj = Global.toObject(self);
*** 573,583 **** * * @param self self reference * @param v v prototype object to check against * @return true if object is prototype of v */ ! @Function(attributes = Attribute.NOT_ENUMERABLE) public static boolean isPrototypeOf(final Object self, final Object v) { if (!(v instanceof ScriptObject)) { return false; } --- 591,602 ---- * * @param self self reference * @param v v prototype object to check against * @return true if object is prototype of v */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, ! documentation = "tests for this object in another object's prototype chain") public static boolean isPrototypeOf(final Object self, final Object v) { if (!(v instanceof ScriptObject)) { return false; }
*** 599,609 **** * * @param self self reference * @param v property to check if enumerable * @return true if property is enumerable */ ! @Function(attributes = Attribute.NOT_ENUMERABLE) public static boolean propertyIsEnumerable(final Object self, final Object v) { final String str = JSType.toString(v); final Object obj = Global.toObject(self); if (obj instanceof ScriptObject) { --- 618,629 ---- * * @param self self reference * @param v property to check if enumerable * @return true if property is enumerable */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, ! documentation = "tells whether the given property is enumerable or not") public static boolean propertyIsEnumerable(final Object self, final Object v) { final String str = JSType.toString(v); final Object obj = Global.toObject(self); if (obj instanceof ScriptObject) {
*** 674,684 **** * @param self self reference * @param target the target object to which the source object's properties are bound * @param source the source object whose properties are bound to the target * @return the target object after property binding */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object bindProperties(final Object self, final Object target, final Object source) { // target object has to be a ScriptObject final ScriptObject targetObj = Global.checkObject(target); // check null or undefined source object Global.checkObjectCoercible(source); --- 694,705 ---- * @param self self reference * @param target the target object to which the source object's properties are bound * @param source the source object whose properties are bound to the target * @return the target object after property binding */ ! @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, ! documentation = "binds the source object's properties to the target object (nashorn extension)") public static Object bindProperties(final Object self, final Object target, final Object source) { // target object has to be a ScriptObject final ScriptObject targetObj = Global.checkObject(target); // check null or undefined source object Global.checkObjectCoercible(source);
< prev index next >