Subj : Re: API docs To : netscape.public.mozilla.jseng From : Sterling Bates Date : Fri Apr 16 2004 12:14 pm This is a multi-part message in MIME format. --------------080206030908050200000105 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit OK, here's a patch for the first 2,000 lines of the jsref.xml file (or up to JS_ValueToObject's entry). It has a bunch of grammar corrections and updated #define's. I need help in the following locations (for correctness, and initial documentation where I'm not qualified): 1. JSPROP_SHARED documentation 2. All of the JSFUN_ definitions 3. The new JSCLASS_ properties (_PRIVATE_IS_NSISUPPORTS, _SHARE_ALL_PROPERTIES, _NEW_RESOLVE_GETS_START) 4. I'm not sure if all JSPROP_ flags apply to JSConstDoubleSpec.flags, but I put them in 5. Should I remove references to HTML pages in the JSErrorReport spec? 6. Anywhere that I used "XXX" as the description for an item :-) I have real work to do, so I'll do more over the weekend. Sterling --------------080206030908050200000105 Content-Type: text/plain; name="diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff.txt" Index: jsref.xml =================================================================== RCS file: /cvsroot/mozilla/js/docs/jsref.xml,v retrieving revision 1.7 diff -r1.7 jsref.xml 402,403c402 < JSVAL_LOCK locks a JS value, v, to prevent the value from being garbage collected. v is a JS object, string, or double value.

< JSVAL_LOCK determines if v is an object, string, or double value, and if it is, it locks the value. If locking is successful, or v already cannot be garbage collected because it is not an object, string, or double value, JSVAL_LOCK evaluates to true. Otherwise JSVAL_LOCK evaluates to false.

--- > JSVAL_LOCK locks a JS value, v, to prevent the value from being garbage collected. JSVAL_LOCK determines if v is an object, string, or double value, and if it is, it locks the value. If locking is successful, or v already cannot be garbage collected because it is not an object, string, or double value, JSVAL_LOCK evaluates to true. Otherwise JSVAL_LOCK evaluates to false.

422,423c421 < JSVAL_UNLOCK unlocks a previously locked JS value, v, so it can be garbage collected. v is a JS object, string, or double value.

< JSVAL_UNLOCK determine if v is an object, string, or double value, and if it is, it unlocks the value. If unlocking is successful, or v is not affected by garbage collection because it is not an object, string, or double value, JSVAL_UNLOCK evaluates to true. Otherwise JSVAL_UNLOCK evaluates to false.

--- > JSVAL_UNLOCK unlocks a previously locked JS value, v, so it can be garbage collected. JSVAL_UNLOCK determines if v is an object, string, or double value, and if it is, it unlocks the value. If unlocking is successful, or v is not affected by garbage collection because it is not an object, string, or double value, JSVAL_UNLOCK evaluates to true. Otherwise JSVAL_UNLOCK evaluates to false.

463c461 < JSVAL_TO_INT converts a specified JS integer value, v, to a C integer value by performing a bitwise right shift operation. JSVAL_TO_INT assumes that it was passed a JS value of type JSVAL_INT, and returns that JS value's corresponding C integer value. Note that because of the bit-shifting operation, that a C comparison of JSVAL_TO_INT(v) to v always results in nonequality.

--- > JSVAL_TO_INT converts a specified JS integer value, v, to a C integer value by performing a bitwise right shift operation. JSVAL_TO_INT assumes that it was passed a JS value of type JSVAL_INT, and returns that JS value's corresponding C integer value. Note that, because of the bit-shifting operation, a C comparison of JSVAL_TO_INT(v) to v always results in nonequality.

478c476 < INT_TO_JSVAL converts a C integer, i, to a JS integer value type using a bitwise left shift operation and OR'ing the result with the JSVAL_INT macro.

--- > INT_TO_JSVAL converts a C integer, i, to a JS integer value type using a bitwise left shift operation and setting the data type flag to JSVAL_INT.

523c521 < JSVAL_TO_PRIVATE casts a JS value, v, to a void pointer to private data. Private data is associated with an JS class on which the JSCLASS_HAS_PRIVATE attribute is set. Private data is user-allocated, defined, and maintained. Private pointers must be word aligned.

