@@ -1569,6 +1569,13 @@ static inline std::string fromStringView(v8::Isolate* isolate, const v8_inspecto
15691569 return *result;
15701570}
15711571
1572+ const char * toHeapCharPtr (const v8_inspector::String16& str) {
1573+ std::string utf8_str = str.utf8 (); // Note that this may hold the string on the stack as an SSO
1574+ char * heap_str = new char [utf8_str.length () + 1 ];
1575+ strcpy (heap_str, utf8_str.c_str ());
1576+ return heap_str;
1577+ }
1578+
15721579// Inspector
15731580
15741581v8_inspector::V8Inspector *v8_inspector__Inspector__Create (
@@ -1629,21 +1636,141 @@ void v8_inspector__Session__dispatchProtocolMessage(
16291636 session->dispatchProtocolMessage (str_view);
16301637}
16311638
1632- v8_inspector::protocol::Runtime::API:: RemoteObject* v8_inspector__Session__wrapObject (
1639+ v8_inspector::protocol::Runtime::RemoteObject* v8_inspector__Session__wrapObject (
16331640 v8_inspector::V8InspectorSession *session, v8::Isolate *isolate,
16341641 const v8::Context* ctx, const v8::Value* val,
16351642 const char *grpname, int grpname_len, bool generatepreview) {
16361643 auto sv_grpname = toStringView (grpname, grpname_len);
16371644 auto remote_object = session->wrapObject (ptr_to_local (ctx), ptr_to_local (val), sv_grpname, generatepreview);
1638- return remote_object.release ();
1645+ assert (remote_object != nullptr );
1646+ auto * not_api = static_cast <v8_inspector::protocol::Runtime::RemoteObject*>(remote_object.release ());
1647+ assert (not_api != nullptr );
1648+ return not_api;
16391649}
16401650
16411651// RemoteObject
16421652
1643- void v8_inspector__RemoteObject__DELETE (v8_inspector::protocol::Runtime::API::RemoteObject* self) {
1653+ // To prevent extra allocations on every call a single default value value is reused everytime.
1654+ // It is expected that the precense of a value is checked before calling get* methods.
1655+ const v8_inspector::String16 DEFAULT_STRING = {" default" };
1656+
1657+ void v8_inspector__RemoteObject__DELETE (v8_inspector::protocol::Runtime::RemoteObject* self) {
16441658 delete self;
16451659}
16461660
1661+ // RemoteObject - Type
1662+ const char * v8_inspector__RemoteObject__getType (v8_inspector::protocol::Runtime::RemoteObject* self) {
1663+ auto str = self->getType ();
1664+ return toHeapCharPtr (str);
1665+ }
1666+ void v8_inspector__RemoteObject__setType (v8_inspector::protocol::Runtime::RemoteObject* self, const char * type, int type_len) {
1667+ self->setType (v8_inspector::String16::fromUTF8 (type, type_len));
1668+ }
1669+
1670+ // RemoteObject - Subtype
1671+ bool v8_inspector__RemoteObject__hasSubtype (v8_inspector::protocol::Runtime::RemoteObject* self) {
1672+ return self->hasSubtype ();
1673+ }
1674+ const char * v8_inspector__RemoteObject__getSubtype (v8_inspector::protocol::Runtime::RemoteObject* self) {
1675+ auto str = self->getSubtype (DEFAULT_STRING);
1676+ return toHeapCharPtr (str);
1677+ }
1678+ void v8_inspector__RemoteObject__setSubtype (v8_inspector::protocol::Runtime::RemoteObject* self, const char * subtype, int subtype_len) {
1679+ self->setSubtype (v8_inspector::String16::fromUTF8 (subtype, subtype_len));
1680+ }
1681+
1682+ // RemoteObject - ClassName
1683+ bool v8_inspector__RemoteObject__hasClassName (v8_inspector::protocol::Runtime::RemoteObject* self) {
1684+ return self->hasClassName ();
1685+ }
1686+ const char * v8_inspector__RemoteObject__getClassName (v8_inspector::protocol::Runtime::RemoteObject* self) {
1687+ auto str = self->getClassName (DEFAULT_STRING);
1688+ return toHeapCharPtr (str);
1689+ }
1690+ void v8_inspector__RemoteObject__setClassName (v8_inspector::protocol::Runtime::RemoteObject* self, const char * className, int className_len) {
1691+ self->setClassName (v8_inspector::String16::fromUTF8 (className, className_len));
1692+ }
1693+
1694+ // RemoteObject - Value
1695+ bool v8_inspector__RemoteObject__hasValue (v8_inspector::protocol::Runtime::RemoteObject* self) {
1696+ return self->hasValue ();
1697+ }
1698+ v8_inspector::protocol::Value* v8_inspector__RemoteObject__getValue (v8_inspector::protocol::Runtime::RemoteObject* self) {
1699+ return self->getValue (nullptr );
1700+ }
1701+ void v8_inspector__RemoteObject__setValue (v8_inspector::protocol::Runtime::RemoteObject* self, v8_inspector::protocol::Value* value) {
1702+ self->setValue (std::unique_ptr<v8_inspector::protocol::Value>(value));
1703+ }
1704+
1705+ // RemoteObject - UnserializableValue
1706+ bool v8_inspector__RemoteObject__hasUnserializableValue (v8_inspector::protocol::Runtime::RemoteObject* self) {
1707+ return self->hasUnserializableValue ();
1708+ }
1709+ const char * v8_inspector__RemoteObject__getUnserializableValue (v8_inspector::protocol::Runtime::RemoteObject* self) {
1710+ auto str = self->getUnserializableValue (DEFAULT_STRING);
1711+ return toHeapCharPtr (str);
1712+ }
1713+ void v8_inspector__RemoteObject__setUnserializableValue (v8_inspector::protocol::Runtime::RemoteObject* self, const char * unserializableValue, int unserializableValue_len) {
1714+ self->setUnserializableValue (v8_inspector::String16::fromUTF8 (unserializableValue, unserializableValue_len));
1715+ }
1716+
1717+ // RemoteObject - Description
1718+ bool v8_inspector__RemoteObject__hasDescription (v8_inspector::protocol::Runtime::RemoteObject* self) {
1719+ return self->hasDescription ();
1720+ }
1721+ const char * v8_inspector__RemoteObject__getDescription (v8_inspector::protocol::Runtime::RemoteObject* self) {
1722+ auto str = self->getDescription (DEFAULT_STRING);
1723+ return toHeapCharPtr (str);
1724+ }
1725+ void v8_inspector__RemoteObject__setDescription (v8_inspector::protocol::Runtime::RemoteObject* self, const char * description, int description_len) {
1726+ self->setDescription (v8_inspector::String16::fromUTF8 (description, description_len));
1727+ }
1728+
1729+ // RemoteObject - WebDriverValue
1730+ bool v8_inspector__RemoteObject__hasWebDriverValue (v8_inspector::protocol::Runtime::RemoteObject* self) {
1731+ return self->hasWebDriverValue ();
1732+ }
1733+ v8_inspector::protocol::Runtime::WebDriverValue* v8_inspector__RemoteObject__getWebDriverValue (v8_inspector::protocol::Runtime::RemoteObject* self) {
1734+ return self->getWebDriverValue (nullptr );
1735+ }
1736+ void v8_inspector__RemoteObject__setWebDriverValue (v8_inspector::protocol::Runtime::RemoteObject* self, v8_inspector::protocol::Runtime::WebDriverValue* webDriverValue) {
1737+ self->setWebDriverValue (std::unique_ptr<v8_inspector::protocol::Runtime::WebDriverValue>(webDriverValue));
1738+ }
1739+
1740+ // RemoteObject - ObjectId
1741+ bool v8_inspector__RemoteObject__hasObjectId (v8_inspector::protocol::Runtime::RemoteObject* self) {
1742+ return self->hasObjectId ();
1743+ }
1744+ const char * v8_inspector__RemoteObject__getObjectId (v8_inspector::protocol::Runtime::RemoteObject* self) {
1745+ auto str = self->getObjectId (DEFAULT_STRING);
1746+ return toHeapCharPtr (str);
1747+ }
1748+ void v8_inspector__RemoteObject__setObjectId (v8_inspector::protocol::Runtime::RemoteObject* self, const char * objectId, int objectId_len) {
1749+ self->setObjectId (v8_inspector::String16::fromUTF8 (objectId, objectId_len));
1750+ }
1751+
1752+ // RemoteObject - Preview
1753+ bool v8_inspector__RemoteObject__hasPreview (v8_inspector::protocol::Runtime::RemoteObject* self) {
1754+ return self->hasPreview ();
1755+ }
1756+ const v8_inspector::protocol::Runtime::ObjectPreview* v8_inspector__RemoteObject__getPreview (v8_inspector::protocol::Runtime::RemoteObject* self) {
1757+ return self->getPreview (nullptr );
1758+ }
1759+ void v8_inspector__RemoteObject__setPreview (v8_inspector::protocol::Runtime::RemoteObject* self, v8_inspector::protocol::Runtime::ObjectPreview* preview) {
1760+ self->setPreview (std::unique_ptr<v8_inspector::protocol::Runtime::ObjectPreview>(preview));
1761+ }
1762+
1763+ // RemoteObject - CustomPreview
1764+ bool v8_inspector__RemoteObject__hasCustomPreview (v8_inspector::protocol::Runtime::RemoteObject* self) {
1765+ return self->hasCustomPreview ();
1766+ }
1767+ const v8_inspector::protocol::Runtime::CustomPreview* v8_inspector__RemoteObject__getCustomPreview (v8_inspector::protocol::Runtime::RemoteObject* self) {
1768+ return self->getCustomPreview (nullptr );
1769+ }
1770+ void v8_inspector__RemoteObject__setCustomPreview (v8_inspector::protocol::Runtime::RemoteObject* self, v8_inspector::protocol::Runtime::CustomPreview* customPreview) {
1771+ self->setCustomPreview (std::unique_ptr<v8_inspector::protocol::Runtime::CustomPreview>(customPreview));
1772+ }
1773+
16471774// InspectorChannel
16481775
16491776v8_inspector__Channel__IMPL * v8_inspector__Channel__IMPL__CREATE (v8::Isolate *isolate) {
0 commit comments