Skip to content

Commit 10b440f

Browse files
KevinEadymhdawson
authored andcommitted
src: reformat all code
Reformat all code to pass current linter checks PR-URL: #1160 Reviewed-By: Michael Dawson <[email protected] Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 33e4029 commit 10b440f

File tree

107 files changed

+6116
-5763
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+6116
-5763
lines changed

benchmark/function_args.cc

Lines changed: 95 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "napi.h"
22

33
static napi_value NoArgFunction_Core(napi_env env, napi_callback_info info) {
4-
(void) env;
5-
(void) info;
4+
(void)env;
5+
(void)info;
66
return nullptr;
77
}
88

@@ -12,7 +12,7 @@ static napi_value OneArgFunction_Core(napi_env env, napi_callback_info info) {
1212
if (napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr) != napi_ok) {
1313
return nullptr;
1414
}
15-
(void) argv;
15+
(void)argv;
1616
return nullptr;
1717
}
1818

@@ -22,8 +22,8 @@ static napi_value TwoArgFunction_Core(napi_env env, napi_callback_info info) {
2222
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
2323
return nullptr;
2424
}
25-
(void) argv[0];
26-
(void) argv[1];
25+
(void)argv[0];
26+
(void)argv[1];
2727
return nullptr;
2828
}
2929

@@ -33,9 +33,9 @@ static napi_value ThreeArgFunction_Core(napi_env env, napi_callback_info info) {
3333
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
3434
return nullptr;
3535
}
36-
(void) argv[0];
37-
(void) argv[1];
38-
(void) argv[2];
36+
(void)argv[0];
37+
(void)argv[1];
38+
(void)argv[2];
3939
return nullptr;
4040
}
4141

@@ -45,95 +45,128 @@ static napi_value FourArgFunction_Core(napi_env env, napi_callback_info info) {
4545
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
4646
return nullptr;
4747
}
48-
(void) argv[0];
49-
(void) argv[1];
50-
(void) argv[2];
51-
(void) argv[3];
48+
(void)argv[0];
49+
(void)argv[1];
50+
(void)argv[2];
51+
(void)argv[3];
5252
return nullptr;
5353
}
5454

5555
static void NoArgFunction(const Napi::CallbackInfo& info) {
56-
(void) info;
56+
(void)info;
5757
}
5858

5959
static void OneArgFunction(const Napi::CallbackInfo& info) {
60-
Napi::Value argv0 = info[0]; (void) argv0;
60+
Napi::Value argv0 = info[0];
61+
(void)argv0;
6162
}
6263

6364
static void TwoArgFunction(const Napi::CallbackInfo& info) {
64-
Napi::Value argv0 = info[0]; (void) argv0;
65-
Napi::Value argv1 = info[1]; (void) argv1;
65+
Napi::Value argv0 = info[0];
66+
(void)argv0;
67+
Napi::Value argv1 = info[1];
68+
(void)argv1;
6669
}
6770

6871
static void ThreeArgFunction(const Napi::CallbackInfo& info) {
69-
Napi::Value argv0 = info[0]; (void) argv0;
70-
Napi::Value argv1 = info[1]; (void) argv1;
71-
Napi::Value argv2 = info[2]; (void) argv2;
72+
Napi::Value argv0 = info[0];
73+
(void)argv0;
74+
Napi::Value argv1 = info[1];
75+
(void)argv1;
76+
Napi::Value argv2 = info[2];
77+
(void)argv2;
7278
}
7379

7480
static void FourArgFunction(const Napi::CallbackInfo& info) {
75-
Napi::Value argv0 = info[0]; (void) argv0;
76-
Napi::Value argv1 = info[1]; (void) argv1;
77-
Napi::Value argv2 = info[2]; (void) argv2;
78-
Napi::Value argv3 = info[3]; (void) argv3;
81+
Napi::Value argv0 = info[0];
82+
(void)argv0;
83+
Napi::Value argv1 = info[1];
84+
(void)argv1;
85+
Napi::Value argv2 = info[2];
86+
(void)argv2;
87+
Napi::Value argv3 = info[3];
88+
(void)argv3;
7989
}
8090

