napi_type_tag_object
napi_status napi_type_tag_object(napi_env env,
napi_value js_object,
const napi_type_tag* type_tag);
-
[in] env
:调用 API 的环境。¥
[in] env
: The environment that the API is invoked under. -
[in] js_object
:要标记的 JavaScript 对象。¥
[in] js_object
: The JavaScript object to be marked. -
[in] type_tag
:要标记对象的标签。¥
[in] type_tag
: The tag with which the object is to be marked.
如果 API 成功,则返回 napi_ok
。
¥Returns napi_ok
if the API succeeded.
将 type_tag
指针的值与 JavaScript 对象相关联。然后可以使用 napi_check_object_type_tag()
将附加到对象的标签与插件拥有的标签进行比较,以确保对象具有正确的类型。
¥Associates the value of the type_tag
pointer with the JavaScript object.
napi_check_object_type_tag()
can then be used to compare the tag that was
attached to the object with one owned by the addon to ensure that the object
has the right type.
如果对象已经有关联的类型标签,此 API 将返回 napi_invalid_arg
。
¥If the object already has an associated type tag, this API will return
napi_invalid_arg
.