Skip to content

Commit 1deba98

Browse files
authored
Merge pull request #5 from richerfu/fix-typed-array
fix: typed array
2 parents c6e7ca8 + 295a7ff commit 1deba98

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# node-addon-api-ohos
22

3-
![Platform](https://img.shields.io/badge/platform-arm64/arm/x86__64-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![Ohpm Version](https://img.shields.io/badge/OhpmVersion-0.0.1-green)
3+
![Platform](https://img.shields.io/badge/platform-arm64/arm/x86__64-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![Ohpm Version](https://img.shields.io/badge/OhpmVersion-0.0.3-green)
44

55
`node-addon-api` for OpenHarmony/HarmonyNext.
66

@@ -31,11 +31,12 @@ target_link_libraries(entry PRIVATE node_addon_api_ohos)
3131

3232
For node-addon-api-ohos, we acccepted the following environment variables:
3333

34-
| Name | Description | Default Value |
35-
| --------------------------- | ----------------------------------- | ------------- |
36-
| NAPI_CPP_EXCEPTIONS | Allow catch the cpp exception | true |
37-
| NAPI_DISABLE_CPP_EXCEPTIONS | Disable catch the cpp exception | false |
38-
| NAPI_NORMAL | Hidden some APIs or cases for Harmony | true |
34+
| Name | Description | Default Value |
35+
| --------------------------- | ----------------------------------------- | ------------- |
36+
| NAPI_CPP_EXCEPTIONS | Allow catch the cpp exception | true |
37+
| NAPI_DISABLE_CPP_EXCEPTIONS | Disable catch the cpp exception | false |
38+
| NAPI_NORMAL | Hidden some APIs or cases for Harmony | true |
39+
| NODE_GYP_MODULE_NAME | `NODE_API_ADDON` use it as library's name | |
3940

4041
## Build
4142

include/napi-inl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -2219,15 +2219,17 @@ inline void ArrayBuffer::Detach() {
22192219
_type(napi_typedarray_type::napi_int8_array),
22202220
_length(0) {
22212221
if (value != nullptr) {
2222+
size_t len = 0;
22222223
napi_status status =
22232224
napi_get_typedarray_info(_env,
22242225
_value,
22252226
&const_cast<TypedArray*>(this)->_type,
2226-
&const_cast<TypedArray*>(this)->_length,
2227+
&len,
22272228
nullptr,
22282229
nullptr,
22292230
nullptr);
22302231
NAPI_THROW_IF_FAILED_VOID(_env, status);
2232+
_length = len / ElementSize();
22312233
}
22322234
}
22332235

package/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.0.3
2+
- The length of a TypedArray should be divided by its element length.
3+
4+
---
15
# 0.0.2
26
- Buffer should extend Object directly.
37

package/oh-package.json5

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
name: "@ohos-rs/node-addon-api",
55
description: "Node-addon-api for OpenHarmony/HarmonyNext",
66
main: "index.ets",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
types: "libs/index.d.ts",
99
dependencies: {}
1010
}

0 commit comments

Comments
 (0)