8191
#if NAPI_VERSION > 5
8292
class FunctionArgsBenchmark : public Napi::Addon<FunctionArgsBenchmark> {
8393
public:
8494
FunctionArgsBenchmark(Napi::Env env, Napi::Object exports) {
85-
DefineAddon(exports, {
86-
InstanceValue("addon", DefineProperties(Napi::Object::New(env), {
87-
InstanceMethod("noArgFunction", &FunctionArgsBenchmark::NoArgFunction),
88-
InstanceMethod("oneArgFunction",
89-
&FunctionArgsBenchmark::OneArgFunction),
90-
InstanceMethod("twoArgFunction",
91-
&FunctionArgsBenchmark::TwoArgFunction),
92-
InstanceMethod("threeArgFunction",
93-
&FunctionArgsBenchmark::ThreeArgFunction),
94-
InstanceMethod("fourArgFunction",
95-
&FunctionArgsBenchmark::FourArgFunction),
96-
}), napi_enumerable),
97-
InstanceValue("addon_templated",
98-
DefineProperties(Napi::Object::New(env), {
99-
InstanceMethod<&FunctionArgsBenchmark::NoArgFunction>(
100-
"noArgFunction"),
101-
InstanceMethod<&FunctionArgsBenchmark::OneArgFunction>(
102-
"oneArgFunction"),
103-
InstanceMethod<&FunctionArgsBenchmark::TwoArgFunction>(
104-
"twoArgFunction"),
105-
InstanceMethod<&FunctionArgsBenchmark::ThreeArgFunction>(
106-
"threeArgFunction"),
107-
InstanceMethod<&FunctionArgsBenchmark::FourArgFunction>(
108-
"fourArgFunction"),
109-
}), napi_enumerable),
110-
});
95+
DefineAddon(
96+
exports,
97+
{
98+
InstanceValue(
99+
"addon",
100+
DefineProperties(
101+
Napi::Object::New(env),
102+
{
103+
InstanceMethod("noArgFunction",
104+
&FunctionArgsBenchmark::NoArgFunction),
105+
InstanceMethod("oneArgFunction",
106+
&FunctionArgsBenchmark::OneArgFunction),
107+
InstanceMethod("twoArgFunction",
108+
&FunctionArgsBenchmark::TwoArgFunction),
109+
InstanceMethod(
110+
"threeArgFunction",
111+
&FunctionArgsBenchmark::ThreeArgFunction),
112+
InstanceMethod("fourArgFunction",
113+
&FunctionArgsBenchmark::FourArgFunction),
114+
}),
115+
napi_enumerable),
116+
InstanceValue(
117+
"addon_templated",
118+
DefineProperties(
119+
Napi::Object::New(env),
120+
{
121+
InstanceMethod<&FunctionArgsBenchmark::NoArgFunction>(
122+
"noArgFunction"),
123+
InstanceMethod<&FunctionArgsBenchmark::OneArgFunction>(
124+
"oneArgFunction"),
125+
InstanceMethod<&FunctionArgsBenchmark::TwoArgFunction>(
126+
"twoArgFunction"),
127+
InstanceMethod<
128+
&FunctionArgsBenchmark::ThreeArgFunction>(
129+
"threeArgFunction"),
130+
InstanceMethod<&FunctionArgsBenchmark::FourArgFunction>(
131+
"fourArgFunction"),
132+
}),
133+
napi_enumerable),
134+
});
111135
}
136+
112137
private:
113-
void NoArgFunction(const Napi::CallbackInfo& info) {
114-
(void) info;
115-
}
138+
void NoArgFunction(const Napi::CallbackInfo& info) { (void)info; }
116139

117140
void OneArgFunction(const Napi::CallbackInfo& info) {
118-
Napi::Value argv0 = info[0]; (void) argv0;
141+
Napi::Value argv0 = info[0];
142+
(void)argv0;
119143
}
120144

121145
void TwoArgFunction(const Napi::CallbackInfo& info) {
122-
Napi::Value argv0 = info[0]; (void) argv0;
123-
Napi::Value argv1 = info[1]; (void) argv1;
146+
Napi::Value argv0 = info[0];
147+
(void)argv0;
148+
Napi::Value argv1 = info[1];
149+
(void)argv1;
124150
}
125151

126152
void ThreeArgFunction(const Napi::CallbackInfo& info) {
127-
Napi::Value argv0 = info[0]; (void) argv0;
128-
Napi::Value argv1 = info[1]; (void) argv1;
129-
Napi::Value argv2 = info[2]; (void) argv2;
153+
Napi::Value argv0 = info[0];
154+
(void)argv0;
155+
Napi::Value argv1 = info[1];
156+
(void)argv1;
157+
Napi::Value argv2 = info[2];
158+
(void)argv2;
130159
}
131160

132161
void FourArgFunction(const Napi::CallbackInfo& info) {
133-
Napi::Value argv0 = info[0]; (void) argv0;
134-
Napi::Value argv1 = info[1]; (void) argv1;
135-
Napi::Value argv2 = info[2]; (void) argv2;
136-
Napi::Value argv3 = info[3]; (void) argv3;
162+
Napi::Value argv0 = info[0];
163+
(void)argv0;
164+
Napi::Value argv1 = info[1];
165+
(void)argv1;
166+
Napi::Value argv2 = info[2];
167+
(void)argv2;
168+
Napi::Value argv3 = info[3];
169+
(void)argv3;
137170
}
138171
};
139172
#endif // NAPI_VERSION > 5

