Entry: JSClass (Data Structure)
Summary: Defines a base class for use in building and maintaining JS objects.
Syntax:
struct JSClass {
char *name;
uint32 flags;
/* Mandatory non-null function pointer members. */
JSPropertyOp addProperty;
JSPropertyOp delProperty;
JSPropertyOp getProperty;
JSPropertyOp setProperty;
JSEnumerateOp enumerate;
JSResolveOp resolve;
JSConvertOp convert;
JSFinalizeOp finalize;
/* Optionally non-null members start here. */
JSGetObjectOps getObjectOps;
JSCheckAccessOp checkAccess;
JSNative call;
JSNative construct;
JSXDRObjectOp xdrObject;
JSHasInstanceOp hasInstance;
prword spare[2];
};
Argument Type Description
*name char Class name
flags uint32 Class attributes. 0 indicates no attributes are set. Attributes can be one or both of the following values OR'd together:
JSCLASS_HAS_PRIVATE: class can use private data.
JSCLASS_NEW_ENUMERATE: class defines getObjectOps to point to a new method for enumerating properties.
JSCLASS_NEW_RESOLVE: class defines getObjectOps to point to a new method for property resolution.
addProperty JSPropertyOp Method for adding a property to the class.
delProperty JSPropertyOp Method for deleting a property from the class.
getProperty JSPropertyOp Method for getting a property value.
setProperty JSPropertyOp Method for setting a property value.
enumerate JSEnumerateOp Method for enumerating over class properties.
resolve JSResolveOp Method for resolving property ambiguities.
convert JSConvertOp Method for converting property values.
finalize JSFinalizeOp Method for finalizing the class.
getObjectOps JSGetObjectOps Pointer to an optional structure that defines method overrides for a class. If you do not intend to override the default methods for a class, set getObjectOps to NULL.
checkAccess JSCheckAccessOp Pointer to an optional custom access control method for a class or object operations structure. If you do not intend to provide custom access control, set this value to NULL.
call JSNative Pointer to the method for calling into the object that represents this class.
construct JSNative Pointer to the constructor for the object that represents this class
xdrObject JSXDRObjectOp Pointer to an optional XDR object and its methods. If you do not use XDR, set this value to NULL.
hasInstance JSHasInstanceOp Pointer to an optional hasInstance method for this object. If you do not provide a method for hasInstance, set this pointer to NULL.
spare prword Reserved for future use.
Description:
Use JSClass to define a base class used in object creation and manipulation. In your applications, you may use JSClass to declare a constructor function, base properties, methods, and attributes common to a series of objects you create.
By default, JSClass defines a set of default property access methods that can be used by all objects derived in whole or in part from the class. You can define getObjectOps to point to an optional JSObjectOps struct that contains pointers to an array of methods that override the default access methods. For more information about creating method overrides, see JSObjectOps.
See also:
|
|
|