Skip to content

Commit 78da4fa

Browse files
authored
fix: mark external memory and version APIs as basic (#1597)
1 parent 8b5b8b7 commit 78da4fa

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

doc/memory_management.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ more often than it would otherwise in an attempt to garbage collect the JavaScri
1717
objects that keep the externally allocated memory alive.
1818

1919
```cpp
20-
static int64_t Napi::MemoryManagement::AdjustExternalMemory(Napi::Env env, int64_t change_in_bytes);
20+
static int64_t Napi::MemoryManagement::AdjustExternalMemory(Napi::BasicEnv env, int64_t change_in_bytes);
2121
```
2222
2323
- `[in] env`: The environment in which the API is invoked under.

doc/version_management.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ important to make decisions based on different versions of the system.
1111
Retrieves the highest Node-API version supported by Node.js runtime.
1212

1313
```cpp
14-
static uint32_t Napi::VersionManagement::GetNapiVersion(Env env);
14+
static uint32_t Napi::VersionManagement::GetNapiVersion(Napi::BasicEnv env);
1515
```
1616
1717
- `[in] env`: The environment in which the API is invoked under.
@@ -34,7 +34,7 @@ typedef struct {
3434
````
3535
3636
```cpp
37-
static const napi_node_version* Napi::VersionManagement::GetNodeVersion(Env env);
37+
static const napi_node_version* Napi::VersionManagement::GetNodeVersion(Napi::BasicEnv env);
3838
```
3939

4040
- `[in] env`: The environment in which the API is invoked under.

napi-inl.h

+11-6
Original file line numberDiff line numberDiff line change
@@ -6699,30 +6699,35 @@ inline void AsyncProgressQueueWorker<T>::ExecutionProgress::Send(
66996699
// Memory Management class
67006700
////////////////////////////////////////////////////////////////////////////////
67016701

6702-
inline int64_t MemoryManagement::AdjustExternalMemory(Env env,
6702+
inline int64_t MemoryManagement::AdjustExternalMemory(BasicEnv env,
67036703
int64_t change_in_bytes) {
67046704
int64_t result;
67056705
napi_status status =
67066706
napi_adjust_external_memory(env, change_in_bytes, &result);
6707-
NAPI_THROW_IF_FAILED(env, status, 0);
6707+
NAPI_FATAL_IF_FAILED(status,
6708+
"MemoryManagement::AdjustExternalMemory",
6709+
"napi_adjust_external_memory");
67086710
return result;
67096711
}
67106712

67116713
////////////////////////////////////////////////////////////////////////////////
67126714
// Version Management class
67136715
////////////////////////////////////////////////////////////////////////////////
67146716

6715-
inline uint32_t VersionManagement::GetNapiVersion(Env env) {
6717+
inline uint32_t VersionManagement::GetNapiVersion(BasicEnv env) {
67166718
uint32_t result;
67176719
napi_status status = napi_get_version(env, &result);
6718-
NAPI_THROW_IF_FAILED(env, status, 0);
6720+
NAPI_FATAL_IF_FAILED(
6721+
status, "VersionManagement::GetNapiVersion", "napi_get_version");
67196722
return result;
67206723
}
67216724

6722-
inline const napi_node_version* VersionManagement::GetNodeVersion(Env env) {
6725+
inline const napi_node_version* VersionManagement::GetNodeVersion(
6726+
BasicEnv env) {
67236727
const napi_node_version* result;
67246728
napi_status status = napi_get_node_version(env, &result);
6725-
NAPI_THROW_IF_FAILED(env, status, 0);
6729+
NAPI_FATAL_IF_FAILED(
6730+
status, "VersionManagement::GetNodeVersion", "napi_get_node_version");
67266731
return result;
67276732
}
67286733

napi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -3234,14 +3234,14 @@ class AsyncProgressQueueWorker
32343234
// Memory management.
32353235
class MemoryManagement {
32363236
public:
3237-
static int64_t AdjustExternalMemory(Env env, int64_t change_in_bytes);
3237+
static int64_t AdjustExternalMemory(BasicEnv env, int64_t change_in_bytes);
32383238
};
32393239

32403240
// Version management
32413241
class VersionManagement {
32423242
public:
3243-
static uint32_t GetNapiVersion(Env env);
3244-
static const napi_node_version* GetNodeVersion(Env env);
3243+
static uint32_t GetNapiVersion(BasicEnv env);
3244+
static const napi_node_version* GetNodeVersion(BasicEnv env);
32453245
};
32463246

32473247
#if NAPI_VERSION > 5

0 commit comments

Comments
 (0)