Skip to content

Commit

Permalink
[unreal]继续减少std::string的使用
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Dec 6, 2024
1 parent d4b8b21 commit 1ab6536
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion unity/native_src/Src/BackendEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ std::string FBackendEnv::GetJSStackTrace()
JS_FreeValue(ctx, stack);
return ret;
#else
return StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed));
return StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed)).c_str();
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ FString FJsEnvImpl::CurrentStackTrace()
v8::Isolate::Scope IsolateScope(Isolate);
v8::HandleScope HandleScope(Isolate);

std::string StackTrace = StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed));
PString StackTrace = StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed));
return UTF8_TO_TCHAR(StackTrace.c_str());
#else
return TEXT("");
Expand Down
5 changes: 3 additions & 2 deletions unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <sstream>
#include "PString.h"
#if !defined(PUERTS_NAMESPACE)
#if defined(WITH_QJS_NAMESPACE_SUFFIX)
#define PUERTS_NAMESPACE puerts_qjs
Expand Down Expand Up @@ -71,7 +72,7 @@ void SetPromiseRejectCallback(const v8::FunctionCallbackInfo<v8::Value>& Args)

// TODO: rename this file
#ifndef WITH_QUICKJS
std::string StackTraceToString(v8::Isolate* InIsolate, v8::Local<v8::StackTrace> InStack)
PString StackTraceToString(v8::Isolate* InIsolate, v8::Local<v8::StackTrace> InStack)
{
std::ostringstream stm;
for (int i = 0; i < InStack->GetFrameCount(); i++)
Expand Down Expand Up @@ -106,7 +107,7 @@ std::string StackTraceToString(v8::Isolate* InIsolate, v8::Local<v8::StackTrace>
<< ")" << std::endl;
}
}
return stm.str();
return stm.str().c_str();
}
#endif

Expand Down

0 comments on commit 1ab6536

Please sign in to comment.