From de388d8f61af996a9a91f8fb6e13540dfffd0a5f Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Mon, 6 Jun 2022 23:34:43 +0800 Subject: [PATCH] Descriptor: debugger refactor of independent js_runtime [ part-1 ] details: using stl instead of js_runtime container ans string issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5AYKS Signed-off-by: wengchangcheng Change-Id: I32b4809a4bbd759a562326a59e0cfb0e8e728297 --- ecmascript/base/error_helper.cpp | 18 +- ecmascript/base/error_helper.h | 4 +- ecmascript/base/string_helper.h | 8 +- ecmascript/dfx/cpu_profiler/cpu_profiler.cpp | 8 +- ecmascript/js_function.cpp | 4 +- ecmascript/js_method.cpp | 6 +- ecmascript/js_method.h | 2 +- .../jspandafile/class_info_extractor.cpp | 8 +- .../jspandafile/debug_info_extractor.cpp | 10 +- ecmascript/jspandafile/debug_info_extractor.h | 16 +- ecmascript/napi/dfx_jsnapi.cpp | 6 +- ecmascript/tooling/agent/debugger_impl.cpp | 86 +-- ecmascript/tooling/agent/debugger_impl.h | 34 +- .../tooling/agent/heapprofiler_impl.cpp | 8 +- ecmascript/tooling/agent/profiler_impl.cpp | 4 +- ecmascript/tooling/agent/runtime_impl.cpp | 26 +- ecmascript/tooling/agent/runtime_impl.h | 16 +- ecmascript/tooling/backend/debugger_api.cpp | 16 +- ecmascript/tooling/backend/debugger_api.h | 8 +- .../tooling/backend/js_pt_extractor.cpp | 8 +- ecmascript/tooling/backend/js_pt_extractor.h | 6 +- ecmascript/tooling/base/pt_events.h | 152 ++--- ecmascript/tooling/base/pt_params.cpp | 70 +- ecmascript/tooling/base/pt_params.h | 52 +- ecmascript/tooling/base/pt_returns.cpp | 2 +- ecmascript/tooling/base/pt_returns.h | 60 +- ecmascript/tooling/base/pt_script.cpp | 2 +- ecmascript/tooling/base/pt_script.h | 32 +- ecmascript/tooling/base/pt_types.cpp | 302 ++++---- ecmascript/tooling/base/pt_types.h | 438 ++++++------ ecmascript/tooling/debugger_service.cpp | 2 +- ecmascript/tooling/dispatcher.cpp | 18 +- ecmascript/tooling/dispatcher.h | 26 +- ecmascript/tooling/interface/file_stream.cpp | 3 +- ecmascript/tooling/protocol_handler.cpp | 2 +- ecmascript/tooling/protocol_handler.h | 2 +- .../tooling/test/debugger_entry_test.cpp | 2 +- .../tooling/test/debugger_events_test.cpp | 73 +- .../tooling/test/debugger_params_test.cpp | 168 ++--- .../tooling/test/debugger_returns_test.cpp | 34 +- .../tooling/test/debugger_types_test.cpp | 643 +++++++++--------- ecmascript/tooling/test/utils/test_entry.cpp | 2 +- ecmascript/tooling/test/utils/test_events.h | 2 +- .../tooling/test/utils/test_extractor.h | 2 +- ecmascript/tooling/test/utils/test_hooks.h | 4 +- ecmascript/tooling/test/utils/test_util.h | 6 +- .../testcases/js_breakpoint_arrow_test.h | 6 +- .../testcases/js_breakpoint_async_test.h | 6 +- .../test/utils/testcases/js_breakpoint_test.h | 6 +- .../test/utils/testcases/js_exception_test.h | 10 +- .../utils/testcases/js_single_step_test.h | 6 +- .../test/utils/testcases/test_list.cpp | 12 +- .../tooling/test/utils/testcases/test_list.h | 8 +- 53 files changed, 1213 insertions(+), 1242 deletions(-) diff --git a/ecmascript/base/error_helper.cpp b/ecmascript/base/error_helper.cpp index 2ce134ed87..6e0faefa48 100644 --- a/ecmascript/base/error_helper.cpp +++ b/ecmascript/base/error_helper.cpp @@ -172,7 +172,7 @@ JSTaggedValue ErrorHelper::ErrorCommonConstructor(EcmaRuntimeCallInfo *argv, return nativeInstanceObj.GetTaggedValue(); } -CString ErrorHelper::DecodeFunctionName(const CString &name) +std::string ErrorHelper::DecodeFunctionName(const std::string &name) { if (name.empty()) { return "anonymous"; @@ -182,16 +182,16 @@ CString ErrorHelper::DecodeFunctionName(const CString &name) JSHandle ErrorHelper::BuildEcmaStackTrace(JSThread *thread) { - CString data = BuildJsStackTrace(thread, false); + std::string data = BuildJsStackTrace(thread, false); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); LOG(DEBUG, ECMASCRIPT) << data; - return factory->NewFromUtf8(data); + return factory->NewFromStdString(data); } -CString ErrorHelper::BuildJsStackTrace(JSThread *thread, bool needNative) +std::string ErrorHelper::BuildJsStackTrace(JSThread *thread, bool needNative) { - CString data; - CString fristLineSrcCode; + std::string data; + std::string fristLineSrcCode; bool isFirstLine = true; FrameHandler frameHandler(thread); for (; frameHandler.HasFrame(); frameHandler.PrevInterpretedFrame()) { @@ -204,12 +204,12 @@ CString ErrorHelper::BuildJsStackTrace(JSThread *thread, bool needNative) } if (!method->IsNativeWithCallField()) { data.append(" at "); - data += DecodeFunctionName(method->ParseFunctionName()); + data += DecodeFunctionName(method->ParseFunctionName().c_str()); data.append(" ("); // source file tooling::JSPtExtractor *debugExtractor = JSPandaFileManager::GetInstance()->GetJSPtExtractor(method->GetJSPandaFile()); - const CString &sourceFile = debugExtractor->GetSourceFile(method->GetMethodId()); + const std::string &sourceFile = debugExtractor->GetSourceFile(method->GetMethodId()); if (sourceFile.empty()) { data.push_back('?'); } else { @@ -237,7 +237,7 @@ CString ErrorHelper::BuildJsStackTrace(JSThread *thread, bool needNative) data.push_back(')'); data.push_back('\n'); if (isFirstLine) { - const CString &sourceCode = debugExtractor->GetSourceCode( + const std::string &sourceCode = debugExtractor->GetSourceCode( panda_file::File::EntityId(method->GetJSPandaFile()->GetMainMethodIndex())); fristLineSrcCode = StringHelper::GetSpecifiedLine(sourceCode, lineNumber); isFirstLine = false; diff --git a/ecmascript/base/error_helper.h b/ecmascript/base/error_helper.h index f262152ff0..cde0d80a3f 100644 --- a/ecmascript/base/error_helper.h +++ b/ecmascript/base/error_helper.h @@ -31,10 +31,10 @@ public: static JSTaggedValue ErrorCommonConstructor(EcmaRuntimeCallInfo *argv, const ErrorType &errorType); - static CString BuildJsStackTrace(JSThread *thread, bool needNative); + static std::string BuildJsStackTrace(JSThread *thread, bool needNative); private: - static CString DecodeFunctionName(const CString &name); + static std::string DecodeFunctionName(const std::string &name); static JSHandle BuildEcmaStackTrace(JSThread *thread); diff --git a/ecmascript/base/string_helper.h b/ecmascript/base/string_helper.h index bee9d4e73e..b12404b061 100644 --- a/ecmascript/base/string_helper.h +++ b/ecmascript/base/string_helper.h @@ -201,16 +201,16 @@ public: return res; } - static inline CString GetSpecifiedLine(const CString &srcStr, int lineNumber) + static inline std::string GetSpecifiedLine(const std::string &srcStr, int lineNumber) { - std::stringstream ss(CstringConvertToStdString(srcStr)); + std::stringstream ss(srcStr); int count = 0; - CString lineStr = ""; + std::string lineStr = ""; std::string tempLine; while (getline(ss, tempLine, '\n')) { count++; if (count == lineNumber) { - lineStr = ConvertToString(tempLine); + lineStr = tempLine; break; } } diff --git a/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp b/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp index d894de9152..e7237a686f 100644 --- a/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp +++ b/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp @@ -278,20 +278,20 @@ void CpuProfiler::ParseMethodInfo(JSMethod *method, FrameHandler frameHandler) staticStackInfo_.insert(std::make_pair(method, codeEntry)); } else if (method != nullptr) { codeEntry.codeType = "JS"; - const CString &functionName = method->ParseFunctionName(); + const std::string &functionName = method->ParseFunctionName(); if (functionName.empty()) { codeEntry.functionName = "anonymous"; } else { - codeEntry.functionName = functionName.c_str(); + codeEntry.functionName = functionName; } // source file tooling::JSPtExtractor *debugExtractor = JSPandaFileManager::GetInstance()->GetJSPtExtractor(method->GetJSPandaFile()); - const CString &sourceFile = debugExtractor->GetSourceFile(method->GetMethodId()); + const std::string &sourceFile = debugExtractor->GetSourceFile(method->GetMethodId()); if (sourceFile.empty()) { codeEntry.url = ""; } else { - codeEntry.url = sourceFile.c_str(); + codeEntry.url = sourceFile; auto iter = scriptIdMap_.find(codeEntry.url); if (iter == scriptIdMap_.end()) { scriptIdMap_.insert(std::make_pair(codeEntry.url, scriptIdMap_.size() + 1)); diff --git a/ecmascript/js_function.cpp b/ecmascript/js_function.cpp index 7a8e90340c..8f3db64acf 100644 --- a/ecmascript/js_function.cpp +++ b/ecmascript/js_function.cpp @@ -145,7 +145,7 @@ JSTaggedValue JSFunction::NameGetter(JSThread *thread, const JSHandle if (target->GetPandaFile() == nullptr) { return JSTaggedValue::Undefined(); } - CString funcName = target->ParseFunctionName(); + std::string funcName = target->ParseFunctionName(); if (funcName.empty()) { return thread->GlobalConstants()->GetEmptyString(); } @@ -157,7 +157,7 @@ JSTaggedValue JSFunction::NameGetter(JSThread *thread, const JSHandle } ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - return factory->NewFromUtf8(funcName).GetTaggedValue(); + return factory->NewFromStdString(funcName).GetTaggedValue(); } bool JSFunction::OrdinaryHasInstance(JSThread *thread, const JSHandle &constructor, diff --git a/ecmascript/js_method.cpp b/ecmascript/js_method.cpp index bcbcb1c928..76f239f593 100644 --- a/ecmascript/js_method.cpp +++ b/ecmascript/js_method.cpp @@ -38,14 +38,14 @@ JSMethod::JSMethod(const JSPandaFile *jsPandaFile, panda_file::File::EntityId me } // It's not allowed '#' token appear in ECMA function(method) name, which discriminates same names in panda methods. -CString JSMethod::ParseFunctionName() const +std::string JSMethod::ParseFunctionName() const { - CString methodName(utf::Mutf8AsCString(GetName().data)); + std::string methodName(utf::Mutf8AsCString(GetName().data)); if (LIKELY(methodName[0] != '#')) { return methodName; } size_t index = methodName.find_last_of('#'); - return CString(methodName.substr(index + 1)); + return methodName.substr(index + 1); } void JSMethod::InitializeCallField(uint32_t numVregs, uint32_t numArgs) diff --git a/ecmascript/js_method.h b/ecmascript/js_method.h index 165f2f125a..e1c84ca3eb 100644 --- a/ecmascript/js_method.h +++ b/ecmascript/js_method.h @@ -100,7 +100,7 @@ struct PUBLIC_API JSMethod : public base::AlignedStructGetConstructorMethod()->ParseFunctionName(); - JSHandle clsNameHandle = factory->NewFromUtf8(clsName); + std::string clsName = extractor->GetConstructorMethod()->ParseFunctionName(); + JSHandle clsNameHandle = factory->NewFromStdString(clsName); staticProperties->Set(thread, NAME_INDEX, clsNameHandle); } @@ -150,8 +150,8 @@ bool ClassInfoExtractor::ExtractAndReturnWhetherWithElements(JSThread *thread, c if (LIKELY(!keysHasNameFlag)) { [[maybe_unused]] EcmaHandleScope handleScope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - CString clsName = detail.ctorMethod->ParseFunctionName(); - JSHandle clsNameHandle = factory->NewFromUtf8(clsName); + std::string clsName = detail.ctorMethod->ParseFunctionName(); + JSHandle clsNameHandle = factory->NewFromStdString(clsName); properties->Set(thread, NAME_INDEX, clsNameHandle); } else { // class has static name property, reserved length bigger 1 than actual, need trim diff --git a/ecmascript/jspandafile/debug_info_extractor.cpp b/ecmascript/jspandafile/debug_info_extractor.cpp index 2c134b96ae..edf18e932c 100644 --- a/ecmascript/jspandafile/debug_info_extractor.cpp +++ b/ecmascript/jspandafile/debug_info_extractor.cpp @@ -32,7 +32,7 @@ using panda::panda_file::ProtoDataAccessor; static const char *GetStringFromConstantPool(const panda_file::File &pf, uint32_t offset) { - return utf::Mutf8AsCString(pf.GetStringData(panda_file::File::EntityId(offset)).data); + return reinterpret_cast(pf.GetStringData(panda_file::File::EntityId(offset)).data); } DebugInfoExtractor::DebugInfoExtractor(const JSPandaFile *jsPandaFile) @@ -196,8 +196,8 @@ void DebugInfoExtractor::Extract(const panda_file::File *pf) programProcessor.Process(); panda_file::File::EntityId methodId = mda.GetMethodId(); - const char *sourceFile = utf::Mutf8AsCString(handler.GetFile()); - const char *sourceCode = utf::Mutf8AsCString(handler.GetSourceCode()); + const char *sourceFile = reinterpret_cast(handler.GetFile()); + const char *sourceCode = reinterpret_cast(handler.GetSourceCode()); methods_.insert(std::make_pair(methodId.GetOffset(), MethodDebugInfo {sourceFile, sourceCode, handler.GetLineNumberTable(), handler.GetColumnNumberTable(), @@ -239,7 +239,7 @@ const LocalVariableTable &DebugInfoExtractor::GetLocalVariableTable(panda_file:: return iter->second.localVariableTable; } -const CString &DebugInfoExtractor::GetSourceFile(panda_file::File::EntityId methodId) const +const std::string &DebugInfoExtractor::GetSourceFile(panda_file::File::EntityId methodId) const { auto iter = methods_.find(methodId.GetOffset()); if (iter == methods_.end()) { @@ -248,7 +248,7 @@ const CString &DebugInfoExtractor::GetSourceFile(panda_file::File::EntityId meth return iter->second.sourceFile; } -const CString &DebugInfoExtractor::GetSourceCode(panda_file::File::EntityId methodId) const +const std::string &DebugInfoExtractor::GetSourceCode(panda_file::File::EntityId methodId) const { auto iter = methods_.find(methodId.GetOffset()); if (iter == methods_.end()) { diff --git a/ecmascript/jspandafile/debug_info_extractor.h b/ecmascript/jspandafile/debug_info_extractor.h index fb82247fa5..ab67fa796c 100644 --- a/ecmascript/jspandafile/debug_info_extractor.h +++ b/ecmascript/jspandafile/debug_info_extractor.h @@ -49,14 +49,14 @@ using ColumnNumberTable = CVector; /* * LocalVariableInfo define in frontend, now only use name and regNumber: - * CString name - * CString type - * CString typeSignature + * std::string name + * std::string type + * std::string typeSignature * int32_t regNumber * uint32_t startOffset * uint32_t endOffset */ -using LocalVariableTable = CUnorderedMap; // name, regNumber +using LocalVariableTable = CUnorderedMap; // name, regNumber // public for debugger class PUBLIC_API DebugInfoExtractor { @@ -74,9 +74,9 @@ public: const LocalVariableTable &GetLocalVariableTable(panda_file::File::EntityId methodId) const; - const CString &GetSourceFile(panda_file::File::EntityId methodId) const; + const std::string &GetSourceFile(panda_file::File::EntityId methodId) const; - const CString &GetSourceCode(panda_file::File::EntityId methodId) const; + const std::string &GetSourceCode(panda_file::File::EntityId methodId) const; CVector GetMethodIdList() const; @@ -84,8 +84,8 @@ private: void Extract(const panda_file::File *pf); struct MethodDebugInfo { - CString sourceFile; - CString sourceCode; + std::string sourceFile; + std::string sourceCode; LineNumberTable lineNumberTable; ColumnNumberTable columnNumberTable; LocalVariableTable localVariableTable; diff --git a/ecmascript/napi/dfx_jsnapi.cpp b/ecmascript/napi/dfx_jsnapi.cpp index cd3016c168..31efbb038b 100644 --- a/ecmascript/napi/dfx_jsnapi.cpp +++ b/ecmascript/napi/dfx_jsnapi.cpp @@ -74,8 +74,7 @@ void DFXJSNApi::DumpHeapSnapshot([[maybe_unused]] const EcmaVM *vm, [[maybe_unus bool DFXJSNApi::BuildNativeAndJsStackTrace(const EcmaVM *vm, std::string &stackTraceStr) { - CString trace = ecmascript::base::ErrorHelper::BuildJsStackTrace(vm->GetJSThreadNoCheck(), true); - stackTraceStr = CstringConvertToStdString(trace); + stackTraceStr = ecmascript::base::ErrorHelper::BuildJsStackTrace(vm->GetJSThreadNoCheck(), true); if (stackTraceStr.empty()) { return false; } @@ -84,8 +83,7 @@ bool DFXJSNApi::BuildNativeAndJsStackTrace(const EcmaVM *vm, std::string &stackT bool DFXJSNApi::BuildJsStackTrace(const EcmaVM *vm, std::string &stackTraceStr) { - CString trace = ecmascript::base::ErrorHelper::BuildJsStackTrace(vm->GetJSThreadNoCheck(), false); - stackTraceStr = CstringConvertToStdString(trace); + stackTraceStr = ecmascript::base::ErrorHelper::BuildJsStackTrace(vm->GetJSThreadNoCheck(), false); if (stackTraceStr.empty()) { return false; } diff --git a/ecmascript/tooling/agent/debugger_impl.cpp b/ecmascript/tooling/agent/debugger_impl.cpp index 266f31ef68..9c33f2c143 100644 --- a/ecmascript/tooling/agent/debugger_impl.cpp +++ b/ecmascript/tooling/agent/debugger_impl.cpp @@ -37,9 +37,9 @@ using ObjectSubType = RemoteObject::SubTypeName; using ObjectClassName = RemoteObject::ClassName; #ifdef DEBUGGER_TEST -const CString DATA_APP_PATH = "/"; +const std::string DATA_APP_PATH = "/"; #else -const CString DATA_APP_PATH = "/data/"; +const std::string DATA_APP_PATH = "/data/"; #endif DebuggerImpl::DebuggerImpl(const EcmaVM *vm, ProtocolChannel *channel, RuntimeImpl *runtime) @@ -60,7 +60,7 @@ DebuggerImpl::~DebuggerImpl() DebuggerApi::DestroyJSDebugger(jsDebugger_); } -bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const CString &fileName) +bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &fileName) { if (fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH) { LOG(WARNING, DEBUGGER) << "NotifyScriptParsed: unsupport file: " << fileName; @@ -77,7 +77,7 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const CString &fileName const JSPandaFile *jsPandaFile = nullptr; JSPandaFileManager::GetInstance()->EnumerateJSPandaFiles([&jsPandaFile, &fileName]( const panda::ecmascript::JSPandaFile *pf) { - if (pf->GetJSPandaFileDesc() == fileName) { + if (fileName == pf->GetJSPandaFileDesc().c_str()) { jsPandaFile = pf; return false; } @@ -95,8 +95,8 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const CString &fileName } auto mainMethodIndex = panda_file::File::EntityId(jsPandaFile->GetMainMethodIndex()); - const CString &source = extractor->GetSourceCode(mainMethodIndex); - const CString &url = extractor->GetSourceFile(mainMethodIndex); + const std::string &source = extractor->GetSourceCode(mainMethodIndex); + const std::string &url = extractor->GetSourceFile(mainMethodIndex); const uint32_t MIN_SOURCE_CODE_LENGTH = 5; // maybe return 'ANDA' when source code is empty if (source.size() < MIN_SOURCE_CODE_LENGTH) { LOG(ERROR, DEBUGGER) << "NotifyScriptParsed: invalid file: " << fileName; @@ -176,7 +176,7 @@ void DebuggerImpl::NotifyPaused(std::optional location, PauseReaso } Local exception = DebuggerApi::GetAndClearException(vm_); - CVector hitBreakpoints; + std::vector hitBreakpoints; if (location.has_value()) { BreakpointDetails detail; JSPtExtractor *extractor = nullptr; @@ -208,7 +208,7 @@ void DebuggerImpl::NotifyPaused(std::optional location, PauseReaso CleanUpOnPaused(); // Notify paused event - CVector> callFrames; + std::vector> callFrames; if (!GenerateCallFrames(&callFrames)) { LOG(ERROR, DEBUGGER) << "NotifyPaused: GenerateCallFrames failed"; return; @@ -236,7 +236,7 @@ void DebuggerImpl::NotifyPendingJobEntry() void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { - static CUnorderedMap dispatcherTable { + static std::unordered_map dispatcherTable { { "enable", &DebuggerImpl::DispatcherImpl::Enable }, { "disable", &DebuggerImpl::DispatcherImpl::Disable }, { "evaluateOnCallFrame", &DebuggerImpl::DispatcherImpl::EvaluateOnCallFrame }, @@ -253,7 +253,7 @@ void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { "stepOver", &DebuggerImpl::DispatcherImpl::StepOver } }; - const CString &method = request.GetMethod(); + const std::string &method = request.GetMethod(); LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to DebuggerImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end() && entry->second != nullptr) { @@ -307,7 +307,7 @@ void DebuggerImpl::DispatcherImpl::GetPossibleBreakpoints(const DispatchRequest SendResponse(request, DispatchResponse::Fail("wrong params")); return; } - CVector> locations; + std::vector> locations; DispatchResponse response = debugger_->GetPossibleBreakpoints(std::move(params), &locations); GetPossibleBreakpointsReturns result(std::move(locations)); SendResponse(request, response, result); @@ -321,7 +321,7 @@ void DebuggerImpl::DispatcherImpl::GetScriptSource(const DispatchRequest &reques SendResponse(request, DispatchResponse::Fail("wrong params")); return; } - CString source; + std::string source; DispatchResponse response = debugger_->GetScriptSource(std::move(params), &source); GetScriptSourceReturns result(source); SendResponse(request, response, result); @@ -371,8 +371,8 @@ void DebuggerImpl::DispatcherImpl::SetBreakpointByUrl(const DispatchRequest &req return; } - CString out_id; - CVector> outLocations; + std::string out_id; + std::vector> outLocations; DispatchResponse response = debugger_->SetBreakpointByUrl(std::move(params), &out_id, &outLocations); SetBreakpointByUrlReturns result(out_id, std::move(outLocations)); SendResponse(request, response, result); @@ -519,12 +519,12 @@ DispatchResponse DebuggerImpl::EvaluateOnCallFrame(std::unique_ptr *result) { CallFrameId callFrameId = params->GetCallFrameId(); - CString expression = params->GetExpression(); + std::string expression = params->GetExpression(); if (callFrameId < 0 || callFrameId >= callFrameHandlers_.size()) { return DispatchResponse::Fail("Invalid callFrameId."); } - CString dest; + std::string dest; if (!DecodeAndCheckBase64(expression, dest)) { LOG(ERROR, DEBUGGER) << "EvaluateValue: base64 decode failed"; auto ret = CmptEvaluateValue(callFrameId, expression, result); @@ -540,7 +540,7 @@ DispatchResponse DebuggerImpl::EvaluateOnCallFrame(std::unique_ptrGetJSThread()->HasPendingException()) { LOG(ERROR, DEBUGGER) << "EvaluateValue: has pending exception"; - CString msg; + std::string msg; DebuggerApi::HandleUncaughtException(vm_, msg); *result = RemoteObject::FromTagged(vm_, Exception::EvalError(vm_, StringRef::NewFromUtf8(vm_, msg.data()))); @@ -553,7 +553,7 @@ DispatchResponse DebuggerImpl::EvaluateOnCallFrame(std::unique_ptr params, - CVector> *locations) + std::vector> *locations) { Location *start = params->GetStart(); auto iter = scripts_.find(start->GetScriptId()); @@ -579,13 +579,13 @@ DispatchResponse DebuggerImpl::GetPossibleBreakpoints(std::unique_ptr params, CString *source) +DispatchResponse DebuggerImpl::GetScriptSource(std::unique_ptr params, std::string *source) { ScriptId scriptId = params->GetScriptId(); auto iter = scripts_.find(scriptId); if (iter == scripts_.end()) { *source = ""; - return DispatchResponse::Fail("unknown script id: " + ToCString(scriptId)); + return DispatchResponse::Fail("unknown script id: " + std::to_string(scriptId)); } *source = iter->second->GetScriptSource(); @@ -600,7 +600,7 @@ DispatchResponse DebuggerImpl::Pause() DispatchResponse DebuggerImpl::RemoveBreakpoint(std::unique_ptr params) { - CString id = params->GetBreakpointId(); + std::string id = params->GetBreakpointId(); LOG(INFO, DEBUGGER) << "RemoveBreakpoint: " << id; BreakpointDetails metaData{}; if (!BreakpointDetails::ParseBreakpointId(id, &metaData)) { @@ -612,7 +612,7 @@ DispatchResponse DebuggerImpl::RemoveBreakpoint(std::unique_ptr bool { fileName = script->GetFileName(); return true; @@ -650,13 +650,13 @@ DispatchResponse DebuggerImpl::SetAsyncCallStackDepth() } DispatchResponse DebuggerImpl::SetBreakpointByUrl(std::unique_ptr params, - CString *outId, - CVector> *outLocations) + std::string *outId, + std::vector> *outLocations) { - const CString &url = params->GetUrl(); + const std::string &url = params->GetUrl(); int32_t lineNumber = params->GetLine(); int32_t columnNumber = params->GetColumn(); - std::optional condition = params->HasCondition() ? params->GetCondition() : std::optional {}; + auto condition = params->HasCondition() ? params->GetCondition() : std::optional {}; JSPtExtractor *extractor = GetExtractor(url); if (extractor == nullptr) { @@ -665,7 +665,7 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(std::unique_ptr bool { scriptId = script->GetScriptId(); fileName = script->GetFileName(); @@ -680,7 +680,7 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(std::unique_ptr condFuncRef = FunctionRef::Undefined(vm_); if (condition.has_value() && !condition.value().empty()) { - CString dest; + std::string dest; if (!DecodeAndCheckBase64(condition.value(), dest)) { LOG(ERROR, DEBUGGER) << "SetBreakpointByUrl: base64 decode failed"; return false; @@ -701,7 +701,7 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(std::unique_ptr>(); + *outLocations = std::vector>(); std::unique_ptr location = std::make_unique(); location->SetScriptId(scriptId).SetLine(lineNumber).SetColumn(0); outLocations->emplace_back(std::move(location)); @@ -774,9 +774,9 @@ void DebuggerImpl::CleanUpOnPaused() scopeObjects_.clear(); } -CString DebuggerImpl::Trim(const CString &str) +std::string DebuggerImpl::Trim(const std::string &str) { - CString ret = str; + std::string ret = str; // If ret has only ' ', remove all charactors. ret.erase(ret.find_last_not_of(' ') + 1); // If ret has only ' ', remove all charactors. @@ -789,7 +789,7 @@ JSPtExtractor *DebuggerImpl::GetExtractor(const JSPandaFile *jsPandaFile) return JSPandaFileManager::GetInstance()->GetJSPtExtractor(jsPandaFile); } -JSPtExtractor *DebuggerImpl::GetExtractor(const CString &url) +JSPtExtractor *DebuggerImpl::GetExtractor(const std::string &url) { auto iter = extractors_.find(url); if (iter == extractors_.end()) { @@ -799,7 +799,7 @@ JSPtExtractor *DebuggerImpl::GetExtractor(const CString &url) return iter->second; } -bool DebuggerImpl::GenerateCallFrames(CVector> *callFrames) +bool DebuggerImpl::GenerateCallFrames(std::vector> *callFrames) { CallFrameId callFrameId = 0; auto walkerFunc = [this, &callFrameId, &callFrames](const FrameHandler *frameHandler) -> StackState { @@ -842,7 +842,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, // location std::unique_ptr location = std::make_unique(); - CString url = extractor->GetSourceFile(method->GetMethodId()); + std::string url = extractor->GetSourceFile(method->GetMethodId()); auto scriptFunc = [&location](PtScript *script) -> bool { location->SetScriptId(script->GetScriptId()); return true; @@ -870,12 +870,12 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, std::unique_ptr thisObj = std::make_unique(); thisObj->SetType(ObjectType::Undefined); - CVector> scopeChain; + std::vector> scopeChain; scopeChain.emplace_back(GetLocalScopeChain(frameHandler, &thisObj)); scopeChain.emplace_back(GetGlobalScopeChain()); // functionName - CString functionName = DebuggerApi::ParseFunctionName(method); + std::string functionName = DebuggerApi::ParseFunctionName(method); callFrame->SetCallFrameId(callFrameId) .SetFunctionName(functionName) @@ -1036,7 +1036,7 @@ void DebuggerImpl::UpdateScopeObject(const FrameHandler *frameHandler, } } -std::optional DebuggerImpl::CmptEvaluateValue(CallFrameId callFrameId, const CString &expression, +std::optional DebuggerImpl::CmptEvaluateValue(CallFrameId callFrameId, const std::string &expression, std::unique_ptr *result) { JSMethod *method = DebuggerApi::GetMethod(vm_); @@ -1051,10 +1051,10 @@ std::optional DebuggerImpl::CmptEvaluateValue(CallFrameId callFrameId, Exception::EvalError(vm_, StringRef::NewFromUtf8(vm_, "Internal error."))); return "Internal error."; } - CString varName = expression; - CString varValue; - CString::size_type indexEqual = expression.find_first_of('=', 0); - if (indexEqual != CString::npos) { + std::string varName = expression; + std::string varValue; + std::string::size_type indexEqual = expression.find_first_of('=', 0); + if (indexEqual != std::string::npos) { varName = Trim(expression.substr(0, indexEqual)); varValue = Trim(expression.substr(indexEqual + 1, expression.length())); } @@ -1085,7 +1085,7 @@ std::optional DebuggerImpl::CmptEvaluateValue(CallFrameId callFrameId, return "Unsupported expression."; } -Local DebuggerImpl::ConvertToLocal(const CString &varValue) +Local DebuggerImpl::ConvertToLocal(const std::string &varValue) { Local taggedValue; if (varValue == "false") { @@ -1108,7 +1108,7 @@ Local DebuggerImpl::ConvertToLocal(const CString &varValue) return taggedValue; } -bool DebuggerImpl::DecodeAndCheckBase64(const CString &src, CString &dest) +bool DebuggerImpl::DecodeAndCheckBase64(const std::string &src, std::string &dest) { dest.resize(base64::decoded_size(src.size())); auto [numOctets, _] = base64::decode(dest.data(), src.data(), src.size()); diff --git a/ecmascript/tooling/agent/debugger_impl.h b/ecmascript/tooling/agent/debugger_impl.h index 53fa39ed88..a86d0d459b 100644 --- a/ecmascript/tooling/agent/debugger_impl.h +++ b/ecmascript/tooling/agent/debugger_impl.h @@ -34,7 +34,7 @@ public: ~DebuggerImpl(); // event - bool NotifyScriptParsed(ScriptId scriptId, const CString &fileName); + bool NotifyScriptParsed(ScriptId scriptId, const std::string &fileName); bool NotifySingleStep(const JSPtLocation &location); void NotifyPaused(std::optional location, PauseReason reason); void NotifyPendingJobEntry(); @@ -44,14 +44,14 @@ public: DispatchResponse EvaluateOnCallFrame(std::unique_ptr params, std::unique_ptr *result); DispatchResponse GetPossibleBreakpoints(std::unique_ptr params, - CVector> *outLocations); - DispatchResponse GetScriptSource(std::unique_ptr params, CString *source); + std::vector> *outLocations); + DispatchResponse GetScriptSource(std::unique_ptr params, std::string *source); DispatchResponse Pause(); DispatchResponse RemoveBreakpoint(std::unique_ptr params); DispatchResponse Resume(std::unique_ptr params); DispatchResponse SetAsyncCallStackDepth(); - DispatchResponse SetBreakpointByUrl(std::unique_ptr params, CString *outId, - CVector> *outLocations); + DispatchResponse SetBreakpointByUrl(std::unique_ptr params, std::string *outId, + std::vector> *outLocations); DispatchResponse SetPauseOnExceptions(std::unique_ptr params); DispatchResponse StepInto(std::unique_ptr params); DispatchResponse StepOut(); @@ -64,10 +64,10 @@ public: * @return: true means matched and callback execute success */ template - bool MatchScripts(const Callback &cb, const CString &matchStr, ScriptMatchType type) const + bool MatchScripts(const Callback &cb, const std::string &matchStr, ScriptMatchType type) const { for (const auto &script : scripts_) { - CString value; + std::string value; switch (type) { case ScriptMatchType::URL: { value = script.second->GetUrl(); @@ -91,7 +91,7 @@ public: } return false; } - bool GenerateCallFrames(CVector> *callFrames); + bool GenerateCallFrames(std::vector> *callFrames); class DispatcherImpl final : public DispatcherBase { public: @@ -128,10 +128,10 @@ private: NO_COPY_SEMANTIC(DebuggerImpl); NO_MOVE_SEMANTIC(DebuggerImpl); - CString Trim(const CString &str); + std::string Trim(const std::string &str); JSPtExtractor *GetExtractor(const JSPandaFile *jsPandaFile); - JSPtExtractor *GetExtractor(const CString &url); - std::optional CmptEvaluateValue(CallFrameId callFrameId, const CString &expression, + JSPtExtractor *GetExtractor(const std::string &url); + std::optional CmptEvaluateValue(CallFrameId callFrameId, const std::string &expression, std::unique_ptr *result); bool GenerateCallFrame(CallFrame *callFrame, const FrameHandler *frameHandler, CallFrameId frameId); void SaveCallFrameHandler(const FrameHandler *frameHandler); @@ -142,8 +142,8 @@ private: Local &thisVal, Local &localObj); void CleanUpOnPaused(); void UpdateScopeObject(const FrameHandler *frameHandler, std::string_view varName, const Local &newVal); - Local ConvertToLocal(const CString &varValue); - bool DecodeAndCheckBase64(const CString &src, CString &dest); + Local ConvertToLocal(const std::string &varValue); + bool DecodeAndCheckBase64(const std::string &src, std::string &dest); bool IsSkipLine(const JSPtLocation &location); class Frontend { @@ -170,14 +170,14 @@ private: std::unique_ptr hooks_ {nullptr}; JSDebugger *jsDebugger_ {nullptr}; - CUnorderedMap extractors_ {}; - CUnorderedMap> scripts_ {}; + std::unordered_map extractors_ {}; + std::unordered_map> scripts_ {}; bool pauseOnException_ {false}; bool pauseOnNextByteCode_ {false}; std::unique_ptr singleStepper_ {nullptr}; - CUnorderedMap scopeObjects_ {}; - CVector> callFrameHandlers_; + std::unordered_map scopeObjects_ {}; + std::vector> callFrameHandlers_; JsDebuggerManager::ObjectUpdaterFunc updaterFunc_ {nullptr}; friend class JSPtHooks; diff --git a/ecmascript/tooling/agent/heapprofiler_impl.cpp b/ecmascript/tooling/agent/heapprofiler_impl.cpp index bcce9c3ede..3a8b6b00af 100644 --- a/ecmascript/tooling/agent/heapprofiler_impl.cpp +++ b/ecmascript/tooling/agent/heapprofiler_impl.cpp @@ -18,7 +18,7 @@ namespace panda::ecmascript::tooling { void HeapProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { - static CUnorderedMap dispatcherTable { + static std::unordered_map dispatcherTable { { "addInspectedHeapObject", &HeapProfilerImpl::DispatcherImpl::AddInspectedHeapObject }, { "collectGarbage", &HeapProfilerImpl::DispatcherImpl::CollectGarbage }, { "enable", &HeapProfilerImpl::DispatcherImpl::Enable }, @@ -33,7 +33,7 @@ void HeapProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { "takeHeapSnapshot", &HeapProfilerImpl::DispatcherImpl::TakeHeapSnapshot } }; - const CString &method = request.GetMethod(); + const std::string &method = request.GetMethod(); LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to HeapProfilerImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end() && entry->second != nullptr) { @@ -208,14 +208,14 @@ void HeapProfilerImpl::Frontend::HeapStatsUpdate(HeapStat* updateData, int count if (!AllowNotify()) { return; } - auto statsDiff = CVector(); + std::vector statsDiff; for (int i = 0; i < count; ++i) { statsDiff.emplace_back(updateData[i].index_); statsDiff.emplace_back(updateData[i].count_); statsDiff.emplace_back(updateData[i].size_); } tooling::HeapStatsUpdate heapStatsUpdate; - heapStatsUpdate.SetStatsUpdate(statsDiff); + heapStatsUpdate.SetStatsUpdate(std::move(statsDiff)); channel_->SendNotification(heapStatsUpdate); } diff --git a/ecmascript/tooling/agent/profiler_impl.cpp b/ecmascript/tooling/agent/profiler_impl.cpp index def58ac132..d0870ddbd1 100644 --- a/ecmascript/tooling/agent/profiler_impl.cpp +++ b/ecmascript/tooling/agent/profiler_impl.cpp @@ -23,7 +23,7 @@ namespace panda::ecmascript::tooling { void ProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { - static CUnorderedMap dispatcherTable { + static std::unordered_map dispatcherTable { { "disable", &ProfilerImpl::DispatcherImpl::Disable }, { "enable", &ProfilerImpl::DispatcherImpl::Enable }, { "start", &ProfilerImpl::DispatcherImpl::Start }, @@ -38,7 +38,7 @@ void ProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { "takeTypeProfile", &ProfilerImpl::DispatcherImpl::TakeTypeProfile } }; - const CString &method = request.GetMethod(); + const std::string &method = request.GetMethod(); LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to ProfilerImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end() && entry->second != nullptr) { diff --git a/ecmascript/tooling/agent/runtime_impl.cpp b/ecmascript/tooling/agent/runtime_impl.cpp index f58448305f..aceec6aa5c 100644 --- a/ecmascript/tooling/agent/runtime_impl.cpp +++ b/ecmascript/tooling/agent/runtime_impl.cpp @@ -25,7 +25,7 @@ namespace panda::ecmascript::tooling { void RuntimeImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { - static CUnorderedMap dispatcherTable { + static std::unordered_map dispatcherTable { { "enable", &RuntimeImpl::DispatcherImpl::Enable }, { "getProperties", &RuntimeImpl::DispatcherImpl::GetProperties }, { "runIfWaitingForDebugger", &RuntimeImpl::DispatcherImpl::RunIfWaitingForDebugger }, @@ -33,7 +33,7 @@ void RuntimeImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { "getHeapUsage", &RuntimeImpl::DispatcherImpl::GetHeapUsage } }; - const CString &method = request.GetMethod(); + const std::string &method = request.GetMethod(); LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to RuntimeImpl"; auto entry = dispatcherTable.find(method); @@ -71,9 +71,9 @@ void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request) return; } - CVector> outPropertyDesc; - std::optional>> outInternalDescs; - std::optional>> outPrivateProperties; + std::vector> outPropertyDesc; + std::optional>> outInternalDescs; + std::optional>> outPrivateProperties; std::optional> outExceptionDetails; DispatchResponse response = runtime_->GetProperties(std::move(params), &outPropertyDesc, &outInternalDescs, &outPrivateProperties, &outExceptionDetails); @@ -163,9 +163,9 @@ DispatchResponse RuntimeImpl::GetHeapUsage(double *usedSize, double *totalSize) } DispatchResponse RuntimeImpl::GetProperties(std::unique_ptr params, - CVector> *outPropertyDesc, - [[maybe_unused]] std::optional>> *outInternalDescs, - [[maybe_unused]] std::optional>> *outPrivateProps, + std::vector> *outPropertyDesc, + [[maybe_unused]] std::optional>> *outInternalDescs, + [[maybe_unused]] std::optional>> *outPrivateProps, [[maybe_unused]] std::optional> *outExceptionDetails) { RemoteObjectId objectId = params->GetObjectId(); @@ -227,7 +227,7 @@ DispatchResponse RuntimeImpl::GetProperties(std::unique_ptr } void RuntimeImpl::AddTypedArrayRefs(Local arrayBufferRef, - CVector> *outPropertyDesc) + std::vector> *outPropertyDesc) { int32_t arrayBufferByteLength = arrayBufferRef->ByteLength(vm_); int32_t typedArrayLength = arrayBufferByteLength; @@ -258,7 +258,7 @@ void RuntimeImpl::AddTypedArrayRefs(Local arrayBufferRef, template void RuntimeImpl::AddTypedArrayRef(Local arrayBufferRef, int32_t length, const char* name, - CVector> *outPropertyDesc) + std::vector> *outPropertyDesc) { Local jsValueRefTypedArray(TypedArrayRef::New(vm_, arrayBufferRef, 0, length)); std::unique_ptr remoteObjectTypedArray = RemoteObject::FromTagged(vm_, jsValueRefTypedArray); @@ -283,7 +283,7 @@ void RuntimeImpl::CacheObjectIfNeeded(Local valRef, RemoteObject *re } void RuntimeImpl::GetProtoOrProtoType(const Local &value, bool isOwn, bool isAccessorOnly, - CVector> *outPropertyDesc) + std::vector> *outPropertyDesc) { if (!isAccessorOnly && isOwn && !value->IsProxy()) { return; @@ -317,7 +317,7 @@ void RuntimeImpl::GetProtoOrProtoType(const Local &value, bool isOwn } void RuntimeImpl::GetAdditionalProperties(const Local &value, - CVector> *outPropertyDesc) + std::vector> *outPropertyDesc) { // The length of the TypedArray have to be limited(less than or equal to lengthTypedArrayLimit) until we construct // the PropertyPreview class. Let lengthTypedArrayLimit be 10000 temporarily. @@ -343,7 +343,7 @@ void RuntimeImpl::GetAdditionalProperties(const Local &value, std::ostringstream osNameElement; osNameElement << std::right << std::setw(widthStrExprMaxElementIndex) << i; - CString cStrNameElement = CString(osNameElement.str()); + std::string cStrNameElement = osNameElement.str(); debuggerProperty->SetName(cStrNameElement) .SetWritable(true) .SetConfigurable(true) diff --git a/ecmascript/tooling/agent/runtime_impl.h b/ecmascript/tooling/agent/runtime_impl.h index 41ee6181ff..5ebad5ef43 100644 --- a/ecmascript/tooling/agent/runtime_impl.h +++ b/ecmascript/tooling/agent/runtime_impl.h @@ -37,9 +37,9 @@ public: DispatchResponse GetHeapUsage(double *usedSize, double *totalSize); DispatchResponse GetProperties( std::unique_ptr params, - CVector> *outPropertyDesc, - std::optional>> *outInternalDescs, - std::optional>> *outPrivateProps, + std::vector> *outPropertyDesc, + std::optional>> *outInternalDescs, + std::optional>> *outPrivateProps, std::optional> *outExceptionDetails); class DispatcherImpl final : public DispatcherBase { @@ -73,13 +73,13 @@ private: template void AddTypedArrayRef(Local arrayBufferRef, int32_t length, - const char* name, CVector> *outPropertyDesc); + const char* name, std::vector> *outPropertyDesc); void AddTypedArrayRefs(Local arrayBufferRef, - CVector> *outPropertyDesc); + std::vector> *outPropertyDesc); void GetProtoOrProtoType(const Local &value, bool isOwn, bool isAccessorOnly, - CVector> *outPropertyDesc); + std::vector> *outPropertyDesc); void GetAdditionalProperties(const Local &value, - CVector> *outPropertyDesc); + std::vector> *outPropertyDesc); class Frontend { public: @@ -97,7 +97,7 @@ private: Frontend frontend_; RemoteObjectId curObjectId_ {0}; - CUnorderedMap> properties_ {}; + std::unordered_map> properties_ {}; friend class DebuggerImpl; }; diff --git a/ecmascript/tooling/backend/debugger_api.cpp b/ecmascript/tooling/backend/debugger_api.cpp index 2fe331061f..0ca20e5e23 100644 --- a/ecmascript/tooling/backend/debugger_api.cpp +++ b/ecmascript/tooling/backend/debugger_api.cpp @@ -24,7 +24,6 @@ #include "ecmascript/js_handle.h" #include "ecmascript/js_method.h" #include "ecmascript/jspandafile/js_pandafile_manager.h" -#include "ecmascript/mem/c_string.h" #include "ecmascript/napi/jsnapi_helper.h" #include "ecmascript/tooling/backend/js_debugger.h" @@ -135,22 +134,17 @@ Local DebuggerApi::GetVRegValue(const EcmaVM *ecmaVm, return JSNApiHelper::ToLocal(handledValue); } -CString DebuggerApi::ToCString(Local str) +std::string DebuggerApi::ToStdString(Local str) { ecmascript::JSHandle ret = JSNApiHelper::ToJSHandle(str); ASSERT(ret->IsString()); EcmaString *ecmaStr = EcmaString::Cast(ret.GetTaggedValue().GetTaggedObject()); - return ConvertToString(ecmaStr); -} - -int32_t DebuggerApi::CStringToInt(const CString &str) -{ - return CStringToL(str); + return CstringConvertToStdString(ConvertToString(ecmaStr)); } int32_t DebuggerApi::StringToInt(Local str) { - return CStringToInt(ToCString(str)); + return std::stoi(ToStdString(str)); } // JSThread @@ -206,7 +200,7 @@ bool DebuggerApi::RemoveBreakpoint(JSDebugger *debugger, const JSPtLocation &loc } // JSMethod -CString DebuggerApi::ParseFunctionName(const JSMethod *method) +std::string DebuggerApi::ParseFunctionName(const JSMethod *method) { return method->ParseFunctionName(); } @@ -309,7 +303,7 @@ bool DebuggerApi::SetGlobalValue(const EcmaVM *vm, Local name, Local< return false; } -void DebuggerApi::HandleUncaughtException(const EcmaVM *ecmaVm, CString &message) +void DebuggerApi::HandleUncaughtException(const EcmaVM *ecmaVm, std::string &message) { JSThread *thread = ecmaVm->GetJSThread(); [[maybe_unused]] EcmaHandleScope handleScope(thread); diff --git a/ecmascript/tooling/backend/debugger_api.h b/ecmascript/tooling/backend/debugger_api.h index 774e01987c..2c71543970 100644 --- a/ecmascript/tooling/backend/debugger_api.h +++ b/ecmascript/tooling/backend/debugger_api.h @@ -20,7 +20,6 @@ #include "ecmascript/common.h" #include "ecmascript/jspandafile/scope_info_extractor.h" -#include "ecmascript/mem/c_string.h" #include "ecmascript/napi/include/jsnapi.h" #include "ecmascript/lexical_env.h" #include "ecmascript/tooling/backend/js_debugger_interface.h" @@ -70,8 +69,7 @@ public: static bool SetGlobalValue(const EcmaVM *vm, Local name, Local value); // String - static int32_t CStringToInt(const CString &str); - static CString ToCString(Local str); + static std::string ToStdString(Local str); static int32_t StringToInt(Local str); // JSThread @@ -89,14 +87,14 @@ public: static bool SetBreakpoint(JSDebugger *debugger, const JSPtLocation &location, const Local &condFuncRef); static bool RemoveBreakpoint(JSDebugger *debugger, const JSPtLocation &location); - static void HandleUncaughtException(const EcmaVM *ecmaVm, CString &message); + static void HandleUncaughtException(const EcmaVM *ecmaVm, std::string &message); static Local EvaluateViaFuncCall(EcmaVM *ecmaVm, const Local &funcRef, std::shared_ptr &frameHandler); static Local GenerateFuncFromBuffer(const EcmaVM *ecmaVm, const void *buffer, size_t size, std::string_view entryPoint); // JSMethod - static CString ParseFunctionName(const JSMethod *method); + static std::string ParseFunctionName(const JSMethod *method); }; } // namespace panda::ecmascript::tooling diff --git a/ecmascript/tooling/backend/js_pt_extractor.cpp b/ecmascript/tooling/backend/js_pt_extractor.cpp index 5a48add86d..c37311606b 100644 --- a/ecmascript/tooling/backend/js_pt_extractor.cpp +++ b/ecmascript/tooling/backend/js_pt_extractor.cpp @@ -83,9 +83,9 @@ std::unique_ptr JSPtExtractor::GetStepOutStepper(c return GetStepper(ecmaVm, SingleStepper::Type::OUT); } -CList JSPtExtractor::GetStepRanges(File::EntityId methodId, uint32_t offset) +std::list JSPtExtractor::GetStepRanges(File::EntityId methodId, uint32_t offset) { - CList ranges {}; + std::list ranges {}; const LineNumberTable &table = GetLineNumberTable(methodId); auto callbackFunc = [table, &ranges](int32_t line) -> bool { for (auto it = table.begin(); it != table.end(); ++it) { @@ -107,10 +107,10 @@ std::unique_ptr JSPtExtractor::GetStepper(const Ec ASSERT(method != nullptr); if (type == SingleStepper::Type::OUT) { - return std::make_unique(ecmaVm, method, CList {}, type); + return std::make_unique(ecmaVm, method, std::list {}, type); } - CList ranges = GetStepRanges(method->GetMethodId(), DebuggerApi::GetBytecodeOffset(ecmaVm)); + std::list ranges = GetStepRanges(method->GetMethodId(), DebuggerApi::GetBytecodeOffset(ecmaVm)); return std::make_unique(ecmaVm, method, std::move(ranges), type); } } // namespace panda::ecmascript::tooling diff --git a/ecmascript/tooling/backend/js_pt_extractor.h b/ecmascript/tooling/backend/js_pt_extractor.h index 9530f81dd3..e181b8df59 100644 --- a/ecmascript/tooling/backend/js_pt_extractor.h +++ b/ecmascript/tooling/backend/js_pt_extractor.h @@ -30,7 +30,7 @@ public: class SingleStepper { public: enum class Type { INTO, OVER, OUT }; - SingleStepper(const EcmaVM *ecmaVm, JSMethod *method, CList stepRanges, Type type) + SingleStepper(const EcmaVM *ecmaVm, JSMethod *method, std::list stepRanges, Type type) : ecmaVm_(ecmaVm), method_(method), stepRanges_(std::move(stepRanges)), @@ -50,7 +50,7 @@ public: const EcmaVM *ecmaVm_; JSMethod *method_; - CList stepRanges_; + std::list stepRanges_; uint32_t stackDepth_; Type type_; }; @@ -118,7 +118,7 @@ public: private: NO_COPY_SEMANTIC(JSPtExtractor); NO_MOVE_SEMANTIC(JSPtExtractor); - CList GetStepRanges(File::EntityId methodId, uint32_t offset); + std::list GetStepRanges(File::EntityId methodId, uint32_t offset); std::unique_ptr GetStepper(const EcmaVM *ecmaVm, SingleStepper::Type type); }; } // namespace panda::ecmascript::tooling diff --git a/ecmascript/tooling/base/pt_events.h b/ecmascript/tooling/base/pt_events.h index 398722b8e8..2b0c09fcc3 100644 --- a/ecmascript/tooling/base/pt_events.h +++ b/ecmascript/tooling/base/pt_events.h @@ -30,7 +30,7 @@ public: PtBaseEvents() = default; ~PtBaseEvents() override = default; Local ToObject(const EcmaVM *ecmaVm) const override = 0; - virtual CString GetName() const = 0; + virtual std::string GetName() const = 0; private: NO_COPY_SEMANTIC(PtBaseEvents); @@ -43,7 +43,7 @@ public: ~BreakpointResolved() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Debugger.breakpointResolved"; } @@ -84,23 +84,23 @@ public: ~Paused() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Debugger.paused"; } - const CVector> *GetCallFrames() const + const std::vector> *GetCallFrames() const { return &callFrames_; } - Paused &SetCallFrames(CVector> callFrames) + Paused &SetCallFrames(std::vector> callFrames) { callFrames_ = std::move(callFrames); return *this; } - const CString &GetReason() const + const std::string &GetReason() const { return reason_; } @@ -111,7 +111,7 @@ public: return *this; } - static CString GetReasonString(PauseReason reason) + static std::string GetReasonString(PauseReason reason) { switch (reason) { case AMBIGUOUS: { @@ -176,12 +176,12 @@ public: return data_.has_value(); } - CVector GetHitBreakpoints() const + std::vector GetHitBreakpoints() const { - return hitBreakpoints_.value_or(CVector()); + return hitBreakpoints_.value_or(std::vector()); } - Paused &SetHitBreakpoints(CVector hitBreakpoints) + Paused &SetHitBreakpoints(std::vector hitBreakpoints) { hitBreakpoints_ = std::move(hitBreakpoints); return *this; @@ -196,10 +196,10 @@ private: NO_COPY_SEMANTIC(Paused); NO_MOVE_SEMANTIC(Paused); - CVector> callFrames_ {}; - CString reason_ {}; + std::vector> callFrames_ {}; + std::string reason_ {}; std::optional> data_ {}; - std::optional> hitBreakpoints_ {}; + std::optional> hitBreakpoints_ {}; }; class Resumed final : public PtBaseEvents { @@ -208,7 +208,7 @@ public: ~Resumed() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Debugger.resumed"; } @@ -224,7 +224,7 @@ public: ~ScriptFailedToParse() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Debugger.scriptFailedToParse"; } @@ -240,12 +240,12 @@ public: return *this; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_; } - ScriptFailedToParse &SetUrl(const CString &url) + ScriptFailedToParse &SetUrl(const std::string &url) { url_ = url; return *this; @@ -306,12 +306,12 @@ public: return *this; } - const CString &GetHash() const + const std::string &GetHash() const { return hash_; } - ScriptFailedToParse &SetHash(const CString &hash) + ScriptFailedToParse &SetHash(const std::string &hash) { hash_ = hash; return *this; @@ -333,12 +333,12 @@ public: return execContextAuxData_.has_value(); } - const CString &GetSourceMapURL() const + const std::string &GetSourceMapURL() const { return sourceMapUrl_.value(); } - ScriptFailedToParse &SetSourceMapURL(const CString &sourceMapUrl) + ScriptFailedToParse &SetSourceMapURL(const std::string &sourceMapUrl) { sourceMapUrl_ = sourceMapUrl; return *this; @@ -413,12 +413,12 @@ public: return codeOffset_.has_value(); } - const CString &GetScriptLanguage() const + const std::string &GetScriptLanguage() const { return scriptLanguage_.value(); } - ScriptFailedToParse &SetScriptLanguage(const CString &scriptLanguage) + ScriptFailedToParse &SetScriptLanguage(const std::string &scriptLanguage) { scriptLanguage_ = scriptLanguage; return *this; @@ -429,12 +429,12 @@ public: return scriptLanguage_.has_value(); } - const CString &GetEmbedderName() const + const std::string &GetEmbedderName() const { return embedderName_.value(); } - ScriptFailedToParse &SetEmbedderName(const CString &embedderName) + ScriptFailedToParse &SetEmbedderName(const std::string &embedderName) { embedderName_ = embedderName; return *this; @@ -450,21 +450,21 @@ private: NO_MOVE_SEMANTIC(ScriptFailedToParse); ScriptId scriptId_ {}; - CString url_ {}; + std::string url_ {}; int32_t startLine_ {0}; int32_t startColumn_ {0}; int32_t endLine_ {0}; int32_t endColumn_ {0}; ExecutionContextId executionContextId_ {0}; - CString hash_ {}; + std::string hash_ {}; std::optional> execContextAuxData_ {}; - std::optional sourceMapUrl_ {}; + std::optional sourceMapUrl_ {}; std::optional hasSourceUrl_ {}; std::optional isModule_ {}; std::optional length_ {}; std::optional codeOffset_ {}; - std::optional scriptLanguage_ {}; - std::optional embedderName_ {}; + std::optional scriptLanguage_ {}; + std::optional embedderName_ {}; }; class ScriptParsed final : public PtBaseEvents { @@ -473,7 +473,7 @@ public: ~ScriptParsed() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Debugger.scriptParsed"; } @@ -489,12 +489,12 @@ public: return *this; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_; } - ScriptParsed &SetUrl(const CString &url) + ScriptParsed &SetUrl(const std::string &url) { url_ = url; return *this; @@ -555,12 +555,12 @@ public: return *this; } - const CString &GetHash() const + const std::string &GetHash() const { return hash_; } - ScriptParsed &SetHash(const CString &hash) + ScriptParsed &SetHash(const std::string &hash) { hash_ = hash; return *this; @@ -598,12 +598,12 @@ public: return execContextAuxData_.has_value(); } - const CString &GetSourceMapURL() const + const std::string &GetSourceMapURL() const { return sourceMapUrl_.value(); } - ScriptParsed &SetSourceMapURL(const CString &sourceMapUrl) + ScriptParsed &SetSourceMapURL(const std::string &sourceMapUrl) { sourceMapUrl_ = sourceMapUrl; return *this; @@ -678,12 +678,12 @@ public: return codeOffset_.has_value(); } - const CString &GetScriptLanguage() const + const std::string &GetScriptLanguage() const { return scriptLanguage_.value(); } - ScriptParsed &SetScriptLanguage(const CString &scriptLanguage) + ScriptParsed &SetScriptLanguage(const std::string &scriptLanguage) { scriptLanguage_ = scriptLanguage; return *this; @@ -694,12 +694,12 @@ public: return scriptLanguage_.has_value(); } - const CString &GetEmbedderName() const + const std::string &GetEmbedderName() const { return embedderName_.value(); } - ScriptParsed &SetEmbedderName(const CString &embedderName) + ScriptParsed &SetEmbedderName(const std::string &embedderName) { embedderName_ = embedderName; return *this; @@ -715,22 +715,22 @@ private: NO_MOVE_SEMANTIC(ScriptParsed); ScriptId scriptId_ {}; - CString url_ {}; + std::string url_ {}; int32_t startLine_ {0}; int32_t startColumn_ {0}; int32_t endLine_ {0}; int32_t endColumn_ {0}; ExecutionContextId executionContextId_ {0}; - CString hash_ {}; + std::string hash_ {}; std::optional> execContextAuxData_ {}; std::optional isLiveEdit_ {}; - std::optional sourceMapUrl_ {}; + std::optional sourceMapUrl_ {}; std::optional hasSourceUrl_ {}; std::optional isModule_ {}; std::optional length_ {}; std::optional codeOffset_ {}; - std::optional scriptLanguage_ {}; - std::optional embedderName_ {}; + std::optional scriptLanguage_ {}; + std::optional embedderName_ {}; }; class AddHeapSnapshotChunk final : public PtBaseEvents { @@ -739,12 +739,12 @@ public: ~AddHeapSnapshotChunk() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "HeapProfiler.addHeapSnapshotChunk"; } - CString &GetChunk() + std::string &GetChunk() { return chunk_; } @@ -753,7 +753,7 @@ private: NO_COPY_SEMANTIC(AddHeapSnapshotChunk); NO_MOVE_SEMANTIC(AddHeapSnapshotChunk); - CString chunk_ {}; + std::string chunk_ {}; }; class ConsoleProfileFinished final : public PtBaseEvents { @@ -761,17 +761,17 @@ public: ConsoleProfileFinished() = default; ~ConsoleProfileFinished() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Profile.ConsoleProfileFinished"; } - const CString &GetId() const + const std::string &GetId() const { return id_; } - ConsoleProfileFinished &SetId(const CString &id) + ConsoleProfileFinished &SetId(const std::string &id) { id_ = id; return *this; @@ -799,12 +799,12 @@ public: return *this; } - const CString &GetTitle() const + const std::string &GetTitle() const { return title_.value(); } - ConsoleProfileFinished &SetTitle(const CString &title) + ConsoleProfileFinished &SetTitle(const std::string &title) { title_ = title; return *this; @@ -819,10 +819,10 @@ private: NO_COPY_SEMANTIC(ConsoleProfileFinished); NO_MOVE_SEMANTIC(ConsoleProfileFinished); - CString id_ {}; + std::string id_ {}; std::unique_ptr location_ {nullptr}; std::unique_ptr profile_ {nullptr}; - std::optional title_ {}; + std::optional title_ {}; }; class ConsoleProfileStarted final : public PtBaseEvents { @@ -830,17 +830,17 @@ public: ConsoleProfileStarted() = default; ~ConsoleProfileStarted() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Profile.ConsoleProfileStarted"; } - const CString &GetId() const + const std::string &GetId() const { return id_; } - ConsoleProfileStarted &SetId(const CString &id) + ConsoleProfileStarted &SetId(const std::string &id) { id_ = id; return *this; @@ -857,12 +857,12 @@ public: return *this; } - const CString &GetTitle() const + const std::string &GetTitle() const { return title_.value(); } - ConsoleProfileStarted &SetTitle(const CString &title) + ConsoleProfileStarted &SetTitle(const std::string &title) { title_ = title; return *this; @@ -877,9 +877,9 @@ private: NO_COPY_SEMANTIC(ConsoleProfileStarted); NO_MOVE_SEMANTIC(ConsoleProfileStarted); - CString id_ {}; + std::string id_ {}; std::unique_ptr location_ {nullptr}; - std::optional title_ {}; + std::optional title_ {}; }; class PreciseCoverageDeltaUpdate final : public PtBaseEvents { @@ -887,7 +887,7 @@ public: PreciseCoverageDeltaUpdate() = default; ~PreciseCoverageDeltaUpdate() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "Profile.PreciseCoverageDeltaUpdate"; } @@ -903,23 +903,23 @@ public: return *this; } - const CString &GetOccasion() const + const std::string &GetOccasion() const { return occasion_; } - PreciseCoverageDeltaUpdate &SetOccasion(const CString &occasion) + PreciseCoverageDeltaUpdate &SetOccasion(const std::string &occasion) { occasion_ = occasion; return *this; } - const CVector> *GetResult() const + const std::vector> *GetResult() const { return &result_; } - PreciseCoverageDeltaUpdate &SetResult(CVector> result) + PreciseCoverageDeltaUpdate &SetResult(std::vector> result) { result_ = std::move(result); return *this; @@ -930,8 +930,8 @@ private: NO_MOVE_SEMANTIC(PreciseCoverageDeltaUpdate); int64_t timestamp_ {0}; - CString occasion_ {}; - CVector> result_ {}; + std::string occasion_ {}; + std::vector> result_ {}; }; class HeapStatsUpdate final : public PtBaseEvents { @@ -940,17 +940,17 @@ public: ~HeapStatsUpdate() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "HeapProfiler.heapStatsUpdate"; } - const CVector *GetStatsUpdate() const + const std::vector *GetStatsUpdate() const { return &statsUpdate_; } - HeapStatsUpdate &SetStatsUpdate(CVector statsUpdate) + HeapStatsUpdate &SetStatsUpdate(std::vector statsUpdate) { statsUpdate_ = std::move(statsUpdate); return *this; @@ -960,7 +960,7 @@ private: NO_COPY_SEMANTIC(HeapStatsUpdate); NO_MOVE_SEMANTIC(HeapStatsUpdate); - CVector statsUpdate_ {}; + std::vector statsUpdate_ {}; }; class LastSeenObjectId final : public PtBaseEvents { @@ -969,7 +969,7 @@ public: ~LastSeenObjectId() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "HeapProfiler.lastSeenObjectId"; } @@ -1010,7 +1010,7 @@ public: ~ReportHeapSnapshotProgress() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const override + std::string GetName() const override { return "HeapProfiler.reportHeapSnapshotProgress"; } diff --git a/ecmascript/tooling/base/pt_params.cpp b/ecmascript/tooling/base/pt_params.cpp index 3347063c85..b03f3235b7 100644 --- a/ecmascript/tooling/base/pt_params.cpp +++ b/ecmascript/tooling/base/pt_params.cpp @@ -23,7 +23,7 @@ std::unique_ptr EnableParams::Create(const EcmaVM *ecmaVm, const L LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -51,7 +51,7 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con LOG(ERROR, DEBUGGER) << "EvaluateOnCallFrameParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -69,7 +69,7 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "expression"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->expression_ = DebuggerApi::ToCString(result); + paramsObject->expression_ = DebuggerApi::ToStdString(result); } else { error += "'expression' should be a String;"; } @@ -79,7 +79,7 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "objectGroup"))); if (!result.IsEmpty() && result->IsString()) { - paramsObject->objectGroup_ = DebuggerApi::ToCString(result); + paramsObject->objectGroup_ = DebuggerApi::ToStdString(result); } result = Local(params)->Get(ecmaVm, @@ -125,7 +125,7 @@ std::unique_ptr GetPossibleBreakpointsParams::Crea LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -182,7 +182,7 @@ std::unique_ptr GetScriptSourceParams::Create(const EcmaV LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -212,14 +212,14 @@ std::unique_ptr RemoveBreakpointParams::Create(const Ecm LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "breakpointId"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->breakpointId_ = DebuggerApi::ToCString(result); + paramsObject->breakpointId_ = DebuggerApi::ToStdString(result); } else { error += "'breakpointId' should be a String;"; } @@ -241,7 +241,7 @@ std::unique_ptr ResumeParams::Create(const EcmaVM *ecmaVm, const L LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -269,7 +269,7 @@ std::unique_ptr SetAsyncCallStackDepthParams::Crea LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -299,7 +299,7 @@ std::unique_ptr SetBlackboxPatternsParams::Create(con LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -314,7 +314,7 @@ std::unique_ptr SetBlackboxPatternsParams::Create(con Local value = Local(array)->Get(ecmaVm, key->ToString(ecmaVm)); if (value->IsString()) { paramsObject->patterns_.emplace_back( - DebuggerApi::ToCString(value)); + DebuggerApi::ToStdString(value)); } else { error += "'patterns' items should be a String;"; } @@ -341,7 +341,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -358,7 +358,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->url_ = DebuggerApi::ToCString(result); + paramsObject->url_ = DebuggerApi::ToStdString(result); } else { error += "'url' should be a String;"; } @@ -366,7 +366,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "urlRegex"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->urlRegex_ = DebuggerApi::ToCString(result); + paramsObject->urlRegex_ = DebuggerApi::ToStdString(result); } else { error += "'urlRegex' should be a String;"; } @@ -374,7 +374,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptHash"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->scriptHash_ = DebuggerApi::ToCString(result); + paramsObject->scriptHash_ = DebuggerApi::ToStdString(result); } else { error += "'scriptHash' should be a String;"; } @@ -390,7 +390,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "condition"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->condition_ = DebuggerApi::ToCString(result); + paramsObject->condition_ = DebuggerApi::ToStdString(result); } else { error += "'condition' should be a String;"; } @@ -411,14 +411,14 @@ std::unique_ptr SetPauseOnExceptionsParams::Create(c LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "state"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - if (!paramsObject->StoreState(DebuggerApi::ToCString(result))) { + if (!paramsObject->StoreState(DebuggerApi::ToStdString(result))) { error += "'state' is invalid;"; } } else { @@ -442,7 +442,7 @@ std::unique_ptr StepIntoParams::Create(const EcmaVM *ecmaVm, con LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -493,7 +493,7 @@ std::unique_ptr StepOverParams::Create(const EcmaVM *ecmaVm, con LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -536,7 +536,7 @@ std::unique_ptr GetPropertiesParams::Create(const EcmaVM *e LOG(ERROR, DEBUGGER) << "GetPropertiesParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = @@ -592,7 +592,7 @@ std::unique_ptr CallFunctionOnParams::Create(const EcmaVM LOG(ERROR, DEBUGGER) << "CallFunctionOnParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); // paramsObject->functionDeclaration_ @@ -600,7 +600,7 @@ std::unique_ptr CallFunctionOnParams::Create(const EcmaVM Local(StringRef::NewFromUtf8(ecmaVm, "functionDeclaration"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->functionDeclaration_ = DebuggerApi::ToCString(result); + paramsObject->functionDeclaration_ = DebuggerApi::ToStdString(result); } else { error += "'functionDeclaration' should be a String;"; } @@ -701,7 +701,7 @@ std::unique_ptr CallFunctionOnParams::Create(const EcmaVM result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "objectGroup"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->objectGroup_ = DebuggerApi::ToCString(result); + paramsObject->objectGroup_ = DebuggerApi::ToStdString(result); } else { error += "'objectGroup' should be a String;"; } @@ -716,7 +716,7 @@ std::unique_ptr CallFunctionOnParams::Create(const EcmaVM error += "'throwOnSideEffect' should be a Boolean;"; } } - // Check whether the CString(error) is empty. + // Check whether the error is empty. if (!error.empty()) { LOG(ERROR, DEBUGGER) << "CallFunctionOnParams::Create " << error; return nullptr; @@ -733,7 +733,7 @@ std::unique_ptr StartSamplingParams::Create(const EcmaVM *e LOG(ERROR, DEBUGGER) << "StartSamplingParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -771,7 +771,7 @@ std::unique_ptr StartTrackingHeapObjectsParams:: LOG(ERROR, DEBUGGER) << "StartTrackingHeapObjectsParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -808,7 +808,7 @@ std::unique_ptr StopTrackingHeapObjectsParams::Cr LOG(ERROR, DEBUGGER) << "StopTrackingHeapObjectsParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -870,7 +870,7 @@ std::unique_ptr AddInspectedHeapObjectParams::Crea LOG(ERROR, DEBUGGER) << "AddInspectedHeapObjectParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -911,7 +911,7 @@ std::unique_ptr GetHeapObjectIdParams::Create(const EcmaV LOG(ERROR, DEBUGGER) << "GetHeapObjectIdParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -951,7 +951,7 @@ std::unique_ptr GetObjectByHeapObjectIdParams::Cr LOG(ERROR, DEBUGGER) << "GetObjectByHeapObjectIdParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -970,7 +970,7 @@ std::unique_ptr GetObjectByHeapObjectIdParams::Cr Local(StringRef::NewFromUtf8(ecmaVm, "objectGroup"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - paramsObject->objectGroup_ = DebuggerApi::ToCString(result); + paramsObject->objectGroup_ = DebuggerApi::ToStdString(result); } else { error += "'objectGroup' should be a String;"; } @@ -1004,7 +1004,7 @@ std::unique_ptr StartPreciseCoverageParam::Create(con LOG(ERROR, DEBUGGER) << "StartPreciseCoverageParam::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -1066,7 +1066,7 @@ std::unique_ptr SetSamplingIntervalParams::Create(con LOG(ERROR, DEBUGGER) << "SetSamplingIntervalParams::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto paramsObject = std::make_unique(); Local result = diff --git a/ecmascript/tooling/base/pt_params.h b/ecmascript/tooling/base/pt_params.h index c14c7819a4..06eb0104dd 100644 --- a/ecmascript/tooling/base/pt_params.h +++ b/ecmascript/tooling/base/pt_params.h @@ -75,7 +75,7 @@ public: return callFrameId_; } - const CString &GetExpression() + const std::string &GetExpression() { return expression_; } @@ -85,8 +85,8 @@ private: NO_MOVE_SEMANTIC(EvaluateOnCallFrameParams); CallFrameId callFrameId_ {}; - CString expression_ {}; - std::optional objectGroup_ {}; + std::string expression_ {}; + std::optional objectGroup_ {}; std::optional includeCommandLineApi_ {}; std::optional silent_ {}; std::optional returnByValue_ {}; @@ -249,7 +249,7 @@ public: return Local(); } - CList GetPatterns() const + std::list GetPatterns() const { return patterns_; } @@ -258,7 +258,7 @@ private: NO_COPY_SEMANTIC(SetBlackboxPatternsParams); NO_MOVE_SEMANTIC(SetBlackboxPatternsParams); - CList patterns_ {}; + std::list patterns_ {}; }; class SetBreakpointByUrlParams : public PtBaseParams { @@ -277,7 +277,7 @@ public: return line_; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_.value(); } @@ -287,7 +287,7 @@ public: return url_.has_value(); } - const CString &GetUrlRegex() const + const std::string &GetUrlRegex() const { return urlRegex_.value(); } @@ -297,7 +297,7 @@ public: return urlRegex_.has_value(); } - const CString &GetScriptHash() const + const std::string &GetScriptHash() const { return scriptHash_.value(); } @@ -317,7 +317,7 @@ public: return column_.has_value(); } - const CString &GetCondition() const + const std::string &GetCondition() const { return condition_.value(); } @@ -332,11 +332,11 @@ private: NO_MOVE_SEMANTIC(SetBreakpointByUrlParams); int32_t line_ {0}; - std::optional url_ {}; - std::optional urlRegex_ {}; - std::optional scriptHash_ {}; + std::optional url_ {}; + std::optional urlRegex_ {}; + std::optional scriptHash_ {}; std::optional column_ {0}; - std::optional condition_ {}; + std::optional condition_ {}; }; enum class PauseOnExceptionsState : uint8_t { NONE, UNCAUGHT, ALL }; @@ -356,7 +356,7 @@ public: return state_; } - bool StoreState(const CString &state) + bool StoreState(const std::string &state) { if (state == "none") { state_ = PauseOnExceptionsState::NONE; @@ -401,7 +401,7 @@ public: return breakOnAsyncCall_.has_value(); } - const CList> *GetSkipList() const + const std::list> *GetSkipList() const { if (!skipList_) { return nullptr; @@ -419,7 +419,7 @@ private: NO_MOVE_SEMANTIC(StepIntoParams); std::optional breakOnAsyncCall_ {}; - std::optional>> skipList_ {}; + std::optional>> skipList_ {}; }; class StepOverParams : public PtBaseParams { @@ -433,7 +433,7 @@ public: return Local(); } - const CList> *GetSkipList() const + const std::list> *GetSkipList() const { if (!skipList_) { return nullptr; @@ -450,7 +450,7 @@ private: NO_COPY_SEMANTIC(StepOverParams); NO_MOVE_SEMANTIC(StepOverParams); - std::optional>> skipList_ {}; + std::optional>> skipList_ {}; }; class GetPropertiesParams : public PtBaseParams { @@ -520,7 +520,7 @@ public: return Local(); } - const CString &GetFunctionDeclaration() + const std::string &GetFunctionDeclaration() { return functionDeclaration_; } @@ -541,7 +541,7 @@ public: return objectId_.has_value(); } - const CVector> *GetArguments() const + const std::vector> *GetArguments() const { if (!arguments_) { return nullptr; @@ -620,7 +620,7 @@ public: return executionContextId_.has_value(); } - const CString &GetObjectGroup() const + const std::string &GetObjectGroup() const { return objectGroup_.value(); } @@ -644,16 +644,16 @@ private: NO_COPY_SEMANTIC(CallFunctionOnParams); NO_MOVE_SEMANTIC(CallFunctionOnParams); - CString functionDeclaration_ {}; + std::string functionDeclaration_ {}; std::optional objectId_ {}; - std::optional>> arguments_ {}; + std::optional>> arguments_ {}; std::optional silent_ {}; std::optional returnByValue_ {}; std::optional generatePreview_ {}; std::optional userGesture_ {}; std::optional awaitPromise_ {}; std::optional executionContextId_ {}; - std::optional objectGroup_ {}; + std::optional objectGroup_ {}; std::optional throwOnSideEffect_ {}; }; @@ -803,7 +803,7 @@ public: return objectId_; } - const CString &GetObjectGroup() const + const std::string &GetObjectGroup() const { return objectGroup_.value(); } @@ -818,7 +818,7 @@ private: NO_MOVE_SEMANTIC(GetObjectByHeapObjectIdParams); HeapSnapshotObjectId objectId_ {}; - std::optional objectGroup_ {}; + std::optional objectGroup_ {}; }; class StartPreciseCoverageParam : public PtBaseParams { diff --git a/ecmascript/tooling/base/pt_returns.cpp b/ecmascript/tooling/base/pt_returns.cpp index f39a9afecd..2358b83dda 100644 --- a/ecmascript/tooling/base/pt_returns.cpp +++ b/ecmascript/tooling/base/pt_returns.cpp @@ -152,7 +152,7 @@ Local SetScriptSourceReturns::ToObject(const EcmaVM *ecmaVm) const Local result = NewObject(ecmaVm); if (callFrames_) { - const CVector> &callFrame = callFrames_.value(); + const std::vector> &callFrame = callFrames_.value(); size_t len = callFrame.size(); Local values = ArrayRef::New(ecmaVm, len); for (size_t i = 0; i < len; i++) { diff --git a/ecmascript/tooling/base/pt_returns.h b/ecmascript/tooling/base/pt_returns.h index 8ed0fc8cc7..eb0993a649 100644 --- a/ecmascript/tooling/base/pt_returns.h +++ b/ecmascript/tooling/base/pt_returns.h @@ -51,7 +51,7 @@ private: class SetBreakpointByUrlReturns : public PtBaseReturns { public: - explicit SetBreakpointByUrlReturns(const CString &id, CVector> locations) + explicit SetBreakpointByUrlReturns(const std::string &id, std::vector> locations) : id_(id), locations_(std::move(locations)) {} ~SetBreakpointByUrlReturns() override = default; @@ -63,8 +63,8 @@ private: NO_COPY_SEMANTIC(SetBreakpointByUrlReturns); NO_MOVE_SEMANTIC(SetBreakpointByUrlReturns); - CString id_ {}; - CVector> locations_ {}; + std::string id_ {}; + std::vector> locations_ {}; }; class EvaluateOnCallFrameReturns : public PtBaseReturns { @@ -87,7 +87,7 @@ private: class GetPossibleBreakpointsReturns : public PtBaseReturns { public: - explicit GetPossibleBreakpointsReturns(CVector> locations) + explicit GetPossibleBreakpointsReturns(std::vector> locations) : locations_(std::move(locations)) {} ~GetPossibleBreakpointsReturns() override = default; @@ -99,12 +99,12 @@ private: NO_COPY_SEMANTIC(GetPossibleBreakpointsReturns); NO_MOVE_SEMANTIC(GetPossibleBreakpointsReturns); - CVector> locations_ {}; + std::vector> locations_ {}; }; class GetScriptSourceReturns : public PtBaseReturns { public: - explicit GetScriptSourceReturns(const CString &scriptSource, std::optional bytecode = std::nullopt) + explicit GetScriptSourceReturns(const std::string &scriptSource, std::optional bytecode = std::nullopt) : scriptSource_(scriptSource), bytecode_(std::move(bytecode)) {} ~GetScriptSourceReturns() override = default; @@ -116,13 +116,13 @@ private: NO_COPY_SEMANTIC(GetScriptSourceReturns); NO_MOVE_SEMANTIC(GetScriptSourceReturns); - CString scriptSource_ {}; - std::optional bytecode_ {}; + std::string scriptSource_ {}; + std::optional bytecode_ {}; }; class RestartFrameReturns : public PtBaseReturns { public: - explicit RestartFrameReturns(CVector> callFrames) + explicit RestartFrameReturns(std::vector> callFrames) : callFrames_(std::move(callFrames)) {} ~RestartFrameReturns() override = default; @@ -133,12 +133,12 @@ private: NO_COPY_SEMANTIC(RestartFrameReturns); NO_MOVE_SEMANTIC(RestartFrameReturns); - CVector> callFrames_ {}; + std::vector> callFrames_ {}; }; class SearchInContentReturns : public PtBaseReturns { public: - explicit SearchInContentReturns(CVector> result) : result_(std::move(result)) + explicit SearchInContentReturns(std::vector> result) : result_(std::move(result)) {} ~SearchInContentReturns() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; @@ -148,12 +148,12 @@ private: NO_COPY_SEMANTIC(SearchInContentReturns); NO_MOVE_SEMANTIC(SearchInContentReturns); - CVector> result_ {}; + std::vector> result_ {}; }; class SetBreakpointReturns : public PtBaseReturns { public: - explicit SetBreakpointReturns(const CString &id, std::unique_ptr location) + explicit SetBreakpointReturns(const std::string &id, std::unique_ptr location) : breakpointId_(id), location_(std::move(location)) {} ~SetBreakpointReturns() override = default; @@ -163,13 +163,13 @@ private: SetBreakpointReturns() = default; NO_COPY_SEMANTIC(SetBreakpointReturns); NO_MOVE_SEMANTIC(SetBreakpointReturns); - CString breakpointId_ {}; + std::string breakpointId_ {}; std::unique_ptr location_ {}; }; class SetInstrumentationBreakpointReturns : public PtBaseReturns { public: - explicit SetInstrumentationBreakpointReturns(const CString &id) : breakpointId_(id) + explicit SetInstrumentationBreakpointReturns(const std::string &id) : breakpointId_(id) {} ~SetInstrumentationBreakpointReturns() override = default; Local ToObject(const EcmaVM *ecmaVm) const override; @@ -179,12 +179,12 @@ private: NO_COPY_SEMANTIC(SetInstrumentationBreakpointReturns); NO_MOVE_SEMANTIC(SetInstrumentationBreakpointReturns); - CString breakpointId_ {}; + std::string breakpointId_ {}; }; class SetScriptSourceReturns : public PtBaseReturns { public: - explicit SetScriptSourceReturns(std::optional>> callFrames = std::nullopt, + explicit SetScriptSourceReturns(std::optional>> callFrames = std::nullopt, std::optional stackChanged = std::nullopt, std::optional> exceptionDetails = std::nullopt) : callFrames_(std::move(callFrames)), @@ -199,16 +199,16 @@ private: NO_COPY_SEMANTIC(SetScriptSourceReturns); NO_MOVE_SEMANTIC(SetScriptSourceReturns); - std::optional>> callFrames_ {}; + std::optional>> callFrames_ {}; std::optional stackChanged_ {}; std::optional> exceptionDetails_ {}; }; class GetPropertiesReturns : public PtBaseReturns { public: - explicit GetPropertiesReturns(CVector> descriptor, - std::optional>> internalDescripties = std::nullopt, - std::optional>> privateProperties = std::nullopt, + explicit GetPropertiesReturns(std::vector> descriptor, + std::optional>> internalDescripties = std::nullopt, + std::optional>> privateProperties = std::nullopt, std::optional> exceptionDetails = std::nullopt) : result_(std::move(descriptor)), internalPropertyDescripties_(std::move(internalDescripties)), @@ -223,9 +223,9 @@ private: NO_COPY_SEMANTIC(GetPropertiesReturns); NO_MOVE_SEMANTIC(GetPropertiesReturns); - CVector> result_ {}; - std::optional>> internalPropertyDescripties_ {}; - std::optional>> privateProperties_ {}; + std::vector> result_ {}; + std::optional>> internalPropertyDescripties_ {}; + std::optional>> privateProperties_ {}; std::optional> exceptionDetails_ {}; }; @@ -331,7 +331,7 @@ private: class GetBestEffortCoverageReturns : public PtBaseReturns { public: - explicit GetBestEffortCoverageReturns(CVector> result) + explicit GetBestEffortCoverageReturns(std::vector> result) : result_(std::move(result)) {} ~GetBestEffortCoverageReturns() override = default; @@ -342,7 +342,7 @@ private: NO_COPY_SEMANTIC(GetBestEffortCoverageReturns); NO_MOVE_SEMANTIC(GetBestEffortCoverageReturns); - CVector> result_ {}; + std::vector> result_ {}; }; class StartPreciseCoverageReturns : public PtBaseReturns { @@ -361,7 +361,7 @@ private: class TakePreciseCoverageReturns : public PtBaseReturns { public: - explicit TakePreciseCoverageReturns(CVector> result, size_t tamp) + explicit TakePreciseCoverageReturns(std::vector> result, size_t tamp) : result_(std::move(result)), timestamp_(tamp) {} @@ -373,13 +373,13 @@ private: NO_COPY_SEMANTIC(TakePreciseCoverageReturns); NO_MOVE_SEMANTIC(TakePreciseCoverageReturns); - CVector> result_ {}; + std::vector> result_ {}; size_t timestamp_ {0}; }; class TakeTypeProfileturns : public PtBaseReturns { public: - explicit TakeTypeProfileturns(CVector> result) + explicit TakeTypeProfileturns(std::vector> result) : result_(std::move(result)) {} ~TakeTypeProfileturns() override = default; @@ -390,7 +390,7 @@ private: NO_COPY_SEMANTIC(TakeTypeProfileturns); NO_MOVE_SEMANTIC(TakeTypeProfileturns); - CVector> result_ {}; + std::vector> result_ {}; }; } // namespace panda::ecmascript::tooling #endif \ No newline at end of file diff --git a/ecmascript/tooling/base/pt_script.cpp b/ecmascript/tooling/base/pt_script.cpp index ad3bc09855..120442d93b 100644 --- a/ecmascript/tooling/base/pt_script.cpp +++ b/ecmascript/tooling/base/pt_script.cpp @@ -17,7 +17,7 @@ #include "ecmascript/tooling/backend/debugger_api.h" namespace panda::ecmascript::tooling { -PtScript::PtScript(ScriptId scriptId, const CString &fileName, const CString &url, const CString &source) +PtScript::PtScript(ScriptId scriptId, const std::string &fileName, const std::string &url, const std::string &source) : scriptId_(scriptId), fileName_(fileName), url_(url), diff --git a/ecmascript/tooling/base/pt_script.h b/ecmascript/tooling/base/pt_script.h index 16a3364e25..a7425bb8e5 100644 --- a/ecmascript/tooling/base/pt_script.h +++ b/ecmascript/tooling/base/pt_script.h @@ -28,7 +28,7 @@ enum class ScriptMatchType : uint8_t { class PtScript { public: - PtScript(ScriptId scriptId, const CString &fileName, const CString &url, const CString &source); + PtScript(ScriptId scriptId, const std::string &fileName, const std::string &url, const std::string &source); ~PtScript() = default; ScriptId GetScriptId() const @@ -41,52 +41,52 @@ public: scriptId_ = scriptId; } - const CString &GetFileName() const + const std::string &GetFileName() const { return fileName_; } - void SetFileName(const CString &fileName) + void SetFileName(const std::string &fileName) { fileName_ = fileName; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_; } - void SetUrl(const CString &url) + void SetUrl(const std::string &url) { url_ = url; } - const CString &GetHash() const + const std::string &GetHash() const { return hash_; } - void SetHash(const CString &hash) + void SetHash(const std::string &hash) { hash_ = hash; } - const CString &GetScriptSource() const + const std::string &GetScriptSource() const { return scriptSource_; } - void SetScriptSource(const CString &scriptSource) + void SetScriptSource(const std::string &scriptSource) { scriptSource_ = scriptSource; } - const CString &GetSourceMapUrl() const + const std::string &GetSourceMapUrl() const { return sourceMapUrl_; } - void SetSourceMapUrl(const CString &sourceMapUrl) + void SetSourceMapUrl(const std::string &sourceMapUrl) { sourceMapUrl_ = sourceMapUrl; } @@ -106,11 +106,11 @@ private: NO_MOVE_SEMANTIC(PtScript); ScriptId scriptId_ {}; // start from 0, such as "0","1","2"... - CString fileName_ {}; // binary file name, such as xx.bin - CString url_ {}; // source file name, such as xx.js - CString hash_ {}; // js source file hash code - CString scriptSource_ {}; // js source code - CString sourceMapUrl_ {}; // source map url + std::string fileName_ {}; // binary file name, such as xx.bin + std::string url_ {}; // source file name, such as xx.js + std::string hash_ {}; // js source file hash code + std::string scriptSource_ {}; // js source code + std::string sourceMapUrl_ {}; // source map url int32_t endLine_ {0}; // total line number of source file }; } // namespace panda::ecmascript::tooling diff --git a/ecmascript/tooling/base/pt_types.cpp b/ecmascript/tooling/base/pt_types.cpp index be87bbe3d2..ffe4195a03 100644 --- a/ecmascript/tooling/base/pt_types.cpp +++ b/ecmascript/tooling/base/pt_types.cpp @@ -22,73 +22,73 @@ using ObjectType = RemoteObject::TypeName; using ObjectSubType = RemoteObject::SubTypeName; using ObjectClassName = RemoteObject::ClassName; -const CString ObjectType::Object = "object"; // NOLINT (readability-identifier-naming) -const CString ObjectType::Function = "function"; // NOLINT (readability-identifier-naming) -const CString ObjectType::Undefined = "undefined"; // NOLINT (readability-identifier-naming) -const CString ObjectType::String = "string"; // NOLINT (readability-identifier-naming) -const CString ObjectType::Number = "number"; // NOLINT (readability-identifier-naming) -const CString ObjectType::Boolean = "boolean"; // NOLINT (readability-identifier-naming) -const CString ObjectType::Symbol = "symbol"; // NOLINT (readability-identifier-naming) -const CString ObjectType::Bigint = "bigint"; // NOLINT (readability-identifier-naming) -const CString ObjectType::Wasm = "wasm"; // NOLINT (readability-identifier-naming) - -const CString ObjectSubType::Array = "array"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Null = "null"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Node = "node"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Regexp = "regexp"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Date = "date"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Map = "map"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Set = "set"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Weakmap = "weakmap"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Weakset = "weakset"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Iterator = "iterator"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Generator = "generator"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Error = "error"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Proxy = "proxy"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Promise = "promise"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Typedarray = "typedarray"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Arraybuffer = "arraybuffer"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Dataview = "dataview"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::I32 = "i32"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::I64 = "i64"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::F32 = "f32"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::F64 = "f64"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::V128 = "v128"; // NOLINT (readability-identifier-naming) -const CString ObjectSubType::Externref = "externref"; // NOLINT (readability-identifier-naming) - -const CString ObjectClassName::Object = "Object"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Function = "Function"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Array = "Array"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Regexp = "RegExp"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Date = "Date"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Map = "Map"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Set = "Set"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Weakmap = "Weakmap"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Weakset = "Weakset"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::ArrayIterator = "ArrayIterator"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::StringIterator = "StringIterator"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::SetIterator = "SetIterator"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::MapIterator = "MapIterator"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Iterator = "Iterator"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Error = "Error"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Proxy = "Object"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Promise = "Promise"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Typedarray = "Typedarray"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Arraybuffer = "Arraybuffer"; // NOLINT (readability-identifier-naming) -const CString ObjectClassName::Global = "global"; // NOLINT (readability-identifier-naming) - -const CString RemoteObject::ObjectDescription = "Object"; // NOLINT (readability-identifier-naming) -const CString RemoteObject::GlobalDescription = "global"; // NOLINT (readability-identifier-naming) -const CString RemoteObject::ProxyDescription = "Proxy"; // NOLINT (readability-identifier-naming) -const CString RemoteObject::PromiseDescription = "Promise"; // NOLINT (readability-identifier-naming) -const CString RemoteObject::ArrayIteratorDescription = // NOLINT (readability-identifier-naming) +const std::string ObjectType::Object = "object"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::Function = "function"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::Undefined = "undefined"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::String = "string"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::Number = "number"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::Boolean = "boolean"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::Symbol = "symbol"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::Bigint = "bigint"; // NOLINT (readability-identifier-naming) +const std::string ObjectType::Wasm = "wasm"; // NOLINT (readability-identifier-naming) + +const std::string ObjectSubType::Array = "array"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Null = "null"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Node = "node"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Regexp = "regexp"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Date = "date"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Map = "map"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Set = "set"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Weakmap = "weakmap"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Weakset = "weakset"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Iterator = "iterator"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Generator = "generator"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Error = "error"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Proxy = "proxy"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Promise = "promise"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Typedarray = "typedarray"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Arraybuffer = "arraybuffer"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Dataview = "dataview"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::I32 = "i32"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::I64 = "i64"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::F32 = "f32"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::F64 = "f64"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::V128 = "v128"; // NOLINT (readability-identifier-naming) +const std::string ObjectSubType::Externref = "externref"; // NOLINT (readability-identifier-naming) + +const std::string ObjectClassName::Object = "Object"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Function = "Function"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Array = "Array"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Regexp = "RegExp"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Date = "Date"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Map = "Map"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Set = "Set"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Weakmap = "Weakmap"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Weakset = "Weakset"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::ArrayIterator = "ArrayIterator"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::StringIterator = "StringIterator"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::SetIterator = "SetIterator"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::MapIterator = "MapIterator"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Iterator = "Iterator"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Error = "Error"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Proxy = "Object"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Promise = "Promise"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Typedarray = "Typedarray"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Arraybuffer = "Arraybuffer"; // NOLINT (readability-identifier-naming) +const std::string ObjectClassName::Global = "global"; // NOLINT (readability-identifier-naming) + +const std::string RemoteObject::ObjectDescription = "Object"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::GlobalDescription = "global"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::ProxyDescription = "Proxy"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::PromiseDescription = "Promise"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::ArrayIteratorDescription = // NOLINT (readability-identifier-naming) "ArrayIterator"; -const CString RemoteObject::StringIteratorDescription = // NOLINT (readability-identifier-naming) +const std::string RemoteObject::StringIteratorDescription = // NOLINT (readability-identifier-naming) "StringIterator"; -const CString RemoteObject::SetIteratorDescription = "SetIterator"; // NOLINT (readability-identifier-naming) -const CString RemoteObject::MapIteratorDescription = "MapIterator"; // NOLINT (readability-identifier-naming) -const CString RemoteObject::WeakMapDescription = "WeakMap"; // NOLINT (readability-identifier-naming) -const CString RemoteObject::WeakSetDescription = "WeakSet"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::SetIteratorDescription = "SetIterator"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::MapIteratorDescription = "MapIterator"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::WeakMapDescription = "WeakMap"; // NOLINT (readability-identifier-naming) +const std::string RemoteObject::WeakSetDescription = "WeakSet"; // NOLINT (readability-identifier-naming) static constexpr uint64_t DOUBLE_SIGN_MASK = 0x8000000000000000ULL; @@ -179,7 +179,7 @@ PrimitiveRemoteObject::PrimitiveRemoteObject(const EcmaVM *ecmaVm, const LocalSetType(ObjectType::Undefined); } else if (tagged->IsNumber()) { this->SetType(ObjectType::Number) - .SetDescription(DebuggerApi::ToCString(tagged->ToString(ecmaVm))); + .SetDescription(DebuggerApi::ToStdString(tagged->ToString(ecmaVm))); double val = Local(tagged)->Value(); if (!std::isfinite(val) || (val == 0 && ((bit_cast(val) & DOUBLE_SIGN_MASK) == DOUBLE_SIGN_MASK))) { this->SetUnserializableValue(this->GetDescription()); @@ -192,7 +192,7 @@ PrimitiveRemoteObject::PrimitiveRemoteObject(const EcmaVM *ecmaVm, const Local &tagged) +std::string ObjectRemoteObject::DescriptionForObject(const EcmaVM *ecmaVm, const Local &tagged) { if (tagged->IsArray(ecmaVm)) { return DescriptionForArray(ecmaVm, Local(tagged)); @@ -242,69 +242,69 @@ CString ObjectRemoteObject::DescriptionForObject(const EcmaVM *ecmaVm, const Loc return RemoteObject::ObjectDescription; } -CString ObjectRemoteObject::DescriptionForArray(const EcmaVM *ecmaVm, const Local &tagged) +std::string ObjectRemoteObject::DescriptionForArray(const EcmaVM *ecmaVm, const Local &tagged) { - CString description = "Array(" + ToCString(tagged->Length(ecmaVm)) + ")"; + std::string description = "Array(" + std::to_string(tagged->Length(ecmaVm)) + ")"; return description; } -CString ObjectRemoteObject::DescriptionForRegexp(const EcmaVM *ecmaVm, const Local &tagged) +std::string ObjectRemoteObject::DescriptionForRegexp(const EcmaVM *ecmaVm, const Local &tagged) { - CString regexpSource = DebuggerApi::ToCString(tagged->GetOriginalSource(ecmaVm)); - CString description = "/" + regexpSource + "/"; + std::string regexpSource = DebuggerApi::ToStdString(tagged->GetOriginalSource(ecmaVm)); + std::string description = "/" + regexpSource + "/"; return description; } -CString ObjectRemoteObject::DescriptionForDate(const EcmaVM *ecmaVm, const Local &tagged) +std::string ObjectRemoteObject::DescriptionForDate(const EcmaVM *ecmaVm, const Local &tagged) { - CString description = DebuggerApi::ToCString(tagged->ToString(ecmaVm)); + std::string description = DebuggerApi::ToStdString(tagged->ToString(ecmaVm)); return description; } -CString ObjectRemoteObject::DescriptionForMap(const Local &tagged) +std::string ObjectRemoteObject::DescriptionForMap(const Local &tagged) { - CString description = ("Map(" + ToCString(tagged->GetSize()) + ")"); + std::string description = ("Map(" + std::to_string(tagged->GetSize()) + ")"); return description; } -CString ObjectRemoteObject::DescriptionForSet(const Local &tagged) +std::string ObjectRemoteObject::DescriptionForSet(const Local &tagged) { - CString description = ("Set(" + ToCString(tagged->GetSize()) + ")"); + std::string description = ("Set(" + std::to_string(tagged->GetSize()) + ")"); return description; } -CString ObjectRemoteObject::DescriptionForError(const EcmaVM *ecmaVm, const Local &tagged) +std::string ObjectRemoteObject::DescriptionForError(const EcmaVM *ecmaVm, const Local &tagged) { // add message Local stack = StringRef::NewFromUtf8(ecmaVm, "message"); Local result = Local(tagged)->Get(ecmaVm, stack); - return DebuggerApi::ToCString(result->ToString(ecmaVm)); + return DebuggerApi::ToStdString(result->ToString(ecmaVm)); } -CString ObjectRemoteObject::DescriptionForArrayBuffer(const EcmaVM *ecmaVm, const Local &tagged) +std::string ObjectRemoteObject::DescriptionForArrayBuffer(const EcmaVM *ecmaVm, const Local &tagged) { int32_t len = tagged->ByteLength(ecmaVm); - CString description = ("ArrayBuffer(" + ToCString(len) + ")"); + std::string description = ("ArrayBuffer(" + std::to_string(len) + ")"); return description; } -CString SymbolRemoteObject::DescriptionForSymbol(const EcmaVM *ecmaVm, const Local &tagged) const +std::string SymbolRemoteObject::DescriptionForSymbol(const EcmaVM *ecmaVm, const Local &tagged) const { - CString description = - "Symbol(" + DebuggerApi::ToCString(tagged->GetDescription(ecmaVm)) + ")"; + std::string description = + "Symbol(" + DebuggerApi::ToStdString(tagged->GetDescription(ecmaVm)) + ")"; return description; } -CString FunctionRemoteObject::DescriptionForFunction(const EcmaVM *ecmaVm, const Local &tagged) const +std::string FunctionRemoteObject::DescriptionForFunction(const EcmaVM *ecmaVm, const Local &tagged) const { - CString sourceCode; + std::string sourceCode; if (tagged->IsNative(ecmaVm)) { sourceCode = "[native code]"; } else { sourceCode = "[js code]"; } Local name = tagged->GetName(ecmaVm); - CString description = "function " + DebuggerApi::ToCString(name) + "( { " + sourceCode + " }"; + std::string description = "function " + DebuggerApi::ToStdString(name) + "( { " + sourceCode + " }"; return description; } @@ -314,14 +314,14 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L LOG(ERROR, DEBUGGER) << "RemoteObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto remoteObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "type"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - auto type = DebuggerApi::ToCString(result); + auto type = DebuggerApi::ToStdString(result); if (ObjectType::Valid(type)) { remoteObject->type_ = type; } else { @@ -336,7 +336,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "subtype"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - auto type = DebuggerApi::ToCString(result); + auto type = DebuggerApi::ToStdString(result); if (ObjectSubType::Valid(type)) { remoteObject->subtype_ = type; } else { @@ -349,7 +349,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "className"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - remoteObject->className_ = DebuggerApi::ToCString(result); + remoteObject->className_ = DebuggerApi::ToStdString(result); } else { error += "'className' should be a String;"; } @@ -362,7 +362,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "unserializableValue"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - remoteObject->unserializableValue_ = DebuggerApi::ToCString(result); + remoteObject->unserializableValue_ = DebuggerApi::ToStdString(result); } else { error += "'unserializableValue' should be a String;"; } @@ -370,7 +370,7 @@ std::unique_ptr RemoteObject::Create(const EcmaVM *ecmaVm, const L result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "description"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - remoteObject->description_ = DebuggerApi::ToCString(result); + remoteObject->description_ = DebuggerApi::ToStdString(result); } else { error += "'description' should be a String;"; } @@ -436,7 +436,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, LOG(ERROR, DEBUGGER) << "ExceptionDetails::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto exceptionDetails = std::make_unique(); Local result = @@ -453,7 +453,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "text"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - exceptionDetails->text_ = DebuggerApi::ToCString(result); + exceptionDetails->text_ = DebuggerApi::ToStdString(result); } else { error += "'text' should be a String;"; } @@ -491,7 +491,7 @@ std::unique_ptr ExceptionDetails::Create(const EcmaVM *ecmaVm, result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - exceptionDetails->url_ = DebuggerApi::ToCString(result); + exceptionDetails->url_ = DebuggerApi::ToStdString(result); } else { error += "'url' should be a String;"; } @@ -573,14 +573,14 @@ std::unique_ptr InternalPropertyDescriptor::Create(c LOG(ERROR, DEBUGGER) << "InternalPropertyDescriptor::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto internalPropertyDescriptor = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - internalPropertyDescriptor->name_ = DebuggerApi::ToCString(result); + internalPropertyDescriptor->name_ = DebuggerApi::ToStdString(result); } else { error += "'name' should be a String;"; } @@ -632,14 +632,14 @@ std::unique_ptr PrivatePropertyDescriptor::Create(con LOG(ERROR, DEBUGGER) << "PrivatePropertyDescriptor::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto propertyDescriptor = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - propertyDescriptor->name_ = DebuggerApi::ToCString(result); + propertyDescriptor->name_ = DebuggerApi::ToStdString(result); } else { error += "'name' should be a String;"; } @@ -727,14 +727,14 @@ std::unique_ptr PropertyDescriptor::FromProperty(const EcmaV { std::unique_ptr debuggerProperty = std::make_unique(); - CString nameStr; + std::string nameStr; if (name->IsSymbol()) { Local symbol(name); nameStr = - "Symbol(" + DebuggerApi::ToCString(Local(name)->GetDescription(ecmaVm)) + ")"; + "Symbol(" + DebuggerApi::ToStdString(Local(name)->GetDescription(ecmaVm)) + ")"; debuggerProperty->symbol_ = RemoteObject::FromTagged(ecmaVm, name); } else { - nameStr = DebuggerApi::ToCString(name->ToString(ecmaVm)); + nameStr = DebuggerApi::ToStdString(name->ToString(ecmaVm)); } debuggerProperty->name_ = nameStr; @@ -763,14 +763,14 @@ std::unique_ptr PropertyDescriptor::Create(const EcmaVM *ecm LOG(ERROR, DEBUGGER) << "PropertyDescriptor::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto propertyDescriptor = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - propertyDescriptor->name_ = DebuggerApi::ToCString(result); + propertyDescriptor->name_ = DebuggerApi::ToStdString(result); } else { error += "'name' should be a String;"; } @@ -942,7 +942,7 @@ std::unique_ptr CallArgument::Create(const EcmaVM *ecmaVm, const L LOG(ERROR, DEBUGGER) << "CallArgument::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto callArgument = std::make_unique(); Local result = @@ -954,7 +954,7 @@ std::unique_ptr CallArgument::Create(const EcmaVM *ecmaVm, const L Local(StringRef::NewFromUtf8(ecmaVm, "unserializableValue"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - callArgument->unserializableValue_ = DebuggerApi::ToCString(result); + callArgument->unserializableValue_ = DebuggerApi::ToStdString(result); } else { error += "'unserializableValue' should be a String;"; } @@ -1002,7 +1002,7 @@ std::unique_ptr Location::Create(const EcmaVM *ecmaVm, const Local(); Local result = @@ -1066,7 +1066,7 @@ std::unique_ptr ScriptPosition::Create(const EcmaVM *ecmaVm, con LOG(ERROR, DEBUGGER) << "ScriptPosition::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto scriptPosition = std::make_unique(); Local result = @@ -1116,7 +1116,7 @@ std::unique_ptr SearchMatch::Create(const EcmaVM *ecmaVm, const Loc LOG(ERROR, DEBUGGER) << "SearchMatch::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto locationSearch = std::make_unique(); Local result = @@ -1134,7 +1134,7 @@ std::unique_ptr SearchMatch::Create(const EcmaVM *ecmaVm, const Loc result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "lineContent"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - locationSearch->lineContent_ = DebuggerApi::ToCString(result); + locationSearch->lineContent_ = DebuggerApi::ToStdString(result); } else { error += "'lineContent' should be a String;"; } @@ -1168,7 +1168,7 @@ std::unique_ptr LocationRange::Create(const EcmaVM *ecmaVm, const LOG(ERROR, DEBUGGER) << "BreakLocation::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto locationRange = std::make_unique(); Local result = @@ -1244,7 +1244,7 @@ std::unique_ptr BreakLocation::Create(const EcmaVM *ecmaVm, const LOG(ERROR, DEBUGGER) << "BreakLocation::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto breakLocation = std::make_unique(); Local result = @@ -1279,7 +1279,7 @@ std::unique_ptr BreakLocation::Create(const EcmaVM *ecmaVm, const result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "type"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - auto type = DebuggerApi::ToCString(result); + auto type = DebuggerApi::ToStdString(result); if (BreakType::Valid(type)) { breakLocation->type_ = type; } else { @@ -1326,14 +1326,14 @@ std::unique_ptr Scope::Create(const EcmaVM *ecmaVm, const Local(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "type"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - auto type = DebuggerApi::ToCString(result); + auto type = DebuggerApi::ToStdString(result); if (Scope::Type::Valid(type)) { scope->type_ = type; } else { @@ -1363,7 +1363,7 @@ std::unique_ptr Scope::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - scope->name_ = DebuggerApi::ToCString(result); + scope->name_ = DebuggerApi::ToStdString(result); } else { error += "'name' should be a String;"; } @@ -1440,7 +1440,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(); Local result = @@ -1457,7 +1457,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "functionName"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - callFrame->functionName_ = DebuggerApi::ToCString(result); + callFrame->functionName_ = DebuggerApi::ToStdString(result); } else { error += "'functionName' should be a String;"; } @@ -1496,7 +1496,7 @@ std::unique_ptr CallFrame::Create(const EcmaVM *ecmaVm, const Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - callFrame->url_ = DebuggerApi::ToCString(result); + callFrame->url_ = DebuggerApi::ToStdString(result); } else { error += "'url' should be a String;"; } @@ -1610,7 +1610,7 @@ std::unique_ptr SamplingHeapProfileSample::Create(con LOG(ERROR, DEBUGGER) << "SamplingHeapProfileSample::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto samplingHeapProfileSample = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -1675,14 +1675,14 @@ std::unique_ptr RuntimeCallFrame::Create(const EcmaVM *ecmaVm, LOG(ERROR, DEBUGGER) << "RuntimeCallFrame::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto runtimeCallFrame = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "functionName"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - runtimeCallFrame->functionName_ = DebuggerApi::ToCString(result); + runtimeCallFrame->functionName_ = DebuggerApi::ToStdString(result); } else { error += "'functionName' should be a String;"; } @@ -1693,7 +1693,7 @@ std::unique_ptr RuntimeCallFrame::Create(const EcmaVM *ecmaVm, result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - runtimeCallFrame->scriptId_ = DebuggerApi::ToCString(result); + runtimeCallFrame->scriptId_ = DebuggerApi::ToStdString(result); } else { error += "'scriptId' should be a String;"; } @@ -1704,7 +1704,7 @@ std::unique_ptr RuntimeCallFrame::Create(const EcmaVM *ecmaVm, result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - runtimeCallFrame->url_ = DebuggerApi::ToCString(result); + runtimeCallFrame->url_ = DebuggerApi::ToStdString(result); } else { error += "'url' should be a String;"; } @@ -1745,11 +1745,11 @@ std::unique_ptr RuntimeCallFrame::Create(const EcmaVM *ecmaVm, std::unique_ptr RuntimeCallFrame::FromFrameInfo(const FrameInfo &cpuFrameInfo) { auto runtimeCallFrame = std::make_unique(); - runtimeCallFrame->SetFunctionName(cpuFrameInfo.functionName.c_str()); - runtimeCallFrame->SetScriptId(std::to_string(cpuFrameInfo.scriptId).c_str()); + runtimeCallFrame->SetFunctionName(cpuFrameInfo.functionName); + runtimeCallFrame->SetScriptId(std::to_string(cpuFrameInfo.scriptId)); runtimeCallFrame->SetColumnNumber(cpuFrameInfo.columnNumber); runtimeCallFrame->SetLineNumber(cpuFrameInfo.lineNumber); - runtimeCallFrame->SetUrl(cpuFrameInfo.url.c_str()); + runtimeCallFrame->SetUrl(cpuFrameInfo.url); return runtimeCallFrame; } @@ -1783,7 +1783,7 @@ std::unique_ptr SamplingHeapProfileNode::Create(const E return nullptr; } - CString error; + std::string error; auto samplingHeapProfileNode = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -1889,7 +1889,7 @@ std::unique_ptr SamplingHeapProfile::Create(const EcmaVM *e LOG(ERROR, DEBUGGER) << "SamplingHeapProfile::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto samplingHeapProfile = std::make_unique(); Local result = Local(params)->Get(ecmaVm, @@ -1969,7 +1969,7 @@ std::unique_ptr PositionTickInfo::Create(const EcmaVM *ecmaVm, LOG(ERROR, DEBUGGER) << "PositionTickInfo::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto positionTicks = std::make_unique(); Local result = @@ -2019,7 +2019,7 @@ std::unique_ptr ProfileNode::Create(const EcmaVM *ecmaVm, const Loc LOG(ERROR, DEBUGGER) << "ProfileNode::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto profileNode = std::make_unique(); Local result = @@ -2098,7 +2098,7 @@ std::unique_ptr ProfileNode::Create(const EcmaVM *ecmaVm, const Loc result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "deoptReason"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - profileNode->deoptReason_ = DebuggerApi::ToCString(result); + profileNode->deoptReason_ = DebuggerApi::ToStdString(result); } else { error += "'deoptReason' should be a String;"; } @@ -2119,7 +2119,7 @@ std::unique_ptr ProfileNode::FromCpuProfileNode(const CpuProfileNod profileNode->SetHitCount(cpuProfileNode.hitCount); size_t childrenLen = cpuProfileNode.children.size(); - CVector tmpChildren; + std::vector tmpChildren; tmpChildren.reserve(childrenLen); for (uint32_t i = 0; i < childrenLen; ++i) { tmpChildren.push_back(cpuProfileNode.children[i]); @@ -2180,7 +2180,7 @@ std::unique_ptr Profile::Create(const EcmaVM *ecmaVm, const Local(); Local result = @@ -2273,7 +2273,7 @@ std::unique_ptr Profile::FromProfileInfo(const ProfileInfo &profileInfo profile->SetStartTime(static_cast(profileInfo.startTime)); profile->SetEndTime(static_cast(profileInfo.stopTime)); size_t samplesLen = profileInfo.samples.size(); - CVector tmpSamples; + std::vector tmpSamples; tmpSamples.reserve(samplesLen); for (uint32_t i = 0; i < samplesLen; ++i) { tmpSamples.push_back(profileInfo.samples[i]); @@ -2281,14 +2281,14 @@ std::unique_ptr Profile::FromProfileInfo(const ProfileInfo &profileInfo profile->SetSamples(tmpSamples); size_t timeDeltasLen = profileInfo.timeDeltas.size(); - CVector tmpTimeDeltas; + std::vector tmpTimeDeltas; tmpTimeDeltas.reserve(timeDeltasLen); for (uint32_t i = 0; i < timeDeltasLen; ++i) { tmpTimeDeltas.push_back(profileInfo.timeDeltas[i]); } profile->SetTimeDeltas(tmpTimeDeltas); - CVector> profileNode; + std::vector> profileNode; size_t nodesLen = profileInfo.nodes.size(); for (uint32_t i = 0; i < nodesLen; ++i) { const auto &cpuProfileNode = profileInfo.nodes[i]; @@ -2344,7 +2344,7 @@ std::unique_ptr Coverage::Create(const EcmaVM *ecmaVm, const Local(); Local result = @@ -2403,14 +2403,14 @@ std::unique_ptr FunctionCoverage::Create(const EcmaVM *ecmaVm, LOG(ERROR, DEBUGGER) << "FunctionCoverage::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto functionCoverage = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "functionName"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - functionCoverage->functionName_ = DebuggerApi::ToCString(result); + functionCoverage->functionName_ = DebuggerApi::ToStdString(result); } else { error += "'functionName' should be a String;"; } @@ -2481,14 +2481,14 @@ std::unique_ptr ScriptCoverage::Create(const EcmaVM *ecmaVm, con LOG(ERROR, DEBUGGER) << "ScriptCoverage::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto scriptCoverage = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - scriptCoverage->scriptId_ = DebuggerApi::ToCString(result); + scriptCoverage->scriptId_ = DebuggerApi::ToStdString(result); } else { error += "'scriptId' should be a String;"; } @@ -2498,7 +2498,7 @@ std::unique_ptr ScriptCoverage::Create(const EcmaVM *ecmaVm, con result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - scriptCoverage->url_ = DebuggerApi::ToCString(result); + scriptCoverage->url_ = DebuggerApi::ToStdString(result); } else { error += "'url' should be a String;"; } @@ -2555,14 +2555,14 @@ std::unique_ptr TypeObject::Create(const EcmaVM *ecmaVm, const Local LOG(ERROR, DEBUGGER) << "TypeObject::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto typeObject = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "name"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - typeObject->name_ = DebuggerApi::ToCString(result); + typeObject->name_ = DebuggerApi::ToStdString(result); } else { error += "'name' should be a String;"; } @@ -2591,7 +2591,7 @@ std::unique_ptr TypeProfileEntry::Create(const EcmaVM *ecmaVm, LOG(ERROR, DEBUGGER) << "TypeProfileEntry::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto typeProfileEntry = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "offset"))); @@ -2651,14 +2651,14 @@ std::unique_ptr ScriptTypeProfile::Create(const EcmaVM *ecmaV LOG(ERROR, DEBUGGER) << "ScriptTypeProfile::Create params is nullptr"; return nullptr; } - CString error; + std::string error; auto scriptTypeProfile = std::make_unique(); Local result = Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "scriptId"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - scriptTypeProfile->scriptId_ = DebuggerApi::ToCString(result); + scriptTypeProfile->scriptId_ = DebuggerApi::ToStdString(result); } else { error += "'scriptId' should be a String;"; } @@ -2669,7 +2669,7 @@ std::unique_ptr ScriptTypeProfile::Create(const EcmaVM *ecmaV Local(params)->Get(ecmaVm, Local(StringRef::NewFromUtf8(ecmaVm, "url"))); if (!result.IsEmpty() && !result->IsUndefined()) { if (result->IsString()) { - scriptTypeProfile->url_ = DebuggerApi::ToCString(result); + scriptTypeProfile->url_ = DebuggerApi::ToStdString(result); } else { error += "'url' should be a String;"; } diff --git a/ecmascript/tooling/base/pt_types.h b/ecmascript/tooling/base/pt_types.h index c116267f48..c2257f2c67 100644 --- a/ecmascript/tooling/base/pt_types.h +++ b/ecmascript/tooling/base/pt_types.h @@ -20,8 +20,6 @@ #include #include "ecmascript/dfx/cpu_profiler/samples_record.h" -#include "ecmascript/mem/c_containers.h" -#include "ecmascript/mem/c_string.h" #include "ecmascript/tooling/backend/debugger_api.h" #include "libpandabase/macros.h" @@ -46,33 +44,33 @@ private: // ========== Debugger types begin // Debugger.BreakpointId -using BreakpointId = CString; +using BreakpointId = std::string; struct BreakpointDetails { static BreakpointId ToString(const BreakpointDetails &metaData) { - return "id:" + ToCString(metaData.line_) + ":" + ToCString(metaData.column_) + ":" + - metaData.url_; + return "id:" + std::to_string(metaData.line_) + ":" + std::to_string(metaData.column_) + ":" + + metaData.url_; } static bool ParseBreakpointId(const BreakpointId &id, BreakpointDetails *metaData) { auto lineStart = id.find(':'); - if (lineStart == CString::npos) { + if (lineStart == std::string::npos) { return false; } auto columnStart = id.find(':', lineStart + 1); - if (columnStart == CString::npos) { + if (columnStart == std::string::npos) { return false; } auto urlStart = id.find(':', columnStart + 1); - if (urlStart == CString::npos) { + if (urlStart == std::string::npos) { return false; } - CString lineStr = id.substr(lineStart + 1, columnStart - lineStart - 1); - CString columnStr = id.substr(columnStart + 1, urlStart - columnStart - 1); - CString url = id.substr(urlStart + 1); - metaData->line_ = DebuggerApi::CStringToInt(lineStr); - metaData->column_ = DebuggerApi::CStringToInt(columnStr); + std::string lineStr = id.substr(lineStart + 1, columnStart - lineStart - 1); + std::string columnStr = id.substr(columnStart + 1, urlStart - columnStart - 1); + std::string url = id.substr(urlStart + 1); + metaData->line_ = std::stoi(lineStr); + metaData->column_ = std::stoi(columnStr); metaData->url_ = url; return true; @@ -80,7 +78,7 @@ struct BreakpointDetails { int32_t line_ {0}; int32_t column_ {0}; - CString url_ {}; + std::string url_ {}; }; // Debugger.CallFrameId @@ -98,7 +96,7 @@ using RemoteObjectId = uint32_t; using ExecutionContextId = int32_t; // Runtime.UnserializableValue -using UnserializableValue = CString; +using UnserializableValue = std::string; // Runtime.UniqueDebuggerId using UniqueDebuggerId = uint32_t; @@ -116,12 +114,12 @@ public: /* * @see {#ObjectType} */ - const CString &GetType() const + const std::string &GetType() const { return type_; } - RemoteObject &SetType(const CString &type) + RemoteObject &SetType(const std::string &type) { type_ = type; return *this; @@ -129,12 +127,12 @@ public: /* * @see {#ObjectSubType} */ - const CString &GetSubType() const + const std::string &GetSubType() const { return subtype_.value(); } - RemoteObject &SetSubType(const CString &type) + RemoteObject &SetSubType(const std::string &type) { subtype_ = type; return *this; @@ -145,12 +143,12 @@ public: return subtype_.has_value(); } - const CString &GetClassName() const + const std::string &GetClassName() const { return className_.value(); } - RemoteObject &SetClassName(const CString &className) + RemoteObject &SetClassName(const std::string &className) { className_ = className; return *this; @@ -193,12 +191,12 @@ public: return unserializableValue_.has_value(); } - const CString &GetDescription() const + const std::string &GetDescription() const { return description_.value(); } - RemoteObject &SetDescription(const CString &description) + RemoteObject &SetDescription(const std::string &description) { description_ = description; return *this; @@ -226,16 +224,16 @@ public: } struct TypeName { - static const CString Object; // NOLINT (readability-identifier-naming) - static const CString Function; // NOLINT (readability-identifier-naming) - static const CString Undefined; // NOLINT (readability-identifier-naming) - static const CString String; // NOLINT (readability-identifier-naming) - static const CString Number; // NOLINT (readability-identifier-naming) - static const CString Boolean; // NOLINT (readability-identifier-naming) - static const CString Symbol; // NOLINT (readability-identifier-naming) - static const CString Bigint; // NOLINT (readability-identifier-naming) - static const CString Wasm; // NOLINT (readability-identifier-naming) - static bool Valid(const CString &type) + static const std::string Object; // NOLINT (readability-identifier-naming) + static const std::string Function; // NOLINT (readability-identifier-naming) + static const std::string Undefined; // NOLINT (readability-identifier-naming) + static const std::string String; // NOLINT (readability-identifier-naming) + static const std::string Number; // NOLINT (readability-identifier-naming) + static const std::string Boolean; // NOLINT (readability-identifier-naming) + static const std::string Symbol; // NOLINT (readability-identifier-naming) + static const std::string Bigint; // NOLINT (readability-identifier-naming) + static const std::string Wasm; // NOLINT (readability-identifier-naming) + static bool Valid(const std::string &type) { return type == Object || type == Function || type == Undefined || type == String || type == Number || type == Boolean || type == Symbol || type == Bigint || type == Wasm; @@ -243,30 +241,30 @@ public: }; struct SubTypeName { - static const CString Array; // NOLINT (readability-identifier-naming) - static const CString Null; // NOLINT (readability-identifier-naming) - static const CString Node; // NOLINT (readability-identifier-naming) - static const CString Regexp; // NOLINT (readability-identifier-naming) - static const CString Date; // NOLINT (readability-identifier-naming) - static const CString Map; // NOLINT (readability-identifier-naming) - static const CString Set; // NOLINT (readability-identifier-naming) - static const CString Weakmap; // NOLINT (readability-identifier-naming) - static const CString Weakset; // NOLINT (readability-identifier-naming) - static const CString Iterator; // NOLINT (readability-identifier-naming) - static const CString Generator; // NOLINT (readability-identifier-naming) - static const CString Error; // NOLINT (readability-identifier-naming) - static const CString Proxy; // NOLINT (readability-identifier-naming) - static const CString Promise; // NOLINT (readability-identifier-naming) - static const CString Typedarray; // NOLINT (readability-identifier-naming) - static const CString Arraybuffer; // NOLINT (readability-identifier-naming) - static const CString Dataview; // NOLINT (readability-identifier-naming) - static const CString I32; // NOLINT (readability-identifier-naming) - static const CString I64; // NOLINT (readability-identifier-naming) - static const CString F32; // NOLINT (readability-identifier-naming) - static const CString F64; // NOLINT (readability-identifier-naming) - static const CString V128; // NOLINT (readability-identifier-naming) - static const CString Externref; // NOLINT (readability-identifier-naming) - static bool Valid(const CString &type) + static const std::string Array; // NOLINT (readability-identifier-naming) + static const std::string Null; // NOLINT (readability-identifier-naming) + static const std::string Node; // NOLINT (readability-identifier-naming) + static const std::string Regexp; // NOLINT (readability-identifier-naming) + static const std::string Date; // NOLINT (readability-identifier-naming) + static const std::string Map; // NOLINT (readability-identifier-naming) + static const std::string Set; // NOLINT (readability-identifier-naming) + static const std::string Weakmap; // NOLINT (readability-identifier-naming) + static const std::string Weakset; // NOLINT (readability-identifier-naming) + static const std::string Iterator; // NOLINT (readability-identifier-naming) + static const std::string Generator; // NOLINT (readability-identifier-naming) + static const std::string Error; // NOLINT (readability-identifier-naming) + static const std::string Proxy; // NOLINT (readability-identifier-naming) + static const std::string Promise; // NOLINT (readability-identifier-naming) + static const std::string Typedarray; // NOLINT (readability-identifier-naming) + static const std::string Arraybuffer; // NOLINT (readability-identifier-naming) + static const std::string Dataview; // NOLINT (readability-identifier-naming) + static const std::string I32; // NOLINT (readability-identifier-naming) + static const std::string I64; // NOLINT (readability-identifier-naming) + static const std::string F32; // NOLINT (readability-identifier-naming) + static const std::string F64; // NOLINT (readability-identifier-naming) + static const std::string V128; // NOLINT (readability-identifier-naming) + static const std::string Externref; // NOLINT (readability-identifier-naming) + static bool Valid(const std::string &type) { return type == Array || type == Null || type == Node || type == Regexp || type == Map || type == Set || type == Weakmap || type == Iterator || type == Generator || type == Error || type == Proxy || @@ -275,27 +273,27 @@ public: } }; struct ClassName { - static const CString Object; // NOLINT (readability-identifier-naming) - static const CString Function; // NOLINT (readability-identifier-naming) - static const CString Array; // NOLINT (readability-identifier-naming) - static const CString Regexp; // NOLINT (readability-identifier-naming) - static const CString Date; // NOLINT (readability-identifier-naming) - static const CString Map; // NOLINT (readability-identifier-naming) - static const CString Set; // NOLINT (readability-identifier-naming) - static const CString Weakmap; // NOLINT (readability-identifier-naming) - static const CString Weakset; // NOLINT (readability-identifier-naming) - static const CString ArrayIterator; // NOLINT (readability-identifier-naming) - static const CString StringIterator; // NOLINT (readability-identifier-naming) - static const CString SetIterator; // NOLINT (readability-identifier-naming) - static const CString MapIterator; // NOLINT (readability-identifier-naming) - static const CString Iterator; // NOLINT (readability-identifier-naming) - static const CString Error; // NOLINT (readability-identifier-naming) - static const CString Proxy; // NOLINT (readability-identifier-naming) - static const CString Promise; // NOLINT (readability-identifier-naming) - static const CString Typedarray; // NOLINT (readability-identifier-naming) - static const CString Arraybuffer; // NOLINT (readability-identifier-naming) - static const CString Global; // NOLINT (readability-identifier-naming) - static bool Valid(const CString &type) + static const std::string Object; // NOLINT (readability-identifier-naming) + static const std::string Function; // NOLINT (readability-identifier-naming) + static const std::string Array; // NOLINT (readability-identifier-naming) + static const std::string Regexp; // NOLINT (readability-identifier-naming) + static const std::string Date; // NOLINT (readability-identifier-naming) + static const std::string Map; // NOLINT (readability-identifier-naming) + static const std::string Set; // NOLINT (readability-identifier-naming) + static const std::string Weakmap; // NOLINT (readability-identifier-naming) + static const std::string Weakset; // NOLINT (readability-identifier-naming) + static const std::string ArrayIterator; // NOLINT (readability-identifier-naming) + static const std::string StringIterator; // NOLINT (readability-identifier-naming) + static const std::string SetIterator; // NOLINT (readability-identifier-naming) + static const std::string MapIterator; // NOLINT (readability-identifier-naming) + static const std::string Iterator; // NOLINT (readability-identifier-naming) + static const std::string Error; // NOLINT (readability-identifier-naming) + static const std::string Proxy; // NOLINT (readability-identifier-naming) + static const std::string Promise; // NOLINT (readability-identifier-naming) + static const std::string Typedarray; // NOLINT (readability-identifier-naming) + static const std::string Arraybuffer; // NOLINT (readability-identifier-naming) + static const std::string Global; // NOLINT (readability-identifier-naming) + static bool Valid(const std::string &type) { return type == Object || type == Array || type == Regexp || type == Date || type == Map || type == Set || type == Weakmap || type == Weakset || type == ArrayIterator || type == StringIterator || @@ -303,27 +301,27 @@ public: type == Promise || type == Typedarray || type == Arraybuffer || type == Function; } }; - static const CString ObjectDescription; // NOLINT (readability-identifier-naming) - static const CString GlobalDescription; // NOLINT (readability-identifier-naming) - static const CString ProxyDescription; // NOLINT (readability-identifier-naming) - static const CString PromiseDescription; // NOLINT (readability-identifier-naming) - static const CString ArrayIteratorDescription; // NOLINT (readability-identifier-naming) - static const CString StringIteratorDescription; // NOLINT (readability-identifier-naming) - static const CString SetIteratorDescription; // NOLINT (readability-identifier-naming) - static const CString MapIteratorDescription; // NOLINT (readability-identifier-naming) - static const CString WeakMapDescription; // NOLINT (readability-identifier-naming) - static const CString WeakSetDescription; // NOLINT (readability-identifier-naming) + static const std::string ObjectDescription; // NOLINT (readability-identifier-naming) + static const std::string GlobalDescription; // NOLINT (readability-identifier-naming) + static const std::string ProxyDescription; // NOLINT (readability-identifier-naming) + static const std::string PromiseDescription; // NOLINT (readability-identifier-naming) + static const std::string ArrayIteratorDescription; // NOLINT (readability-identifier-naming) + static const std::string StringIteratorDescription; // NOLINT (readability-identifier-naming) + static const std::string SetIteratorDescription; // NOLINT (readability-identifier-naming) + static const std::string MapIteratorDescription; // NOLINT (readability-identifier-naming) + static const std::string WeakMapDescription; // NOLINT (readability-identifier-naming) + static const std::string WeakSetDescription; // NOLINT (readability-identifier-naming) private: NO_COPY_SEMANTIC(RemoteObject); NO_MOVE_SEMANTIC(RemoteObject); - CString type_ {}; - std::optional subtype_ {}; - std::optional className_ {}; + std::string type_ {}; + std::optional subtype_ {}; + std::optional className_ {}; std::optional> value_ {}; std::optional unserializableValue_ {}; - std::optional description_ {}; + std::optional description_ {}; std::optional objectId_ {}; }; @@ -351,7 +349,7 @@ public: ~SymbolRemoteObject() override = default; private: - CString DescriptionForSymbol(const EcmaVM *ecmaVm, const Local &tagged) const; + std::string DescriptionForSymbol(const EcmaVM *ecmaVm, const Local &tagged) const; }; class FunctionRemoteObject final : public RemoteObject { @@ -365,19 +363,19 @@ public: ~FunctionRemoteObject() override = default; private: - CString DescriptionForFunction(const EcmaVM *ecmaVm, const Local &tagged) const; + std::string DescriptionForFunction(const EcmaVM *ecmaVm, const Local &tagged) const; }; class ObjectRemoteObject final : public RemoteObject { public: - explicit ObjectRemoteObject(const EcmaVM *ecmaVm, const Local &tagged, const CString &classname) + explicit ObjectRemoteObject(const EcmaVM *ecmaVm, const Local &tagged, const std::string &classname) { SetType(RemoteObject::TypeName::Object) .SetClassName(classname) .SetDescription(DescriptionForObject(ecmaVm, tagged)); } - explicit ObjectRemoteObject(const EcmaVM *ecmaVm, const Local &tagged, const CString &classname, - const CString &subtype) + explicit ObjectRemoteObject(const EcmaVM *ecmaVm, const Local &tagged, const std::string &classname, + const std::string &subtype) { SetType(RemoteObject::TypeName::Object) .SetSubType(subtype) @@ -385,16 +383,16 @@ public: .SetDescription(DescriptionForObject(ecmaVm, tagged)); } ~ObjectRemoteObject() override = default; - static CString DescriptionForObject(const EcmaVM *ecmaVm, const Local &tagged); + static std::string DescriptionForObject(const EcmaVM *ecmaVm, const Local &tagged); private: - static CString DescriptionForArray(const EcmaVM *ecmaVm, const Local &tagged); - static CString DescriptionForRegexp(const EcmaVM *ecmaVm, const Local &tagged); - static CString DescriptionForDate(const EcmaVM *ecmaVm, const Local &tagged); - static CString DescriptionForMap(const Local &tagged); - static CString DescriptionForSet(const Local &tagged); - static CString DescriptionForError(const EcmaVM *ecmaVm, const Local &tagged); - static CString DescriptionForArrayBuffer(const EcmaVM *ecmaVm, const Local &tagged); + static std::string DescriptionForArray(const EcmaVM *ecmaVm, const Local &tagged); + static std::string DescriptionForRegexp(const EcmaVM *ecmaVm, const Local &tagged); + static std::string DescriptionForDate(const EcmaVM *ecmaVm, const Local &tagged); + static std::string DescriptionForMap(const Local &tagged); + static std::string DescriptionForSet(const Local &tagged); + static std::string DescriptionForError(const EcmaVM *ecmaVm, const Local &tagged); + static std::string DescriptionForArrayBuffer(const EcmaVM *ecmaVm, const Local &tagged); }; // Runtime.ExceptionDetails @@ -416,12 +414,12 @@ public: return *this; } - const CString &GetText() const + const std::string &GetText() const { return text_; } - ExceptionDetails &SetText(const CString &text) + ExceptionDetails &SetText(const std::string &text) { text_ = text; return *this; @@ -465,12 +463,12 @@ public: return scriptId_.has_value(); } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_.value(); } - ExceptionDetails &SetUrl(const CString &url) + ExceptionDetails &SetUrl(const std::string &url) { url_ = url; return *this; @@ -521,11 +519,11 @@ private: NO_MOVE_SEMANTIC(ExceptionDetails); int32_t exceptionId_ {0}; - CString text_ {}; + std::string text_ {}; int32_t line_ {0}; int32_t column_ {0}; std::optional scriptId_ {}; - std::optional url_ {}; + std::optional url_ {}; std::optional> exception_ {}; std::optional executionContextId_ {0}; }; @@ -539,12 +537,12 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const + std::string GetName() const { return name_; } - InternalPropertyDescriptor &SetName(const CString &name) + InternalPropertyDescriptor &SetName(const std::string &name) { name_ = name; return *this; @@ -573,7 +571,7 @@ private: NO_COPY_SEMANTIC(InternalPropertyDescriptor); NO_MOVE_SEMANTIC(InternalPropertyDescriptor); - CString name_ {}; + std::string name_ {}; std::optional> value_ {}; }; @@ -586,12 +584,12 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const + std::string GetName() const { return name_; } - PrivatePropertyDescriptor &SetName(const CString &name) + PrivatePropertyDescriptor &SetName(const std::string &name) { name_ = name; return *this; @@ -658,7 +656,7 @@ private: NO_COPY_SEMANTIC(PrivatePropertyDescriptor); NO_MOVE_SEMANTIC(PrivatePropertyDescriptor); - CString name_ {}; + std::string name_ {}; std::optional> value_ {}; std::optional> get_ {}; std::optional> set_ {}; @@ -675,12 +673,12 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; - CString GetName() const + std::string GetName() const { return name_; } - PropertyDescriptor &SetName(const CString &name) + PropertyDescriptor &SetName(const std::string &name) { name_ = name; return *this; @@ -836,7 +834,7 @@ private: NO_COPY_SEMANTIC(PropertyDescriptor); NO_MOVE_SEMANTIC(PropertyDescriptor); - CString name_ {}; + std::string name_ {}; std::optional> value_ {}; std::optional writable_ {}; std::optional> get_ {}; @@ -917,15 +915,15 @@ private: // ========== Debugger types begin // Debugger.ScriptLanguage struct ScriptLanguage { - static bool Valid(const CString &language) + static bool Valid(const std::string &language) { return language == JavaScript() || language == WebAssembly(); } - static CString JavaScript() + static std::string JavaScript() { return "JavaScript"; } - static CString WebAssembly() + static std::string WebAssembly() { return "WebAssembly"; } @@ -1039,7 +1037,7 @@ private: NO_MOVE_SEMANTIC(SearchMatch); int32_t lineNumber_ {0}; - CString lineContent_ {}; + std::string lineContent_ {}; }; // Debugger.LocationRange @@ -1143,12 +1141,12 @@ public: /* * @see {#BreakType} */ - const CString &GetType() const + const std::string &GetType() const { return type_.value(); } - BreakLocation &SetType(const CString &type) + BreakLocation &SetType(const std::string &type) { type_ = type; return *this; @@ -1160,19 +1158,19 @@ public: } struct Type { - static bool Valid(const CString &type) + static bool Valid(const std::string &type) { return type == DebuggerStatement() || type == Call() || type == Return(); } - static CString DebuggerStatement() + static std::string DebuggerStatement() { return "debuggerStatement"; } - static CString Call() + static std::string Call() { return "call"; } - static CString Return() + static std::string Return() { return "return"; } @@ -1185,7 +1183,7 @@ private: ScriptId scriptId_ {}; int32_t line_ {0}; std::optional column_ {}; - std::optional type_ {}; + std::optional type_ {}; }; using BreakType = BreakLocation::Type; @@ -1214,12 +1212,12 @@ public: /* * @see {#Scope::Type} */ - const CString &GetType() const + const std::string &GetType() const { return type_; } - Scope &SetType(const CString &type) + Scope &SetType(const std::string &type) { type_ = type; return *this; @@ -1236,12 +1234,12 @@ public: return *this; } - const CString &GetName() const + const std::string &GetName() const { return name_.value(); } - Scope &SetName(const CString &name) + Scope &SetName(const std::string &name) { name_ = name; return *this; @@ -1291,49 +1289,49 @@ public: } struct Type { - static bool Valid(const CString &type) + static bool Valid(const std::string &type) { return type == Global() || type == Local() || type == With() || type == Closure() || type == Catch() || type == Block() || type == Script() || type == Eval() || type == Module() || type == WasmExpressionStack(); } - static CString Global() + static std::string Global() { return "global"; } - static CString Local() + static std::string Local() { return "local"; } - static CString With() + static std::string With() { return "with"; } - static CString Closure() + static std::string Closure() { return "closure"; } - static CString Catch() + static std::string Catch() { return "catch"; } - static CString Block() + static std::string Block() { return "block"; } - static CString Script() + static std::string Script() { return "script"; } - static CString Eval() + static std::string Eval() { return "eval"; } - static CString Module() + static std::string Module() { return "module"; } - static CString WasmExpressionStack() + static std::string WasmExpressionStack() { return "wasm-expression-stack"; } @@ -1343,9 +1341,9 @@ private: NO_COPY_SEMANTIC(Scope); NO_MOVE_SEMANTIC(Scope); - CString type_ {}; + std::string type_ {}; std::unique_ptr object_ {nullptr}; - std::optional name_ {}; + std::optional name_ {}; std::optional> startLocation_ {}; std::optional> endLocation_ {}; }; @@ -1370,12 +1368,12 @@ public: return *this; } - const CString &GetFunctionName() const + const std::string &GetFunctionName() const { return functionName_; } - CallFrame &SetFunctionName(const CString &functionName) + CallFrame &SetFunctionName(const std::string &functionName) { functionName_ = functionName; return *this; @@ -1411,23 +1409,23 @@ public: return *this; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_; } - CallFrame &SetUrl(const CString &url) + CallFrame &SetUrl(const std::string &url) { url_ = url; return *this; } - const CVector> *GetScopeChain() const + const std::vector> *GetScopeChain() const { return &scopeChain_; } - CallFrame &SetScopeChain(CVector> scopeChain) + CallFrame &SetScopeChain(std::vector> scopeChain) { scopeChain_ = std::move(scopeChain); return *this; @@ -1467,11 +1465,11 @@ private: NO_MOVE_SEMANTIC(CallFrame); CallFrameId callFrameId_ {}; - CString functionName_ {}; + std::string functionName_ {}; std::optional> functionLocation_ {}; std::unique_ptr location_ {nullptr}; - CString url_ {}; - CVector> scopeChain_ {}; + std::string url_ {}; + std::vector> scopeChain_ {}; std::unique_ptr this_ {nullptr}; std::optional> returnValue_ {}; }; @@ -1537,35 +1535,35 @@ public: static std::unique_ptr FromFrameInfo(const FrameInfo &cpuFrameInfo); Local ToObject(const EcmaVM *ecmaVm) const override; - RuntimeCallFrame &SetFunctionName(const CString &functionName) + RuntimeCallFrame &SetFunctionName(const std::string &functionName) { functionName_ = functionName; return *this; } - const CString &GetFunctionName() const + const std::string &GetFunctionName() const { return functionName_; } - RuntimeCallFrame &SetScriptId(const CString &scriptId) + RuntimeCallFrame &SetScriptId(const std::string &scriptId) { scriptId_ = scriptId; return *this; } - const CString &GetScriptId() const + const std::string &GetScriptId() const { return scriptId_; } - RuntimeCallFrame &SetUrl(const CString &url) + RuntimeCallFrame &SetUrl(const std::string &url) { url_ = url; return *this; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_; } @@ -1596,9 +1594,9 @@ private: NO_COPY_SEMANTIC(RuntimeCallFrame); NO_MOVE_SEMANTIC(RuntimeCallFrame); - CString functionName_ {}; - CString scriptId_ {}; - CString url_ {}; + std::string functionName_ {}; + std::string scriptId_ {}; + std::string url_ {}; int32_t lineNumber_ {}; int32_t columnNumber_ {}; }; @@ -1643,13 +1641,13 @@ public: return id_; } - SamplingHeapProfileNode &SetChildren(CVector> children) + SamplingHeapProfileNode &SetChildren(std::vector> children) { children_ = std::move(children); return *this; } - const CVector> *GetChildren() const + const std::vector> *GetChildren() const { return &children_; } @@ -1661,7 +1659,7 @@ private: std::unique_ptr callFrame_ {nullptr}; size_t selfSize_ {}; int32_t id_ {}; - CVector> children_ {}; + std::vector> children_ {}; }; class SamplingHeapProfile final : public PtBaseTypes { @@ -1682,13 +1680,13 @@ public: return head_.get(); } - SamplingHeapProfile &SetSamples(CVector> samples) + SamplingHeapProfile &SetSamples(std::vector> samples) { samples_ = std::move(samples); return *this; } - const CVector> *GetSamples() const + const std::vector> *GetSamples() const { return &samples_; } @@ -1698,7 +1696,7 @@ private: NO_MOVE_SEMANTIC(SamplingHeapProfile); std::unique_ptr head_ {nullptr}; - CVector> samples_ {}; + std::vector> samples_ {}; }; // ========== Profiler types begin @@ -1787,7 +1785,7 @@ public: return hitCount_.has_value(); } - const CVector *GetChildren() const + const std::vector *GetChildren() const { if (children_) { return &children_.value(); @@ -1795,7 +1793,7 @@ public: return nullptr; } - ProfileNode &SetChildren(CVector children) + ProfileNode &SetChildren(std::vector children) { children_ = std::move(children); return *this; @@ -1806,7 +1804,7 @@ public: return children_.has_value(); } - const CVector> *GetPositionTicks() const + const std::vector> *GetPositionTicks() const { if (positionTicks_) { return &positionTicks_.value(); @@ -1814,7 +1812,7 @@ public: return nullptr; } - ProfileNode &SetPositionTicks(CVector> positionTicks) + ProfileNode &SetPositionTicks(std::vector> positionTicks) { positionTicks_ = std::move(positionTicks); return *this; @@ -1825,12 +1823,12 @@ public: return positionTicks_.has_value(); } - const CString &GetDeoptReason() const + const std::string &GetDeoptReason() const { return deoptReason_.value(); } - ProfileNode &SetDeoptReason(const CString &deoptReason) + ProfileNode &SetDeoptReason(const std::string &deoptReason) { deoptReason_ = deoptReason; return *this; @@ -1847,9 +1845,9 @@ private: int32_t id_ {0}; std::unique_ptr callFrame_ {nullptr}; std::optional hitCount_ {0}; - std::optional> children_ {}; - std::optional>> positionTicks_ {}; - std::optional deoptReason_ {}; + std::optional> children_ {}; + std::optional>> positionTicks_ {}; + std::optional deoptReason_ {}; }; // Profiler.Profile @@ -1884,18 +1882,18 @@ public: return *this; } - const CVector> *GetNodes() const + const std::vector> *GetNodes() const { return &nodes_; } - Profile &SetNodes(CVector> nodes) + Profile &SetNodes(std::vector> nodes) { nodes_ = std::move(nodes); return *this; } - const CVector *GetSamples() const + const std::vector *GetSamples() const { if (samples_) { return &samples_.value(); @@ -1903,7 +1901,7 @@ public: return nullptr; } - Profile &SetSamples(CVector samples) + Profile &SetSamples(std::vector samples) { samples_ = std::move(samples); return *this; @@ -1914,7 +1912,7 @@ public: return samples_.has_value(); } - const CVector *GetTimeDeltas() const + const std::vector *GetTimeDeltas() const { if (timeDeltas_) { return &timeDeltas_.value(); @@ -1922,7 +1920,7 @@ public: return nullptr; } - Profile &SetTimeDeltas(CVector timeDeltas) + Profile &SetTimeDeltas(std::vector timeDeltas) { timeDeltas_ = std::move(timeDeltas); return *this; @@ -1939,9 +1937,9 @@ private: int64_t startTime_ {0}; int64_t endTime_ {0}; - CVector> nodes_ {}; - std::optional> samples_ {}; - std::optional> timeDeltas_ {}; + std::vector> nodes_ {}; + std::optional> samples_ {}; + std::optional> timeDeltas_ {}; }; // Profiler.Coverage @@ -2004,23 +2002,23 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; - const CString &GetFunctionName() const + const std::string &GetFunctionName() const { return functionName_; } - FunctionCoverage &SetFunctionName(const CString &functionName) + FunctionCoverage &SetFunctionName(const std::string &functionName) { functionName_ = functionName; return *this; } - const CVector> *GetRanges() const + const std::vector> *GetRanges() const { return &ranges_; } - FunctionCoverage &SetFunctions(CVector> ranges) + FunctionCoverage &SetFunctions(std::vector> ranges) { ranges_ = std::move(ranges); return *this; @@ -2041,8 +2039,8 @@ private: NO_COPY_SEMANTIC(FunctionCoverage); NO_MOVE_SEMANTIC(FunctionCoverage); - CString functionName_ {}; - CVector> ranges_ {}; + std::string functionName_ {}; + std::vector> ranges_ {}; bool isBlockCoverage_ {}; }; @@ -2056,34 +2054,34 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; - const CString &GetScriptId() const + const std::string &GetScriptId() const { return scriptId_; } - ScriptCoverage &SetScriptId(const CString &scriptId) + ScriptCoverage &SetScriptId(const std::string &scriptId) { scriptId_ = scriptId; return *this; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_; } - ScriptCoverage &SetUrl(const CString &url) + ScriptCoverage &SetUrl(const std::string &url) { url_ = url; return *this; } - const CVector> *GetFunctions() const + const std::vector> *GetFunctions() const { return &functions_; } - ScriptCoverage &SetFunctions(CVector> functions) + ScriptCoverage &SetFunctions(std::vector> functions) { functions_ = std::move(functions); return *this; @@ -2093,9 +2091,9 @@ private: NO_COPY_SEMANTIC(ScriptCoverage); NO_MOVE_SEMANTIC(ScriptCoverage); - CString scriptId_ {}; - CString url_ {}; - CVector> functions_ {}; + std::string scriptId_ {}; + std::string url_ {}; + std::vector> functions_ {}; }; // Profiler.TypeObject @@ -2106,12 +2104,12 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; - const CString &GetName() const + const std::string &GetName() const { return name_; } - TypeObject &SetName(const CString &name) + TypeObject &SetName(const std::string &name) { name_ = name; return *this; @@ -2121,7 +2119,7 @@ private: NO_COPY_SEMANTIC(TypeObject); NO_MOVE_SEMANTIC(TypeObject); - CString name_ {}; + std::string name_ {}; }; // Profiler.TypeProfileEntry @@ -2143,12 +2141,12 @@ public: return *this; } - const CVector> *GetTypes() const + const std::vector> *GetTypes() const { return &types_; } - TypeProfileEntry &SetTypes(CVector> types) + TypeProfileEntry &SetTypes(std::vector> types) { types_ = std::move(types); return *this; @@ -2159,7 +2157,7 @@ private: NO_MOVE_SEMANTIC(TypeProfileEntry); size_t offset_ {0}; - CVector> types_ {}; + std::vector> types_ {}; }; // Profiler.ScriptTypeProfile @@ -2170,34 +2168,34 @@ public: static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) const override; - const CString &GetScriptId() const + const std::string &GetScriptId() const { return scriptId_; } - ScriptTypeProfile &SetScriptId(const CString &scriptId) + ScriptTypeProfile &SetScriptId(const std::string &scriptId) { scriptId_ = scriptId; return *this; } - const CString &GetUrl() const + const std::string &GetUrl() const { return url_; } - ScriptTypeProfile &SetUrl(const CString &url) + ScriptTypeProfile &SetUrl(const std::string &url) { url_ = url; return *this; } - const CVector> *GetEntries() const + const std::vector> *GetEntries() const { return &entries_; } - ScriptTypeProfile &SetEntries(CVector> entries) + ScriptTypeProfile &SetEntries(std::vector> entries) { entries_ = std::move(entries); return *this; @@ -2207,9 +2205,9 @@ private: NO_COPY_SEMANTIC(ScriptTypeProfile); NO_MOVE_SEMANTIC(ScriptTypeProfile); - CString scriptId_ {}; - CString url_ {}; - CVector> entries_ {}; + std::string scriptId_ {}; + std::string url_ {}; + std::vector> entries_ {}; }; } // namespace panda::ecmascript::tooling #endif diff --git a/ecmascript/tooling/debugger_service.cpp b/ecmascript/tooling/debugger_service.cpp index a8173fa9a6..1e91a31d30 100644 --- a/ecmascript/tooling/debugger_service.cpp +++ b/ecmascript/tooling/debugger_service.cpp @@ -40,7 +40,7 @@ void DispatchProtocolMessage(const ::panda::ecmascript::EcmaVM *vm, const std::s { ProtocolHandler *handler = vm->GetJsDebuggerManager()->GetDebuggerHandler(); if (handler != nullptr) { - handler->ProcessCommand(message.c_str()); + handler->ProcessCommand(message); } } } // namespace panda::ecmascript::tooling \ No newline at end of file diff --git a/ecmascript/tooling/dispatcher.cpp b/ecmascript/tooling/dispatcher.cpp index 6b22f2ee91..d272755629 100644 --- a/ecmascript/tooling/dispatcher.cpp +++ b/ecmascript/tooling/dispatcher.cpp @@ -24,7 +24,7 @@ #include "ecmascript/tooling/protocol_channel.h" namespace panda::ecmascript::tooling { -DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const CString &message) : ecmaVm_(ecmaVm) +DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const std::string &message) : ecmaVm_(ecmaVm) { Local msgValue = JSON::Parse(ecmaVm, StringRef::NewFromUtf8(ecmaVm, message.c_str())); if (msgValue->IsException()) { @@ -65,11 +65,11 @@ DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const CString &message) : LOG(ERROR, DEBUGGER) << "method format error"; return; } - CString wholeMethod = DebuggerApi::ToCString(methodResult); - CString::size_type length = wholeMethod.length(); - CString::size_type indexPoint; + std::string wholeMethod = DebuggerApi::ToStdString(methodResult); + std::string::size_type length = wholeMethod.length(); + std::string::size_type indexPoint; indexPoint = wholeMethod.find_first_of('.', 0); - if (indexPoint == CString::npos || indexPoint == 0 || indexPoint == length - 1) { + if (indexPoint == std::string::npos || indexPoint == 0 || indexPoint == length - 1) { code_ = RequestCode::METHOD_FORMAT_ERROR; LOG(ERROR, DEBUGGER) << "method format error: " << wholeMethod; return; @@ -94,7 +94,7 @@ DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const CString &message) : params_ = paramsValue; } -DispatchResponse DispatchResponse::Create(ResponseCode code, const CString &msg) +DispatchResponse DispatchResponse::Create(ResponseCode code, const std::string &msg) { DispatchResponse response; response.code_ = code; @@ -102,7 +102,7 @@ DispatchResponse DispatchResponse::Create(ResponseCode code, const CString &msg) return response; } -DispatchResponse DispatchResponse::Create(std::optional error) +DispatchResponse DispatchResponse::Create(std::optional error) { DispatchResponse response; if (error.has_value()) { @@ -117,7 +117,7 @@ DispatchResponse DispatchResponse::Ok() return DispatchResponse(); } -DispatchResponse DispatchResponse::Fail(const CString &message) +DispatchResponse DispatchResponse::Fail(const std::string &message) { DispatchResponse response; response.code_ = ResponseCode::NOK; @@ -158,7 +158,7 @@ void Dispatcher::Dispatch(const DispatchRequest &request) LOG(ERROR, DEBUGGER) << "Unknown request"; return; } - const CString &domain = request.GetDomain(); + const std::string &domain = request.GetDomain(); auto dispatcher = dispatchers_.find(domain); if (dispatcher != dispatchers_.end()) { dispatcher->second->Dispatch(request); diff --git a/ecmascript/tooling/dispatcher.h b/ecmascript/tooling/dispatcher.h index 3138dacacb..d8c43788bd 100644 --- a/ecmascript/tooling/dispatcher.h +++ b/ecmascript/tooling/dispatcher.h @@ -19,8 +19,6 @@ #include #include -#include "ecmascript/mem/c_containers.h" -#include "ecmascript/mem/c_string.h" #include "ecmascript/napi/include/jsnapi.h" #include "ecmascript/tooling/backend/js_debugger_interface.h" #include "ecmascript/tooling/base/pt_returns.h" @@ -49,7 +47,7 @@ enum class ResponseCode : uint8_t { OK, NOK }; class DispatchRequest { public: - explicit DispatchRequest(const EcmaVM *ecmaVm, const CString &message); + explicit DispatchRequest(const EcmaVM *ecmaVm, const std::string &message); bool IsValid() const { @@ -63,11 +61,11 @@ public: { return params_; } - const CString &GetDomain() const + const std::string &GetDomain() const { return domain_; } - const CString &GetMethod() const + const std::string &GetMethod() const { return method_; } @@ -81,11 +79,11 @@ public: private: const EcmaVM *ecmaVm_ {nullptr}; int32_t callId_ {-1}; - CString domain_ {}; - CString method_ {}; + std::string domain_ {}; + std::string method_ {}; Local params_ {}; RequestCode code_ {RequestCode::OK}; - CString errorMsg_ {}; + std::string errorMsg_ {}; }; class DispatchResponse { @@ -100,15 +98,15 @@ public: return code_; } - const CString &GetMessage() const + const std::string &GetMessage() const { return errorMsg_; } - static DispatchResponse Create(ResponseCode code, const CString &msg = ""); - static DispatchResponse Create(std::optional error); + static DispatchResponse Create(ResponseCode code, const std::string &msg = ""); + static DispatchResponse Create(std::optional error); static DispatchResponse Ok(); - static DispatchResponse Fail(const CString &message); + static DispatchResponse Fail(const std::string &message); ~DispatchResponse() = default; @@ -116,7 +114,7 @@ private: DispatchResponse() = default; ResponseCode code_ {ResponseCode::OK}; - CString errorMsg_ {}; + std::string errorMsg_ {}; }; class DispatcherBase { @@ -146,7 +144,7 @@ public: void Dispatch(const DispatchRequest &request); private: - CUnorderedMap> dispatchers_ {}; + std::unordered_map> dispatchers_ {}; NO_COPY_SEMANTIC(Dispatcher); NO_MOVE_SEMANTIC(Dispatcher); diff --git a/ecmascript/tooling/interface/file_stream.cpp b/ecmascript/tooling/interface/file_stream.cpp index 6cd5a7f424..6c02144bdb 100644 --- a/ecmascript/tooling/interface/file_stream.cpp +++ b/ecmascript/tooling/interface/file_stream.cpp @@ -19,7 +19,6 @@ #include #include "ecmascript/ecma_macros.h" -#include "ecmascript/mem/c_string.h" #include "libpandabase/utils/logger.h" namespace panda::ecmascript { @@ -106,7 +105,7 @@ bool FileDescriptorStream::WriteChunk(char *data, int size) return false; } - CString str; + std::string str; str.resize(size); for (int i = 0; i < size; ++i) { str[i] = data[i]; diff --git a/ecmascript/tooling/protocol_handler.cpp b/ecmascript/tooling/protocol_handler.cpp index ca045d52a3..48e18a060f 100644 --- a/ecmascript/tooling/protocol_handler.cpp +++ b/ecmascript/tooling/protocol_handler.cpp @@ -34,7 +34,7 @@ void ProtocolHandler::RunIfWaitingForDebugger() waitingForDebugger_ = false; } -void ProtocolHandler::ProcessCommand(const CString &msg) +void ProtocolHandler::ProcessCommand(const std::string &msg) { LOG(DEBUG, DEBUGGER) << "ProtocolHandler::ProcessCommand: " << msg; [[maybe_unused]] LocalScope scope(vm_); diff --git a/ecmascript/tooling/protocol_handler.h b/ecmascript/tooling/protocol_handler.h index d4141ed72f..cffaf53efe 100644 --- a/ecmascript/tooling/protocol_handler.h +++ b/ecmascript/tooling/protocol_handler.h @@ -31,7 +31,7 @@ public: void WaitForDebugger() override; void RunIfWaitingForDebugger() override; - void ProcessCommand(const CString &msg); + void ProcessCommand(const std::string &msg); void SendResponse(const DispatchRequest &request, const DispatchResponse &response, const PtBaseReturns &result) override; void SendNotification(const PtBaseEvents &events) override; diff --git a/ecmascript/tooling/test/debugger_entry_test.cpp b/ecmascript/tooling/test/debugger_entry_test.cpp index f910bd1be6..ed893fee2e 100644 --- a/ecmascript/tooling/test/debugger_entry_test.cpp +++ b/ecmascript/tooling/test/debugger_entry_test.cpp @@ -53,7 +53,7 @@ public: HWTEST_P_L0(DebuggerEntryTest, DebuggerSuite) { - CString testName = GetCurrentTestName(); + std::string testName = GetCurrentTestName(); std::cout << "Running " << testName << std::endl; ASSERT_NE(instance, nullptr); auto [pandaFile, entryPoint] = GetTestEntryPoint(testName); diff --git a/ecmascript/tooling/test/debugger_events_test.cpp b/ecmascript/tooling/test/debugger_events_test.cpp index 84fb2af0f5..2470553b31 100644 --- a/ecmascript/tooling/test/debugger_events_test.cpp +++ b/ecmascript/tooling/test/debugger_events_test.cpp @@ -62,7 +62,6 @@ protected: HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToObjectTest) { - CString msg; BreakpointResolved breakpointResolved; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); @@ -79,7 +78,7 @@ HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("00", DebuggerApi::ToCString(result)); + EXPECT_EQ("00", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "location"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -90,16 +89,11 @@ HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToObjectTest) HWTEST_F_L0(DebuggerEventsTest, PausedToObjectTest) { - CString msg; Paused paused; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params": - {"callFrames":[{"callFrameId":"10","functionName":"name0", - "location":{"scriptId":"5","lineNumber":19},"url":"url7", - "scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}], - "this":{"type":"object","subtype":"v128"}}],"reason":"exception"}})"; - paused.SetCallFrames(CVector>{}) + std::vector> v; + paused.SetCallFrames(std::move(v)) .SetReason(PauseReason::EXCEPTION); Local object1 = paused.ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); @@ -111,7 +105,7 @@ HWTEST_F_L0(DebuggerEventsTest, PausedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("exception", DebuggerApi::ToCString(result)); + EXPECT_EQ("exception", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "callFrames"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -122,7 +116,6 @@ HWTEST_F_L0(DebuggerEventsTest, PausedToObjectTest) HWTEST_F_L0(DebuggerEventsTest, ResumedToObjectTest) { - CString msg; Resumed resumed; Local tmpStr; @@ -132,7 +125,7 @@ HWTEST_F_L0(DebuggerEventsTest, ResumedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(resumed.GetName(), DebuggerApi::ToCString(result)); + EXPECT_EQ(resumed.GetName(), DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -143,7 +136,6 @@ HWTEST_F_L0(DebuggerEventsTest, ResumedToObjectTest) HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest) { - CString msg; ScriptFailedToParse parsed; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); @@ -172,13 +164,13 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("100", DebuggerApi::ToCString(result)); + EXPECT_EQ("100", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("use/test.js", DebuggerApi::ToCString(result)); + EXPECT_EQ("use/test.js", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLine"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -214,7 +206,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("hash0001", DebuggerApi::ToCString(result)); + EXPECT_EQ("hash0001", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData"); ASSERT_FALSE(object->Has(ecmaVm, tmpStr)); @@ -223,7 +215,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("usr/", DebuggerApi::ToCString(result)); + EXPECT_EQ("usr/", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "hasSourceURL"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -253,18 +245,17 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("JavaScript", DebuggerApi::ToCString(result)); + EXPECT_EQ("JavaScript", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "embedderName"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("hh", DebuggerApi::ToCString(result)); + EXPECT_EQ("hh", DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest) { - CString msg; ScriptParsed parsed; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); @@ -294,13 +285,13 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("10", DebuggerApi::ToCString(result)); + EXPECT_EQ("10", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("use/test.js", DebuggerApi::ToCString(result)); + EXPECT_EQ("use/test.js", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLine"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -336,7 +327,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("hash0001", DebuggerApi::ToCString(result)); + EXPECT_EQ("hash0001", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData"); ASSERT_FALSE(object->Has(ecmaVm, tmpStr)); @@ -351,7 +342,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("usr/", DebuggerApi::ToCString(result)); + EXPECT_EQ("usr/", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "hasSourceURL"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -381,29 +372,29 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("JavaScript", DebuggerApi::ToCString(result)); + EXPECT_EQ("JavaScript", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "embedderName"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("hh", DebuggerApi::ToCString(result)); + EXPECT_EQ("hh", DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerEventsTest, ConsoleProfileFinishedToObjectTest) { - CString msg; ConsoleProfileFinished consoleProfileFinished; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); auto location = std::make_unique(); location->SetScriptId(13).SetLine(20); + std::vector> v; auto profile = std::make_unique(); - profile->SetNodes(CVector>{}) + profile->SetNodes(std::move(v)) .SetStartTime(0) .SetEndTime(15) - .SetSamples(CVector{}) - .SetTimeDeltas(CVector{}); + .SetSamples(std::vector{}) + .SetTimeDeltas(std::vector{}); consoleProfileFinished.SetId("11").SetLocation(std::move(location)).SetProfile(std::move(profile)).SetTitle("001"); Local object1 = consoleProfileFinished.ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); @@ -415,7 +406,7 @@ HWTEST_F_L0(DebuggerEventsTest, ConsoleProfileFinishedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "11"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "11"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "location"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -433,12 +424,11 @@ HWTEST_F_L0(DebuggerEventsTest, ConsoleProfileFinishedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "001"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "001"); } HWTEST_F_L0(DebuggerEventsTest, ConsoleProfileStartedToObjectTest) { - CString msg; ConsoleProfileStarted consoleProfileStarted; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); @@ -455,14 +445,14 @@ HWTEST_F_L0(DebuggerEventsTest, ConsoleProfileStartedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "12"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "12"); Local tmpObject = consoleProfileStarted.GetLocation()->ToObject(ecmaVm); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(tmpObject->Has(ecmaVm, tmpStr)); Local tmpResult = tmpObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!tmpResult.IsEmpty() && !tmpResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(tmpResult), "17"); + EXPECT_EQ(DebuggerApi::ToStdString(tmpResult), "17"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(tmpObject->Has(ecmaVm, tmpStr)); tmpResult = tmpObject->Get(ecmaVm, tmpStr); @@ -473,17 +463,17 @@ HWTEST_F_L0(DebuggerEventsTest, ConsoleProfileStartedToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "002"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "002"); } HWTEST_F_L0(DebuggerEventsTest, PreciseCoverageDeltaUpdateToObjectTest) { - CString msg; PreciseCoverageDeltaUpdate preciseCoverageDeltaUpdate; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); + std::vector> v; preciseCoverageDeltaUpdate.SetOccasion("percise") - .SetResult(CVector>{}) + .SetResult(std::move(v)) .SetTimestamp(77); Local object1 = preciseCoverageDeltaUpdate.ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); @@ -500,7 +490,7 @@ HWTEST_F_L0(DebuggerEventsTest, PreciseCoverageDeltaUpdateToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "percise"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "percise"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "result"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -510,11 +500,10 @@ HWTEST_F_L0(DebuggerEventsTest, PreciseCoverageDeltaUpdateToObjectTest) HWTEST_F_L0(DebuggerEventsTest, HeapStatsUpdateToObjectTest) { - CString msg; HeapStatsUpdate heapStatsUpdate; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); - heapStatsUpdate.SetStatsUpdate(CVector {}); + heapStatsUpdate.SetStatsUpdate(std::vector {}); Local object1 = heapStatsUpdate.ToObject(ecmaVm); Local result = object1->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); @@ -530,7 +519,6 @@ HWTEST_F_L0(DebuggerEventsTest, HeapStatsUpdateToObjectTest) HWTEST_F_L0(DebuggerEventsTest, LastSeenObjectIdToObjectTest) { - CString msg; LastSeenObjectId lastSeenObjectId; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); @@ -555,7 +543,6 @@ HWTEST_F_L0(DebuggerEventsTest, LastSeenObjectIdToObjectTest) HWTEST_F_L0(DebuggerEventsTest, ReportHeapSnapshotProgressToObjectTest) { - CString msg; ReportHeapSnapshotProgress reportHeapSnapshotProgress; Local tmpStr = StringRef::NewFromUtf8(ecmaVm, "params"); diff --git a/ecmascript/tooling/test/debugger_params_test.cpp b/ecmascript/tooling/test/debugger_params_test.cpp index 42ee1f58f0..d08694f2b0 100644 --- a/ecmascript/tooling/test/debugger_params_test.cpp +++ b/ecmascript/tooling/test/debugger_params_test.cpp @@ -67,43 +67,43 @@ protected: HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsCreateTest) { - CString msg; + std::string msg; std::unique_ptr startSamplingData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(startSamplingData, nullptr); EXPECT_EQ(startSamplingData->GetSamplingInterval(), 32768); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(startSamplingData, nullptr); EXPECT_EQ(startSamplingData->GetSamplingInterval(), 32768); // abnormal params of params.sub-key=["samplingInterval":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":true}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":true}})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of params.sub-key=["samplingInterval":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":"Test"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":"Test"}})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(startSamplingData, nullptr); // abnormal params of params.sub-key = [ "size"=100,"nodeId"=1,"ordinal"=10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":1000}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":1000}})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(startSamplingData, nullptr); EXPECT_EQ(startSamplingData->GetSamplingInterval(), 1000); @@ -111,11 +111,11 @@ HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsCreateTest) HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr startSamplingData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":1000}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":1000}})"; startSamplingData = StartSamplingParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(startSamplingData, nullptr); Local object = startSamplingData->ToObject(ecmaVm); @@ -129,43 +129,43 @@ HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsToObjectTest) HWTEST_F_L0(DebuggerParamsTest, StartTrackingHeapObjectsParamsCreateTest) { - CString msg; + std::string msg; std::unique_ptr objectData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetTrackAllocations()); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetTrackAllocations()); // abnormal params of params.sub-key=["trackAllocations":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":10}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":10}})"; objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["trackAllocations":"Test"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":"Test"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":"Test"}})"; objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["trackAllocations":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":true}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":true}})"; objectData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); ASSERT_TRUE(objectData->GetTrackAllocations()); @@ -173,11 +173,11 @@ HWTEST_F_L0(DebuggerParamsTest, StartTrackingHeapObjectsParamsCreateTest) HWTEST_F_L0(DebuggerParamsTest, StartTrackingHeapObjectsParamsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr startTrackingData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":true}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":true}})"; startTrackingData = StartTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(startTrackingData, nullptr); Local object = startTrackingData->ToObject(ecmaVm); @@ -191,21 +191,21 @@ HWTEST_F_L0(DebuggerParamsTest, StartTrackingHeapObjectsParamsToObjectTest) HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsCreateTest) { - CString msg; + std::string msg; std::unique_ptr objectData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetReportProgress()); @@ -213,28 +213,28 @@ HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsCreateTest) ASSERT_FALSE(objectData->GetCaptureNumericValue()); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); ASSERT_FALSE(objectData->GetReportProgress()); ASSERT_FALSE(objectData->GetTreatGlobalObjectsAsRoots()); ASSERT_FALSE(objectData->GetCaptureNumericValue()); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "reportProgress":10, "treatGlobalObjectsAsRoots":10, "captureNumericValue":10}})"; objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "reportProgress":"Test", "treatGlobalObjectsAsRoots":"Test", "captureNumericValue":"Test"}})"; objectData = StopTrackingHeapObjectsParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "reportProgress":true, "treatGlobalObjectsAsRoots":true, "captureNumericValue":true}})"; @@ -247,11 +247,11 @@ HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsCreateTest) HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr stopTrackingData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "reportProgress":true, "treatGlobalObjectsAsRoots":true, "captureNumericValue":true}})"; @@ -280,41 +280,41 @@ HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsToObjectTest) HWTEST_F_L0(DebuggerParamsTest, AddInspectedHeapObjectParamsCreateTest) { - CString msg; + std::string msg; std::unique_ptr objectData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["heapObjectId":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":10}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":10}})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["heapObjectId":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":true}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":true}})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["heapObjectId":“10”] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":"10"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":"10"}})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetHeapObjectId(), 10); @@ -322,11 +322,11 @@ HWTEST_F_L0(DebuggerParamsTest, AddInspectedHeapObjectParamsCreateTest) HWTEST_F_L0(DebuggerParamsTest, AddInspectedHeapObjectParamsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr objectData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":"10"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":"10"}})"; objectData = AddInspectedHeapObjectParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); Local object = objectData->ToObject(ecmaVm); @@ -335,46 +335,46 @@ HWTEST_F_L0(DebuggerParamsTest, AddInspectedHeapObjectParamsToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "10"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "10"); } HWTEST_F_L0(DebuggerParamsTest, GetHeapObjectIdParamsCreateTest) { - CString msg; + std::string msg; std::unique_ptr objectData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":true}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":true}})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":“10”] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetObjectId(), 10); @@ -382,11 +382,11 @@ HWTEST_F_L0(DebuggerParamsTest, GetHeapObjectIdParamsCreateTest) HWTEST_F_L0(DebuggerParamsTest, GetHeapObjectIdParamsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr objectData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; objectData = GetHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); Local object = objectData->ToObject(ecmaVm); @@ -395,52 +395,52 @@ HWTEST_F_L0(DebuggerParamsTest, GetHeapObjectIdParamsToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "10"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "10"); } HWTEST_F_L0(DebuggerParamsTest, GetObjectByHeapObjectIdParamsCreateTest) { - CString msg; + std::string msg; std::unique_ptr objectData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":10}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":10}})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of params.sub-key=["objectId":“10”] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetObjectId(), 10); ASSERT_FALSE(objectData->HasObjectGroup()); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":"groupname"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":"groupname"}})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); EXPECT_EQ((int)objectData->GetObjectId(), 10); @@ -449,11 +449,11 @@ HWTEST_F_L0(DebuggerParamsTest, GetObjectByHeapObjectIdParamsCreateTest) HWTEST_F_L0(DebuggerParamsTest, GetObjectByHeapObjectIdParamsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr objectData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":"groupname"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":"groupname"}})"; objectData = GetObjectByHeapObjectIdParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); Local object = objectData->ToObject(ecmaVm); @@ -462,55 +462,55 @@ HWTEST_F_L0(DebuggerParamsTest, GetObjectByHeapObjectIdParamsToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "10"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "10"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "objectGroup"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "groupname"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "groupname"); } HWTEST_F_L0(DebuggerParamsTest, StartPreciseCoverageParamCreateTest) { - CString msg; + std::string msg; std::unique_ptr objectData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callCount":8, "detailed":8, "allowTriggeredUpdates":8}})"; objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callCount":"Test", "detailed":"Test", "allowTriggeredUpdates":"Test"}})"; objectData = StartPreciseCoverageParam::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callCount":true, "detailed":true, "allowTriggeredUpdates":true}})"; @@ -523,11 +523,11 @@ HWTEST_F_L0(DebuggerParamsTest, StartPreciseCoverageParamCreateTest) HWTEST_F_L0(DebuggerParamsTest, StartPreciseCoverageParamToObjectTest) { - CString msg; + std::string msg; std::unique_ptr startTrackingData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callCount":true, "detailed":true, "allowTriggeredUpdates":true}})"; @@ -556,35 +556,35 @@ HWTEST_F_L0(DebuggerParamsTest, StartPreciseCoverageParamToObjectTest) HWTEST_F_L0(DebuggerParamsTest, SetSamplingIntervalParamsCreateTest) { - CString msg; + std::string msg; std::unique_ptr objectData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "interval":"500"}})"; objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(objectData, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"interval":500}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"interval":500}})"; objectData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(objectData, nullptr); EXPECT_EQ(objectData->GetInterval(), 500); @@ -592,11 +592,11 @@ HWTEST_F_L0(DebuggerParamsTest, SetSamplingIntervalParamsCreateTest) HWTEST_F_L0(DebuggerParamsTest, SetSamplingIntervalParamsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr setSamplingIntervalData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"interval":500}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"interval":500}})"; setSamplingIntervalData = SetSamplingIntervalParams::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(setSamplingIntervalData, nullptr); Local object = setSamplingIntervalData->ToObject(ecmaVm); diff --git a/ecmascript/tooling/test/debugger_returns_test.cpp b/ecmascript/tooling/test/debugger_returns_test.cpp index ed8a56030f..ac261edc4a 100644 --- a/ecmascript/tooling/test/debugger_returns_test.cpp +++ b/ecmascript/tooling/test/debugger_returns_test.cpp @@ -69,12 +69,12 @@ HWTEST_F_L0(DebuggerReturnsTest, EnableReturnsToObjectTest) ASSERT_TRUE(enableObject->Has(ecmaVm, tmpStr)); Local result = enableObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString("100"), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string("100"), DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointByUrlReturnsToObjectTest) { - auto locations = CVector>(); + auto locations = std::vector>(); std::unique_ptr location = std::make_unique(); location->SetScriptId(1); locations.emplace_back(std::move(location)); @@ -88,7 +88,7 @@ HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointByUrlReturnsToObjectTest) ASSERT_TRUE(setObject->Has(ecmaVm, tmpStr)); Local result = setObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString("11"), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string("11"), DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerReturnsTest, EvaluateOnCallFrameReturnsToObjectTest) @@ -114,7 +114,7 @@ HWTEST_F_L0(DebuggerReturnsTest, EvaluateOnCallFrameReturnsToObjectTest) HWTEST_F_L0(DebuggerReturnsTest, GetPossibleBreakpointsReturnsToObjectTest) { - auto locations = CVector>(); + auto locations = std::vector>(); std::unique_ptr breakLocation = std::make_unique(); std::unique_ptr getPossibleBreakpointsReturns = std::make_unique (std::move(locations)); @@ -136,18 +136,18 @@ HWTEST_F_L0(DebuggerReturnsTest, GetScriptSourceReturnsToObjectTest) ASSERT_TRUE(scriptObject->Has(ecmaVm, tmpStr)); Local result = scriptObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString("source_1"), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string("source_1"), DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "bytecode"); ASSERT_TRUE(scriptObject->Has(ecmaVm, tmpStr)); result = scriptObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString("bytecode_1"), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string("bytecode_1"), DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerReturnsTest, RestartFrameReturnsToObjectTest) { - auto callFrames = CVector>(); + auto callFrames = std::vector>(); std::unique_ptr callFrame = std::make_unique(); std::unique_ptr restartFrameReturns = std::make_unique (std::move(callFrames)); @@ -170,7 +170,7 @@ HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointReturnsToObjectTest) ASSERT_TRUE(breakObject->Has(ecmaVm, tmpStr)); Local result = breakObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString("breakpointId_1"), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string("breakpointId_1"), DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "actualLocation"); ASSERT_TRUE(breakObject->Has(ecmaVm, tmpStr)); @@ -189,12 +189,12 @@ HWTEST_F_L0(DebuggerReturnsTest, SetInstrumentationBreakpointReturnsToObjectTest ASSERT_TRUE(instrumentationObject->Has(ecmaVm, tmpStr)); Local result = instrumentationObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString("111"), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string("111"), DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerReturnsTest, SetScriptSourceReturnsToObjectTest) { - auto callFrames = CVector>(); + auto callFrames = std::vector>(); std::unique_ptr callFrame = std::make_unique(); std::unique_ptr exceptionDetails = std::make_unique(); std::unique_ptr setScriptSourceReturns = std::make_unique @@ -213,7 +213,7 @@ HWTEST_F_L0(DebuggerReturnsTest, SetScriptSourceReturnsToObjectTest) HWTEST_F_L0(DebuggerReturnsTest, GetPropertiesReturnsToObjectTest) { - auto descriptor = CVector>(); + auto descriptor = std::vector>(); std::unique_ptr propertyDescriptor = std::make_unique(); std::unique_ptr exceptionDetails = std::make_unique(); std::unique_ptr getPropertiesReturns = std::make_unique @@ -229,14 +229,14 @@ HWTEST_F_L0(DebuggerReturnsTest, GetPropertiesReturnsToObjectTest) ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); ASSERT_TRUE(result->IsArray(ecmaVm)); - auto internalDescripties = CVector>(); + auto internalDescripties = std::vector>(); std::unique_ptr internalPropertyDescriptor = std::make_unique(); internalPropertyDescriptor->SetName("filename1"); internalDescripties.emplace_back(std::move(internalPropertyDescriptor)); ASSERT_EQ(internalDescripties.back()->GetName(), "filename1"); - auto privateProperties = CVector>(); + auto privateProperties = std::vector>(); std::unique_ptr privatePropertyDescriptor = std::make_unique(); privatePropertyDescriptor->SetName("filename2"); @@ -268,7 +268,7 @@ HWTEST_F_L0(DebuggerReturnsTest, GetHeapObjectIdReturnsToObjectTest) Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString("10"), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string("10"), DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerReturnsTest, GetObjectByHeapObjectIdReturnsToObjectTest) @@ -322,7 +322,7 @@ HWTEST_F_L0(DebuggerReturnsTest, GetHeapUsageReturnsToObjectTest) HWTEST_F_L0(DebuggerReturnsTest, GetBestEffortCoverageReturnsToObjectTest) { - auto result = CVector>(); + auto result = std::vector>(); std::unique_ptr scriptCoverage = std::make_unique(); std::unique_ptr getBestEffortCoverageReturns = std::make_unique(std::move(result)); @@ -349,7 +349,7 @@ HWTEST_F_L0(DebuggerReturnsTest, StartPreciseCoverageReturnsToObjectTest) HWTEST_F_L0(DebuggerReturnsTest, TakePreciseCoverageReturnsToObjectTest) { - auto coverage = CVector>(); + auto coverage = std::vector>(); std::unique_ptr takePreciseCoverageReturns = std::make_unique(std::move(coverage), 1001); ASSERT_NE(takePreciseCoverageReturns, nullptr); @@ -370,7 +370,7 @@ HWTEST_F_L0(DebuggerReturnsTest, TakePreciseCoverageReturnsToObjectTest) HWTEST_F_L0(DebuggerReturnsTest, TakeTypeProfileturnsToObjectTest) { - auto result = CVector>(); + auto result = std::vector>(); std::unique_ptr scriptTypeProfile = std::make_unique(); std::unique_ptr takeTypeProfileturns = std::make_unique (std::move(result)); diff --git a/ecmascript/tooling/test/debugger_types_test.cpp b/ecmascript/tooling/test/debugger_types_test.cpp index fe2578cab5..b7a44fe7ae 100644 --- a/ecmascript/tooling/test/debugger_types_test.cpp +++ b/ecmascript/tooling/test/debugger_types_test.cpp @@ -67,60 +67,60 @@ protected: HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) { - CString msg; + std::string msg; std::unique_ptr remoteObject; Local tmpStr; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = 100, ] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = [ "sub": "test" ] }, ] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", ] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"("}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"("}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); // abnormal params of params.sub-key = [ type = "object", subtype = "unknown"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":"unknown"}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", subtype = 100] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", subtype = "array"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Array + R"("}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); @@ -129,19 +129,19 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) EXPECT_EQ(ObjectSubType::Array, remoteObject->GetSubType()); // abnormal params of params.sub-key = [ type = "object", className = 100] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","className":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", className = {"xx":"yy"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","className":{"xx":"yy"}}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", className = "TestClass"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","className":"TestClass"}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); @@ -150,7 +150,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) EXPECT_EQ("TestClass", remoteObject->GetClassName()); // normal params of params.sub-key = [ type = "object", value = 100] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","value":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); @@ -159,7 +159,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) EXPECT_EQ(Local(remoteObject->GetValue())->Value(), 100.0); // normal params of params.sub-key = [ type = "object", value = {"xx":"yy"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","value":{"xx":"yy"}}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); @@ -170,28 +170,28 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) ASSERT_TRUE(Local(remoteObject->GetValue())->Has(ecmaVm, Local(tmpStr))); // normal params of params.sub-key = [ type = "object", value = "Test"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","value":"Test"}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); EXPECT_EQ(ObjectType::Object, remoteObject->GetType()); ASSERT_TRUE(remoteObject->HasValue()); - EXPECT_EQ("Test", DebuggerApi::ToCString(remoteObject->GetValue())); + EXPECT_EQ("Test", DebuggerApi::ToStdString(remoteObject->GetValue())); // abnormal params of params.sub-key = [ type = "object", unserializableValue = 100] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","unserializableValue":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", unserializableValue = {"xx":"yy"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","unserializableValue":{"xx":"yy"}}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", unserializableValue = "TestClass"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","unserializableValue":"Test"}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); @@ -200,19 +200,19 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) EXPECT_EQ("Test", remoteObject->GetUnserializableValue()); // abnormal params of params.sub-key = [ type = "object", description = 100] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","description":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", description = {"xx":"yy"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","description":{"xx":"yy"}}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", description = "Test"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","description":"Test"}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); @@ -221,19 +221,19 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) EXPECT_EQ("Test", remoteObject->GetDescription()); // abnormal params of params.sub-key = [ type = "object", objectId = 100] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","objectId":100}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // abnormal params of params.sub-key = [ type = "object", objectId = {"xx":"yy"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","objectId":{"xx":"yy"}}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(remoteObject, nullptr); // normal params of params.sub-key = [ type = "object", objectId = "id_1"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","objectId":"1"}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); @@ -244,14 +244,13 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest) HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest) { - CString msg; + std::string msg; std::unique_ptr remoteObject; Local tmpStr; - msg = - CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":")" + - ObjectSubType::Array + - R"(","className":"TestClass","value":100,"unserializableValue":"Test","description":"Test","objectId":"1"}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + + R"(", "subtype":")" + ObjectSubType::Array + + R"(","className":"TestClass","value":100, "unserializableValue":"Test","description":"Test","objectId":"1"}})"; remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(remoteObject, nullptr); Local object = remoteObject->ToObject(ecmaVm); @@ -260,17 +259,17 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Array.c_str()), DebuggerApi::ToCString(result)); + EXPECT_EQ(std::string(ObjectSubType::Array.c_str()), DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "className"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("TestClass", DebuggerApi::ToCString(result)); + EXPECT_EQ("TestClass", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "value"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -280,94 +279,94 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("Test", DebuggerApi::ToCString(result)); + EXPECT_EQ("Test", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "description"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("Test", DebuggerApi::ToCString(result)); + EXPECT_EQ("Test", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "objectId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("1", DebuggerApi::ToCString(result)); + EXPECT_EQ("1", DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) { - CString msg; + std::string msg; std::unique_ptr exceptionMetaData; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId="Test","text"="text0","lineNumber"=10,"columnNumber"=20] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":"Test","text":"text0","lineNumber":10,"columnNumber":20}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId={"xx":"yy"},"text"="text0","lineNumber"=10,"columnNumber"=20] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":{"xx":"yy"},"text":"text0","lineNumber":10,"columnNumber":20}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"=10,"lineNumber"=10,"columnNumber"=20] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":10,"lineNumber":10,"columnNumber":20}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"=["text0"],"lineNumber"=10,"columnNumber"=20] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":["text0"],"lineNumber":10,"columnNumber":20}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"="10","columnNumber"=20] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":"10","columnNumber":20}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=["10"],"columnNumber"=20] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":["10"],"columnNumber":20}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"="20"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":"20"}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=["20"]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":["20"]}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = [ exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(exceptionMetaData, nullptr); @@ -378,21 +377,21 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"scriptId"=10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":10}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"scriptId"=["10"]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":["10"]}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"scriptId"="id0"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"0"}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(exceptionMetaData, nullptr); @@ -404,21 +403,21 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"url"=10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"url":10}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"url"=["10"]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"url":["10"]}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"url"="url0"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"url":"url0"}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(exceptionMetaData, nullptr); @@ -430,21 +429,21 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"exception"=10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"exception":10}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"exception"=["10"]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"exception":["10"]}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"exception"={}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"exception":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Error + R"("}}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -460,21 +459,21 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"executionContextId"="10"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"executionContextId":"10"}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // abnormal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"executionContextId"=["10"]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"executionContextId":["10"]}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(exceptionMetaData, nullptr); // normal params of params.sub-key = // [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"executionContextId"=2] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"executionContextId":2}})"; exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(exceptionMetaData, nullptr); @@ -487,11 +486,11 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest) HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest) { - CString msg; + std::string msg; std::unique_ptr exceptionMetaData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "exceptionId":5,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"100","url":"url0", "exception":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Error + R"("},"executionContextId":30}})"; @@ -508,7 +507,7 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("text0", DebuggerApi::ToCString(result)); + EXPECT_EQ("text0", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -523,12 +522,12 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("100", DebuggerApi::ToCString(result)); + EXPECT_EQ("100", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("url0", DebuggerApi::ToCString(result)); + EXPECT_EQ("url0", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "exception"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -538,12 +537,12 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Error.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Error.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextId"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -553,81 +552,81 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest) HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorCreateTest) { - CString msg; + std::string msg; std::unique_ptr internalPropertyDescriptor; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8","value":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":99}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":[99]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":[99]}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name7"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name7"}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(internalPropertyDescriptor, nullptr); EXPECT_EQ("name7", internalPropertyDescriptor->GetName()); // abnormal params of unknown params.sub-key=["name":"name8","value":{"type":"object","subtype":"map"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":"99"}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // abnormal params of unknown params.sub-key=["name":"name8","value":{"type":"object","subtype":"wrong"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":{"type":")" + ObjectType::Object + R"(","subtype":"wrong"}}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(internalPropertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","value":{"type":"object","subtype":"map"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Map + R"("}}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -642,11 +641,11 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorCreateTest) HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorToObjectTest) { - CString msg; + std::string msg; std::unique_ptr internalPropertyDescriptor; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Map + R"("}}})"; internalPropertyDescriptor = InternalPropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -657,7 +656,7 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("name8", DebuggerApi::ToCString(result)); + EXPECT_EQ("name8", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "value"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -667,89 +666,89 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Map.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Map.c_str()), DebuggerApi::ToStdString(subResult)); } HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) { - CString msg; + std::string msg; std::unique_ptr propertyDescriptor; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":10,"configurable":true,"enumerable":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":10,"configurable":true,"enumerable":true,"value":10}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":["name85"],"configurable":true,"enumerable":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":["name85"],"configurable":true,"enumerable":true,"value":10}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":10,"enumerable":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":10,"enumerable":true}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":"true","enumerable":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":"true","enumerable":true}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":10}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":"true"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":"true"}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"value":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"value":10}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"value":{"ee":"11"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"value":{"ee":"11"}}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"value":{..}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"value":{"type":")" + ObjectType::Symbol + R"("}}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -762,19 +761,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) EXPECT_EQ(value->GetType(), ObjectType::Symbol); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"writable":98] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"writable":98}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"writable":[true]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"writable":[true]}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"writable":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"writable":true}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(propertyDescriptor, nullptr); @@ -784,19 +783,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) ASSERT_TRUE(propertyDescriptor->GetWritable()); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"get":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"get":10}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"get":[10]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"get":[10]}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"get":{}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"get":{"type":")" + ObjectType::Function + R"("}}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -809,19 +808,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) EXPECT_EQ(get->GetType(), ObjectType::Function); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"set":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"set":10}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"set":[10]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"set":[10]}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"set":{}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"set":{"type":")" + ObjectType::String + R"("}}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -834,19 +833,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) EXPECT_EQ(set->GetType(), ObjectType::String); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"wasThrown":98] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"wasThrown":98}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"wasThrown":[true]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"wasThrown":[true]}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"wasThrown":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"wasThrown":true}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(propertyDescriptor, nullptr); @@ -856,19 +855,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) ASSERT_TRUE(propertyDescriptor->GetWasThrown()); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"isOwn":98] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"isOwn":98}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"isOwn":[true]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"isOwn":[true]}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true,"isOwn":true] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"isOwn":true}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(propertyDescriptor, nullptr); @@ -878,19 +877,19 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) ASSERT_TRUE(propertyDescriptor->GetIsOwn()); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true, "symbol":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"symbol":10}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // abnormal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true, "symbol":[10]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"symbol":[10]}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(propertyDescriptor, nullptr); // normal params of params.sub-key=["name":"name8","configurable":true,"enumerable":true, "symbol":{}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name85","configurable":true,"enumerable":true,"symbol":{"type":")" + ObjectType::Wasm + R"("}}})"; propertyDescriptor = PropertyDescriptor::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -905,11 +904,11 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest) HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) { - CString msg; + std::string msg; std::unique_ptr propertyDescriptor; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "name":"name8","value":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Map + R"("}, "writable":true,"get":{"type":")" + @@ -925,7 +924,7 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("name8", DebuggerApi::ToCString(result)); + EXPECT_EQ("name8", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "value"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -935,12 +934,12 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Map.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Map.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "writable"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -955,12 +954,12 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Regexp.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Regexp.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "set"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -970,12 +969,12 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Generator.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Generator.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "configurable"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1005,76 +1004,76 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Proxy.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Proxy.c_str()), DebuggerApi::ToStdString(subResult)); } HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest) { - CString msg; + std::string msg; std::unique_ptr location; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":10,"lineNumber":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":10,"lineNumber":99 }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":["id3"],"lineNumber":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":["id3"],"lineNumber":99 }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":"99"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":"99" }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":[99]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":[99] }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18" }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(location, nullptr); // normal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":138] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":138 }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1084,7 +1083,7 @@ HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest) EXPECT_EQ(location->GetColumn(), 138); // normal params of params.sub-key=["scriptId":"2122","lineNumber":8299] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"2122","lineNumber":8299 }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1095,11 +1094,11 @@ HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest) HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest) { - CString msg; + std::string msg; std::unique_ptr location; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"2","lineNumber":99,"columnNumber":18 }})"; location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1110,7 +1109,7 @@ HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("2", DebuggerApi::ToCString(result)); + EXPECT_EQ("2", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1125,80 +1124,80 @@ HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest) HWTEST_F_L0(DebuggerTypesTest, BreakLocationCreateTest) { - CString msg; + std::string msg; std::unique_ptr breakLocation; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":10,"lineNumber":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":10,"lineNumber":99 }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":["id3"],"lineNumber":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":["id3"],"lineNumber":99 }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":"99"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":"99" }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"222","lineNumber":[99]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":[99] }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18" }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18","type":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18","type":10 }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18","type":"ee"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":"18","type":"ee" }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(breakLocation, nullptr); // normal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":138,"type":"return"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"222","lineNumber":899,"columnNumber":138,"type":"return" }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1209,7 +1208,7 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationCreateTest) EXPECT_EQ("return", breakLocation->GetType()); // normal params of params.sub-key=["scriptId":"2122","lineNumber":8299] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"2122","lineNumber":8299 }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1220,11 +1219,11 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationCreateTest) HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest) { - CString msg; + std::string msg; std::unique_ptr breakLocation; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"12","lineNumber":919,"columnNumber":148,"type":"call" }})"; breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1235,7 +1234,7 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("12", DebuggerApi::ToCString(result)); + EXPECT_EQ("12", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1250,77 +1249,77 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("call", DebuggerApi::ToCString(result)); + EXPECT_EQ("call", DebuggerApi::ToStdString(result)); } HWTEST_F_L0(DebuggerTypesTest, ScopeCreateTest) { - CString msg; + std::string msg; std::unique_ptr scope; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"ss","object":{..}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"ss","object":{"type":")" + ObjectType::Bigint + R"("}}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":12,"object":{..}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":12,"object":{"type":")" + ObjectType::Bigint + R"("}}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":10}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"ww":")" + ObjectType::Bigint + R"("}}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"name":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"name":10}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"name":["10"]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"name":["10"]}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // normal params of params.sub-key=["type":"global","object":{..},"name":"name128"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"name":"name117"}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1328,35 +1327,35 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeCreateTest) EXPECT_EQ("name117", scope->GetName()); // abnormal params of params.sub-key=["type":"global","object":{..},"startLocation":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"startLocation":10}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"startLocation":{"12":"34"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"startLocation":{"12":"34"}}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"endLocation":10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"endLocation":10}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // abnormal params of params.sub-key=["type":"global","object":{..},"endLocation":{"12":"34"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("},"endLocation":{"12":"34"}}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scope, nullptr); // normal params of params.sub-key=["type":"global","object":{..}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Bigint + R"("}}})"; scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); @@ -1369,11 +1368,11 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeCreateTest) HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) { - CString msg; + std::string msg; std::unique_ptr scope; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "type":"global","object":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Dataview + R"("},"name":"name9", "startLocation":{"scriptId":"2","lineNumber":99}, @@ -1387,7 +1386,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("global", DebuggerApi::ToCString(result)); + EXPECT_EQ("global", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "object"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1397,17 +1396,17 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Dataview.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Dataview.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "name"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("name9", DebuggerApi::ToCString(result)); + EXPECT_EQ("name9", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLocation"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1417,7 +1416,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ("2", DebuggerApi::ToCString(subResult)); + EXPECT_EQ("2", DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); @@ -1432,7 +1431,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ("13", DebuggerApi::ToCString(subResult)); + EXPECT_EQ("13", DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); @@ -1442,31 +1441,31 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest) HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) { - CString msg; + std::string msg; std::unique_ptr callFrame; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(callFrame, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(callFrame, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(callFrame, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":10,"functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1476,7 +1475,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":["0"],"functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1486,7 +1485,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":10, "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1496,7 +1495,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":["name0"], "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1506,7 +1505,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0","functionLocation":10, "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1516,7 +1515,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0","functionLocation":{"scriptId11":"id5","lineNumber":19}, "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1526,7 +1525,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId2":"id5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1536,7 +1535,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":10,"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1546,7 +1545,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":10,"scopeChain": [{"type":"global","object":{"type":")" + @@ -1556,7 +1555,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":{"url":"url7"},"scopeChain": [{"type":"global","object":{"type":")" + @@ -1566,7 +1565,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19}, "url":"url7","scopeChain":10,"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})"; @@ -1574,7 +1573,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": {"type":"22","object":{"type":")" + @@ -1584,7 +1583,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1594,7 +1593,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1604,7 +1603,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1615,7 +1614,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1626,7 +1625,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(callFrame, nullptr); // normal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1641,7 +1640,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) EXPECT_EQ(5U, location->GetScriptId()); EXPECT_EQ(location->GetLine(), 19); EXPECT_EQ("url7", callFrame->GetUrl()); - const CVector> *scopeChain = callFrame->GetScopeChain(); + const std::vector> *scopeChain = callFrame->GetScopeChain(); EXPECT_EQ(scopeChain->size(), 2U); RemoteObject *thisObj = callFrame->GetThis(); ASSERT_NE(thisObj, nullptr); @@ -1650,7 +1649,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) ASSERT_FALSE(callFrame->HasReturnValue()); // normal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"10","functionName":"name0","functionLocation":{"scriptId":"3","lineNumber":16}, "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1682,11 +1681,11 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest) HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) { - CString msg; + std::string msg; std::unique_ptr callFrame; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrameId":"0","functionName":"name0","functionLocation":{"scriptId":"3","lineNumber":16}, "location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain": [{"type":"global","object":{"type":")" + @@ -1701,12 +1700,12 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); Local result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("0", DebuggerApi::ToCString(result)); + EXPECT_EQ("0", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "functionName"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("name0", DebuggerApi::ToCString(result)); + EXPECT_EQ("name0", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "functionLocation"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1716,7 +1715,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); Local subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ("3", DebuggerApi::ToCString(subResult)); + EXPECT_EQ("3", DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); @@ -1731,7 +1730,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ("5", DebuggerApi::ToCString(subResult)); + EXPECT_EQ("5", DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); @@ -1741,7 +1740,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ("url7", DebuggerApi::ToCString(result)); + EXPECT_EQ("url7", DebuggerApi::ToStdString(result)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scopeChain"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1758,12 +1757,12 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::Iterator.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::Iterator.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "returnValue"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -1773,53 +1772,53 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest) ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectType::Object.c_str()), DebuggerApi::ToStdString(subResult)); tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype"); ASSERT_TRUE(Local(result)->Has(ecmaVm, Local(tmpStr))); subResult = Local(result)->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(CString(ObjectSubType::I64.c_str()), DebuggerApi::ToCString(subResult)); + EXPECT_EQ(std::string(ObjectSubType::I64.c_str()), DebuggerApi::ToStdString(subResult)); } HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileSampleCreateTest) { - CString msg; + std::string msg; std::unique_ptr object; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of params.sub-key = [ "size"="Test","nodeId"="Test","ordinal"="Test"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "size":"Test","nodeId":"Test","ordinal":"Test"}})"; object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of params.sub-key = [ "size"={"xx":"yy"},"nodeId"={"xx":"yy"},"ordinal"={"xx":"yy"}] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "size":{"xx":"yy"},"nodeId":{"xx":"yy"},"ordinal":{"xx":"yy"}}})"; object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of params.sub-key = [ "size"=100,"nodeId"=1,"ordinal"=10] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"size":100,"nodeId":1,"ordinal":10}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"size":100,"nodeId":1,"ordinal":10}})"; object = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(object, nullptr); EXPECT_EQ(object->GetSize(), 100); @@ -1829,11 +1828,11 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileSampleCreateTest) HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileSampleToObjectTest) { - CString msg; + std::string msg; std::unique_ptr samplingHeapProfileSampleData; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"size":100,"nodeId":1,"ordinal":10}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"size":100,"nodeId":1,"ordinal":10}})"; samplingHeapProfileSampleData = SamplingHeapProfileSample::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(samplingHeapProfileSampleData, nullptr); Local object = samplingHeapProfileSampleData->ToObject(ecmaVm); @@ -1859,30 +1858,30 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileSampleToObjectTest) HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeCreateTest) { - CString msg; + std::string msg; std::unique_ptr object; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; object = SamplingHeapProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrame": {"functionName":"Create", "scriptId":"10", "url":"url3", "lineNumber":100, "columnNumber":20}, "selfSize":10, "id":5, @@ -1900,18 +1899,18 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeCreateTest) EXPECT_EQ(object->GetSelfSize(), 10); EXPECT_EQ(object->GetId(), 5); - const CVector> *children = object->GetChildren(); + const std::vector> *children = object->GetChildren(); ASSERT_NE(children, nullptr); EXPECT_EQ((int)children->size(), 0); } HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeToObjectTest) { - CString msg; + std::string msg; std::unique_ptr samplingHeapProfileNode; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "callFrame": {"functionName":"Create", "scriptId":"10", "url":"url3", "lineNumber":100, "columnNumber":20}, "selfSize":10, "id":5, @@ -1930,17 +1929,17 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeToObjectTest) ASSERT_TRUE(subObject->Has(ecmaVm, tmpStr)); Local subResult = subObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(subResult), "Create"); + EXPECT_EQ(DebuggerApi::ToStdString(subResult), "Create"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(subObject->Has(ecmaVm, tmpStr)); subResult = subObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(subResult), "10"); + EXPECT_EQ(DebuggerApi::ToStdString(subResult), "10"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(subObject->Has(ecmaVm, tmpStr)); subResult = subObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(subResult), "url3"); + EXPECT_EQ(DebuggerApi::ToStdString(subResult), "url3"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "selfSize"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); @@ -1963,30 +1962,30 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileNodeToObjectTest) HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileCreateTest) { - CString msg; + std::string msg; std::unique_ptr object; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; object = SamplingHeapProfile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(object, nullptr); - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "head": { "callFrame": {"functionName":"Create", "scriptId":"10", "url":"url3", "lineNumber":100, "columnNumber":20}, "selfSize":10, @@ -2010,11 +2009,11 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileCreateTest) EXPECT_EQ(head->GetSelfSize(), 10); EXPECT_EQ(head->GetId(), 5); - const CVector> *children = head->GetChildren(); + const std::vector> *children = head->GetChildren(); ASSERT_NE(children, nullptr); EXPECT_EQ((int)children->size(), 0); - const CVector> *samples = object->GetSamples(); + const std::vector> *samples = object->GetSamples(); ASSERT_NE(samples, nullptr); EXPECT_EQ((int)samples->size(), 1); EXPECT_EQ(samples->data()->get()->GetSize(), 100); @@ -2024,11 +2023,11 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileCreateTest) HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileToObjectTest) { - CString msg; + std::string msg; std::unique_ptr samplingHeapProfile; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "head": { "callFrame": {"functionName":"Create", "scriptId":"10", "url":"url3", "lineNumber":100, "columnNumber":20}, "selfSize":10, @@ -2058,17 +2057,17 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileToObjectTest) ASSERT_TRUE(callFrameObject->Has(ecmaVm, tmpStr)); Local subResult = callFrameObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(subResult), "Create"); + EXPECT_EQ(DebuggerApi::ToStdString(subResult), "Create"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(callFrameObject->Has(ecmaVm, tmpStr)); subResult = callFrameObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(subResult), "10"); + EXPECT_EQ(DebuggerApi::ToStdString(subResult), "10"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(callFrameObject->Has(ecmaVm, tmpStr)); subResult = callFrameObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(subResult), "url3"); + EXPECT_EQ(DebuggerApi::ToStdString(subResult), "url3"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "selfSize"); ASSERT_TRUE(headObject->Has(ecmaVm, tmpStr)); @@ -2116,49 +2115,49 @@ HWTEST_F_L0(DebuggerTypesTest, SamplingHeapProfileToObjectTest) HWTEST_F_L0(DebuggerTypesTest, PositionTickInfoCreateTest) { - CString msg; + std::string msg; std::unique_ptr positionTickInfo; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of params.sub-key=["line":11,"ticks":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "line":"11","ticks":99}})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of params.sub-key=["line":"11","ticks":"99"] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "line":"11","ticks":"99"}})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(positionTickInfo, nullptr); // abnormal params of params.sub-key=["line":[11],"ticks":[99]] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "line":[11],"ticks":[99]}})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(positionTickInfo, nullptr); // normal params of params.sub-key=["line":11,"ticks":99] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"line":1,"ticks":0}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"line":1,"ticks":0}})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(positionTickInfo, nullptr); EXPECT_EQ(positionTickInfo->GetLine(), 1); @@ -2168,11 +2167,11 @@ HWTEST_F_L0(DebuggerTypesTest, PositionTickInfoCreateTest) HWTEST_F_L0(DebuggerTypesTest, PositionTickInfoToObjectTest) { - CString msg; + std::string msg; std::unique_ptr positionTickInfo; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "line":1,"ticks":0,}})"; positionTickInfo = PositionTickInfo::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(positionTickInfo, nullptr); @@ -2193,31 +2192,31 @@ HWTEST_F_L0(DebuggerTypesTest, PositionTickInfoToObjectTest) HWTEST_F_L0(DebuggerTypesTest, ProfileNodeCreateTest) { - CString msg; + std::string msg; std::unique_ptr profileNode; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profileNode, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profileNode, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profileNode, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; profileNode = ProfileNode::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profileNode, nullptr); // normal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "id":10, "callFrame": {"functionName":"name0", "scriptId":"12", "url":"url15", "lineNumber":11, "columnNumber":20}, "hitCount":15,"children":[],"positionTicks":[],"deoptReason":"yyy"}})"; @@ -2239,11 +2238,11 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileNodeCreateTest) HWTEST_F_L0(DebuggerTypesTest, ProfileNodeToObjectTest) { - CString msg; + std::string msg; std::unique_ptr profilenode; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "id":10, "callFrame": {"functionName":"name0", "scriptId":"12", "url":"url15", "lineNumber":11, "columnNumber":20}, "hitCount":15,"children":[],"positionTicks":[],"deoptReason":"yyy"}})"; @@ -2267,17 +2266,17 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileNodeToObjectTest) ASSERT_TRUE(tmpObject->Has(ecmaVm, tmpStr)); Local tmpResult = tmpObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!tmpResult.IsEmpty() && !tmpResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(tmpResult), "name0"); + EXPECT_EQ(DebuggerApi::ToStdString(tmpResult), "name0"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "scriptId"); ASSERT_TRUE(tmpObject->Has(ecmaVm, tmpStr)); tmpResult = tmpObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!tmpResult.IsEmpty() && !tmpResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(tmpResult), "12"); + EXPECT_EQ(DebuggerApi::ToStdString(tmpResult), "12"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(tmpObject->Has(ecmaVm, tmpStr)); tmpResult = tmpObject->Get(ecmaVm, tmpStr); ASSERT_TRUE(!tmpResult.IsEmpty() && !tmpResult->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(tmpResult), "url15"); + EXPECT_EQ(DebuggerApi::ToStdString(tmpResult), "url15"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber"); ASSERT_TRUE(tmpObject->Has(ecmaVm, tmpStr)); tmpResult = tmpObject->Get(ecmaVm, tmpStr); @@ -2299,54 +2298,54 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileNodeToObjectTest) ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "yyy"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "yyy"); } HWTEST_F_L0(DebuggerTypesTest, ProfileCreateTest) { - CString msg; + std::string msg; std::unique_ptr profile; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profile, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profile, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profile, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(profile, nullptr); // abnormal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startTime":10,"endTime":25,"nodes":[],"samples":[],"timeDeltas":[]}})"; profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(profile, nullptr); EXPECT_EQ(profile->GetStartTime(), 10LL); EXPECT_EQ(profile->GetEndTime(), 25LL); - const CVector> *profileNode = profile->GetNodes(); + const std::vector> *profileNode = profile->GetNodes(); ASSERT_NE(profileNode, nullptr); EXPECT_EQ((int)profileNode->size(), 0); } HWTEST_F_L0(DebuggerTypesTest, ProfileToObjectTest) { - CString msg; + std::string msg; std::unique_ptr profile; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startTime":10,"endTime":25,"nodes":[],"samples":[],"timeDeltas":[]}})"; profile = Profile::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(profile, nullptr); @@ -2372,31 +2371,31 @@ HWTEST_F_L0(DebuggerTypesTest, ProfileToObjectTest) HWTEST_F_L0(DebuggerTypesTest, CoverageCreateTest) { - CString msg; + std::string msg; std::unique_ptr coverage; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(coverage, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(coverage, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(coverage, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(coverage, nullptr); // normal params of params.sub-key=["startOffset":0,"endOffset":5,"count":13] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startOffset":0,"endOffset":13,"count":13}})"; coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(coverage, nullptr); @@ -2407,11 +2406,11 @@ HWTEST_F_L0(DebuggerTypesTest, CoverageCreateTest) HWTEST_F_L0(DebuggerTypesTest, CoverageToObjectTest) { - CString msg; + std::string msg; std::unique_ptr coverage; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "startOffset":0,"endOffset":13,"count":13}})"; coverage = Coverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(coverage, nullptr); @@ -2439,37 +2438,37 @@ HWTEST_F_L0(DebuggerTypesTest, CoverageToObjectTest) HWTEST_F_L0(DebuggerTypesTest, FunctionCoverageCreateTest) { - CString msg; + std::string msg; std::unique_ptr functionCoverage; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(functionCoverage, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(functionCoverage, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(functionCoverage, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(functionCoverage, nullptr); // normal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "functionName":"Create0","ranges":[],"isBlockCoverage":true}})"; functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(functionCoverage, nullptr); EXPECT_EQ(functionCoverage->GetFunctionName(), "Create0"); - const CVector> *ranges = functionCoverage->GetRanges(); + const std::vector> *ranges = functionCoverage->GetRanges(); ASSERT_NE(ranges, nullptr); EXPECT_EQ((int)ranges->size(), 0); ASSERT_TRUE(functionCoverage->GetIsBlockCoverage()); @@ -2477,11 +2476,11 @@ HWTEST_F_L0(DebuggerTypesTest, FunctionCoverageCreateTest) HWTEST_F_L0(DebuggerTypesTest, FunctionCoverageToObjectTest) { - CString msg; + std::string msg; std::unique_ptr functionCoverage; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "functionName":"Create0","ranges":[],"isBlockCoverage":true}})"; functionCoverage = FunctionCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(functionCoverage, nullptr); @@ -2491,7 +2490,7 @@ HWTEST_F_L0(DebuggerTypesTest, FunctionCoverageToObjectTest) Local result = object->Get(ecmaVm, tmpStr); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "Create0"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "Create0"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "ranges"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); @@ -2506,48 +2505,48 @@ HWTEST_F_L0(DebuggerTypesTest, FunctionCoverageToObjectTest) HWTEST_F_L0(DebuggerTypesTest, ScriptCoverageCreateTest) { - CString msg; + std::string msg; std::unique_ptr scriptCoverage; // abnormal params of null msg - msg = CString() + R"({})"; + msg = std::string() + R"({})"; scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scriptCoverage, nullptr); // abnormal params of unexist key params - msg = CString() + R"({"id":0,"method":"Debugger.Test"})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test"})"; scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scriptCoverage, nullptr); // abnormal params of null params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scriptCoverage, nullptr); // abnormal params of unknown params.sub-key - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})"; scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); EXPECT_EQ(scriptCoverage, nullptr); // normal params of params.sub-key=[..] - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"1001","url":"url17","functions":[]}})"; scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(scriptCoverage, nullptr); EXPECT_EQ(scriptCoverage->GetScriptId(), "1001"); EXPECT_EQ(scriptCoverage->GetUrl(), "url17"); - const CVector> *functions = scriptCoverage->GetFunctions(); + const std::vector> *functions = scriptCoverage->GetFunctions(); ASSERT_NE(functions, nullptr); EXPECT_EQ((int)functions->size(), 0); } HWTEST_F_L0(DebuggerTypesTest, ScriptCoverageToObjectTest) { - CString msg; + std::string msg; std::unique_ptr scriptCoverage; Local tmpStr; - msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{ + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{ "scriptId":"1001","url":"url17","functions":[]}})"; scriptCoverage = ScriptCoverage::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams()); ASSERT_NE(scriptCoverage, nullptr); @@ -2557,12 +2556,12 @@ HWTEST_F_L0(DebuggerTypesTest, ScriptCoverageToObjectTest) Local result = object->Get(ecmaVm, tmpStr); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "1001"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "1001"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "url"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined()); - EXPECT_EQ(DebuggerApi::ToCString(result), "url17"); + EXPECT_EQ(DebuggerApi::ToStdString(result), "url17"); tmpStr = StringRef::NewFromUtf8(ecmaVm, "functions"); ASSERT_TRUE(object->Has(ecmaVm, tmpStr)); result = object->Get(ecmaVm, tmpStr); diff --git a/ecmascript/tooling/test/utils/test_entry.cpp b/ecmascript/tooling/test/utils/test_entry.cpp index 511105fe17..5e3d90b47b 100644 --- a/ecmascript/tooling/test/utils/test_entry.cpp +++ b/ecmascript/tooling/test/utils/test_entry.cpp @@ -26,7 +26,7 @@ static std::unique_ptr g_hooks = nullptr; bool StartDebuggerImpl([[maybe_unused]] const std::string &name, EcmaVM *vm, [[maybe_unused]] bool isDebugMode) { - CString testName = GetCurrentTestName(); + std::string testName = GetCurrentTestName(); g_hooks = std::make_unique(testName, vm); g_debuggerThread = std::thread([] { TestUtil::WaitForInit(); diff --git a/ecmascript/tooling/test/utils/test_events.h b/ecmascript/tooling/test/utils/test_events.h index 17236c9dc7..54e41ba60d 100644 --- a/ecmascript/tooling/test/utils/test_events.h +++ b/ecmascript/tooling/test/utils/test_events.h @@ -59,7 +59,7 @@ struct TestEvents { TestEvents(); virtual ~TestEvents() = default; - virtual std::pair GetEntryPoint() = 0; + virtual std::pair GetEntryPoint() = 0; }; } // namespace panda::ecmascript::tooling::test diff --git a/ecmascript/tooling/test/utils/test_extractor.h b/ecmascript/tooling/test/utils/test_extractor.h index 4cf68e4f2e..5cc9bedc5c 100644 --- a/ecmascript/tooling/test/utils/test_extractor.h +++ b/ecmascript/tooling/test/utils/test_extractor.h @@ -23,7 +23,7 @@ using EntityId = panda_file::File::EntityId; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct SourceLocation { - CString path; // NOLINT(misc-non-private-member-variables-in-classes) + std::string path; // NOLINT(misc-non-private-member-variables-in-classes) int32_t line; // NOLINT(misc-non-private-member-variables-in-classes) int32_t column; diff --git a/ecmascript/tooling/test/utils/test_hooks.h b/ecmascript/tooling/test/utils/test_hooks.h index c5adf6c373..e5fa79c77b 100644 --- a/ecmascript/tooling/test/utils/test_hooks.h +++ b/ecmascript/tooling/test/utils/test_hooks.h @@ -23,7 +23,7 @@ namespace panda::ecmascript::tooling::test { class TestHooks : public PtHooks { public: - TestHooks(const CString &testName, const EcmaVM *vm) : vm_(vm) + TestHooks(const std::string &testName, const EcmaVM *vm) : vm_(vm) { runtime_ = std::make_unique(vm, nullptr); debugger_ = std::make_unique(vm, nullptr, runtime_.get()); @@ -113,7 +113,7 @@ private: std::unique_ptr runtime_ {nullptr}; std::unique_ptr debugger_ {nullptr}; JSDebugger *debugInterface_; - CString testName_; + std::string testName_; TestEvents *test_; }; } // namespace panda::ecmascript::tooling::test diff --git a/ecmascript/tooling/test/utils/test_util.h b/ecmascript/tooling/test/utils/test_util.h index 4186834b40..993826daaa 100644 --- a/ecmascript/tooling/test/utils/test_util.h +++ b/ecmascript/tooling/test/utils/test_util.h @@ -26,16 +26,16 @@ namespace panda::ecmascript::tooling::test { template, class KeyEqual = std::equal_to> using CUnorderedMap = panda::ecmascript::CUnorderedMap; -using TestMap = CUnorderedMap>; +using TestMap = CUnorderedMap>; class TestUtil { public: - static void RegisterTest(const CString &testName, std::unique_ptr test) + static void RegisterTest(const std::string &testName, std::unique_ptr test) { testMap_.insert({testName, std::move(test)}); } - static TestEvents *GetTest(const CString &name) + static TestEvents *GetTest(const std::string &name) { auto iter = std::find_if(testMap_.begin(), testMap_.end(), [&name](auto &it) { return it.first == name; diff --git a/ecmascript/tooling/test/utils/testcases/js_breakpoint_arrow_test.h b/ecmascript/tooling/test/utils/testcases/js_breakpoint_arrow_test.h index 9ce610f248..e502c037e4 100644 --- a/ecmascript/tooling/test/utils/testcases/js_breakpoint_arrow_test.h +++ b/ecmascript/tooling/test/utils/testcases/js_breakpoint_arrow_test.h @@ -66,15 +66,15 @@ public: }; } - std::pair GetEntryPoint() override + std::pair GetEntryPoint() override { return {pandaFile_, entryPoint_}; } ~JsBreakpointArrowTest() = default; private: - CString pandaFile_ = DEBUGGER_ABC_DIR "ArrowFunc.abc"; - CString entryPoint_ = "_GLOBAL::func_main_0"; + std::string pandaFile_ = DEBUGGER_ABC_DIR "ArrowFunc.abc"; + std::string entryPoint_ = "_GLOBAL::func_main_0"; JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0}; size_t breakpointCounter_ = 0; bool flag_ = true; diff --git a/ecmascript/tooling/test/utils/testcases/js_breakpoint_async_test.h b/ecmascript/tooling/test/utils/testcases/js_breakpoint_async_test.h index 07d32c8708..2c90269baa 100644 --- a/ecmascript/tooling/test/utils/testcases/js_breakpoint_async_test.h +++ b/ecmascript/tooling/test/utils/testcases/js_breakpoint_async_test.h @@ -68,15 +68,15 @@ public: }; } - std::pair GetEntryPoint() override + std::pair GetEntryPoint() override { return {pandaFile_, entryPoint_}; } ~JsBreakpointAsyncTest() = default; private: - CString pandaFile_ = DEBUGGER_ABC_DIR "AsyncFunc.abc"; - CString entryPoint_ = "_GLOBAL::func_main_0"; + std::string pandaFile_ = DEBUGGER_ABC_DIR "AsyncFunc.abc"; + std::string entryPoint_ = "_GLOBAL::func_main_0"; JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0}; size_t breakpointCounter_ = 0; bool flag_ = true; diff --git a/ecmascript/tooling/test/utils/testcases/js_breakpoint_test.h b/ecmascript/tooling/test/utils/testcases/js_breakpoint_test.h index de9abb00e3..a598d26166 100644 --- a/ecmascript/tooling/test/utils/testcases/js_breakpoint_test.h +++ b/ecmascript/tooling/test/utils/testcases/js_breakpoint_test.h @@ -68,15 +68,15 @@ public: }; } - std::pair GetEntryPoint() override + std::pair GetEntryPoint() override { return {pandaFile_, entryPoint_}; } ~JsBreakpointTest() = default; private: - CString pandaFile_ = DEBUGGER_ABC_DIR "Sample.abc"; - CString entryPoint_ = "_GLOBAL::func_main_0"; + std::string pandaFile_ = DEBUGGER_ABC_DIR "Sample.abc"; + std::string entryPoint_ = "_GLOBAL::func_main_0"; JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0}; size_t breakpointCounter_ = 0; bool flag_ = true; diff --git a/ecmascript/tooling/test/utils/testcases/js_exception_test.h b/ecmascript/tooling/test/utils/testcases/js_exception_test.h index 004eb6e14e..94b3b5317d 100644 --- a/ecmascript/tooling/test/utils/testcases/js_exception_test.h +++ b/ecmascript/tooling/test/utils/testcases/js_exception_test.h @@ -33,7 +33,7 @@ public: ASSERT_TRUE(location.GetMethodId().IsValid()); ASSERT_LOCATION_EQ(location, location_); ++breakpointCounter_; - CVector> callFrames; + std::vector> callFrames; ASSERT_TRUE(debugger_->GenerateCallFrames(&callFrames)); ASSERT_TRUE(callFrames.size() > 0); auto jsLocation = callFrames[0]->GetLocation(); @@ -49,7 +49,7 @@ public: ASSERT_EQ(sourceLocation.line, 17); ASSERT_EQ(sourceLocation.column, 27); ++exceptionCounter_; - CVector> callFrames; + std::vector> callFrames; ASSERT_TRUE(debugger_->GenerateCallFrames(&callFrames)); ASSERT_TRUE(callFrames.size() > 0); auto jsLocation = callFrames[0]->GetLocation(); @@ -92,15 +92,15 @@ public: }; } - std::pair GetEntryPoint() override + std::pair GetEntryPoint() override { return {pandaFile_, entryPoint_}; } ~JsExceptionTest() = default; private: - CString pandaFile_ = DEBUGGER_ABC_DIR "exception.abc"; - CString entryPoint_ = "_GLOBAL::func_main_0"; + std::string pandaFile_ = DEBUGGER_ABC_DIR "exception.abc"; + std::string entryPoint_ = "_GLOBAL::func_main_0"; JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0}; size_t breakpointCounter_ = 0; size_t exceptionCounter_ = 0; diff --git a/ecmascript/tooling/test/utils/testcases/js_single_step_test.h b/ecmascript/tooling/test/utils/testcases/js_single_step_test.h index 9888595399..08cc43d566 100644 --- a/ecmascript/tooling/test/utils/testcases/js_single_step_test.h +++ b/ecmascript/tooling/test/utils/testcases/js_single_step_test.h @@ -77,14 +77,14 @@ public: }; } - std::pair GetEntryPoint() override + std::pair GetEntryPoint() override { return {pandaFile_, entryPoint_}; } private: - CString pandaFile_ = DEBUGGER_ABC_DIR "Sample.abc"; - CString entryPoint_ = "_GLOBAL::func_main_0"; + std::string pandaFile_ = DEBUGGER_ABC_DIR "Sample.abc"; + std::string entryPoint_ = "_GLOBAL::func_main_0"; JSPtLocation locationStart_ {nullptr, JSPtLocation::EntityId(0), 0}; JSPtLocation locationEnd_ {nullptr, JSPtLocation::EntityId(0), 0}; JSPtLocation locationStep_ {nullptr, JSPtLocation::EntityId(0), 0}; diff --git a/ecmascript/tooling/test/utils/testcases/test_list.cpp b/ecmascript/tooling/test/utils/testcases/test_list.cpp index 430ac42f1b..2cb272b700 100644 --- a/ecmascript/tooling/test/utils/testcases/test_list.cpp +++ b/ecmascript/tooling/test/utils/testcases/test_list.cpp @@ -25,7 +25,7 @@ #include "js_single_step_test.h" namespace panda::ecmascript::tooling::test { -static CString g_currentTestName = ""; +static std::string g_currentTestName = ""; static void RegisterTests() { @@ -37,10 +37,10 @@ static void RegisterTests() TestUtil::RegisterTest("JsBreakpointArrowTest", GetJsBreakpointArrowTest()); } -CVector GetTestList() +std::vector GetTestList() { RegisterTests(); - CVector res; + std::vector res; auto &tests = TestUtil::GetTests(); for (const auto &entry : tests) { @@ -49,17 +49,17 @@ CVector GetTestList() return res; } -void SetCurrentTestName(const CString &testName) +void SetCurrentTestName(const std::string &testName) { g_currentTestName = testName; } -CString GetCurrentTestName() +std::string GetCurrentTestName() { return g_currentTestName; } -std::pair GetTestEntryPoint(const CString &testName) +std::pair GetTestEntryPoint(const std::string &testName) { return TestUtil::GetTest(testName)->GetEntryPoint(); } diff --git a/ecmascript/tooling/test/utils/testcases/test_list.h b/ecmascript/tooling/test/utils/testcases/test_list.h index e9a75a34b0..0409f3897f 100644 --- a/ecmascript/tooling/test/utils/testcases/test_list.h +++ b/ecmascript/tooling/test/utils/testcases/test_list.h @@ -24,12 +24,12 @@ #include "libpandafile/file_items.h" namespace panda::ecmascript::tooling::test { -CVector GetTestList(); +std::vector GetTestList(); -void SetCurrentTestName(const CString &testName); -CString GetCurrentTestName(); +void SetCurrentTestName(const std::string &testName); +std::string GetCurrentTestName(); -std::pair GetTestEntryPoint(const CString &testName); +std::pair GetTestEntryPoint(const std::string &testName); } // namespace panda::ecmascript::tooling::test #endif // ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_TEST_LIST_H -- Gitee