44
55using namespace v8 ;
66using 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}
0 commit comments