Skip to content

Commit

Permalink
Fix C++ via clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEady committed Apr 28, 2022
1 parent 8e02267 commit eb47700
Show file tree
Hide file tree
Showing 38 changed files with 5,001 additions and 4,611 deletions.
157 changes: 95 additions & 62 deletions benchmark/function_args.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "napi.h"

static napi_value NoArgFunction_Core(napi_env env, napi_callback_info info) {
(void) env;
(void) info;
(void)env;
(void)info;
return nullptr;
}

Expand All @@ -12,7 +12,7 @@ static napi_value OneArgFunction_Core(napi_env env, napi_callback_info info) {
if (napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr) != napi_ok) {
return nullptr;
}
(void) argv;
(void)argv;
return nullptr;
}

Expand All @@ -22,8 +22,8 @@ static napi_value TwoArgFunction_Core(napi_env env, napi_callback_info info) {
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
return nullptr;
}
(void) argv[0];
(void) argv[1];
(void)argv[0];
(void)argv[1];
return nullptr;
}

Expand All @@ -33,9 +33,9 @@ static napi_value ThreeArgFunction_Core(napi_env env, napi_callback_info info) {
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
return nullptr;
}
(void) argv[0];
(void) argv[1];
(void) argv[2];
(void)argv[0];
(void)argv[1];
(void)argv[2];
return nullptr;
}

Expand All @@ -45,95 +45,128 @@ static napi_value FourArgFunction_Core(napi_env env, napi_callback_info info) {
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
return nullptr;
}
(void) argv[0];
(void) argv[1];
(void) argv[2];
(void) argv[3];
(void)argv[0];
(void)argv[1];
(void)argv[2];
(void)argv[3];
return nullptr;
}

static void NoArgFunction(const Napi::CallbackInfo& info) {
(void) info;
(void)info;
}

static void OneArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv0 = info[0];
(void)argv0;
}

static void TwoArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv1 = info[1]; (void) argv1;
Napi::Value argv0 = info[0];
(void)argv0;
Napi::Value argv1 = info[1];
(void)argv1;
}

static void ThreeArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv1 = info[1]; (void) argv1;
Napi::Value argv2 = info[2]; (void) argv2;
Napi::Value argv0 = info[0];
(void)argv0;
Napi::Value argv1 = info[1];
(void)argv1;
Napi::Value argv2 = info[2];
(void)argv2;
}

static void FourArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv1 = info[1]; (void) argv1;
Napi::Value argv2 = info[2]; (void) argv2;
Napi::Value argv3 = info[3]; (void) argv3;
Napi::Value argv0 = info[0];
(void)argv0;
Napi::Value argv1 = info[1];
(void)argv1;
Napi::Value argv2 = info[2];
(void)argv2;
Napi::Value argv3 = info[3];
(void)argv3;
}

#if NAPI_VERSION > 5
class FunctionArgsBenchmark : public Napi::Addon<FunctionArgsBenchmark> {
public:
FunctionArgsBenchmark(Napi::Env env, Napi::Object exports) {
DefineAddon(exports, {
InstanceValue("addon", DefineProperties(Napi::Object::New(env), {
InstanceMethod("noArgFunction", &FunctionArgsBenchmark::NoArgFunction),
InstanceMethod("oneArgFunction",
&FunctionArgsBenchmark::OneArgFunction),
InstanceMethod("twoArgFunction",
&FunctionArgsBenchmark::TwoArgFunction),
InstanceMethod("threeArgFunction",
&FunctionArgsBenchmark::ThreeArgFunction),
InstanceMethod("fourArgFunction",
&FunctionArgsBenchmark::FourArgFunction),
}), napi_enumerable),
InstanceValue("addon_templated",
DefineProperties(Napi::Object::New(env), {
InstanceMethod<&FunctionArgsBenchmark::NoArgFunction>(
"noArgFunction"),
InstanceMethod<&FunctionArgsBenchmark::OneArgFunction>(
"oneArgFunction"),
InstanceMethod<&FunctionArgsBenchmark::TwoArgFunction>(
"twoArgFunction"),
InstanceMethod<&FunctionArgsBenchmark::ThreeArgFunction>(
"threeArgFunction"),
InstanceMethod<&FunctionArgsBenchmark::FourArgFunction>(
"fourArgFunction"),
}), napi_enumerable),
});
DefineAddon(
exports,
{
InstanceValue(
"addon",
DefineProperties(
Napi::Object::New(env),
{
InstanceMethod("noArgFunction",
&FunctionArgsBenchmark::NoArgFunction),
InstanceMethod("oneArgFunction",
&FunctionArgsBenchmark::OneArgFunction),
InstanceMethod("twoArgFunction",
&FunctionArgsBenchmark::TwoArgFunction),
InstanceMethod(
"threeArgFunction",
&FunctionArgsBenchmark::ThreeArgFunction),
InstanceMethod("fourArgFunction",
&FunctionArgsBenchmark::FourArgFunction),
}),
napi_enumerable),
InstanceValue(
"addon_templated",
DefineProperties(
Napi::Object::New(env),
{
InstanceMethod<&FunctionArgsBenchmark::NoArgFunction>(
"noArgFunction"),
InstanceMethod<&FunctionArgsBenchmark::OneArgFunction>(
"oneArgFunction"),
InstanceMethod<&FunctionArgsBenchmark::TwoArgFunction>(
"twoArgFunction"),
InstanceMethod<
&FunctionArgsBenchmark::ThreeArgFunction>(
"threeArgFunction"),
InstanceMethod<&FunctionArgsBenchmark::FourArgFunction>(
"fourArgFunction"),
}),
napi_enumerable),
});
}

private:
void NoArgFunction(const Napi::CallbackInfo& info) {
(void) info;
}
void NoArgFunction(const Napi::CallbackInfo& info) { (void)info; }

void OneArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv0 = info[0];
(void)argv0;
}

void TwoArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv1 = info[1]; (void) argv1;
Napi::Value argv0 = info[0];
(void)argv0;
Napi::Value argv1 = info[1];
(void)argv1;
}

void ThreeArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv1 = info[1]; (void) argv1;
Napi::Value argv2 = info[2]; (void) argv2;
Napi::Value argv0 = info[0];
(void)argv0;
Napi::Value argv1 = info[1];
(void)argv1;
Napi::Value argv2 = info[2];
(void)argv2;
}

void FourArgFunction(const Napi::CallbackInfo& info) {
Napi::Value argv0 = info[0]; (void) argv0;
Napi::Value argv1 = info[1]; (void) argv1;
Napi::Value argv2 = info[2]; (void) argv2;
Napi::Value argv3 = info[3]; (void) argv3;
Napi::Value argv0 = info[0];
(void)argv0;
Napi::Value argv1 = info[1];
(void)argv1;
Napi::Value argv2 = info[2];
(void)argv2;
Napi::Value argv3 = info[3];
(void)argv3;
}
};
#endif // NAPI_VERSION > 5
Expand Down
61 changes: 27 additions & 34 deletions benchmark/property_descriptor.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "napi.h"

static napi_value Getter_Core(napi_env env, napi_callback_info info) {
(void) info;
(void)info;
napi_value result;
napi_status status = napi_create_uint32(env, 42, &result);
NAPI_THROW_IF_FAILED(env, status, nullptr);
Expand All @@ -14,7 +14,7 @@ static napi_value Setter_Core(napi_env env, napi_callback_info info) {
napi_status status =
napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr);
NAPI_THROW_IF_FAILED(env, status, nullptr);
(void) argv;
(void)argv;
return nullptr;
}

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

static void Setter(const Napi::CallbackInfo& info) {
(void) info[0];
(void)info[0];
}

#if NAPI_VERSION > 5
class PropDescBenchmark : public Napi::Addon<PropDescBenchmark> {
public:
PropDescBenchmark(Napi::Env, Napi::Object exports) {
DefineAddon(exports, {
InstanceAccessor("addon",
&PropDescBenchmark::Getter,
&PropDescBenchmark::Setter,
napi_enumerable),
InstanceAccessor<&PropDescBenchmark::Getter,
&PropDescBenchmark::Setter>("addon_templated",
napi_enumerable),
});
DefineAddon(exports,
{
InstanceAccessor("addon",
&PropDescBenchmark::Getter,
&PropDescBenchmark::Setter,
napi_enumerable),
InstanceAccessor<&PropDescBenchmark::Getter,
&PropDescBenchmark::Setter>(
"addon_templated", napi_enumerable),
});
}

private:
Expand All @@ -47,39 +48,31 @@ class PropDescBenchmark : public Napi::Addon<PropDescBenchmark> {
}

void Setter(const Napi::CallbackInfo& info, const Napi::Value& val) {
(void) info[0];
(void) val;
(void)info[0];
(void)val;
}
};
#endif // NAPI_VERSION > 5

static Napi::Object Init(Napi::Env env, Napi::Object exports) {
napi_status status;
napi_property_descriptor core_prop = {
"core",
nullptr,
nullptr,
Getter_Core,
Setter_Core,
nullptr,
napi_enumerable,
nullptr
};
napi_property_descriptor core_prop = {"core",
nullptr,
nullptr,
Getter_Core,
Setter_Core,
nullptr,
napi_enumerable,
nullptr};

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

exports.DefineProperty(
Napi::PropertyDescriptor::Accessor(env,
exports,
"cplusplus",
Getter,
Setter,
napi_enumerable));
exports.DefineProperty(Napi::PropertyDescriptor::Accessor(
env, exports, "cplusplus", Getter, Setter, napi_enumerable));

exports.DefineProperty(
Napi::PropertyDescriptor::Accessor<Getter, Setter>("templated",
napi_enumerable));
exports.DefineProperty(Napi::PropertyDescriptor::Accessor<Getter, Setter>(
"templated", napi_enumerable));

#if NAPI_VERSION > 5
PropDescBenchmark::Init(env, exports);
Expand Down
Loading

0 comments on commit eb47700

Please sign in to comment.