Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Side by Side Diff: src/inspector/string-util.cc

Issue 2846673005: Roll third_party/inspector_protocol to efefa86c3183d307f0a0e53bf568fe57c5b58849 (Closed)
Patch Set: ac Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/string-util.h" 5 #include "src/inspector/string-util.h"
6 6
7 #include "src/conversions.h"
7 #include "src/inspector/protocol/Protocol.h" 8 #include "src/inspector/protocol/Protocol.h"
9 #include "src/unicode-cache.h"
8 10
9 namespace v8_inspector { 11 namespace v8_inspector {
10 12
11 v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String16& string) { 13 v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String16& string) {
12 if (string.isEmpty()) return v8::String::Empty(isolate); 14 if (string.isEmpty()) return v8::String::Empty(isolate);
13 DCHECK(string.length() < v8::String::kMaxLength); 15 DCHECK(string.length() < v8::String::kMaxLength);
14 return v8::String::NewFromTwoByte( 16 return v8::String::NewFromTwoByte(
15 isolate, reinterpret_cast<const uint16_t*>(string.characters16()), 17 isolate, reinterpret_cast<const uint16_t*>(string.characters16()),
16 v8::NewStringType::kNormal, static_cast<int>(string.length())) 18 v8::NewStringType::kNormal, static_cast<int>(string.length()))
17 .ToLocalChecked(); 19 .ToLocalChecked();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } else { 87 } else {
86 for (size_t i = 0, j = 0; prefix[j] && i < string.length(); ++i, ++j) { 88 for (size_t i = 0, j = 0; prefix[j] && i < string.length(); ++i, ++j) {
87 if (string.characters16()[i] != prefix[j]) return false; 89 if (string.characters16()[i] != prefix[j]) return false;
88 } 90 }
89 } 91 }
90 return true; 92 return true;
91 } 93 }
92 94
93 namespace protocol { 95 namespace protocol {
94 96
97 // static
98 double StringUtil::toDouble(const char* s, size_t len, bool* isOk) {
99 v8::internal::UnicodeCache unicode_cache;
100 int flags = v8::internal::ALLOW_HEX | v8::internal::ALLOW_OCTAL |
101 v8::internal::ALLOW_BINARY;
102 double result = StringToDouble(&unicode_cache, s, flags);
103 *isOk = !std::isnan(result);
104 return result;
105 }
106
95 std::unique_ptr<protocol::Value> StringUtil::parseJSON( 107 std::unique_ptr<protocol::Value> StringUtil::parseJSON(
96 const StringView& string) { 108 const StringView& string) {
97 if (!string.length()) return nullptr; 109 if (!string.length()) return nullptr;
98 if (string.is8Bit()) { 110 if (string.is8Bit()) {
99 return parseJSONCharacters(string.characters8(), 111 return parseJSONCharacters(string.characters8(),
100 static_cast<int>(string.length())); 112 static_cast<int>(string.length()));
101 } 113 }
102 return parseJSONCharacters(string.characters16(), 114 return parseJSONCharacters(string.characters16(),
103 static_cast<int>(string.length())); 115 static_cast<int>(string.length()));
104 } 116 }
(...skipping 16 matching lines...) Expand all
121 std::unique_ptr<StringBufferImpl> StringBufferImpl::adopt(String16& string) { 133 std::unique_ptr<StringBufferImpl> StringBufferImpl::adopt(String16& string) {
122 return std::unique_ptr<StringBufferImpl>(new StringBufferImpl(string)); 134 return std::unique_ptr<StringBufferImpl>(new StringBufferImpl(string));
123 } 135 }
124 136
125 StringBufferImpl::StringBufferImpl(String16& string) { 137 StringBufferImpl::StringBufferImpl(String16& string) {
126 m_owner.swap(string); 138 m_owner.swap(string);
127 m_string = toStringView(m_owner); 139 m_string = toStringView(m_owner);
128 } 140 }
129 141
130 } // namespace v8_inspector 142 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/string-util.h ('k') | test/inspector/debugger/protocol-string-to-double-locale.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698