--- > JSVAL_TO_PRIVATE casts a JS value, v, to a void pointer to private data. Private data is associated with a JS class for which the JSCLASS_HAS_PRIVATE attribute is set. Private data is user-allocated, defined, and maintained. Private pointers must be word aligned.

538,539c536,537 < PRIVATE_TO_JSVAL enables you to store a private data pointer, p, as a JS value. The private pointer must be word-aligned. Before passing a pointer to PRIVATE_TO_JSVAL, test it with INT_FITS_IN_JSVAL to be verify that the pointer can be cast to a legal JS integer value.

< PRIVATE_TO_JSVAL casts a pointer to a JS integer value and sets the JSVAL_INT type tag on it.

--- > PRIVATE_TO_JSVAL enables you to store a private data pointer, p, as a JS value. The private pointer must be word-aligned. Before passing a pointer to PRIVATE_TO_JSVAL, test it with INT_FITS_IN_JSVAL to verify that the pointer can be cast to a legal JS integer value.

> PRIVATE_TO_JSVAL casts a pointer to a JS integer value and sets the JSVAL_INT type tag on it.

547c545 < Public.Flag that indicates a property is visible to for and in loops. --- > Flag that indicates a property is visible to for..in loops. 553c551 < JSPROP_ENUMERATE is a flag value that indicates a property belonging to a JS object is visible to for and in loops. JSPROP_ENUMERATE is used to set or clear the flags field in a JSPropertySpec structure so that a property can be made visible or invisible to loops.

--- > JSPROP_ENUMERATE is a flag value that indicates a property belonging to a JS object is visible to for..in loops. JSPROP_ENUMERATE is an attribute set in the flags field of a JSPropertySpec structure so that a property can be made visible or invisible to loops.

572a571,573 > > > 587c588 < JSPROP_READONLY is a flag value that indicates that the value for a property belonging to a JS object cannot be set at run time. For JavaScript 1.2 and lower, it is an error to attempt to assign a value to a property marked with the JSPROP_READONLY flag. In JavaScript 1.3 and ECMA-Script, attempts to set a value on a read-only property are ignored. You can, however, always check the flags fields to determine if a property is read only.

--- > JSPROP_READONLY is a flag value that indicates that the value for a property belonging to a JS object cannot be set at run time. For JavaScript 1.2 and lower, it is an error to attempt to assign a value to a property marked with the JSPROP_READONLY flag. In JavaScript 1.3 and ECMA-Script, attempts to set a value on a read-only property are ignored. You can, however, always check the flags field to determine if a property is read only.

599a601,603 > > > 614c618 < JSPROP_PERMANENT is a flag value that indicates that the property belonging to a JS object is a "permanent" property, one that cannot be deleted from the object at run time. Attempting to delete a permanent property is JavaScript 1.2 or lower results in an error. In JavaScript 1.3 and ECMA-Script, such deletion attempts are ignored. You can, however, always check the flags fields to determine if a property is permanent.

--- > JSPROP_PERMANENT is a flag value that indicates that the property belonging to a JS object cannot be deleted from the object at run time. Attempting to delete a permanent property is JavaScript 1.2 or lower results in an error. In JavaScript 1.3 and ECMA-Script, such deletion attempts are ignored. You can, however, always check the flags field to determine if a property is permanent.

626a631,633 > > > 653a661,663 > > > 659c669 < --- > 662c672 < Flag that indicates a property's name is actually an index number into an array. --- > Flag that indicates the property has a getter function. 665c675 < JSPROP_INDEX --- > JSPROP_GETTER 668c678 < JSPROP_INDEX is a flag value that indicates a property's name will automatically be cast to an integer value to use as an index into an array of property values (elements).

--- > JSPROP_GETTER is a flag value that indicates the property has a custom getter function. This custom function overrides the default property getter.

681a692,694 > > > 686c699 < --- > 689c702 < Flag that indicates a function nominally associated with an object is bound, instead, to that object's parent. --- > Flag that indicates the property has a setter function. 692c705 < JSFUN_BOUND_METHOD --- > JSPROP_SETTER 695c708 < This macro is deprecated. JSFUN_BOUND_METHOD is a flag that indicates a method associated with an object is bound to the method's parent, the object on which the method is called.

