From 845046a7ac2ffa3de2b3bd90eda1007d64e53b70 Mon Sep 17 00:00:00 2001 From: pollyzhang Date: Thu, 3 Jun 2021 20:20:05 +0800 Subject: [PATCH] fix(core): fix codecc warning --- android/sdk/src/main/jni/include/jni/uri.h | 6 +- .../src/main/jni/include/loader/adr_loader.h | 4 +- android/sdk/src/main/jni/src/bridge/entry.cc | 2 +- android/sdk/src/main/jni/src/jni/uri.cc | 1 + .../sdk/src/main/jni/src/loader/adr_loader.cc | 23 ++- core/include/core/base/file.h | 4 +- core/include/core/base/js_value_wrapper.h | 16 +- core/include/core/base/string_view_utils.h | 188 ++++++++++-------- core/include/core/modules/console_module.h | 1 - core/include/core/modules/contextify_module.h | 1 + core/include/core/modules/module_register.h | 1 + core/include/core/napi/js_native_api_types.h | 16 +- .../include/core/napi/jsc/js_native_api_jsc.h | 36 ++-- core/include/core/napi/v8/js_native_api_v8.h | 2 +- core/include/core/scope.h | 8 +- core/src/modules/console_module.cc | 5 +- core/src/modules/contextify_module.cc | 145 +++++++------- core/src/modules/timer_module.cc | 3 + core/src/napi/jsc/js_native_api_jsc.cc | 2 + core/src/napi/jsc/js_native_api_value_jsc.cc | 60 ++++-- core/src/napi/v8/js_native_api_v8.cc | 25 +-- core/src/scope.cc | 15 +- .../third_party/base/include/base/log_level.h | 9 - .../base/include/base/unicode_string_view.h | 10 +- 24 files changed, 306 insertions(+), 277 deletions(-) diff --git a/android/sdk/src/main/jni/include/jni/uri.h b/android/sdk/src/main/jni/include/jni/uri.h index d82bb40f4..77db1fa02 100644 --- a/android/sdk/src/main/jni/include/jni/uri.h +++ b/android/sdk/src/main/jni/include/jni/uri.h @@ -28,12 +28,10 @@ #include "base/unicode_string_view.h" -namespace { - using unicode_string_view = tdf::base::unicode_string_view; -} - class Uri { public: + using unicode_string_view = tdf::base::unicode_string_view; + explicit Uri(const unicode_string_view& uri); ~Uri(); unicode_string_view GetPath(); diff --git a/android/sdk/src/main/jni/include/loader/adr_loader.h b/android/sdk/src/main/jni/include/loader/adr_loader.h index 1791e6813..e70a07e9d 100644 --- a/android/sdk/src/main/jni/include/loader/adr_loader.h +++ b/android/sdk/src/main/jni/include/loader/adr_loader.h @@ -30,11 +30,11 @@ #include "jni/scoped_java_ref.h" template -bool ReadAsset(const unicode_string_view& path, +bool ReadAsset(const tdf::base::unicode_string_view& path, AAssetManager* aasset_manager, std::basic_string& bytes, bool is_auto_fill) { - unicode_string_view owner(""_u8s); + tdf::base::unicode_string_view owner(""_u8s); const char* asset_path = StringViewUtils::ToConstCharPointer(path, owner); std::string file_path = std::string(asset_path); if (file_path.length() > 0 && file_path[0] == '/') { diff --git a/android/sdk/src/main/jni/src/bridge/entry.cc b/android/sdk/src/main/jni/src/bridge/entry.cc index 8d8d79d7c..49f422e21 100644 --- a/android/sdk/src/main/jni/src/bridge/entry.cc +++ b/android/sdk/src/main/jni/src/bridge/entry.cc @@ -292,7 +292,7 @@ jboolean RunScriptFromUri(JNIEnv* j_env, TDF_BASE_DLOG(INFO) << "runScriptFromUri enter tast"; bool flag = RunScript(runtime, script_name, j_can_use_code_cache, code_cache_dir, uri, aasset_manager); - jlong value = flag == false ? 0 : 1; + jlong value = !flag ? 0 : 1; hippy::bridge::CallJavaMethod(save_object_->GetObj(), value); auto time_end = std::chrono::time_point_cast( diff --git a/android/sdk/src/main/jni/src/jni/uri.cc b/android/sdk/src/main/jni/src/jni/uri.cc index d829433c6..1625e8011 100644 --- a/android/sdk/src/main/jni/src/jni/uri.cc +++ b/android/sdk/src/main/jni/src/jni/uri.cc @@ -34,6 +34,7 @@ static jmethodID j_to_string_method_id; static jmethodID j_get_scheme_method_id; static jmethodID j_get_path_method_id; +using unicode_string_view = tdf::base::unicode_string_view; using StringViewUtils = hippy::base::StringViewUtils; bool Uri::Init() { diff --git a/android/sdk/src/main/jni/src/loader/adr_loader.cc b/android/sdk/src/main/jni/src/loader/adr_loader.cc index 94e14d375..7f0838725 100644 --- a/android/sdk/src/main/jni/src/loader/adr_loader.cc +++ b/android/sdk/src/main/jni/src/loader/adr_loader.cc @@ -36,6 +36,7 @@ using unicode_string_view = tdf::base::unicode_string_view; using StringViewUtils = hippy::base::StringViewUtils; using HippyFile = hippy::base::HippyFile; using u8string = unicode_string_view::u8string; +using char8_t_ = unicode_string_view::char8_t_; static std::atomic global_request_id{0}; @@ -44,14 +45,16 @@ ADRLoader::ADRLoader() : aasset_manager_(nullptr) {} bool ADRLoader::RequestUntrustedContent(const unicode_string_view& uri, std::function cb) { std::shared_ptr uri_obj = std::make_shared(uri); - unicode_string_view uri_schema = uri_obj->GetScheme(); + unicode_string_view schema = uri_obj->GetScheme(); unicode_string_view path = uri_obj->GetPath(); - if (uri_schema == u"file") { + TDF_BASE_DCHECK(schema.encoding() == unicode_string_view::Encoding::Utf16); + std::u16string schema_str = schema.utf16_value(); + if (schema_str == u"file") { return LoadByFile(path, cb); - } else if (uri_schema == u"http" || uri_schema == u"https" || - uri_schema == u"debug") { + } else if (schema_str == u"http" || schema_str == u"https" || + schema_str == u"debug") { return LoadByHttp(uri, cb); - } else if (uri_schema == u"asset") { + } else if (schema_str == u"asset") { if (aasset_manager_) { return LoadByAsset(path, cb, false); } @@ -59,7 +62,7 @@ bool ADRLoader::RequestUntrustedContent(const unicode_string_view& uri, TDF_BASE_DLOG(ERROR) << "aasset_manager error, uri = " << uri; return false; } else { - TDF_BASE_DLOG(ERROR) << "schema error, schema = %s" << uri_schema; + TDF_BASE_DLOG(ERROR) << "schema error, schema = %s" << schema; return false; } } @@ -70,9 +73,11 @@ bool ADRLoader::RequestUntrustedContent(const unicode_string_view& uri, unicode_string_view schema = uri_obj->GetScheme(); unicode_string_view path = uri_obj->GetPath(); TDF_BASE_DCHECK(schema.encoding() == unicode_string_view::Encoding::Utf16); - if (schema.utf16_value() == u"file") { + std::u16string schema_str = schema.utf16_value(); + if (schema_str == u"file") { return HippyFile::ReadFile(path, content, false); - } else if (schema == u"http" || schema == u"https" || schema == u"debug") { + } else if (schema_str == u"http" || schema_str == u"https" || + schema_str == u"debug") { std::promise promise; std::future read_file_future = promise.get_future(); std::function cb = hippy::base::MakeCopyable( @@ -82,7 +87,7 @@ bool ADRLoader::RequestUntrustedContent(const unicode_string_view& uri, bool ret = LoadByHttp(uri, cb); content = read_file_future.get(); return ret; - } else if (schema == u"asset") { + } else if (schema_str == u"asset") { if (aasset_manager_) { return ReadAsset(path, aasset_manager_, content, false); } diff --git a/core/include/core/base/file.h b/core/include/core/base/file.h index ea2ace5b0..166083ae1 100644 --- a/core/include/core/base/file.h +++ b/core/include/core/base/file.h @@ -62,12 +62,12 @@ class HippyFile { std::streamsize size = file.gcount(); file.clear(); file.seekg(0, std::ios_base::beg); - long data_size = size; + std::streamsize data_size = size; if (is_auto_fill) { data_size += 1; } bytes.resize(data_size); - long read_size = + std::streamsize read_size = file.read(reinterpret_cast(&bytes[0]), size).gcount(); if (size != read_size) { TDF_BASE_DLOG(WARNING) diff --git a/core/include/core/base/js_value_wrapper.h b/core/include/core/base/js_value_wrapper.h index 3025c4112..5b6ca6166 100644 --- a/core/include/core/base/js_value_wrapper.h +++ b/core/include/core/base/js_value_wrapper.h @@ -31,24 +31,22 @@ class JSValueWrapper final { JSValueWrapper() {} JSValueWrapper(const JSValueWrapper& source); - JSValueWrapper(int32_t int32_value) + JSValueWrapper(int32_t int32_value) // NOLINT : type_(Type::Int32), int32_value_(int32_value) {} - JSValueWrapper(uint32_t uint32_value) + JSValueWrapper(uint32_t uint32_value) // NOLINT : type_(Type::Uint32), uint32_value_(uint32_value) {} - JSValueWrapper(double double_value) + JSValueWrapper(double double_value) // NOLINT : type_(Type::Double), double_value_(double_value) {} - JSValueWrapper(bool bool_value) + JSValueWrapper(bool bool_value) // NOLINT : type_(Type::Boolean), bool_value_(bool_value) {} explicit JSValueWrapper(std::string&& string_value) : type_(Type::String), string_value_(std::move(string_value)) {} explicit JSValueWrapper(const std::string& string_value) : type_(Type::String), string_value_(string_value) {} - JSValueWrapper(const char* string_value) - : type_(Type::String), - string_value_(std::string(string_value)) {} + JSValueWrapper(const char* string_value) // NOLINT + : type_(Type::String), string_value_(std::string(string_value)) {} JSValueWrapper(const char* string_value, size_t length) - : type_(Type::String), - string_value_(std::string(string_value, length)) {} + : type_(Type::String), string_value_(std::string(string_value, length)) {} explicit JSValueWrapper(JSObjectType&& object_value) : type_(Type::Object), object_value_(std::move(object_value)) {} explicit JSValueWrapper(const JSObjectType& object_value) diff --git a/core/include/core/base/string_view_utils.h b/core/include/core/base/string_view_utils.h index 964118399..4b41d8f06 100644 --- a/core/include/core/base/string_view_utils.h +++ b/core/include/core/base/string_view_utils.h @@ -32,18 +32,14 @@ #define EXTEND_LITERAL(ch) ch, ch, u##ch, U##ch -namespace { -using unicode_string_view = tdf::base::unicode_string_view; -using u8string = unicode_string_view::u8string; -using char8_t_ = unicode_string_view::char8_t_; -} // namespace - namespace hippy { namespace base { class StringViewUtils { public: using unicode_string_view = tdf::base::unicode_string_view; + using u8string = unicode_string_view::u8string; + using char8_t_ = unicode_string_view::char8_t_; inline static bool IsEmpty(const unicode_string_view& str_view) { unicode_string_view::Encoding encoding = str_view.encoding(); @@ -71,96 +67,123 @@ class StringViewUtils { return true; } - static unicode_string_view Convert( + static unicode_string_view CovertToLatin( const unicode_string_view& str_view, - unicode_string_view::Encoding dst_encoding) { - unicode_string_view::Encoding src_encoding = str_view.encoding(); - switch (dst_encoding) { + unicode_string_view::Encoding src_encoding) { + switch (src_encoding) { case unicode_string_view::Encoding::Latin1: { - switch (src_encoding) { - case unicode_string_view::Encoding::Latin1: { - return unicode_string_view(str_view.latin1_value()); - } - case unicode_string_view::Encoding::Utf16: - case unicode_string_view::Encoding::Utf32: - case unicode_string_view::Encoding::Utf8: - default: { - TDF_BASE_NOTREACHED(); - break; - } - } + return unicode_string_view(str_view.latin1_value()); + } + case unicode_string_view::Encoding::Utf16: + case unicode_string_view::Encoding::Utf32: + case unicode_string_view::Encoding::Utf8: + default: { + TDF_BASE_NOTREACHED(); + break; + } + } + return unicode_string_view(); + } + + static unicode_string_view CovertToUtf16( + const unicode_string_view& str_view, + unicode_string_view::Encoding src_encoding) { + switch (src_encoding) { + case unicode_string_view::Encoding::Latin1: { + return unicode_string_view( + CopyChars(str_view.latin1_value())); } case unicode_string_view::Encoding::Utf16: { - switch (src_encoding) { - case unicode_string_view::Encoding::Latin1: { - return unicode_string_view( - CopyChars(str_view.latin1_value())); - } - case unicode_string_view::Encoding::Utf16: { - return unicode_string_view(str_view.utf16_value()); - } - case unicode_string_view::Encoding::Utf32: { - return unicode_string_view(U32ToU16(str_view.utf32_value())); - } - case unicode_string_view::Encoding::Utf8: { - return unicode_string_view(U8ToU16(str_view.utf8_value())); - } - default: { - TDF_BASE_NOTREACHED(); - break; - } - } + return unicode_string_view(str_view.utf16_value()); } case unicode_string_view::Encoding::Utf32: { - switch (src_encoding) { - case unicode_string_view::Encoding::Latin1: { - return unicode_string_view( - CopyChars(str_view.latin1_value())); - } - case unicode_string_view::Encoding::Utf16: { - return unicode_string_view(U16ToU32(str_view.utf16_value())); - } - case unicode_string_view::Encoding::Utf32: { - return unicode_string_view(str_view.utf32_value()); - } - case unicode_string_view::Encoding::Utf8: { - return unicode_string_view(U8ToU32(str_view.utf8_value())); - } - default: { - TDF_BASE_NOTREACHED(); - break; - } - } + return unicode_string_view(U32ToU16(str_view.utf32_value())); } case unicode_string_view::Encoding::Utf8: { - switch (src_encoding) { - case unicode_string_view::Encoding::Latin1: { - const auto& str = str_view.latin1_value(); - auto ptr = reinterpret_cast( - str.c_str()); - return unicode_string_view(ptr, str.length()); - } - case unicode_string_view::Encoding::Utf16: { - return unicode_string_view(U16ToU8(str_view.utf16_value())); - } - case unicode_string_view::Encoding::Utf32: { - return unicode_string_view(U32ToU8(str_view.utf32_value())); - } - case unicode_string_view::Encoding::Utf8: { - return unicode_string_view(str_view.utf8_value()); - } - default: { - TDF_BASE_NOTREACHED(); - break; - } - } + return unicode_string_view(U8ToU16(str_view.utf8_value())); } default: { TDF_BASE_NOTREACHED(); break; } } + return unicode_string_view(); + } + static unicode_string_view CovertToUtf32( + const unicode_string_view& str_view, + unicode_string_view::Encoding src_encoding) { + switch (src_encoding) { + case unicode_string_view::Encoding::Latin1: { + return unicode_string_view( + CopyChars(str_view.latin1_value())); + } + case unicode_string_view::Encoding::Utf16: { + return unicode_string_view(U16ToU32(str_view.utf16_value())); + } + case unicode_string_view::Encoding::Utf32: { + return unicode_string_view(str_view.utf32_value()); + } + case unicode_string_view::Encoding::Utf8: { + return unicode_string_view(U8ToU32(str_view.utf8_value())); + } + default: { + TDF_BASE_NOTREACHED(); + break; + } + } + return unicode_string_view(); + } + + static unicode_string_view CovertToUtf8( + const unicode_string_view& str_view, + unicode_string_view::Encoding src_encoding) { + switch (src_encoding) { + case unicode_string_view::Encoding::Latin1: { + const auto& str = str_view.latin1_value(); + auto ptr = + reinterpret_cast(str.c_str()); + return unicode_string_view(ptr, str.length()); + } + case unicode_string_view::Encoding::Utf16: { + return unicode_string_view(U16ToU8(str_view.utf16_value())); + } + case unicode_string_view::Encoding::Utf32: { + return unicode_string_view(U32ToU8(str_view.utf32_value())); + } + case unicode_string_view::Encoding::Utf8: { + return unicode_string_view(str_view.utf8_value()); + } + default: { + TDF_BASE_NOTREACHED(); + break; + } + } + return unicode_string_view(); + } + + static unicode_string_view Convert( + const unicode_string_view& str_view, + unicode_string_view::Encoding dst_encoding) { + unicode_string_view::Encoding src_encoding = str_view.encoding(); + switch (dst_encoding) { + case unicode_string_view::Encoding::Latin1: { + return CovertToLatin(str_view, src_encoding); + } + case unicode_string_view::Encoding::Utf16: { + return CovertToUtf16(str_view, src_encoding); + } + case unicode_string_view::Encoding::Utf32: { + return CovertToUtf32(str_view, src_encoding); + } + case unicode_string_view::Encoding::Utf8: { + return CovertToUtf8(str_view, src_encoding); + } + default: { + TDF_BASE_NOTREACHED(); + break; + } + } return unicode_string_view(); } @@ -177,7 +200,8 @@ class StringViewUtils { inline static const char* ToConstCharPointer( const unicode_string_view& str_view, unicode_string_view& view_owner) { - TDF_BASE_DCHECK(view_owner.encoding() == unicode_string_view::Encoding::Utf8); + TDF_BASE_DCHECK(view_owner.encoding() == + unicode_string_view::Encoding::Utf8); unicode_string_view::Encoding encoding = str_view.encoding(); switch (encoding) { case unicode_string_view::Encoding::Latin1: { diff --git a/core/include/core/modules/console_module.h b/core/include/core/modules/console_module.h index 7e11434aa..e2e64aa2d 100644 --- a/core/include/core/modules/console_module.h +++ b/core/include/core/modules/console_module.h @@ -24,7 +24,6 @@ #include "core/modules/module_base.h" #include "core/napi/callback_info.h" -#include "core/napi/js_native_api_types.h" class Scope; diff --git a/core/include/core/modules/contextify_module.h b/core/include/core/modules/contextify_module.h index 3a46651c2..61555bfc2 100644 --- a/core/include/core/modules/contextify_module.h +++ b/core/include/core/modules/contextify_module.h @@ -22,6 +22,7 @@ #pragma once +#include "core/base/string_view_utils.h" #include "core/modules/module_base.h" #include "core/napi/callback_info.h" #include "core/napi/js_native_api_types.h" diff --git a/core/include/core/modules/module_register.h b/core/include/core/modules/module_register.h index 39072ed6d..7cad9a144 100644 --- a/core/include/core/modules/module_register.h +++ b/core/include/core/modules/module_register.h @@ -27,6 +27,7 @@ #include #include +#include "base/unicode_string_view.h" #include "core/base/macros.h" #include "core/modules/module_base.h" #include "core/napi/callback_info.h" diff --git a/core/include/core/napi/js_native_api_types.h b/core/include/core/napi/js_native_api_types.h index 0582a5340..2e4a32b5f 100644 --- a/core/include/core/napi/js_native_api_types.h +++ b/core/include/core/napi/js_native_api_types.h @@ -36,10 +36,6 @@ class Scope; namespace hippy { namespace napi { -namespace { -using JSValueWrapper = hippy::base::JSValueWrapper; -}; - static const char kErrorHandlerJSName[] = "ExceptionHandle.js"; static const char kHippyErrorHandlerName[] = "HippyExceptionHandler"; @@ -80,6 +76,7 @@ class CtxValue { class Ctx { public: + using JSValueWrapper = hippy::base::JSValueWrapper; using unicode_string_view = tdf::base::unicode_string_view; Ctx() {} @@ -167,10 +164,11 @@ class Ctx { virtual std::shared_ptr GetJsFn( const unicode_string_view& name) = 0; virtual bool ThrowExceptionToJS(std::shared_ptr exception) = 0; - + virtual std::shared_ptr ToJsValueWrapper( std::shared_ptr value) = 0; - virtual std::shared_ptr CreateCtxValue(std::shared_ptr wrapper) = 0; + virtual std::shared_ptr CreateCtxValue( + std::shared_ptr wrapper) = 0; }; class VM { @@ -183,9 +181,9 @@ class VM { class TryCatch { public: - TryCatch(bool enable = false, std::shared_ptr ctx = nullptr) - : enable_(enable), ctx_(ctx){}; - virtual ~TryCatch(){}; + explicit TryCatch(bool enable = false, std::shared_ptr ctx = nullptr) + : enable_(enable), ctx_(ctx) {} + virtual ~TryCatch() {} virtual void ReThrow() = 0; virtual bool HasCaught() = 0; virtual bool CanContinue() = 0; diff --git a/core/include/core/napi/jsc/js_native_api_jsc.h b/core/include/core/napi/jsc/js_native_api_jsc.h index 3a01e7a81..08a41161c 100644 --- a/core/include/core/napi/jsc/js_native_api_jsc.h +++ b/core/include/core/napi/jsc/js_native_api_jsc.h @@ -28,8 +28,8 @@ #include #include -#include "base/unicode_string_view.h" #include "base/logging.h" +#include "base/unicode_string_view.h" #include "core/base/macros.h" #include "core/napi/js_native_api_types.h" @@ -45,11 +45,6 @@ const char16_t kLengthStr[] = u"length"; const char16_t kMessageStr[] = u"message"; const char16_t kStackStr[] = u"stack"; -namespace { -using unicode_string_view = tdf::base::unicode_string_view; -using JSValueWrapper = hippy::base::JSValueWrapper; -}; - class JSCVM : public VM { public: JSCVM() { vm_ = JSContextGroupCreate(); } @@ -68,6 +63,9 @@ class JSCCtxValue; class JSCCtx : public Ctx { public: + using unicode_string_view = tdf::base::unicode_string_view; + using JSValueWrapper = hippy::base::JSValueWrapper; + explicit JSCCtx(JSContextGroupRef vm) { context_ = JSGlobalContextCreateInGroup(vm, nullptr); @@ -140,12 +138,9 @@ class JSCCtx : public Ctx { size_t argument_count = 0, const std::shared_ptr argumets[] = nullptr); - virtual bool GetValueNumber(std::shared_ptr value, - double* result); - virtual bool GetValueNumber(std::shared_ptr value, - int32_t* result); - virtual bool GetValueBoolean(std::shared_ptr value, - bool* result); + virtual bool GetValueNumber(std::shared_ptr value, double* result); + virtual bool GetValueNumber(std::shared_ptr value, int32_t* result); + virtual bool GetValueBoolean(std::shared_ptr value, bool* result); virtual bool GetValueString(std::shared_ptr value, unicode_string_view* result); virtual bool GetValueJson(std::shared_ptr value, @@ -168,8 +163,7 @@ class JSCCtx : public Ctx { // Function Helpers virtual bool IsFunction(std::shared_ptr value); - virtual unicode_string_view CopyFunctionName( - std::shared_ptr value); + virtual unicode_string_view CopyFunctionName(std::shared_ptr value); virtual std::shared_ptr RunScript( const unicode_string_view& data, @@ -177,13 +171,13 @@ class JSCCtx : public Ctx { bool is_use_code_cache = false, unicode_string_view* cache = nullptr, bool is_copy = true); - virtual std::shared_ptr GetJsFn( - const unicode_string_view& name); + virtual std::shared_ptr GetJsFn(const unicode_string_view& name); virtual bool ThrowExceptionToJS(std::shared_ptr exception); - + virtual std::shared_ptr ToJsValueWrapper( std::shared_ptr value); - virtual std::shared_ptr CreateCtxValue(std::shared_ptr wrapper); + virtual std::shared_ptr CreateCtxValue( + std::shared_ptr wrapper); unicode_string_view GetExceptionMsg(std::shared_ptr exception); JSStringRef CreateJSCString(const unicode_string_view& str_view); @@ -193,8 +187,10 @@ class JSCCtx : public Ctx { bool is_exception_handled_; }; -inline unicode_string_view ToStrView(JSStringRef str) { - return unicode_string_view(reinterpret_cast(JSStringGetCharactersPtr(str)), JSStringGetLength(str)); +inline tdf::base::unicode_string_view ToStrView(JSStringRef str) { + return tdf::base::unicode_string_view( + reinterpret_cast(JSStringGetCharactersPtr(str)), + JSStringGetLength(str)); } class JSCCtxValue : public CtxValue { diff --git a/core/include/core/napi/v8/js_native_api_v8.h b/core/include/core/napi/v8/js_native_api_v8.h index 40ae33efe..abe31497a 100644 --- a/core/include/core/napi/v8/js_native_api_v8.h +++ b/core/include/core/napi/v8/js_native_api_v8.h @@ -76,7 +76,7 @@ class V8TryCatch : public TryCatch { public: using unicode_string_view = tdf::base::unicode_string_view; - V8TryCatch(bool enable = false, std::shared_ptr ctx = nullptr); + explicit V8TryCatch(bool enable = false, std::shared_ptr ctx = nullptr); virtual ~V8TryCatch(); virtual void ReThrow(); diff --git a/core/include/core/scope.h b/core/include/core/scope.h index 40e455ba3..81639ea1b 100644 --- a/core/include/core/scope.h +++ b/core/include/core/scope.h @@ -48,7 +48,7 @@ class ScopeWrapper { class Scope { public: - using unicode_string_view = tdf::base::unicode_string_view; + using unicode_string_view = tdf::base::unicode_string_view; using RegisterMap = hippy::base::RegisterMap; using CtxValue = hippy::napi::CtxValue; using Ctx = hippy::napi::Ctx; @@ -70,8 +70,10 @@ class Scope { ModuleBase* GetModuleClass(const unicode_string_view& moduleName); void AddModuleClass(const unicode_string_view& name, std::unique_ptr module); - std::shared_ptr GetModuleValue(const unicode_string_view& moduleName); - void AddModuleValue(const unicode_string_view& name, std::shared_ptr value); + std::shared_ptr GetModuleValue( + const unicode_string_view& moduleName); + void AddModuleValue(const unicode_string_view& name, + std::shared_ptr value); void SaveFunctionData(std::unique_ptr data); diff --git a/core/src/modules/console_module.cc b/core/src/modules/console_module.cc index f6d7410e6..88e343400 100644 --- a/core/src/modules/console_module.cc +++ b/core/src/modules/console_module.cc @@ -22,16 +22,14 @@ #include "core/modules/console_module.h" -#include - #include #include "base/logging.h" +#include "core/base/string_view_utils.h" #include "core/modules/module_register.h" #include "core/napi/callback_info.h" #include "core/napi/js_native_api.h" #include "core/scope.h" -#include "core/base/string_view_utils.h" using unicode_string_view = tdf::base::unicode_string_view; using Ctx = hippy::napi::Ctx; @@ -41,7 +39,6 @@ REGISTER_MODULE(ConsoleModule, Log) namespace { -//to do 重载 replace 和 compare unicode_string_view EscapeMessage(const unicode_string_view& str_view) { std::string u8_str = StringViewUtils::ToU8StdStr(str_view); size_t len = u8_str.length(); diff --git a/core/src/modules/contextify_module.cc b/core/src/modules/contextify_module.cc index c3c3f33c7..98ad1736b 100644 --- a/core/src/modules/contextify_module.cc +++ b/core/src/modules/contextify_module.cc @@ -42,6 +42,7 @@ REGISTER_MODULE(ContextifyModule, RunInThisContext) REGISTER_MODULE(ContextifyModule, LoadUntrustedContent) using unicode_string_view = tdf::base::unicode_string_view; +using u8string = unicode_string_view::u8string; using Ctx = hippy::napi::Ctx; using CtxValue = hippy::napi::CtxValue; using CallbackInfo = hippy::napi::CallbackInfo; @@ -69,8 +70,8 @@ void ContextifyModule::RunInThisContext(const hippy::napi::CallbackInfo& info) { std::shared_ptr ret = context->RunScript(str_view, key, false, nullptr, false); if (try_catch->HasCaught()) { - TDF_BASE_DLOG(ERROR) << "GetNativeSourceCode error = " << - try_catch->GetExceptionMsg(); + TDF_BASE_DLOG(ERROR) << "GetNativeSourceCode error = " + << try_catch->GetExceptionMsg(); info.GetExceptionValue()->Set(try_catch->Exception()); } else { info.GetReturnValue()->Set(ret); @@ -116,81 +117,79 @@ void ContextifyModule::LoadUntrustedContent(const CallbackInfo& info) { std::weak_ptr weak_scope = scope; std::weak_ptr weak_function = function; - std::function cb = - [this, weak_scope, weak_function, encode, - uri](u8string code) { - std::shared_ptr scope = weak_scope.lock(); - if (!scope) { - return; - } + std::function cb = [this, weak_scope, weak_function, encode, + uri](u8string code) { + std::shared_ptr scope = weak_scope.lock(); + if (!scope) { + return; + } - unicode_string_view cur_dir; - unicode_string_view file_name; - size_t pos = StringViewUtils::FindLastOf(uri, '/', '/', u'/', U'/'); - if (pos != -1) { - cur_dir = StringViewUtils::SubStr(uri, 0, pos + 1); - size_t len = StringViewUtils::GetLength(uri); - file_name = StringViewUtils::SubStr(uri, pos + 1, len); + unicode_string_view cur_dir; + unicode_string_view file_name; + size_t pos = StringViewUtils::FindLastOf(uri, '/', '/', u'/', U'/'); + if (pos != -1) { + cur_dir = StringViewUtils::SubStr(uri, 0, pos + 1); + size_t len = StringViewUtils::GetLength(uri); + file_name = StringViewUtils::SubStr(uri, pos + 1, len); + } else { + file_name = uri; + } + + if (code.empty()) { + TDF_BASE_DLOG(WARNING) << "Load uri = " << uri << ", code empty"; + } else { + TDF_BASE_DLOG(INFO) << "Load uri = " << uri << ", len = " << code.length() + << ", encode = " << encode + << ", code = " << unicode_string_view(code); + } + std::shared_ptr js_task = + std::make_shared(); + js_task->callback = [this, weak_scope, weak_function, + move_code = std::move(code), cur_dir, file_name, + uri]() { + std::shared_ptr scope = weak_scope.lock(); + if (!scope) { + return; + } + + std::shared_ptr ctx = scope->GetContext(); + std::shared_ptr error; + if (!move_code.empty()) { + auto last_dir_str_obj = ctx->GetGlobalStrVar("__HIPPYCURDIR__"); + TDF_BASE_DLOG(INFO) << "__HIPPYCURDIR__ cur_dir = " << cur_dir; + ctx->SetGlobalStrVar("__HIPPYCURDIR__", cur_dir); + std::shared_ptr try_catch = + CreateTryCatchScope(true, scope->GetContext()); + try_catch->SetVerbose(true); + unicode_string_view view_code(std::move(move_code)); + scope->RunJS(view_code, file_name); + ctx->SetGlobalObjVar("__HIPPYCURDIR__", last_dir_str_obj); + unicode_string_view view_last_dir_str; + ctx->GetValueString(last_dir_str_obj, &view_last_dir_str); + TDF_BASE_DLOG(INFO) + << "restore __HIPPYCURDIR__ = " << view_last_dir_str; + if (try_catch->HasCaught()) { + error = try_catch->Exception(); + TDF_BASE_DLOG(ERROR) << "RequestUntrustedContent error = " + << try_catch->GetExceptionMsg(); } else { - file_name = uri; + error = ctx->CreateNull(); } + } else { + unicode_string_view err_msg = uri + " not found"; + error = ctx->CreateJsError(unicode_string_view(err_msg)); + } - if (code.empty()) { - TDF_BASE_DLOG(WARNING) << "Load uri = " << uri << ", code empty"; - } else { - TDF_BASE_DLOG(INFO) - << "Load uri = " << uri << ", len = " << code.length() - << ", encode = " << encode - << ", code = " << unicode_string_view(code); - } - std::shared_ptr js_task = - std::make_shared(); - js_task->callback = [this, weak_scope, weak_function, - move_code = std::move(code), cur_dir, file_name, - uri]() { - std::shared_ptr scope = weak_scope.lock(); - if (!scope) { - return; - } - - std::shared_ptr ctx = scope->GetContext(); - std::shared_ptr error; - if (!move_code.empty()) { - auto last_dir_str_obj = ctx->GetGlobalStrVar("__HIPPYCURDIR__"); - TDF_BASE_DLOG(INFO) << "__HIPPYCURDIR__ cur_dir = " << cur_dir; - ctx->SetGlobalStrVar("__HIPPYCURDIR__", cur_dir); - std::shared_ptr try_catch = - CreateTryCatchScope(true, scope->GetContext()); - try_catch->SetVerbose(true); - unicode_string_view view_code(std::move(move_code)); - scope->RunJS(view_code, file_name); - ctx->SetGlobalObjVar("__HIPPYCURDIR__", last_dir_str_obj); - unicode_string_view view_last_dir_str; - ctx->GetValueString(last_dir_str_obj, &view_last_dir_str); - TDF_BASE_DLOG(INFO) - << "restore __HIPPYCURDIR__ = " << view_last_dir_str; - if (try_catch->HasCaught()) { - error = try_catch->Exception(); - TDF_BASE_DLOG(ERROR) << "RequestUntrustedContent error = " - << try_catch->GetExceptionMsg(); - } else { - error = ctx->CreateNull(); - } - } else { - unicode_string_view err_msg = uri + " not found"; - error = ctx->CreateJsError(unicode_string_view(err_msg)); - } - - std::shared_ptr function = weak_function.lock(); - if (function) { - TDF_BASE_DLOG(INFO) << "run js cb"; - std::shared_ptr argv[] = {error}; - ctx->CallFunction(function, 1, argv); - RemoveCBFunc(uri); - } - }; - scope->GetTaskRunner()->PostTask(js_task); - }; + std::shared_ptr function = weak_function.lock(); + if (function) { + TDF_BASE_DLOG(INFO) << "run js cb"; + std::shared_ptr argv[] = {error}; + ctx->CallFunction(function, 1, argv); + RemoveCBFunc(uri); + } + }; + scope->GetTaskRunner()->PostTask(js_task); + }; loader->RequestUntrustedContent(uri, cb); info.GetReturnValue()->SetUndefined(); } diff --git a/core/src/modules/timer_module.cc b/core/src/modules/timer_module.cc index 246a0da30..04749eff9 100644 --- a/core/src/modules/timer_module.cc +++ b/core/src/modules/timer_module.cc @@ -26,6 +26,7 @@ #include "base/logging.h" #include "core/base/common.h" +#include "core/base/string_view_utils.h" #include "core/modules/module_register.h" #include "core/napi/callback_info.h" #include "core/task/javascript_task.h" @@ -38,10 +39,12 @@ REGISTER_MODULE(TimerModule, ClearInterval) namespace napi = ::hippy::napi; +using unicode_string_view = tdf::base::unicode_string_view; using Ctx = hippy::napi::Ctx; using CtxValue = hippy::napi::CtxValue; using RegisterFunction = hippy::base::RegisterFunction; using RegisterMap = hippy::base::RegisterMap; + TimerModule::TimerModule() {} TimerModule::~TimerModule() {} diff --git a/core/src/napi/jsc/js_native_api_jsc.cc b/core/src/napi/jsc/js_native_api_jsc.cc index 6d18ab70a..9437a1688 100644 --- a/core/src/napi/jsc/js_native_api_jsc.cc +++ b/core/src/napi/jsc/js_native_api_jsc.cc @@ -36,7 +36,9 @@ namespace hippy { namespace napi { +using unicode_string_view = tdf::base::unicode_string_view; using StringViewUtils = hippy::base::StringViewUtils; +using JSValueWrapper = hippy::base::JSValueWrapper; const char16_t kGlobalStr[] = u"global"; diff --git a/core/src/napi/jsc/js_native_api_value_jsc.cc b/core/src/napi/jsc/js_native_api_value_jsc.cc index b325994f9..2073bcadf 100644 --- a/core/src/napi/jsc/js_native_api_value_jsc.cc +++ b/core/src/napi/jsc/js_native_api_value_jsc.cc @@ -34,6 +34,7 @@ namespace hippy { namespace napi { +using unicode_string_view = tdf::base::unicode_string_view; using StringViewUtils = hippy::base::StringViewUtils; bool JSCCtx::GetValueNumber(std::shared_ptr value, double* result) { @@ -106,7 +107,9 @@ bool JSCCtx::GetValueString(std::shared_ptr value, SetException(std::make_shared(context_, exception)); return false; } - *result = unicode_string_view(reinterpret_cast(JSStringGetCharactersPtr(str_ref)), JSStringGetLength(str_ref)); + *result = unicode_string_view( + reinterpret_cast(JSStringGetCharactersPtr(str_ref)), + JSStringGetLength(str_ref)); return true; } @@ -136,8 +139,9 @@ uint32_t JSCCtx::GetArrayLength(std::shared_ptr value) { SetException(std::make_shared(context_, exception)); return 0; } - //to do - JSStringRef prop_name = JSStringCreateWithCharacters(reinterpret_cast(kLengthStr), arraysize(kLengthStr) - 1); + // to do + JSStringRef prop_name = JSStringCreateWithCharacters( + reinterpret_cast(kLengthStr), arraysize(kLengthStr) - 1); exception = nullptr; JSValueRef val = JSObjectGetProperty(context_, array, prop_name, &exception); if (exception) { @@ -169,7 +173,9 @@ bool JSCCtx::GetValueJson(std::shared_ptr value, SetException(std::make_shared(context_, exception)); return false; } - *result = unicode_string_view(reinterpret_cast(JSStringGetCharactersPtr(str_ref)), JSStringGetLength(str_ref)); + *result = unicode_string_view( + reinterpret_cast(JSStringGetCharactersPtr(str_ref)), + JSStringGetLength(str_ref)); JSStringRelease(str_ref); return true; } @@ -214,7 +220,8 @@ bool JSCCtx::IsFunction(std::shared_ptr value) { return JSObjectIsFunction(context_, object); } -unicode_string_view JSCCtx::CopyFunctionName(std::shared_ptr function) { +unicode_string_view JSCCtx::CopyFunctionName( + std::shared_ptr function) { TDF_BASE_NOTIMPLEMENTED(); return ""; } @@ -229,7 +236,8 @@ std::shared_ptr JSCCtx::CreateBoolean(bool b) { return std::make_shared(context_, value); } -std::shared_ptr JSCCtx::CreateString(const unicode_string_view& str_view) { +std::shared_ptr JSCCtx::CreateString( + const unicode_string_view& str_view) { JSStringRef str_ref = CreateJSCString(str_view); JSValueRef value = JSValueMakeString(context_, str_ref); JSStringRelease(str_ref); @@ -246,7 +254,8 @@ std::shared_ptr JSCCtx::CreateNull() { return std::make_shared(context_, value); } -std::shared_ptr JSCCtx::CreateObject(const unicode_string_view& json) { +std::shared_ptr JSCCtx::CreateObject( + const unicode_string_view& json) { JSStringRef str_ref = CreateJSCString(json); JSValueRef value = JSValueMakeFromJSONString(context_, str_ref); JSStringRelease(str_ref); @@ -276,7 +285,8 @@ std::shared_ptr JSCCtx::CreateArray( return std::make_shared(context_, value_ref); } -std::shared_ptr JSCCtx::CreateJsError(const unicode_string_view& msg) { +std::shared_ptr JSCCtx::CreateJsError( + const unicode_string_view& msg) { JSStringRef str_ref = CreateJSCString(msg); JSValueRef value = JSValueMakeString(context_, str_ref); JSStringRelease(str_ref); @@ -385,27 +395,28 @@ std::shared_ptr JSCCtx::CallFunction( return std::make_shared(context_, ret_value_ref); } -unicode_string_view JSCCtx::GetExceptionMsg(std::shared_ptr exception) { +unicode_string_view JSCCtx::GetExceptionMsg( + std::shared_ptr exception) { if (!exception) { return unicode_string_view(); } - - - std::shared_ptr msg_obj = CopyNamedProperty(exception, unicode_string_view(kMessageStr, arraysize(kMessageStr) - 1)); + + std::shared_ptr msg_obj = CopyNamedProperty( + exception, unicode_string_view(kMessageStr, arraysize(kMessageStr) - 1)); unicode_string_view msg_view; GetValueString(msg_obj, &msg_view); std::u16string u16_msg; if (!StringViewUtils::IsEmpty(msg_view)) { u16_msg = msg_view.utf16_value(); } - std::shared_ptr stack_obj = CopyNamedProperty(exception, unicode_string_view(kStackStr, arraysize(kStackStr) - 1)); + std::shared_ptr stack_obj = CopyNamedProperty( + exception, unicode_string_view(kStackStr, arraysize(kStackStr) - 1)); unicode_string_view stack_view; GetValueString(stack_obj, &stack_view); std::u16string u16_stack; if (!StringViewUtils::IsEmpty(stack_view)) { u16_stack = stack_view.utf16_value(); } - // to do std::u16string str = u"message: " + u16_msg + u", stack: " + u16_stack; unicode_string_view ret(str.c_str(), str.length()); TDF_BASE_DLOG(ERROR) << "GetExceptionMsg msg = " << ret; @@ -423,10 +434,10 @@ bool JSCCtx::ThrowExceptionToJS(std::shared_ptr exception) { const auto& source_code = hippy::GetNativeSourceCode(kErrorHandlerJSName); TDF_BASE_DCHECK(source_code.data_ && source_code.length_); unicode_string_view content(source_code.data_, source_code.length_); - exception_handler = - RunScript(content, kErrorHandlerJSName); + exception_handler = RunScript(content, kErrorHandlerJSName); bool is_func = IsFunction(exception_handler); - TDF_BASE_CHECK(is_func) << "HandleUncaughtJsError ExceptionHandle.js don't return function!!!"; + TDF_BASE_CHECK(is_func) + << "HandleUncaughtJsError ExceptionHandle.js don't return function!!!"; SetGlobalObjVar(kHippyErrorHandlerName, exception_handler, PropertyAttribute::ReadOnly); } @@ -452,18 +463,25 @@ JSStringRef JSCCtx::CreateJSCString(const unicode_string_view& str_view) { break; } case unicode_string_view::Encoding::Utf8: { - std::string aaa(reinterpret_cast(str_view.utf8_value().c_str()), str_view.utf8_value().length()); + std::string aaa( + reinterpret_cast(str_view.utf8_value().c_str()), + str_view.utf8_value().length()); ret = JSStringCreateWithUTF8CString(aaa.c_str()); break; } case unicode_string_view::Encoding::Utf16: { std::u16string u16_str = str_view.utf16_value(); - ret = JSStringCreateWithCharacters(reinterpret_cast(u16_str.c_str()), u16_str.length()); + ret = JSStringCreateWithCharacters( + reinterpret_cast(u16_str.c_str()), u16_str.length()); break; } case unicode_string_view::Encoding::Utf32: { - std::u16string u16_str = StringViewUtils::Convert(str_view, unicode_string_view::Encoding::Utf16).utf16_value(); - ret = JSStringCreateWithCharacters(reinterpret_cast(u16_str.c_str()), u16_str.length()); + std::u16string u16_str = + StringViewUtils::Convert(str_view, + unicode_string_view::Encoding::Utf16) + .utf16_value(); + ret = JSStringCreateWithCharacters( + reinterpret_cast(u16_str.c_str()), u16_str.length()); break; } default: diff --git a/core/src/napi/v8/js_native_api_v8.cc b/core/src/napi/v8/js_native_api_v8.cc index b2e585da5..d85b1dad7 100644 --- a/core/src/napi/v8/js_native_api_v8.cc +++ b/core/src/napi/v8/js_native_api_v8.cc @@ -481,7 +481,6 @@ unicode_string_view V8Ctx::GetStackInfo(v8::Local message) { return ""; } - // to do std::basic_stringstream stack_stream; int len = trace->GetFrameCount(); for (int i = 0; i < len; ++i) { @@ -610,19 +609,19 @@ std::shared_ptr V8Ctx::GetGlobalObjVar( std::shared_ptr V8Ctx::GetProperty( const std::shared_ptr object, const unicode_string_view& name) { - TDF_BASE_DLOG(INFO)<< "GetGlobalStrVar name =" << name; + TDF_BASE_DLOG(INFO) << "GetGlobalStrVar name =" << name; std::shared_ptr ctx_value = - std::static_pointer_cast(object); + std::static_pointer_cast(object); v8::HandleScope handle_scope(isolate_); v8::Local context = context_persistent_.Get(isolate_); v8::Context::Scope context_scope(context); - const v8::Global& persistent_value = - ctx_value->global_value_; + const v8::Global& persistent_value = ctx_value->global_value_; v8::Local str = CreateV8String(name); v8::Local handle_value = v8::Local::New(isolate_, persistent_value); - v8::Local value = - v8::Local::Cast(handle_value)->Get(context, str).ToLocalChecked(); + v8::Local value = v8::Local::Cast(handle_value) + ->Get(context, str) + .ToLocalChecked(); return std::make_shared(isolate_, value); } @@ -780,8 +779,7 @@ std::shared_ptr V8Ctx::InternalRunScript( v8::ScriptCompiler::CachedData* cached_data = new v8::ScriptCompiler::CachedData( str.c_str(), str.length(), - v8::ScriptCompiler::CachedData:: - BufferNotOwned); + v8::ScriptCompiler::CachedData::BufferNotOwned); v8::ScriptCompiler::Source script_source(source, origin, cached_data); script = v8::ScriptCompiler::Compile( context, &script_source, v8::ScriptCompiler::kConsumeCodeCache); @@ -839,18 +837,17 @@ std::shared_ptr V8Ctx::GetJsFn(const unicode_string_view& name) { } bool V8Ctx::ThrowExceptionToJS(std::shared_ptr exception) { + unicode_string_view error_handle_name(kHippyErrorHandlerName); std::shared_ptr exception_handler = - GetGlobalObjVar(kHippyErrorHandlerName); + GetGlobalObjVar(error_handle_name); if (!IsFunction(exception_handler)) { const auto& source_code = hippy::GetNativeSourceCode(kErrorHandlerJSName); TDF_BASE_DCHECK(source_code.data_ && source_code.length_); unicode_string_view str_view(source_code.data_, source_code.length_); exception_handler = - RunScript(str_view, kErrorHandlerJSName, false, nullptr, false); - // bool is_func = IsFunction(exception_handler); - // TDF_BASE_DCHECK(is_func); - SetGlobalObjVar(kHippyErrorHandlerName, exception_handler, + RunScript(str_view, error_handle_name, false, nullptr, false); + SetGlobalObjVar(error_handle_name, exception_handler, PropertyAttribute::ReadOnly); } diff --git a/core/src/scope.cc b/core/src/scope.cc index 9eddaf2bf..dc289f8fb 100644 --- a/core/src/scope.cc +++ b/core/src/scope.cc @@ -44,7 +44,6 @@ using BindingData = hippy::napi::BindingData; using CtxValue = hippy::napi::CtxValue; using TryCatch = hippy::napi::TryCatch; - const char kdeallocFuncName[] = "HippyDealloc"; const char kHippyBootstrapJSName[] = "bootstrap.js"; @@ -126,14 +125,12 @@ void Scope::Initialized() { auto source_code = hippy::GetNativeSourceCode(kHippyBootstrapJSName); TDF_BASE_DCHECK(source_code.data_ && source_code.length_); - unicode_string_view str_view(source_code.data_, source_code.length_); - std::shared_ptr function = - context_->RunScript(str_view, kHippyBootstrapJSName, false, nullptr, true); - //to do + unicode_string_view str_view(source_code.data_, source_code.length_); + std::shared_ptr function = context_->RunScript( + str_view, kHippyBootstrapJSName, false, nullptr, true); bool is_func = context_->IsFunction(function); - TDF_BASE_CHECK(is_func) - << "bootstrap return not function, register fail!!!"; + TDF_BASE_CHECK(is_func) << "bootstrap return not function, register fail!!!"; if (!is_func) { TDF_BASE_DLOG(ERROR) << "bootstrap return not function, js = " << str_view << ", len = " << source_code.length_; @@ -182,7 +179,9 @@ void Scope::SaveFunctionData(std::unique_ptr data) { function_data_.push_back(std::move(data)); } -void Scope::RunJS(const unicode_string_view& data, const unicode_string_view& name, bool is_copy) { +void Scope::RunJS(const unicode_string_view& data, + const unicode_string_view& name, + bool is_copy) { std::weak_ptr weak_context = context_; JavaScriptTask::Function callback = [data, name, is_copy, weak_context] { std::shared_ptr context = weak_context.lock(); diff --git a/core/third_party/base/include/base/log_level.h b/core/third_party/base/include/base/log_level.h index d2f99a223..eb5a3e360 100644 --- a/core/third_party/base/include/base/log_level.h +++ b/core/third_party/base/include/base/log_level.h @@ -5,15 +5,6 @@ namespace tdf { namespace base { -// typedef int LogSeverity; - -// Default log levels. Negative values can be used for verbose log levels. -//constexpr LogSeverity TDF_LOG_INFO = 0; -//constexpr LogSeverity TDF_LOG_WARNING = 1; -//constexpr LogSeverity TDF_LOG_ERROR = 2; -//constexpr LogSeverity TDF_LOG_FATAL = 3; -//constexpr LogSeverity TDF_LOG_NUM_SEVERITIES = 4; - enum LogSeverity { TDF_LOG_DEBUG, TDF_LOG_INFO = 0, diff --git a/core/third_party/base/include/base/unicode_string_view.h b/core/third_party/base/include/base/unicode_string_view.h index 1de42d854..21994aaa3 100644 --- a/core/third_party/base/include/base/unicode_string_view.h +++ b/core/third_party/base/include/base/unicode_string_view.h @@ -36,9 +36,9 @@ class unicode_string_view final { return unicode_string_view(reinterpret_cast(utf8_string)); } unicode_string_view() {} - unicode_string_view(const unicode_string_view& source); + unicode_string_view(const unicode_string_view& source); // NOLINT #pragma region Latin - 1 - unicode_string_view(const char* latin1_string) + unicode_string_view(const char* latin1_string) // NOLINT : encoding_(Encoding::Latin1), latin1_string_(string(latin1_string)) {} unicode_string_view(const char* latin1_string, size_t length) : encoding_(Encoding::Latin1), latin1_string_(string(latin1_string, length)) {} @@ -48,7 +48,7 @@ class unicode_string_view final { : encoding_(Encoding::Latin1), latin1_string_(std::move(latin1_string)) {} #pragma endregion #pragma region UTF - 8 - unicode_string_view(const char8_t_* utf8_string) + unicode_string_view(const char8_t_* utf8_string) // NOLINT : encoding_(Encoding::Utf8), u8_string_(u8string(utf8_string)) {} unicode_string_view(const char8_t_* utf8_string, size_t length) : encoding_(Encoding::Utf8), u8_string_(u8string(utf8_string, length)) {} @@ -58,7 +58,7 @@ class unicode_string_view final { : encoding_(Encoding::Utf8), u8_string_(std::move(utf8_string)) {} #pragma endregion #pragma region UTF - 16 - unicode_string_view(const char16_t* utf16_string) + unicode_string_view(const char16_t* utf16_string) // NOLINT : encoding_(Encoding::Utf16), u16_string_(u16string(utf16_string)) {} unicode_string_view(const char16_t* utf16_string, size_t length) : encoding_(Encoding::Utf16), u16_string_(u16string(utf16_string, length)) {} @@ -68,7 +68,7 @@ class unicode_string_view final { : encoding_(Encoding::Utf16), u16_string_(std::move(utf16_string)) {} #pragma endregion #pragma region UTF - 32 - unicode_string_view(const char32_t* utf32_string) + unicode_string_view(const char32_t* utf32_string) // NOLINT : encoding_(Encoding::Utf32), u32_string_(u32string(utf32_string)) {} unicode_string_view(const char32_t* utf32_string, size_t length) : encoding_(Encoding::Utf32), u32_string_(u32string(utf32_string, length)) {}