benchmark/function_args.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22
const Benchmark = require('benchmark');
33
const addonName = path.basename(__filename, '.js');
44

5-
[ addonName, addonName + '_noexcept' ]
5+
[addonName, addonName + '_noexcept']
66
.forEach((addonName) => {
77
const rootAddon = require('bindings')({
88
bindings: addonName,
@@ -20,23 +20,23 @@ const addonName = path.basename(__filename, '.js');
2020
implems.reduce((suite, implem) => {
2121
const fn = rootAddon[implem].noArgFunction;
2222
return suite.add(implem.padStart(maxNameLength, ' '), () => fn());
23-
}, new Benchmark.Suite)
23+
}, new Benchmark.Suite())
2424
.on('cycle', (event) => console.log(String(event.target)))
2525
.run();
2626

2727
console.log('one argument:');
2828
implems.reduce((suite, implem) => {
2929
const fn = rootAddon[implem].oneArgFunction;
3030
return suite.add(implem.padStart(maxNameLength, ' '), () => fn('x'));
31-
}, new Benchmark.Suite)
31+
}, new Benchmark.Suite())
3232
.on('cycle', (event) => console.log(String(event.target)))
3333
.run();
3434

3535
console.log('two arguments:');
3636
implems.reduce((suite, implem) => {
3737
const fn = rootAddon[implem].twoArgFunction;
3838
return suite.add(implem.padStart(maxNameLength, ' '), () => fn('x', 12));
39-
}, new Benchmark.Suite)
39+
}, new Benchmark.Suite())
4040
.on('cycle', (event) => console.log(String(event.target)))
4141
.run();
4242

@@ -45,7 +45,7 @@ const addonName = path.basename(__filename, '.js');
4545
const fn = rootAddon[implem].threeArgFunction;
4646
return suite.add(implem.padStart(maxNameLength, ' '),
4747
() => fn('x', 12, true));
48-
}, new Benchmark.Suite)
48+
}, new Benchmark.Suite())
4949
.on('cycle', (event) => console.log(String(event.target)))
5050
.run();
5151

@@ -54,7 +54,7 @@ const addonName = path.basename(__filename, '.js');
5454
const fn = rootAddon[implem].fourArgFunction;
5555
return suite.add(implem.padStart(maxNameLength, ' '),
5656
() => fn('x', 12, true, anObject));
57-
}, new Benchmark.Suite)
57+
}, new Benchmark.Suite())
5858
.on('cycle', (event) => console.log(String(event.target)))
5959
.run();
6060
});

benchmark/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path');
66

77
let benchmarks = [];
88