--- > JSPROP_SETTER is a flag value that indicates the property has a custom setter function. This custom function overrides the default property setter.

698,700c711,715 < This macro exists only for backward compatibility with existing applications. Its < use is deprecated. Future versions of the JavaScript engine may not support or < recognize this macro. --- > Property flags cannot be changed at run time. Instead, you either pass a set of > flags as an argument to JS_DefineProperty to create a single property with > fixed flag values, or you set property flags in a JSPropertySpec struct which is > then passed to the JS_DefineProperties function to create multiple > properties on a single object. 703,704c718,727 < < --- > > > > > > > > > > 706c729 < --- > 709c732 < Flag that indicates a call to a function nominally associated with an object is called with the global object as its scope chain, rather than with the parent of the function. --- > XXX 712c735 < JSFUN_GLOBAL_PARENT --- > JSPROP_SHARED 715c738,798 < This macro is deprecated. Instead of using it, use JS_CloneFunctionObject. JSFUN_GLOBAL_PARENT is a flag that indicates a call to a function nominally associated with an object is called with the global object as its scope chain, rather than with the parent of the function. This permits the function to operate on free variables in the larger scope when they are found through prototype lookups.

--- >

> > > Property flags cannot be changed at run time. Instead, you either pass a set of > flags as an argument to JS_DefineProperty to create a single property with > fixed flag values, or you set property flags in a JSPropertySpec struct which is > then passed to the JS_DefineProperties function to create multiple > properties on a single object. >

> > > > > > > > > > > > > > >

> Flag that indicates a property's name is actually an index number into an array. > > > JSPROP_INDEX > > > JSPROP_INDEX is a flag value that indicates a property's name will automatically be cast to an integer value to use as an index into an array of property values (elements).

> > > Property flags cannot be changed at run time. Instead, you either pass a set of > flags as an argument to JS_DefineProperty to create a single property with > fixed flag values, or you set property flags in a JSPropertySpec struct which is > then passed to the JS_DefineProperties function to create multiple > properties on a single object. >

> > > > > > > > > > > > > > >

> Flag that indicates a function nominally associated with an object is bound, instead, to that object's parent. > > > JSFUN_BOUND_METHOD > > > This macro is deprecated. JSFUN_BOUND_METHOD is a flag that indicates a method associated with an object is bound to the method's parent, the object on which the method is called.

723c806,810 < --- > > > > > 791c878 < JSVAL_ZERO defines a JS value of 1. Currently this value is defined as INT_TO_JSVAL(1).

--- > JSVAL_ONE defines a JS value of 1. Currently this value is defined as INT_TO_JSVAL(1).

804c891 < Defines a false JS Boolean value. --- > Defines a false JS boolean value. 810c897 < JSVAL_FALSE defines a false JS Boolean value. Currently this value is defined as BOOLEAN_TO_JSVAL(JS_FALSE).

--- > JSVAL_FALSE defines a false JS boolean value. Currently this value is defined as BOOLEAN_TO_JSVAL(JS_FALSE).

828c915 < Defines a true JS Boolean value. --- > Defines a true JS boolean value. 834c921 < JSVAL_TRUE defines a true JS Boolean value. Currently this value is defined as BOOLEAN_TO_JSVAL(JS_TRUE).

--- > JSVAL_TRUE defines a true JS boolean value. Currently this value is defined as BOOLEAN_TO_JSVAL(JS_TRUE).

859a947,951 > > > > > 874c966,969 < --- > > > > 890a986,1045 > > > > > > > > >

> XXX > > > JSCLASS_PRIVATE_IS_NSISUPPORTS > > >

> > > > > > > > > > > >

> XXX > > > JSCLASS_SHARE_ALL_PROPERTIES > > >

> > > > > > > > > > > >

> XXX > > > JSCLASS_NEW_RESOLVE_GETS_START > > >

