diff --git a/inspector.cc b/inspector.cc index 00e80f3d..fc00358e 100644 --- a/inspector.cc +++ b/inspector.cc @@ -21,6 +21,17 @@ class InspectorClient : public V8InspectorClient { V8StackTrace*) override; }; +StringViewData ConvertStringView(const StringView& view) { + StringViewData msg; + msg.is8bit = view.is8Bit(); + // The ? isn't necessary, the two functions return the sama pointer. But that + // has been considered an implementation detail that may change. + msg.data = + view.is8Bit() ? (void*)view.characters8() : (void*)view.characters16(); + msg.length = view.length(); + return msg; +} + void InspectorClient::consoleAPIMessage(int contextGroupId, v8::Isolate::MessageErrorLevel level, const StringView& message, @@ -28,11 +39,9 @@ void InspectorClient::consoleAPIMessage(int contextGroupId, unsigned lineNumber, unsigned columnNumber, V8StackTrace*) { - StringViewData msg; - msg.is8bit = message.is8Bit(); - msg.data = message.characters8(); - msg.length = message.length(); - goHandleConsoleAPIMessageCallback(_callbackRef, contextGroupId, level, msg); + goHandleConsoleAPIMessageCallback( + _callbackRef, contextGroupId, level, ConvertStringView(message), + ConvertStringView(url), lineNumber, columnNumber); } extern "C" { diff --git a/inspector.go b/inspector.go index ef1940c3..1ecd14cf 100644 --- a/inspector.go +++ b/inspector.go @@ -71,9 +71,9 @@ type ConsoleAPIMessage struct { contextGroupId int ErrorLevel MessageErrorLevel Message string - url string - lineNumber int - columnNumber int + Url string + LineNumber uint + ColumnNumber uint // stackTrace StackTrace } @@ -140,12 +140,19 @@ func goHandleConsoleAPIMessageCallback( contextGroupId C.int, errorLevel C.int, message C.StringViewData, + url C.StringViewData, + lineNumber C.uint, + columnNumber C.uint, ) { // Convert data to Go data client := clientRegistry.get(callbackRef) + // TODO, Stack trace client.handler.ConsoleAPIMessage(ConsoleAPIMessage{ - Message: stringViewToString(message), - ErrorLevel: MessageErrorLevel(errorLevel), + ErrorLevel: MessageErrorLevel(errorLevel), + Message: stringViewToString(message), + Url: stringViewToString(url), + LineNumber: uint(lineNumber), + ColumnNumber: uint(columnNumber), }) // client.handleConsoleAPIMessageCallback(data) }