9-
if (!!process.env.npm_config_benchmarks) {
9+
if (process.env.npm_config_benchmarks) {
1010
benchmarks = process.env.npm_config_benchmarks
1111
.split(';')
1212
.map((item) => (item + '.js'));

benchmark/property_descriptor.cc

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "napi.h"
22

33
static napi_value Getter_Core(napi_env env, napi_callback_info info) {
4-
(void) info;
4+
(void)info;
55
napi_value result;
66
napi_status status = napi_create_uint32(env, 42, &result);
77
NAPI_THROW_IF_FAILED(env, status, nullptr);
@@ -14,7 +14,7 @@ static napi_value Setter_Core(napi_env env, napi_callback_info info) {
1414
napi_status status =
1515
napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr);
1616
NAPI_THROW_IF_FAILED(env, status, nullptr);
17-
(void) argv;
17+
(void)argv;
1818
return nullptr;
1919
}
2020

@@ -23,22 +23,23 @@ static Napi::Value Getter(const Napi::CallbackInfo& info) {
2323
}
2424

2525
static void Setter(const Napi::CallbackInfo& info) {
26-
(void) info[0];
26+
(void)info[0];
2727
}
2828

2929
#if NAPI_VERSION > 5
3030
class PropDescBenchmark : public Napi::Addon<PropDescBenchmark> {
3131
public:
3232
PropDescBenchmark(Napi::Env, Napi::Object exports) {
33-
DefineAddon(exports, {
34-
InstanceAccessor("addon",
35-
&PropDescBenchmark::Getter,
36-
&PropDescBenchmark::Setter,
37-
napi_enumerable),
38-
InstanceAccessor<&PropDescBenchmark::Getter,
39-
&PropDescBenchmark::Setter>("addon_templated",
40-
napi_enumerable),
41-
});
33+
DefineAddon(exports,
34+
{
35+
InstanceAccessor("addon",
36+
&PropDescBenchmark::Getter,
37+
&PropDescBenchmark::Setter,
38+
napi_enumerable),
39+
InstanceAccessor<&PropDescBenchmark::Getter,
40+
&PropDescBenchmark::Setter>(
41+
"addon_templated", napi_enumerable),
42+
});
4243
}
4344

4445
private:
@@ -47,39 +48,31 @@ class PropDescBenchmark : public Napi::Addon<PropDescBenchmark> {
4748
}
4849

4950
void Setter(const Napi::CallbackInfo& info, const Napi::Value& val) {
50-
(void) info[0];
51-
(void) val;
51+
(void)info[0];
52+
(void)val;
5253
}
5354
};
5455
#endif // NAPI_VERSION > 5
5556

5657
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
5758
napi_status status;
58-
napi_property_descriptor core_prop = {
59-
"core",
60-
nullptr,
61-
nullptr,
62-
Getter_Core,
63-
Setter_Core,
64-
nullptr,
65-
napi_enumerable,
66-
nullptr
67-
};
59+
napi_property_descriptor core_prop = {"core",
60+
nullptr,
61+
nullptr,
62+
Getter_Core,
63+
Setter_Core,
64+
nullptr,
65+
napi_enumerable,
66+
nullptr};
6867

6968
status = napi_define_properties(env, exports, 1, &core_prop);
7069
NAPI_THROW_IF_FAILED(env, status, Napi::Object());
7170

72-
exports.DefineProperty(
73-
Napi::PropertyDescriptor::Accessor(env,
74-
exports,
75-
"cplusplus",
76-
Getter,
77-
Setter,
78-
napi_enumerable));
71+
exports.DefineProperty(Napi::PropertyDescriptor::Accessor(
72+
env, exports, "cplusplus", Getter, Setter, napi_enumerable));
7973

80-
exports.DefineProperty(
81-
Napi::PropertyDescriptor::Accessor<Getter, Setter>("templated",
82-
napi_enumerable));
74+
exports.DefineProperty(Napi::PropertyDescriptor::Accessor<Getter, Setter>(
75+
"templated", napi_enumerable));
8376

8477
#if NAPI_VERSION > 5
8578
PropDescBenchmark::Init(env, exports);

0 commit comments

Comments
 (0)