> > > > > > 964c1119 < JS_NewRuntime(maxbytes); --- > JS_NewRuntime(uint32 maxbytes); 979c1134 < JS_DestroyRuntime(rt); --- > JS_DestroyRuntime(JSRuntime *rt); 989c1144 < Flag that specifies that a function's identify can be uniquely resolved without examining the function prototype chain. --- > Flag that specifies that a function's identity can be uniquely resolved without examining the function prototype chain. 995c1150 < JSRESOLVE_QUALIFIED is flag that, if included in a function's flags field, indicates that its identify can be uniquely resolved without reference to its full prototype chain.

--- > JSRESOLVE_QUALIFIED is flag that, if included in a function's flags field, indicates that its identity can be uniquely resolved without reference to its full prototype chain.

998d1152 < 1004c1158 < Flag that specifies that a function's identify can be uniquely resolved by examining the left side of an assignment statement. --- > Flag that specifies that a function's identity can be uniquely resolved by examining the left side of an assignment statement. 1010c1164 < JSRESOLVE_ASSIGNING is a flag that, if included in a function's flags field, indicates that its identity can be uniquely resolved simply by examing the left side of an assignment statement.

--- > JSRESOLVE_ASSIGNING is a flag that, if included in a function's flags field, indicates that its identity can be uniquely resolved simply by examining the left side of an assignment statement.

1013d1166 < 1023c1176 < char *name; --- > const char *name; 1041c1194,1195 < prword spare[2]; --- > JSMarkOp mark; > JSReserveSlotsOp reserveSlots; 1050a1205,1207 > JSCLASS_PRIVATE_IS_NSISUPPORTS: class private is (nsISupports *).
> JSCLASS_SHARE_ALL_PROPERTIES: class shares all properties.
> JSCLASS_NEW_RESOLVE_GETS_START: JSNewResolveOp gets the starting object in the prototype chain passed in via the *objp in/out parameter.
1086c1243 < Pointer to the constructor for the object that represents this class
--- > Pointer to the constructor for the object that represents this class.
1094,1095c1251,1255 < < Reserved for future use.
--- > > See http://lxr.mozilla.org/mozilla/search?string=JSMarkOp
> > > See http://lxr.mozilla.org/mozilla/search?string=JSReserveSlotsOp
1103a1264,1268 > > > > > 1141c1306,1311 < prword spare[2]; --- > JSSetObjectSlotOp setProto; > JSSetObjectSlotOp setParent; > JSMarkOp mark; > JSFinalizeOp clear; > JSGetRequiredSlotOp getRequiredSlot; > JSSetRequiredSlotOp setRequiredSlot; 1197,1198c1367,1383 < < Reserved for future use.
--- > > See http://lxr.mozilla.org/mozilla/search?string=JSSetObjectSlotOp
> > > See http://lxr.mozilla.org/mozilla/search?string=JSSetObjectSlotOp
> > > See http://lxr.mozilla.org/mozilla/search?string=JSMarkOp
> > > See http://lxr.mozilla.org/mozilla/search?string=JSFinalizeOp
> > > See http://lxr.mozilla.org/mozilla/search?string=JSGetRequiredSlotOp
> > > See http://lxr.mozilla.org/mozilla/search?string=JSSetRequiredSlotOp
1231a1417,1419 > JSPROP_GETTER: property has a defined getter function.
> JSPROP_SETTER: property has a defined setter function.
> JSPROP_SHARED: property is shared.
1247a1436,1438 > > > 1284,1287c1475,1481 < Function attributes. If set to 0 the function has no attributes. Otherwise, existing applications can set flags to either or both of the following attributes OR'd:
< JSFUN_BOUND_METHOD
< JSFUN_GLOBAL_PARENT
< Note that these attributes are deprecated, and continue to be supported only for backward compatibility with existing applications. New applications should not use these attributes.
--- > Function attributes. If set to 0 the function has no attributes. Otherwise, existing applications can set flags to any of the following attributes OR'd:
> JSFUN_LAMBDA: the function is expressed but not declared.
> JSFUN_GETTER: function holds a getter function.
> JSFUN_SETTER: function holds a setter function.
> JSFUN_BOUND_METHOD: function is bound to the function object's parent.
> JSFUN_HEAVYWEIGHT: a Call object is required to activate this function.
> JSFUN_FLAGS_MASK: equivalent of all JSFUN_* attributes
1294c1488 < JSFuctionSpec defines the attributes for a single JS function to associate with an object. Generally, you populate an array of JSFunctionSpec to define all the functions for an object, and then call JS_DefineFunctions to create the functions and assign them to an object.

