Commit aed22ad1 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

Roll third_party/inspector_protocol to efefa86c3183d307f0a0e53bf568fe57c5b58849

This roll includes:
  - [inspector_protocol] added StringUtil::toDouble method as requirement [1]

[1] https://codereview.chromium.org/2843223005/

BUG=chromium:712610
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2846673005
Cr-Commit-Position: refs/heads/master@{#44954}
parent 8f0c2949
...@@ -6,6 +6,7 @@ include_rules = [ ...@@ -6,6 +6,7 @@ include_rules = [
"+src/base/logging.h", "+src/base/logging.h",
"+src/base/platform/platform.h", "+src/base/platform/platform.h",
"+src/conversions.h", "+src/conversions.h",
"+src/unicode-cache.h",
"+src/inspector", "+src/inspector",
"+src/tracing", "+src/tracing",
"+src/debug/debug-interface.h", "+src/debug/debug-interface.h",
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include "src/inspector/string-util.h" #include "src/inspector/string-util.h"
#include "src/conversions.h"
#include "src/inspector/protocol/Protocol.h" #include "src/inspector/protocol/Protocol.h"
#include "src/unicode-cache.h"
namespace v8_inspector { namespace v8_inspector {
...@@ -92,6 +94,16 @@ bool stringViewStartsWith(const StringView& string, const char* prefix) { ...@@ -92,6 +94,16 @@ bool stringViewStartsWith(const StringView& string, const char* prefix) {
namespace protocol { namespace protocol {
// static
double StringUtil::toDouble(const char* s, size_t len, bool* isOk) {
v8::internal::UnicodeCache unicode_cache;
int flags = v8::internal::ALLOW_HEX | v8::internal::ALLOW_OCTAL |
v8::internal::ALLOW_BINARY;
double result = StringToDouble(&unicode_cache, s, flags);
*isOk = !std::isnan(result);
return result;
}
std::unique_ptr<protocol::Value> StringUtil::parseJSON( std::unique_ptr<protocol::Value> StringUtil::parseJSON(
const StringView& string) { const StringView& string) {
if (!string.length()) return nullptr; if (!string.length()) return nullptr;
......
...@@ -32,6 +32,7 @@ class StringUtil { ...@@ -32,6 +32,7 @@ class StringUtil {
return String::fromInteger(number); return String::fromInteger(number);
} }
static String fromDouble(double number) { return String::fromDouble(number); } static String fromDouble(double number) { return String::fromDouble(number); }
static double toDouble(const char* s, size_t len, bool* isOk);
static size_t find(const String& s, const char* needle) { static size_t find(const String& s, const char* needle) {
return s.find(needle); return s.find(needle);
} }
......
This test verifies that we correctly parse doubles with non-US locale
{
a : 0.5
}
{
a : 1
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
InspectorTest.log('This test verifies that we correctly parse doubles with non-US locale');
utils.setlocale("fr_CA.UTF-8");
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({
expression: 'inspector.breakProgram(\'\', JSON.stringify({a: 0.5}))'});
let message = await Protocol.Debugger.oncePaused();
InspectorTest.logObject(message.params.data || {});
Protocol.Debugger.resume();
Protocol.Runtime.evaluate({
expression: 'inspector.breakProgram(\'\', JSON.stringify({a: 1}))'});
message = await Protocol.Debugger.oncePaused();
InspectorTest.logObject(message.params.data || {});
Protocol.Debugger.resume();
InspectorTest.completeTest();
})();
...@@ -51,19 +51,13 @@ double charactersToDouble(const uint16_t* characters, size_t length, bool* ok) ...@@ -51,19 +51,13 @@ double charactersToDouble(const uint16_t* characters, size_t length, bool* ok)
buffer.push_back(static_cast<char>(characters[i])); buffer.push_back(static_cast<char>(characters[i]));
} }
buffer.push_back('\0'); buffer.push_back('\0');
char* endptr; return StringUtil::toDouble(buffer.data(), length, ok);
double result = std::strtod(buffer.data(), &endptr);
*ok = !(*endptr);
return result;
} }
double charactersToDouble(const uint8_t* characters, size_t length, bool* ok) double charactersToDouble(const uint8_t* characters, size_t length, bool* ok)
{ {
std::string buffer(reinterpret_cast<const char*>(characters), length); std::string buffer(reinterpret_cast<const char*>(characters), length);
char* endptr; return StringUtil::toDouble(buffer.data(), length, ok);
double result = std::strtod(buffer.data(), &endptr);
*ok = !(*endptr);
return result;
} }
template<typename Char> template<typename Char>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment