JS_DefineConstDoubles 编辑

Create multiple constant double or integer valued properties on an object.

Syntax

bool
JS_DefineConstDoubles(JSContext *cx, JS::HandleObject obj,
                      const JSConstDoubleSpec *cds);

bool
JS_DefineConstIntegers(JSContext *cx, JS::HandleObject obj,
                       const JSConstIntegerSpec *cis); // Added in SpiderMonkey 38
NameTypeDescription
cxJSContext *The context in which to define the new properties. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
objJSObject *Object for which to create new properties.
cdsJSConstDoubleSpec *Pointer to an array of JSConstDoubleSpec records containing property names and values to create. The last array element must contain zero-valued members.
cisJSConstIntegerSpec *Pointer to an array of JSConstIntegerSpec records containing property names and values to create. The last array element must contain zero-valued members.

Description

JS_DefineConstDoubles creates one or more properties for a specified object, obj, where each property consists of a double value.

JS_DefineConstIntegers creates one or more properties for a specified object, obj, where each property consists of a int32_t value.

The attributes for each property is set to JSPROP_READONLY | JSPROP_PERMANENT.

Obsolete from JSAPI 35

Each property is automatically assigned attributes as specified in the flags field of the JSConstDoubleSpec/JSConstIntegerSpec structure pointed to by cds/cis. If flags is set to 0, the attributes for the property are automatically set to JSPROP_PERMANENT | JSPROP_READONLY.

cds and cis are pointers to the first element of an array of JSConstDoubleSpec/JSConstIntegerSpec structures. Each array element defines a single property name and property value to create. The name field of the last element of the array must contain 0.

JS_DefineConstDoubles/JS_DefineConstIntegers create one property for each element in the array what contains a non-zero name field.

On success, JS_DefineConstDoubles/JS_DefineConstIntegers returns true, indicating it has created all properties listed in the array. Otherwise it returns false.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:94 次

字数:5069

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文