--- > JSFuctionSpec defines the attributes for a single JS function to associate with an object. Generally, you populate an array of JSFunctionSpec elements to define all the functions for an object, and then call JS_DefineFunctions to create the functions and assign them to an object.

1296a1491,1493 > > > 1298c1495,1496 < --- > > 1327c1525 < --- > 1331c1529 < Attributes for the double. Currently these can be 0 or more of the following values OR'd:
--- > Attributes for the double. This can be 0 or any of the following values OR'd:
1336c1534,1537 < JSPROP_INDEX: property is actually an array element.
--- > JSPROP_GETTER: property has a defined getter function.
> JSPROP_SETTER: property has a defined setter function.
> JSPROP_SHARED: property is shared.
> JSPROP_INDEX: property is actual an array element.
1338c1539 < --- > 1343,1344c1544,1545 < JSConstDoubleSpecs is typically used to define a set of double values that are assigned as properties to an object using JS_DefineConstDoubles. JS_DefineConstDoubles creates one or more double properties for a specified object.

< JS_DefineConstDoubles takes an argument that is a pointer to an array of JSConstDoubleSpecs. Each array element defines a single property name and property value to create. The last element of the array must contain zero-valued values. JS_DefineConstDoubles creates one property for each non-zero element in the array.

--- > JSConstDoubleSpec is typically used to define a set of double values that are assigned as properties to an object using JS_DefineConstDoubles. JS_DefineConstDoubles creates one or more double properties for a specified object.

> JS_DefineConstDoubles takes an argument that is a pointer to an array of JSConstDoubleSpecs. Each array element defines a single property name and property value to create. The last element of the array must contain zero-valued values. JS_DefineConstDoubles creates one property for each non-zero element in the array.

1360c1561 < typedef struct JSPrincipals { --- > struct JSPrincipals { 1362,1368c1563,1567 < void *(*getPrincipalArray)(JSContext *cx, < struct JSPrincipals *); < JSBool (*globalPrivilegesEnabled)(JSContext *cx, < struct JSPrincipals *); < uintN refcount; < void (*destroy)(JSContext *cx, struct JSPrincipals *); < } JSPrincipals; --- > void *(* JS_DLL_CALLBACK getPrincipalArray)(JSContext *cx, JSPrincipals *); > JSBool (* JS_DLL_CALLBACK globalPrivilegesEnabled)(JSContext *cx, JSPrincipals *); > jsrefcount refcount; > void (* JS_DLL_CALLBACK destroy)(JSContext *cx, struct JSPrincipals *); > }; 1378,1379c1577,1578 < < Reference count for the principals. Each reference to a principal increments refcount by one. As principals references are dropped, call the destroy method to decrement the reference count and free the principals if they are no longer needed.
--- > > Reference count for the principals. Each reference to a principal increments refcount by one. As principal references are dropped, call the destroy method to decrement the reference count and free the principals if they are no longer needed.
1412a1612,1615 > uintN flags; > uintN errorNumber; > const jschar *ucmessage; > const jschar **messageArgs; 1431a1635,1650 > > Error description attributes. The default is 0. This property may be any of the following attributes OR'd:
> JSREPORT_ERROR (default)
> JSREPORT_WARNING
> JSREPORT_EXCEPTION
> JSREPORT_STRICT
> > > The error number. See js.msg for predefined errors.
> > > Unicode error message.
> > > Pointer to the arguments for the error message *ucmessage.
> 1440,1441c1659,1660 < uctokenptr is a pointer into uclinebuf that identifies the precise location line of the problem within the offending Unicode (original) version of the offending line.

< To use JSErrorReport, your application must define a variable of type JSErrorReport and allocate a buffer to hold the text that generated the error condition. Set linebuf to point at the buffer before your application executes a script. For Unicode scripts, define a second buffer that holds the Unicode version of the text the generated the error. For application that do not use Unicode, set uclinebuf and uctokenptr to NULL.

