-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move devtools only calls into inspector
- Loading branch information
Showing
7 changed files
with
72 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "Utils.h" | ||
#include "JsV8InspectorClient.h" | ||
#include "Util.h" | ||
|
||
using namespace v8; | ||
using namespace std; | ||
namespace tns { | ||
|
||
Local <v8::Function> | ||
GetDebuggerFunction(Local <Context> context, std::string domain, std::string functionName, | ||
Local <Object> &domainDebugger) { | ||
auto it = JsV8InspectorClient::Domains.find(domain); | ||
if (it == JsV8InspectorClient::Domains.end()) { | ||
return Local<v8::Function>(); | ||
} | ||
|
||
Isolate *isolate = context->GetIsolate(); | ||
domainDebugger = it->second->Get(isolate); | ||
|
||
Local <Value> value; | ||
auto funcName = v8::String::NewFromUtf8(isolate, functionName.c_str(), | ||
v8::NewStringType::kNormal, | ||
(int) functionName.length()).ToLocalChecked(); | ||
bool success = domainDebugger->Get(context, funcName).ToLocal(&value); | ||
if (success && !value.IsEmpty() && value->IsFunction()) { | ||
return value.As<v8::Function>(); | ||
} | ||
|
||
return Local<v8::Function>(); | ||
} | ||
|
||
Local <v8::Function> | ||
GetDebuggerFunctionFromObject(Local <Context> context, const Local <Object> &object, | ||
Local <Object> &domainDebugger) { | ||
Isolate *isolate = context->GetIsolate(); | ||
auto methodKey = v8::String::NewFromUtf8(isolate, "method", | ||
v8::NewStringType::kNormal).ToLocalChecked(); | ||
auto method = object->Get(context, methodKey).ToLocalChecked(); | ||
auto methodString = Util::ToString(isolate, method); | ||
auto domainSeparatorIndex = methodString.find("."); | ||
auto domain = methodString.substr(0, domainSeparatorIndex); | ||
auto domainMethod = methodString.substr(domainSeparatorIndex + 1, methodString.size()); | ||
|
||
if (domain.size() > 0) { | ||
return GetDebuggerFunction(context, domain, domainMethod, domainDebugger); | ||
} | ||
|
||
return Local<v8::Function>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
#ifndef UTILS_H_ | ||
#define UTILS_H_ | ||
|
||
#include "include/v8-inspector.h" | ||
|
||
namespace tns { | ||
namespace inspector { | ||
static v8::Local<v8::Function> GetDebuggerFunctionFromObject(v8::Local<v8::Context> context, | ||
const v8::Local<v8::Object> &object, | ||
v8::Local<v8::Object> &domainDebugger); | ||
|
||
static v8::Local<v8::Function> | ||
GetDebuggerFunction(v8::Local<v8::Context> context, std::string domain, | ||
std::string functionName, v8::Local<v8::Object> &domainDebugger); | ||
} | ||
} | ||
|
||
#endif /* UTILS_H_ */ |