diff --git a/native/cocos/bindings/jswrapper/v8/debugger/inspector_socket_server.cpp b/native/cocos/bindings/jswrapper/v8/debugger/inspector_socket_server.cpp index 2a94399e89..1f40c60288 100644 --- a/native/cocos/bindings/jswrapper/v8/debugger/inspector_socket_server.cpp +++ b/native/cocos/bindings/jswrapper/v8/debugger/inspector_socket_server.cpp @@ -111,22 +111,23 @@ void PrintDebuggerReadyMessage(const std::string &host, { char buf[512]; uv_interface_address_t *info = nullptr; - int count = 0, i = 0; + int count = 0; + int i = 0; uv_interface_addresses(&info, &count); i = count; if (errno) { - SE_LOGE("failed to get addresses %s\n", strerror(errno)); + SE_LOGE("failed to get addresses %s", strerror(errno)); } - SE_LOGD("Number of interfaces: %d\n", count); + SE_LOGD("Number of interfaces: %d", count); while (i--) { - auto &network_interface = info[i]; + auto &networkInterface = info[i]; - if (network_interface.address.address4.sin_family == AF_INET) { - uv_ip4_name(&network_interface.address.address4, buf, sizeof(buf)); - ipList.push_back(std::make_tuple(network_interface.name, network_interface.is_internal, buf)); + if (networkInterface.address.address4.sin_family == AF_INET) { + uv_ip4_name(&networkInterface.address.address4, buf, sizeof(buf)); + ipList.emplace_back(networkInterface.name, networkInterface.is_internal, buf); } } uv_free_interface_addresses(info, count); @@ -134,25 +135,25 @@ void PrintDebuggerReadyMessage(const std::string &host, // failed to query device interfaces, if (ipList.empty()) { #if ANDROID - SE_LOGD("Please query IP by running the following command in terminal: adb shell ip -4 -br addr\n"); + SE_LOGD("Please query IP by running the following command in terminal: adb shell ip -4 -br addr"); #endif ipList.emplace_back("none", false, "IP_ADDR_OF_THIS_DEVICE"); } for (const std::string &id : ids) { if (host != "0.0.0.0") { - SE_LOGD("Debugger listening..., visit [ devtools://devtools/bundled/js_app.html?v8only=true&ws=%s ] in chrome browser to debug!\n", + SE_LOGD("Debugger listening..., visit [ devtools://devtools/bundled/js_app.html?v8only=true&ws=%s ] in chrome browser to debug!", FormatWsAddress(host, port, id, false).c_str()); } else { - SE_LOGD("Debugger listening..., visit [\n"); + SE_LOGD("Debugger listening..., visit ["); for (auto &nif : ipList) { - SE_LOGD(" devtools://devtools/bundled/js_app.html?v8only=true&ws=%s\n", + SE_LOGD(" devtools://devtools/bundled/js_app.html?v8only=true&ws=%s", FormatWsAddress(std::get<2>(nif), port, id, false).c_str()); } - SE_LOGD(" ] in chrome browser to debug!\n"); + SE_LOGD(" ] in chrome browser to debug!"); } } - SE_LOGD("For help see %s\n", + SE_LOGD("For help see %s", "https://nodejs.org/en/docs/inspector"); } diff --git a/native/cocos/bindings/manual/jsb_conversions.h b/native/cocos/bindings/manual/jsb_conversions.h index d429bab453..aa7d228962 100644 --- a/native/cocos/bindings/manual/jsb_conversions.h +++ b/native/cocos/bindings/manual/jsb_conversions.h @@ -51,31 +51,31 @@ #include "math/Math.h" #include "renderer/gfx-base/states/GFXSampler.h" -#define SE_PRECONDITION2_VOID(condition, ...) \ - do { \ - if (!(condition)) { \ - CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - CC_LOG_ERROR(__VA_ARGS__); \ - return; \ - } \ +#define SE_PRECONDITION2_VOID(condition, ...) \ + do { \ + if (!(condition)) { \ + DO_CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + DO_CC_LOG_ERROR(__VA_ARGS__); \ + return; \ + } \ } while (0) -#define SE_PRECONDITION2_FUNCNAME_VOID(condition, funcName, ...) \ - do { \ - if (!(condition)) { \ - CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, funcName); \ - CC_LOG_ERROR(__VA_ARGS__); \ - return; \ - } \ +#define SE_PRECONDITION2_FUNCNAME_VOID(condition, funcName, ...) \ + do { \ + if (!(condition)) { \ + DO_CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, funcName); \ + DO_CC_LOG_ERROR(__VA_ARGS__); \ + return; \ + } \ } while (0) -#define SE_PRECONDITION2(condition, ret_value, ...) \ - do { \ - if (!(condition)) { \ - CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - CC_LOG_ERROR(__VA_ARGS__); \ - return (ret_value); \ - } \ +#define SE_PRECONDITION2(condition, ret_value, ...) \ + do { \ + if (!(condition)) { \ + DO_CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + DO_CC_LOG_ERROR(__VA_ARGS__); \ + return (ret_value); \ + } \ } while (0) #define SE_PRECONDITION3(condition, ret_value, failed_code) \ @@ -86,20 +86,20 @@ } \ } while (0) -#define SE_PRECONDITION4(condition, ret_value, errorCode) \ - do { \ - if (!(condition)) { \ - CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - __glErrorCode = errorCode; \ - return (ret_value); \ - } \ +#define SE_PRECONDITION4(condition, ret_value, errorCode) \ + do { \ + if (!(condition)) { \ + DO_CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + __glErrorCode = errorCode; \ + return (ret_value); \ + } \ } while (0) -#define SE_PRECONDITION_ERROR_BREAK(condition, ...) \ - if (!(condition)) { \ - CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - CC_LOG_ERROR(__VA_ARGS__); \ - break; \ +#define SE_PRECONDITION_ERROR_BREAK(condition, ...) \ + if (!(condition)) { \ + DO_CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + DO_CC_LOG_ERROR(__VA_ARGS__); \ + break; \ } #if CC_ENABLE_CACHE_JSB_FUNC_RESULT @@ -336,7 +336,7 @@ inline void cc_tmp_set_private_data(se::Object *obj, cc::gfx::Sampler *v) { // N obj->setRawPrivateData(v); } -//handle reference +// handle reference template typename std::enable_if::value, bool>::type native_ptr_to_seval(T &v_ref, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) @@ -546,7 +546,7 @@ struct HolderType { return holder_convert_to(data); } ~HolderType() { - //delete ptr; + // delete ptr; if (ptr) { ptr->~type(); } @@ -606,15 +606,15 @@ struct HolderType, true> { inline type value() { return data; } }; -//template -//struct HolderType, true> { -// using NonconstT = typename std::remove_const::type; -// using type = ccstd::optional; -// using local_type = NonconstT; -// local_type data; -// std::remove_const_t *ptr = nullptr; -// inline type value() { return std::make_optional(data); } -//}; +// template +// struct HolderType, true> { +// using NonconstT = typename std::remove_const::type; +// using type = ccstd::optional; +// using local_type = NonconstT; +// local_type data; +// std::remove_const_t *ptr = nullptr; +// inline type value() { return std::make_optional(data); } +// }; ///////////////////////////////////convertion////////////////////////////////////////////////////////// @@ -670,10 +670,10 @@ template bool sevalue_to_native(const se::Value &from, ccstd::optional *to, se::Object *ctx); // NOLINT(readability-identifier-naming) /// ccstd::unordered_map template -bool sevalue_to_native(const se::Value &from, ccstd::unordered_map *to, se::Object *ctx); //NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, ccstd::unordered_map *to, se::Object *ctx); // NOLINT(readability-identifier-naming) /// ccstd::map template -bool sevalue_to_native(const se::Value &from, ccstd::map *to, se::Object *ctx); //NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, ccstd::map *to, se::Object *ctx); // NOLINT(readability-identifier-naming) // std::tuple template bool sevalue_to_native(const se::Value &from, std::tuple *to, se::Object *ctx); // NOLINT(readability-identifier-naming) @@ -774,8 +774,8 @@ template typename std::enable_if_t::value && is_jsb_object_v, bool> sevalue_to_native(const se::Value &from, T **to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) if (from.isNullOrUndefined()) { - //const ccstd::string stack = se::ScriptEngine::getInstance()->getCurrentStackTrace(); - //SE_LOGE("[ERROR] sevalue_to_native jsval is null/undefined: %s\nstack: %s", typeid(T).name(), stack.c_str()); + // const ccstd::string stack = se::ScriptEngine::getInstance()->getCurrentStackTrace(); + // SE_LOGE("[ERROR] sevalue_to_native jsval is null/undefined: %s\nstack: %s", typeid(T).name(), stack.c_str()); *to = nullptr; return true; } @@ -804,8 +804,8 @@ template typename std::enable_if_t::value && is_jsb_object_v, bool> sevalue_to_native(const se::Value &from, T ***to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) if (from.isNullOrUndefined()) { - //const ccstd::string stack = se::ScriptEngine::getInstance()->getCurrentStackTrace(); - //SE_LOGE("[ERROR] sevalue_to_native jsval is null/undefined: %s\nstack: %s", typeid(T).name(), stack.c_str()); + // const ccstd::string stack = se::ScriptEngine::getInstance()->getCurrentStackTrace(); + // SE_LOGE("[ERROR] sevalue_to_native jsval is null/undefined: %s\nstack: %s", typeid(T).name(), stack.c_str()); *to = nullptr; return true; } @@ -1128,7 +1128,7 @@ bool sevalue_to_native(const se::Value &from, std::tuple *to, se::Objec ////////////// ccstd::unordered_map template -bool sevalue_to_native(const se::Value &from, ccstd::unordered_map *to, se::Object *ctx) { //NOLINT +bool sevalue_to_native(const se::Value &from, ccstd::unordered_map *to, se::Object *ctx) { // NOLINT se::Object *jsmap = from.toObject(); ccstd::vector allKeys; jsmap->getAllKeys(&allKeys); @@ -1145,7 +1145,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::unordered_map -bool sevalue_to_native(const se::Value &from, ccstd::map *to, se::Object *ctx) { //NOLINT +bool sevalue_to_native(const se::Value &from, ccstd::map *to, se::Object *ctx) { // NOLINT se::Object *jsmap = from.toObject(); ccstd::vector allKeys; jsmap->getAllKeys(&allKeys); @@ -1162,7 +1162,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::map *to, ///////////////// ccstd::optional template -bool sevalue_to_native(const se::Value &from, ccstd::optional *to, se::Object *ctx) { //NOLINT +bool sevalue_to_native(const se::Value &from, ccstd::optional *to, se::Object *ctx) { // NOLINT static_assert(!is_optional::value, "bad match ?"); if (from.isNullOrUndefined()) { to->reset(); @@ -1216,29 +1216,29 @@ inline bool nativevalue_to_se(ccstd::vector *const from, se::Value &to, se::O return nativevalue_to_se(*from, to, ctx); } -//TODO(): just comment it to make compiler work. Should use CONSTEXPR version. +// TODO(): just comment it to make compiler work. Should use CONSTEXPR version. //#if HAS_CONSTEXPR // -//template -//inline bool nativevalue_to_se(const T &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) -// if CC_CONSTEXPR (std::is_enum::value) { -// to.setInt32(static_cast(from)); -// return true; -// } else if CC_CONSTEXPR (std::is_pointer::value) { -// return native_ptr_to_seval(from, &to); -// } else if CC_CONSTEXPR (is_jsb_object_v) { -// return native_ptr_to_seval(from, &to); -// } else if CC_CONSTEXPR (std::is_same::value || std::is_same::value) { -// to.setInt64(static_cast(from)); -// return true; -// } else if CC_CONSTEXPR (std::is_arithmetic::value) { -// to.setDouble(static_cast(from)); -// return true; -// } else { -// static_assert(!std::is_const::value, "Only non-const value accepted here"); -// return nativevalue_to_se::value, T, typename std::add_const::type>>(from, to, ctx); -// } -//} +// template +// inline bool nativevalue_to_se(const T &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) +// if CC_CONSTEXPR (std::is_enum::value) { +// to.setInt32(static_cast(from)); +// return true; +// } else if CC_CONSTEXPR (std::is_pointer::value) { +// return native_ptr_to_seval(from, &to); +// } else if CC_CONSTEXPR (is_jsb_object_v) { +// return native_ptr_to_seval(from, &to); +// } else if CC_CONSTEXPR (std::is_same::value || std::is_same::value) { +// to.setInt64(static_cast(from)); +// return true; +// } else if CC_CONSTEXPR (std::is_arithmetic::value) { +// to.setDouble(static_cast(from)); +// return true; +// } else { +// static_assert(!std::is_const::value, "Only non-const value accepted here"); +// return nativevalue_to_se::value, T, typename std::add_const::type>>(from, to, ctx); +// } +// } // //#else @@ -1511,7 +1511,7 @@ bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object * return true; } -#endif //CC_USE_SPINE +#endif // CC_USE_SPINE /////////////////// shorter form template @@ -1531,12 +1531,12 @@ bool nativevalue_to_se(const ccstd::variant &from, se::Value &to, se::O } template -inline bool nativevalue_to_se(const std::shared_ptr> &from, se::Value &to, se::Object *ctx) { //NOLINT +inline bool nativevalue_to_se(const std::shared_ptr> &from, se::Value &to, se::Object *ctx) { // NOLINT return nativevalue_to_se(*from, to, ctx); } template -inline bool nativevalue_to_se(const std::shared_ptr &from, se::Value &to, se::Object *ctx) { //NOLINT +inline bool nativevalue_to_se(const std::shared_ptr &from, se::Value &to, se::Object *ctx) { // NOLINT auto *nativePtr = from.get(); if (!nativePtr) { @@ -1558,7 +1558,7 @@ inline bool nativevalue_to_se(const std::shared_ptr &from, se::Value &to, se: } template -inline bool nativevalue_to_se(const cc::IntrusivePtr &from, se::Value &to, se::Object *ctx) { //NOLINT +inline bool nativevalue_to_se(const cc::IntrusivePtr &from, se::Value &to, se::Object *ctx) { // NOLINT auto *nativePtr = from.get(); if (!nativePtr) {