From 5d75653f5ff84c2b70e14bfd0832cff2179a6ab5 Mon Sep 17 00:00:00 2001 From: Aaron Meriwether Date: Tue, 11 Jan 2022 17:29:13 -0600 Subject: [PATCH] Appease the pedantic gcc and eslint --- napi-inl.h | 7 +++---- test/objectwrap_nonconstructor.cc | 18 +++++++++--------- test/objectwrap_nonconstructor.js | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index 280f1340d..42dd55683 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -4454,7 +4454,7 @@ inline ClassPropertyDescriptor ObjectWrap::StaticValue(Symbol name, template inline Value ObjectWrap::NonConstructor(const Napi::CallbackInfo& info) { NAPI_THROW(TypeError::New(info.Env(), "Class constructors cannot be invoked without 'new'"), Napi::Value()); -}; +} template inline void ObjectWrap::Finalize(Napi::Env /*env*/) {} @@ -4469,9 +4469,8 @@ inline napi_value ObjectWrap::ConstructorCallbackWrapper( bool isConstructCall = (new_target != nullptr); if (!isConstructCall) { - return details::WrapCallback([&] { - return T::NonConstructor(CallbackInfo(env, info)); - }); + return details::WrapCallback( + [&] { return T::NonConstructor(CallbackInfo(env, info)); }); } napi_value wrapper = details::WrapCallback([&] { diff --git a/test/objectwrap_nonconstructor.cc b/test/objectwrap_nonconstructor.cc index e7f798177..616952432 100644 --- a/test/objectwrap_nonconstructor.cc +++ b/test/objectwrap_nonconstructor.cc @@ -1,21 +1,20 @@ #include -#include "test_helper.h" #include +#include "test_helper.h" -class NonConstructorTest : - public Napi::ObjectWrap { -public: - NonConstructorTest(const Napi::CallbackInfo& info) : - Napi::ObjectWrap(info) {} +class NonConstructorTest : public Napi::ObjectWrap { + public: + NonConstructorTest(const Napi::CallbackInfo& info) + : Napi::ObjectWrap(info) {} static Napi::Value NonConstructor(const Napi::CallbackInfo& info) { // If called with a "true" argument, throw an exeption to test the handling. - if(!info[0].IsUndefined() && MaybeUnwrap(info[0].ToBoolean())) { + if (!info[0].IsUndefined() && MaybeUnwrap(info[0].ToBoolean())) { NAPI_THROW(Napi::Error::New(info.Env(), "an exception"), Napi::Value()); } // Otherwise, act as a factory. std::vector args; - for(size_t i = 0; i < info.Length(); i++) args.push_back(info[i]); + for (size_t i = 0; i < info.Length(); i++) args.push_back(info[i]); return MaybeUnwrap(GetConstructor(info.Env()).New(args)); } @@ -37,7 +36,8 @@ class NonConstructorTest : } }; -std::unordered_map NonConstructorTest::constructors = {}; +std::unordered_map + NonConstructorTest::constructors = {}; Napi::Object InitObjectWrapNonConstructor(Napi::Env env) { Napi::Object exports = Napi::Object::New(env); diff --git a/test/objectwrap_nonconstructor.js b/test/objectwrap_nonconstructor.js index c605a0ecf..110ee3827 100644 --- a/test/objectwrap_nonconstructor.js +++ b/test/objectwrap_nonconstructor.js @@ -3,7 +3,7 @@ const assert = require('assert'); const testUtil = require('./testUtil'); -function test(binding) { +function test (binding) { return testUtil.runGCTests([ 'objectwrap nonconstructor', () => {