--- > uctokenptr is a pointer into uclinebuf that identifies the precise location line of the problem within the Unicode (original) version of the offending line.

> To use JSErrorReport, your application must define a variable of type JSErrorReport and allocate a buffer to hold the text that generated the error condition. Set linebuf to point at the buffer before your application executes a script. For Unicode scripts, define a second buffer that holds the Unicode version of the text the generated the error. For applications that do not use Unicode, set uclinebuf and uctokenptr to NULL.

1450c1669 < Internal use only. Describes an array of property IDs to associated with an object. --- > Internal use only. Describes an array of property IDs associated with an object. 1523c1742 < As a value in mathematical calculations infinite values behaves like infinity. For example, anything multiplied by infinity is infinity, and anything divided by infinity is zero.

--- > As a value in mathematical calculations infinite values behave like infinity. For example, anything multiplied by infinity is infinity, and anything divided by infinity is zero.

1550,1552c1769,1770 < JSBool JS_ConvertArguments(JSContext *cx, uintN argc, < jsval *argv, const char *format, ...); < --- > JSBool JS_ConvertArguments(JSContext *cx, uintN argc, jsval *argv, const char *format, ...); > 1558c1776 < --- > 1561c1779 < --- > 1564c1782 < --- > 1590c1808 < uint32 (32-bit, ECMA-compliant, unsigned integer)

--- > uint32 (32-bit, ECMA-compliant unsigned integer)

1623c1841 < JS_ConvertArguments expects to be passed an argument vector that belongs to a native JS function, such that every argument passed is already a JS value. By default, when you first call JS_ConvertArguments, it automatically provides built-in error checking to guarantee that the proper number of arguments has been passed. If an improper number of arguments is passed in, JS_ConvertArguments reports an error and terminates. You can turn off this error-checking at any time by passing a slash (/) as a character any place in format where you no longer desire the argument number check to be made.

--- > JS_ConvertArguments expects to be passed an argument vector that belongs to a native JS function, such that every argument passed is already a JS value. By default, when you first call JS_ConvertArguments, it automatically provides built-in error checking to guarantee that the proper number of arguments has been passed. If an improper number of arguments is passed in, JS_ConvertArguments reports an error and terminates. You can turn off this error-checking at any time by passing a slash (/) as a character any place in format where you no longer desire the argument number check to be made.

1627a1846 > 1638a1858,1967 > > >

> XXX > > > jsval * JS_PushArguments(JSContext *cx, void **markp, const char *format, ...); > > Pointer to a JS context from which to derive runtime information.
> > >
> > >
> > >
> >
> >

> > > > > > > > > > > > > > > > > >

> XXX > > > void JS_PopArguments(JSContext *cx, void *mark); > > Pointer to a JS context from which to derive runtime information.
> > >
> >
> >

> > > > > > > > > > > > > > > > > > >

> XXX > > > JSBool JS_AddArgumentFormatter(JSContext *cx, const char *format, JSArgumentFormatter formatter); > > Pointer to a JS context from which to derive runtime information.
> > >
> > >
> >
> >

> > > > > >

> XXX > > > void JS_AddArgumentFormatter(JSContext *cx, const char *format); > > Pointer to a JS context from which to derive runtime information.
> > >
> >
> >

> > > 1642c1971 < Converts a JS value to a value of a specific JS type. --- > Converts a JS value to a specific JS type. 1645,1647c1974,1975 < JSBool JS_ConvertValue(JSContext *cx, jsval v, JSType type, < jsval *vp); < --- > JSBool JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp); > 1654c1982 < The type to which to convert the value. type must be one of JSTYPE_VOID, JSTYPE_OBJECT, JSTYPE_FUNCTION, JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_BOOLEAN. Otherwise JS_ConvertValue reports an error.
--- > The type to which to convert the value. type must be one of JSTYPE_VOID, JSTYPE_OBJECT, JSTYPE_FUNCTION, JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_BOOLEAN. Otherwise JS_ConvertValue reports an error.
1656c1984 < --- > 4647c4975 < jsint *lengthp); --- > jsuint *lengthp); --------------080206030908050200000105-- .