Skip to content

Commit 2563401

Browse files
legendecasRafaelGSS
authored andcommitted
node-api: cleanup redundant static modifiers
Functions declared in anonymous namespaces are not necessarily to be marked as static. PR-URL: #44301 Refs: #44141 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent 8e2dcaf commit 2563401

File tree

3 files changed

+30
-33
lines changed

3 files changed

+30
-33
lines changed

src/js_native_api_v8.cc

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace v8impl {
6161

6262
namespace {
6363

64-
inline static napi_status V8NameFromPropertyDescriptor(
64+
inline napi_status V8NameFromPropertyDescriptor(
6565
napi_env env,
6666
const napi_property_descriptor* p,
6767
v8::Local<v8::Name>* result) {
@@ -79,7 +79,7 @@ inline static napi_status V8NameFromPropertyDescriptor(
7979
}
8080

8181
// convert from n-api property attributes to v8::PropertyAttribute
82-
inline static v8::PropertyAttribute V8PropertyAttributesFromDescriptor(
82+
inline v8::PropertyAttribute V8PropertyAttributesFromDescriptor(
8383
const napi_property_descriptor* descriptor) {
8484
unsigned int attribute_flags = v8::PropertyAttribute::None;
8585

@@ -100,12 +100,12 @@ inline static v8::PropertyAttribute V8PropertyAttributesFromDescriptor(
100100
return static_cast<v8::PropertyAttribute>(attribute_flags);
101101
}
102102

103-
inline static napi_deferred JsDeferredFromNodePersistent(
103+
inline napi_deferred JsDeferredFromNodePersistent(
104104
v8impl::Persistent<v8::Value>* local) {
105105
return reinterpret_cast<napi_deferred>(local);
106106
}
107107

108-
inline static v8impl::Persistent<v8::Value>* NodePersistentFromJsDeferred(
108+
inline v8impl::Persistent<v8::Value>* NodePersistentFromJsDeferred(
109109
napi_deferred local) {
110110
return reinterpret_cast<v8impl::Persistent<v8::Value>*>(local);
111111
}
@@ -139,32 +139,30 @@ class EscapableHandleScopeWrapper {
139139
bool escape_called_;
140140
};
141141

142-
inline static napi_handle_scope JsHandleScopeFromV8HandleScope(
143-
HandleScopeWrapper* s) {
142+
inline napi_handle_scope JsHandleScopeFromV8HandleScope(HandleScopeWrapper* s) {
144143
return reinterpret_cast<napi_handle_scope>(s);
145144
}
146145

147-
inline static HandleScopeWrapper* V8HandleScopeFromJsHandleScope(
148-
napi_handle_scope s) {
146+
inline HandleScopeWrapper* V8HandleScopeFromJsHandleScope(napi_handle_scope s) {
149147
return reinterpret_cast<HandleScopeWrapper*>(s);
150148
}
151149

152-
inline static napi_escapable_handle_scope
150+
inline napi_escapable_handle_scope
153151
JsEscapableHandleScopeFromV8EscapableHandleScope(
154152
EscapableHandleScopeWrapper* s) {
155153
return reinterpret_cast<napi_escapable_handle_scope>(s);
156154
}
157155

158-
inline static EscapableHandleScopeWrapper*
156+
inline EscapableHandleScopeWrapper*
159157
V8EscapableHandleScopeFromJsEscapableHandleScope(
160158
napi_escapable_handle_scope s) {
161159
return reinterpret_cast<EscapableHandleScopeWrapper*>(s);
162160
}
163161

164-
inline static napi_status ConcludeDeferred(napi_env env,
165-
napi_deferred deferred,
166-
napi_value result,
167-
bool is_resolved) {
162+
inline napi_status ConcludeDeferred(napi_env env,
163+
napi_deferred deferred,
164+
napi_value result,
165+
bool is_resolved) {
168166
NAPI_PREAMBLE(env);
169167
CHECK_ARG(env, result);
170168

@@ -191,10 +189,10 @@ inline static napi_status ConcludeDeferred(napi_env env,
191189

192190
enum UnwrapAction { KeepWrap, RemoveWrap };
193191

194-
inline static napi_status Unwrap(napi_env env,
195-
napi_value js_object,
196-
void** result,
197-
UnwrapAction action) {
192+
inline napi_status Unwrap(napi_env env,
193+
napi_value js_object,
194+
void** result,
195+
UnwrapAction action) {
198196
NAPI_PREAMBLE(env);
199197
CHECK_ARG(env, js_object);
200198
if (action == KeepWrap) {

src/js_native_api_v8.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef SRC_JS_NATIVE_API_V8_H_
22
#define SRC_JS_NATIVE_API_V8_H_
33

4-
// This file needs to be compatible with C compilers.
5-
#include <string.h> // NOLINT(modernize-deprecated-headers)
64
#include "js_native_api_types.h"
75
#include "js_native_api_v8_internals.h"
86

@@ -152,7 +150,7 @@ class EnvRefHolder {
152150
napi_env _env;
153151
};
154152

155-
static inline napi_status napi_clear_last_error(napi_env env) {
153+
inline napi_status napi_clear_last_error(napi_env env) {
156154
env->last_error.error_code = napi_ok;
157155

158156
// TODO(boingoing): Should this be a callback?
@@ -162,10 +160,10 @@ static inline napi_status napi_clear_last_error(napi_env env) {
162160
return napi_ok;
163161
}
164162

165-
static inline napi_status napi_set_last_error(napi_env env,
166-
napi_status error_code,
167-
uint32_t engine_error_code = 0,
168-
void* engine_reserved = nullptr) {
163+
inline napi_status napi_set_last_error(napi_env env,
164+
napi_status error_code,
165+
uint32_t engine_error_code = 0,
166+
void* engine_reserved = nullptr) {
169167
env->last_error.error_code = error_code;
170168
env->last_error.engine_error_code = engine_error_code;
171169
env->last_error.engine_reserved = engine_reserved;
@@ -275,6 +273,12 @@ static inline napi_status napi_set_last_error(napi_env env,
275273
#define CHECK_MAYBE_EMPTY_WITH_PREAMBLE(env, maybe, status) \
276274
RETURN_STATUS_IF_FALSE_WITH_PREAMBLE((env), !((maybe).IsEmpty()), (status))
277275

276+
#define STATUS_CALL(call) \
277+
do { \
278+
napi_status status = (call); \
279+
if (status != napi_ok) return status; \
280+
} while (0)
281+
278282
namespace v8impl {
279283

280284
//=== Conversion between V8 Handles and napi_value ========================
@@ -431,10 +435,4 @@ class Reference : public RefBase {
431435

432436
} // end of namespace v8impl
433437

434-
#define STATUS_CALL(call) \
435-
do { \
436-
napi_status status = (call); \
437-
if (status != napi_ok) return status; \
438-
} while (0)
439-
440438
#endif // SRC_JS_NATIVE_API_V8_H_

src/node_api.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "util-inl.h"
1717

1818
#include <atomic>
19+
#include <cstring>
1920
#include <memory>
2021

2122
node_napi_env__::node_napi_env__(v8::Local<v8::Context> context,
@@ -124,8 +125,8 @@ class BufferFinalizer : private Finalizer {
124125
};
125126
};
126127

127-
static inline napi_env NewEnv(v8::Local<v8::Context> context,
128-
const std::string& module_filename) {
128+
inline napi_env NewEnv(v8::Local<v8::Context> context,
129+
const std::string& module_filename) {
129130
node_napi_env result;
130131

131132
result = new node_napi_env__(context, module_filename);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy