Skip to content

Commit 5aaac57

Browse files
authored
fix: devtools namespace usage (#1810)
1 parent f0b3c58 commit 5aaac57

File tree

3 files changed

+42
-40
lines changed

3 files changed

+42
-40
lines changed

test-app/runtime/src/main/cpp/JsV8InspectorClient.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212

1313
#include "ArgConverter.h"
1414
#include "Util.h"
15+
#include "Utils.h"
1516

1617
using namespace std;
1718
using namespace tns;
1819
using namespace v8;
1920

2021
using namespace v8_inspector;
22+
using namespace inspector;
2123

2224
// Utility functions for converting between inspector StringView and UTF8 string
2325

@@ -164,7 +166,7 @@ void JsV8InspectorClient::dispatchMessage(const std::string& message) {
164166
if(!arg.IsEmpty() && arg->IsObject()) {
165167
Local<Object> domainDebugger;
166168
Local<Object> argObject = arg.As<Object>();
167-
Local<v8::Function> domainMethodFunc = tns::Util::GetDebuggerFunctionFromObject(context, argObject, domainDebugger);
169+
Local<v8::Function> domainMethodFunc = GetDebuggerFunctionFromObject(context, argObject, domainDebugger);
168170

169171
Local<Value> result;
170172
success = this->CallDomainHandlerFunction(context, domainMethodFunc, argObject, domainDebugger, result);

test-app/runtime/src/main/cpp/v8_inspector/Utils.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,47 @@
44

55
using namespace v8;
66
using namespace std;
7-
namespace tns {
8-
9-
Local <v8::Function>
10-
GetDebuggerFunction(Local <Context> context, std::string domain, std::string functionName,
11-
Local <Object> &domainDebugger) {
12-
auto it = JsV8InspectorClient::Domains.find(domain);
13-
if (it == JsV8InspectorClient::Domains.end()) {
14-
return Local<v8::Function>();
15-
}
16-
17-
Isolate *isolate = context->GetIsolate();
18-
domainDebugger = it->second->Get(isolate);
19-
20-
Local <Value> value;
21-
auto funcName = v8::String::NewFromUtf8(isolate, functionName.c_str(),
22-
v8::NewStringType::kNormal,
23-
(int) functionName.length()).ToLocalChecked();
24-
bool success = domainDebugger->Get(context, funcName).ToLocal(&value);
25-
if (success && !value.IsEmpty() && value->IsFunction()) {
26-
return value.As<v8::Function>();
27-
}
287

8+
9+
Local<v8::Function>
10+
tns::inspector::GetDebuggerFunction(Local<Context> context, std::string domain,
11+
std::string functionName,
12+
Local<Object> &domainDebugger) {
13+
auto it = JsV8InspectorClient::Domains.find(domain);
14+
if (it == JsV8InspectorClient::Domains.end()) {
2915
return Local<v8::Function>();
3016
}
3117

32-
Local <v8::Function>
33-
GetDebuggerFunctionFromObject(Local <Context> context, const Local <Object> &object,
34-
Local <Object> &domainDebugger) {
35-
Isolate *isolate = context->GetIsolate();
36-
auto methodKey = v8::String::NewFromUtf8(isolate, "method",
37-
v8::NewStringType::kNormal).ToLocalChecked();
38-
auto method = object->Get(context, methodKey).ToLocalChecked();
39-
auto methodString = Util::ToString(isolate, method);
40-
auto domainSeparatorIndex = methodString.find(".");
41-
auto domain = methodString.substr(0, domainSeparatorIndex);
42-
auto domainMethod = methodString.substr(domainSeparatorIndex + 1, methodString.size());
43-
44-
if (domain.size() > 0) {
45-
return GetDebuggerFunction(context, domain, domainMethod, domainDebugger);
46-
}
18+
Isolate *isolate = context->GetIsolate();
19+
domainDebugger = it->second->Get(isolate);
4720

48-
return Local<v8::Function>();
21+
Local<Value> value;
22+
auto funcName = v8::String::NewFromUtf8(isolate, functionName.c_str(),
23+
v8::NewStringType::kNormal,
24+
(int) functionName.length()).ToLocalChecked();
25+
bool success = domainDebugger->Get(context, funcName).ToLocal(&value);
26+
if (success && !value.IsEmpty() && value->IsFunction()) {
27+
return value.As<v8::Function>();
4928
}
29+
30+
return Local<v8::Function>();
31+
}
32+
33+
Local<v8::Function>
34+
tns::inspector::GetDebuggerFunctionFromObject(Local<Context> context, const Local<Object> &object,
35+
Local<Object> &domainDebugger) {
36+
Isolate *isolate = context->GetIsolate();
37+
auto methodKey = v8::String::NewFromUtf8(isolate, "method",
38+
v8::NewStringType::kNormal).ToLocalChecked();
39+
auto method = object->Get(context, methodKey).ToLocalChecked();
40+
auto methodString = Util::ToString(isolate, method);
41+
auto domainSeparatorIndex = methodString.find(".");
42+
auto domain = methodString.substr(0, domainSeparatorIndex);
43+
auto domainMethod = methodString.substr(domainSeparatorIndex + 1, methodString.size());
44+
45+
if (domain.size() > 0) {
46+
return GetDebuggerFunction(context, domain, domainMethod, domainDebugger);
47+
}
48+
49+
return Local<v8::Function>();
5050
}

test-app/runtime/src/main/cpp/v8_inspector/Utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
namespace tns {
1010
namespace inspector {
11-
static v8::Local<v8::Function> GetDebuggerFunctionFromObject(v8::Local<v8::Context> context,
11+
v8::Local<v8::Function> GetDebuggerFunctionFromObject(v8::Local<v8::Context> context,
1212
const v8::Local<v8::Object> &object,
1313
v8::Local<v8::Object> &domainDebugger);
1414

15-
static v8::Local<v8::Function>
15+
v8::Local<v8::Function>
1616
GetDebuggerFunction(v8::Local<v8::Context> context, std::string domain,
1717
std::string functionName, v8::Local<v8::Object> &domainDebugger);
1818
}

0 commit comments

Comments
 (0)