diff --git a/native_mate/native_mate/arguments.h b/native_mate/native_mate/arguments.h index 108e73f38b0b..956c998d95ca 100644 --- a/native_mate/native_mate/arguments.h +++ b/native_mate/native_mate/arguments.h @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_ARGUMENTS_H_ -#define NATIVE_MATE_ARGUMENTS_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_ARGUMENTS_H_ +#define NATIVE_MATE_NATIVE_MATE_ARGUMENTS_H_ + +#include +#include #include "base/macros.h" #include "native_mate/converter.h" @@ -88,4 +91,4 @@ class Arguments { } // namespace mate -#endif // NATIVE_MATE_ARGUMENTS_H_ +#endif // NATIVE_MATE_NATIVE_MATE_ARGUMENTS_H_ diff --git a/native_mate/native_mate/constructor.h b/native_mate/native_mate/constructor.h index da5ffddb6d38..8152df152e88 100644 --- a/native_mate/native_mate/constructor.h +++ b/native_mate/native_mate/constructor.h @@ -6,8 +6,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_WRAPPABLE_CLASS_H_ -#define NATIVE_MATE_WRAPPABLE_CLASS_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_CONSTRUCTOR_H_ +#define NATIVE_MATE_NATIVE_MATE_CONSTRUCTOR_H_ #include "base/bind.h" #include "native_mate/function_template.h" @@ -150,4 +150,4 @@ void InvokeNew(const base::Callback& factory, } // namespace mate -#endif // NATIVE_MATE_WRAPPABLE_CLASS_H_ +#endif // NATIVE_MATE_NATIVE_MATE_CONSTRUCTOR_H_ diff --git a/native_mate/native_mate/converter.cc b/native_mate/native_mate/converter.cc index b146395b8ffc..464dc14cb6b3 100644 --- a/native_mate/native_mate/converter.cc +++ b/native_mate/native_mate/converter.cc @@ -6,29 +6,12 @@ #include "v8/include/v8.h" -using v8::Array; -using v8::Boolean; -using v8::External; -using v8::Function; -using v8::Int32; -using v8::Integer; -using v8::Isolate; -using v8::Local; -using v8::Maybe; -using v8::MaybeLocal; -using v8::Number; -using v8::Object; -using v8::Promise; -using v8::String; -using v8::Uint32; -using v8::Value; - namespace mate { namespace { template -bool FromMaybe(Maybe maybe, U* out) { +bool FromMaybe(v8::Maybe maybe, U* out) { if (maybe.IsNothing()) return false; *out = static_cast(maybe.FromJust()); @@ -37,64 +20,71 @@ bool FromMaybe(Maybe maybe, U* out) { } // namespace -Local Converter::ToV8(Isolate* isolate, bool val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, bool val) { return v8::Boolean::New(isolate, val); } -bool Converter::FromV8(Isolate* isolate, Local val, bool* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + bool* out) { if (!val->IsBoolean()) return false; - *out = val.As()->Value(); + *out = val.As()->Value(); return true; } #if !defined(OS_LINUX) && !defined(OS_FREEBSD) -Local Converter::ToV8(Isolate* isolate, - unsigned long val) { +v8::Local Converter::ToV8( // NOLINT(runtime/int) + v8::Isolate* isolate, + unsigned long val) { // NOLINT(runtime/int) return v8::Integer::New(isolate, val); } -bool Converter::FromV8(Isolate* isolate, - Local val, - unsigned long* out) { +bool Converter::FromV8( // NOLINT(runtime/int) + v8::Isolate* isolate, + v8::Local val, + unsigned long* out) { // NOLINT(runtime/int) if (!val->IsNumber()) return false; return FromMaybe(val->IntegerValue(isolate->GetCurrentContext()), out); } #endif -Local Converter::ToV8(Isolate* isolate, int32_t val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, + int32_t val) { return v8::Integer::New(isolate, val); } -bool Converter::FromV8(Isolate* isolate, - Local val, +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, int32_t* out) { if (!val->IsInt32()) return false; - *out = val.As()->Value(); + *out = val.As()->Value(); return true; } -Local Converter::ToV8(Isolate* isolate, uint32_t val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, + uint32_t val) { return v8::Integer::NewFromUnsigned(isolate, val); } -bool Converter::FromV8(Isolate* isolate, - Local val, +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, uint32_t* out) { if (!val->IsUint32()) return false; - *out = val.As()->Value(); + *out = val.As()->Value(); return true; } -Local Converter::ToV8(Isolate* isolate, int64_t val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, + int64_t val) { return v8::Number::New(isolate, static_cast(val)); } -bool Converter::FromV8(Isolate* isolate, - Local val, +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, int64_t* out) { if (!val->IsNumber()) return false; @@ -103,154 +93,168 @@ bool Converter::FromV8(Isolate* isolate, return FromMaybe(val->IntegerValue(isolate->GetCurrentContext()), out); } -Local Converter::ToV8(Isolate* isolate, uint64_t val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, + uint64_t val) { return v8::Number::New(isolate, static_cast(val)); } -bool Converter::FromV8(Isolate* isolate, - Local val, +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, uint64_t* out) { if (!val->IsNumber()) return false; return FromMaybe(val->IntegerValue(isolate->GetCurrentContext()), out); } -Local Converter::ToV8(Isolate* isolate, float val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, float val) { return v8::Number::New(isolate, val); } -bool Converter::FromV8(Isolate* isolate, Local val, float* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + float* out) { if (!val->IsNumber()) return false; - *out = static_cast(val.As()->Value()); + *out = static_cast(val.As()->Value()); return true; } -Local Converter::ToV8(Isolate* isolate, double val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, double val) { return v8::Number::New(isolate, val); } -bool Converter::FromV8(Isolate* isolate, - Local val, +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, double* out) { if (!val->IsNumber()) return false; - *out = val.As()->Value(); + *out = val.As()->Value(); return true; } -Local Converter::ToV8(Isolate* isolate, const char* val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, + const char* val) { return v8::String::NewFromUtf8(isolate, val, v8::NewStringType::kNormal) .ToLocalChecked(); } -Local Converter::ToV8(Isolate* isolate, - const base::StringPiece& val) { +v8::Local Converter::ToV8( + v8::Isolate* isolate, + const base::StringPiece& val) { return v8::String::NewFromUtf8(isolate, val.data(), v8::NewStringType::kNormal, static_cast(val.length())) .ToLocalChecked(); } -Local Converter::ToV8(Isolate* isolate, - const std::string& val) { +v8::Local Converter::ToV8(v8::Isolate* isolate, + const std::string& val) { return Converter::ToV8(isolate, val); } -bool Converter::FromV8(Isolate* isolate, - Local val, +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, std::string* out) { if (!val->IsString()) return false; - Local str = Local::Cast(val); + v8::Local str = v8::Local::Cast(val); int length = str->Utf8Length(isolate); out->resize(length); str->WriteUtf8(isolate, &(*out)[0], length, NULL, - String::NO_NULL_TERMINATION); + v8::String::NO_NULL_TERMINATION); return true; } -Local Converter>::ToV8(Isolate* isolate, - Local val) { +v8::Local Converter>::ToV8( + v8::Isolate* isolate, + v8::Local val) { return val; } -bool Converter>::FromV8(Isolate* isolate, - Local val, - Local* out) { +bool Converter>::FromV8(v8::Isolate* isolate, + v8::Local val, + v8::Local* out) { if (!val->IsFunction()) return false; - *out = Local::Cast(val); + *out = v8::Local::Cast(val); return true; } -Local Converter>::ToV8(Isolate* isolate, - Local val) { +v8::Local Converter>::ToV8( + v8::Isolate* isolate, + v8::Local val) { return val; } -bool Converter>::FromV8(Isolate* isolate, - Local val, - Local* out) { +bool Converter>::FromV8(v8::Isolate* isolate, + v8::Local val, + v8::Local* out) { if (!val->IsObject()) return false; - *out = Local::Cast(val); + *out = v8::Local::Cast(val); return true; } -Local Converter>::ToV8(Isolate* isolate, - Local val) { +v8::Local Converter>::ToV8( + v8::Isolate* isolate, + v8::Local val) { return val; } -bool Converter>::FromV8(Isolate* isolate, - Local val, - Local* out) { +bool Converter>::FromV8(v8::Isolate* isolate, + v8::Local val, + v8::Local* out) { if (!val->IsString()) return false; - *out = Local::Cast(val); + *out = v8::Local::Cast(val); return true; } -Local Converter>::ToV8(Isolate* isolate, - Local val) { +v8::Local Converter>::ToV8( + v8::Isolate* isolate, + v8::Local val) { return val; } -bool Converter>::FromV8(Isolate* isolate, - v8::Local val, - Local* out) { +bool Converter>::FromV8(v8::Isolate* isolate, + v8::Local val, + v8::Local* out) { if (!val->IsExternal()) return false; - *out = Local::Cast(val); + *out = v8::Local::Cast(val); return true; } -Local Converter>::ToV8(Isolate* isolate, Local val) { +v8::Local Converter>::ToV8( + v8::Isolate* isolate, + v8::Local val) { return val; } -bool Converter>::FromV8(Isolate* isolate, - v8::Local val, - Local* out) { +bool Converter>::FromV8(v8::Isolate* isolate, + v8::Local val, + v8::Local* out) { if (!val->IsArray()) return false; - *out = Local::Cast(val); + *out = v8::Local::Cast(val); return true; } -Local Converter>::ToV8(Isolate* isolate, Local val) { +v8::Local Converter>::ToV8( + v8::Isolate* isolate, + v8::Local val) { return val; } -Local Converter>::ToV8(Isolate* isolate, - Local val) { +v8::Local Converter>::ToV8( + v8::Isolate* isolate, + v8::Local val) { return val; } -bool Converter>::FromV8(Isolate* isolate, - Local val, - Local* out) { +bool Converter>::FromV8(v8::Isolate* isolate, + v8::Local val, + v8::Local* out) { *out = val; return true; } diff --git a/native_mate/native_mate/converter.h b/native_mate/native_mate/converter.h index 55ebbe2104dc..ac9167eade5a 100644 --- a/native_mate/native_mate/converter.h +++ b/native_mate/native_mate/converter.h @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_CONVERTER_H_ -#define NATIVE_MATE_CONVERTER_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_CONVERTER_H_ +#define NATIVE_MATE_NATIVE_MATE_CONVERTER_H_ #include #include #include #include +#include #include #include "base/strings/string_piece.h" @@ -56,11 +57,12 @@ struct Converter { #if !defined(OS_LINUX) && !defined(OS_FREEBSD) template <> -struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, unsigned long val); +struct Converter { // NOLINT(runtime/int) + static v8::Local ToV8(v8::Isolate* isolate, + unsigned long val); // NOLINT(runtime/int) static bool FromV8(v8::Isolate* isolate, v8::Local val, - unsigned long* out); + unsigned long* out); // NOLINT(runtime/int) }; #endif @@ -347,4 +349,4 @@ inline v8::Local StringToV8(v8::Isolate* isolate, } // namespace mate -#endif // NATIVE_MATE_CONVERTER_H_ +#endif // NATIVE_MATE_NATIVE_MATE_CONVERTER_H_ diff --git a/native_mate/native_mate/dictionary.h b/native_mate/native_mate/dictionary.h index 39cc26efa0b9..8e2969ba860e 100644 --- a/native_mate/native_mate/dictionary.h +++ b/native_mate/native_mate/dictionary.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_DICTIONARY_H_ -#define NATIVE_MATE_DICTIONARY_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_DICTIONARY_H_ +#define NATIVE_MATE_NATIVE_MATE_DICTIONARY_H_ #include "native_mate/converter.h" #include "native_mate/object_template_builder.h" @@ -141,4 +141,4 @@ struct Converter { } // namespace mate -#endif // NATIVE_MATE_DICTIONARY_H_ +#endif // NATIVE_MATE_NATIVE_MATE_DICTIONARY_H_ diff --git a/native_mate/native_mate/function_template.h b/native_mate/native_mate/function_template.h index 045dc14fb518..f557ee55ab0b 100644 --- a/native_mate/native_mate/function_template.h +++ b/native_mate/native_mate/function_template.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_FUNCTION_TEMPLATE_H_ -#define NATIVE_MATE_FUNCTION_TEMPLATE_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_FUNCTION_TEMPLATE_H_ +#define NATIVE_MATE_NATIVE_MATE_FUNCTION_TEMPLATE_H_ #include "base/callback.h" #include "base/logging.h" @@ -285,4 +285,4 @@ void CreateFunctionHandler(v8::Isolate* isolate, } // namespace mate -#endif // NATIVE_MATE_FUNCTION_TEMPLATE_H_ +#endif // NATIVE_MATE_NATIVE_MATE_FUNCTION_TEMPLATE_H_ diff --git a/native_mate/native_mate/handle.h b/native_mate/native_mate/handle.h index 10bd6a32a793..5ab8556285b8 100644 --- a/native_mate/native_mate/handle.h +++ b/native_mate/native_mate/handle.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_HANDLE_H_ -#define NATIVE_MATE_HANDLE_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_HANDLE_H_ +#define NATIVE_MATE_NATIVE_MATE_HANDLE_H_ #include "native_mate/converter.h" @@ -69,4 +69,4 @@ mate::Handle CreateHandle(v8::Isolate* isolate, T* object) { } // namespace mate -#endif // NATIVE_MATE_HANDLE_H_ +#endif // NATIVE_MATE_NATIVE_MATE_HANDLE_H_ diff --git a/native_mate/native_mate/object_template_builder.h b/native_mate/native_mate/object_template_builder.h index 88ce1d28c646..1f502c02d7ee 100644 --- a/native_mate/native_mate/object_template_builder.h +++ b/native_mate/native_mate/object_template_builder.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_OBJECT_TEMPLATE_BUILDER_H_ -#define NATIVE_MATE_OBJECT_TEMPLATE_BUILDER_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_OBJECT_TEMPLATE_BUILDER_H_ +#define NATIVE_MATE_NATIVE_MATE_OBJECT_TEMPLATE_BUILDER_H_ #include "base/bind.h" #include "base/callback.h" @@ -14,8 +14,6 @@ namespace mate { -namespace { - // Base template - used only for non-member function pointers. Other types // either go to one of the below specializations, or go here and fail to compile // because of base::Bind(). @@ -62,8 +60,6 @@ struct CallbackTraits> { } }; -} // namespace - // ObjectTemplateBuilder provides a handy interface to creating // v8::ObjectTemplate instances with various sorts of properties. class ObjectTemplateBuilder { @@ -124,4 +120,4 @@ class ObjectTemplateBuilder { } // namespace mate -#endif // NATIVE_MATE_OBJECT_TEMPLATE_BUILDER_H_ +#endif // NATIVE_MATE_NATIVE_MATE_OBJECT_TEMPLATE_BUILDER_H_ diff --git a/native_mate/native_mate/persistent_dictionary.h b/native_mate/native_mate/persistent_dictionary.h index 7a83916f1505..d30f6707c73f 100644 --- a/native_mate/native_mate/persistent_dictionary.h +++ b/native_mate/native_mate/persistent_dictionary.h @@ -2,8 +2,8 @@ // Use of this source code is governed by MIT license that can be found in the // LICENSE file. -#ifndef NATIVE_MATE_PERSISTENT_DICTIONARY_H_ -#define NATIVE_MATE_PERSISTENT_DICTIONARY_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_PERSISTENT_DICTIONARY_H_ +#define NATIVE_MATE_NATIVE_MATE_PERSISTENT_DICTIONARY_H_ #include "native_mate/dictionary.h" #include "native_mate/scoped_persistent.h" @@ -34,4 +34,4 @@ struct Converter { } // namespace mate -#endif // NATIVE_MATE_PERSISTENT_DICTIONARY_H_ +#endif // NATIVE_MATE_NATIVE_MATE_PERSISTENT_DICTIONARY_H_ diff --git a/native_mate/native_mate/promise.h b/native_mate/native_mate/promise.h index a236eee63126..82fc47006f19 100644 --- a/native_mate/native_mate/promise.h +++ b/native_mate/native_mate/promise.h @@ -2,8 +2,10 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef NATIVE_MATE_PROMISE_H_ -#define NATIVE_MATE_PROMISE_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_PROMISE_H_ +#define NATIVE_MATE_NATIVE_MATE_PROMISE_H_ + +#include #include "native_mate/converter.h" @@ -12,7 +14,7 @@ namespace mate { class Promise { public: Promise(); - Promise(v8::Isolate* isolate); + explicit Promise(v8::Isolate* isolate); virtual ~Promise(); static Promise Create(v8::Isolate* isolate); @@ -53,4 +55,4 @@ struct Converter { } // namespace mate -#endif // NATIVE_MATE_PROMISE_H_ +#endif // NATIVE_MATE_NATIVE_MATE_PROMISE_H_ diff --git a/native_mate/native_mate/scoped_persistent.h b/native_mate/native_mate/scoped_persistent.h index 0d1273f15447..2b21fc7afb65 100644 --- a/native_mate/native_mate/scoped_persistent.h +++ b/native_mate/native_mate/scoped_persistent.h @@ -2,8 +2,8 @@ // Use of this source code is governed by MIT license that can be found in the // LICENSE file. -#ifndef NATIVE_MATE_SCOPED_PERSISTENT_H_ -#define NATIVE_MATE_SCOPED_PERSISTENT_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_SCOPED_PERSISTENT_H_ +#define NATIVE_MATE_NATIVE_MATE_SCOPED_PERSISTENT_H_ #include "base/memory/ref_counted.h" #include "native_mate/converter.h" @@ -99,4 +99,4 @@ struct Converter> { } // namespace mate -#endif // NATIVE_MATE_SCOPED_PERSISTENT_H_ +#endif // NATIVE_MATE_NATIVE_MATE_SCOPED_PERSISTENT_H_ diff --git a/native_mate/native_mate/wrappable.h b/native_mate/native_mate/wrappable.h index faba6f332e4a..2051ee3b5c9d 100644 --- a/native_mate/native_mate/wrappable.h +++ b/native_mate/native_mate/wrappable.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. -#ifndef NATIVE_MATE_WRAPPABLE_H_ -#define NATIVE_MATE_WRAPPABLE_H_ +#ifndef NATIVE_MATE_NATIVE_MATE_WRAPPABLE_H_ +#define NATIVE_MATE_NATIVE_MATE_WRAPPABLE_H_ #include "base/bind.h" #include "gin/per_isolate_data.h" @@ -97,4 +97,4 @@ struct Converter filename.endsWith('.cc') || filename.endsWith('.h'), run: (opts, filenames) => { if (opts.fix) {