66#include " include/v8.h"
77#include " src/api/api.h"
88#include " src/inspector/protocol/Runtime.h"
9+ #include " src/inspector/string-util.h"
910#include " src/inspector/v8-string-conversions.h"
11+
1012#include " src/debug/debug-interface.h"
1113
1214#include " inspector.h"
@@ -1724,15 +1726,15 @@ static inline v8_inspector::StringView toStringView(const std::string &str) {
17241726 return toStringView (str.c_str (), str.length ());
17251727}
17261728
1727- static v8::Local<v8::String> fromStringView (v8::Isolate* isolate, const v8_inspector::StringView stringView) {
1728- int length = static_cast <int >(stringView.length ());
1729- v8::Local<v8::String> message = (
1730- stringView.is8Bit ()
1731- ? v8::String::NewFromOneByte (isolate, stringView.characters8 (), v8::NewStringType::kNormal , length)
1732- : v8::String::NewFromTwoByte (isolate, stringView.characters16 (), v8::NewStringType::kNormal , length)
1733- ).ToLocalChecked ();
1734- return message;
1735- }
1729+ // static v8::Local<v8::String> fromStringView(v8::Isolate* isolate, const v8_inspector::StringView stringView) {
1730+ // int length = static_cast<int>(stringView.length());
1731+ // v8::Local<v8::String> message = (
1732+ // stringView.is8Bit()
1733+ // ? v8::String::NewFromOneByte(isolate, stringView.characters8(), v8::NewStringType::kNormal, length)
1734+ // : v8::String::NewFromTwoByte(isolate, stringView.characters16(), v8::NewStringType::kNormal, length)
1735+ // ).ToLocalChecked();
1736+ // return message;
1737+ // }
17361738
17371739// / Allocates a string as utf8 on the allocator without \0 terminator, for use in Zig.
17381740// / The strings pointer and length should therefore be returned together
@@ -1996,24 +1998,23 @@ void v8_inspector__Channel__IMPL__SET_DATA(v8_inspector__Channel__IMPL *self, vo
19961998// NOTE: zig project should provide those implementations with C-ABI functions
19971999void v8_inspector__Channel__IMPL__sendResponse (
19982000 v8_inspector__Channel__IMPL* self, void * data,
1999- int callId, v8::Local<v8::String> resp);
2001+ int callId, v8_inspector::StringView resp);
20002002void v8_inspector__Channel__IMPL__sendNotification (
2001- v8_inspector__Channel__IMPL* self, void *data,
2002- v8::Local<v8::String> notif);
2003+ v8_inspector__Channel__IMPL * self, void *data,
2004+ v8_inspector::StringView notif);
20032005void v8_inspector__Channel__IMPL__flushProtocolNotifications (
20042006 v8_inspector__Channel__IMPL* self, void *data);
20052007
20062008// c++ implementation (just wrappers around the C/zig functions)
20072009} // extern "C"
20082010void v8_inspector__Channel__IMPL::sendResponse (
20092011 int callId, std::unique_ptr<v8_inspector::StringBuffer> message) {
2010- const v8::Local<v8::String> resp = fromStringView (this ->isolate , message->string ());
2011- return v8_inspector__Channel__IMPL__sendResponse (this , this ->data , callId, resp);
2012+ return v8_inspector__Channel__IMPL__sendResponse (this , this ->data , callId, message->string ());
20122013}
20132014void v8_inspector__Channel__IMPL::sendNotification (
20142015 std::unique_ptr<v8_inspector::StringBuffer> message) {
2015- const v8::Local<v8::String> notif = fromStringView (this ->isolate , message->string ());
2016- return v8_inspector__Channel__IMPL__sendNotification (this , this ->data , notif );
2016+ // const v8::Local<v8::String> msg = v8_inspector::toV8String (this->isolate, message->string());
2017+ return v8_inspector__Channel__IMPL__sendNotification (this , this ->data , message-> string () );
20172018}
20182019void v8_inspector__Channel__IMPL::flushProtocolNotifications () {
20192020 return v8_inspector__Channel__IMPL__flushProtocolNotifications (this , this ->data );
@@ -2026,14 +2027,15 @@ extern "C" {
20262027void v8_inspector__Channel__sendResponse (
20272028 v8_inspector::V8Inspector::Channel* self, int callId,
20282029 v8_inspector::StringBuffer* message) {
2030+
20292031 self->sendResponse (
20302032 callId,
20312033 static_cast <std::unique_ptr<v8_inspector::StringBuffer>>(message));
20322034}
20332035void v8_inspector__Channel__sendNotification (
20342036 v8_inspector::V8Inspector::Channel* self,
20352037 v8_inspector::StringBuffer* message) {
2036- self->sendNotification (
2038+ self->sendNotification (
20372039 static_cast <std::unique_ptr<v8_inspector::StringBuffer>>(message));
20382040}
20392041void v8_inspector__Channel__flushProtocolNotifications (
@@ -2146,4 +2148,13 @@ void v8_inspector__Client__consoleAPIMessage(
21462148 columnNumber, stackTrace);
21472149}
21482150
2151+ size_t v8__StringView__Length (const v8_inspector::StringView* self) {
2152+ return self->length ();
2153+ }
2154+
2155+ const uint8_t * v8__StringView__Bytes (const v8_inspector::StringView* self) {
2156+ return self->characters8 ();
2157+ }
2158+
21492159} // extern "C"
2160+
0 commit comments