Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JSClass

摘要

数据结构 定义一个基本类用于建立和维护JS对象。

语法

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;
    JSMarkOp mark;
    JSReserveSlotsOp reserveSlots;
};
名称 类型 描述
name char * 类名
flags uint32 类的属性(成员变量)。0表明属性不是一个集合. 属性值可以是下面这些值中的一个或多个:
addProperty JSPropertyOp 为类增加属性的函数。
delProperty JSPropertyOp 从类中删除属性的函数。
getProperty JSPropertyOp 获取属性值的函数。
setProperty JSPropertyOp 设置属性值的函数
enumerate JSEnumerateOp 枚举类所有属性的函数。
resolve JSResolveOp Method for resolving property ambiguities.
convert JSConvertOp 进行属性值转换的函数。
finalize JSFinalizeOp 将类设为不可修改(finalizing)的函数。
getObjectOps JSGetObjectOps 为类定义重载方法指向一个可选的结构。如果你不想重载类的默认方法,可以将getObjectOps 设为 NULL
checkAccess JSCheckAccessOp 为类或对象操作结构指定可选的自定义请求控制方法。如果你不想提供自定义的请求控制,设置此值为NULL
call JSNative 为对象提供替换这个类的方法。
construct JSNative 为对象提供方法去替换这个类的构造器。
xdrObject JSXDRObjectOp 指向一个可选的XDR对象和它的方法。如果你不想使用XDR, 设置这个值为 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.
mark JSMarkOp Pointer to an optional mark method for this object. If you do not provide a method for mark, set this pointer to NULL.
reserveSlots JSReserveSlotsOp Pointer to an optional reserveSlots method for this object. If you do not provide a method for reserveSlots, set this pointer to NULL.

 

文档标签和贡献者

 此页面的贡献者: ziyunfei, Suweite
 最后编辑者: ziyunfei,