From 86fb560d9e9a8919e1bbf232668ea3c958714a8a Mon Sep 17 00:00:00 2001 From: chenwei Date: Thu, 11 May 2023 20:20:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9StartTrace=E7=AC=AC=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=BF=9B=E8=A1=8Cnull=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenwei --- .../kits/js/napi/bytrace_napi_common.cpp | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/interfaces/kits/js/napi/bytrace_napi_common.cpp b/interfaces/kits/js/napi/bytrace_napi_common.cpp index 51cb57c..1a0d849 100644 --- a/interfaces/kits/js/napi/bytrace_napi_common.cpp +++ b/interfaces/kits/js/napi/bytrace_napi_common.cpp @@ -67,28 +67,25 @@ void GetStringParam(const napi_env& env, const napi_value& value, std::string& d bool ParseStringParam(const napi_env& env, const napi_value& value, std::string& dest) { - if (!TypeCheck(env, value, napi_string)) { - if (!TypeCheck(env, value, napi_number)) { - if (!TypeCheck(env, value, napi_undefined)) { - if (!TypeCheck(env, value, napi_null)) { - return false; - } else { - dest = "null"; - } - } else { - dest = "undefined"; - } - } else { - int64_t destI64; - napi_get_value_int64(env, value, &destI64); - dest = std::to_string(destI64); - } - } else { + if (TypeCheck(env, value, napi_string)) { GetStringParam(env, value, dest); + return true; } - HiLog::Error(LABEL, "finally dest: %{public}s.", dest.c_str()); - - return true; + if (TypeCheck(env, value, napi_number)) { + int64_t destI64; + napi_get_value_int64(env, value, &destI64); + dest = std::to_string(destI64); + return true; + } + if (TypeCheck(env, value, napi_undefined)) { + dest = "undefined"; + return true; + } + if (TypeCheck(env, value, napi_null)) { + dest = "null"; + return true; + } + return false; } bool ParseInt32Param(const napi_env& env, const napi_value& value, int& dest)