|
5 | 5 | #include "include/v8-inspector.h" |
6 | 6 | #include "include/v8.h" |
7 | 7 | #include "src/api/api.h" |
| 8 | +#include "src/inspector/protocol/Runtime.h" |
8 | 9 |
|
9 | 10 | #include "inspector.h" |
10 | 11 |
|
@@ -1549,9 +1550,12 @@ void v8__base__SetDcheckFunction(void (*func)(const char*, int, const char*)) { |
1549 | 1550 |
|
1550 | 1551 | // Utils |
1551 | 1552 |
|
| 1553 | +static inline v8_inspector::StringView toStringView(const char *str, size_t length) { |
| 1554 | + auto* stringView = reinterpret_cast<const uint8_t*>(str); |
| 1555 | + return { stringView, length }; |
| 1556 | +} |
1552 | 1557 | static inline v8_inspector::StringView toStringView(const std::string &str) { |
1553 | | - auto* stringView = reinterpret_cast<const uint8_t*>(str.c_str()); |
1554 | | - return { stringView, str.length() }; |
| 1558 | + return toStringView(str.c_str(), str.length()); |
1555 | 1559 | } |
1556 | 1560 |
|
1557 | 1561 | static inline std::string fromStringView(v8::Isolate* isolate, const v8_inspector::StringView stringView) { |
@@ -1621,12 +1625,25 @@ void v8_inspector__Session__DELETE(v8_inspector::V8InspectorSession* self) { |
1621 | 1625 | void v8_inspector__Session__dispatchProtocolMessage( |
1622 | 1626 | v8_inspector::V8InspectorSession *session, v8::Isolate *isolate, |
1623 | 1627 | const char *msg, int msg_len) { |
1624 | | - std::string message; |
1625 | | - message.assign(msg, msg_len); |
1626 | | - auto str_view = toStringView(message); |
| 1628 | + auto str_view = toStringView(msg, msg_len); |
1627 | 1629 | session->dispatchProtocolMessage(str_view); |
1628 | 1630 | } |
1629 | 1631 |
|
| 1632 | +v8_inspector::protocol::Runtime::API::RemoteObject* v8_inspector__Session__wrapObject( |
| 1633 | + v8_inspector::V8InspectorSession *session, v8::Isolate *isolate, |
| 1634 | + const v8::Context* ctx, const v8::Value* val, |
| 1635 | + const char *grpname, int grpname_len, bool generatepreview) { |
| 1636 | + auto sv_grpname = toStringView(grpname, grpname_len); |
| 1637 | + auto remote_object = session->wrapObject(ptr_to_local(ctx), ptr_to_local(val), sv_grpname, generatepreview); |
| 1638 | + return remote_object.release(); |
| 1639 | +} |
| 1640 | + |
| 1641 | +// RemoteObject |
| 1642 | + |
| 1643 | +void v8_inspector__RemoteObject__DELETE(v8_inspector::protocol::Runtime::API::RemoteObject* self) { |
| 1644 | + delete self; |
| 1645 | +} |
| 1646 | + |
1630 | 1647 | // InspectorChannel |
1631 | 1648 |
|
1632 | 1649 | v8_inspector__Channel__IMPL * v8_inspector__Channel__IMPL__CREATE(v8::Isolate *isolate) { |
|
0 commit comments