< prev index next >

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

Print this page

        

@@ -146,11 +146,12 @@
      * @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)
+    @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,11 +167,12 @@
      *
      * @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)
+    @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,11 +195,12 @@
      * @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)
+    @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,11 +217,12 @@
      * @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)
+    @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,11 +242,12 @@
      *
      * @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)
+    @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,11 +261,12 @@
      *
      * @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)
+    @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,11 +280,12 @@
      * @param self  self reference
      * @param proto prototype object
      * @param props properties to define
      * @return object created
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
+    @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,11 +307,12 @@
      * @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)
+    @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,11 +323,12 @@
      * @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)
+    @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,11 +346,12 @@
      *
      * @param self self reference
      * @param obj  object to seal
      * @return sealed object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
+    @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,11 +366,12 @@
      *
      * @param self self reference
      * @param obj object to freeze
      * @return frozen object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
+    @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,11 +385,12 @@
      *
      * @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)
+    @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,11 +404,12 @@
      *
      * @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)
+    @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,11 +423,12 @@
      *
      * @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)
+    @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,11 +442,12 @@
      *
      * @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)
+    @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,11 +461,12 @@
      *
      * @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)
+    @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,11 +485,11 @@
      * @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
+    @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,11 +519,12 @@
      * ECMA 15.2.4.2 Object.prototype.toString ( )
      *
      * @param self self reference
      * @return ToString of object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE)
+    @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,11 +573,12 @@
      *
      * @param self self reference
      * @param v property to check for
      * @return true if property exists in object
      */
-    @Function(attributes = Attribute.NOT_ENUMERABLE)
+    @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,11 +591,12 @@
      *
      * @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)
+    @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,11 +618,12 @@
      *
      * @param self self reference
      * @param v property to check if enumerable
      * @return true if property is enumerable
      */
-    @Function(attributes = Attribute.NOT_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,11 +694,12 @@
      * @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)
+    @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 >