Index: third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp |
diff --git a/third_party/WebKit/Source/platform/JSONParser.cpp b/third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp |
similarity index 85% |
copy from third_party/WebKit/Source/platform/JSONParser.cpp |
copy to third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp |
index 68ab5a1ea58c0ecbfc5d5ada1206e40d4b9809d6..2257c3c81653c26d462a9e1ebba2400e3dfed55b 100644 |
--- a/third_party/WebKit/Source/platform/JSONParser.cpp |
+++ b/third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp |
@@ -1,41 +1,16 @@ |
-/* |
- * Copyright (C) 2010 Google Inc. All rights reserved. |
- * |
- * Redistribution and use in source and binary forms, with or without |
- * modification, are permitted provided that the following conditions are |
- * met: |
- * |
- * * Redistributions of source code must retain the above copyright |
- * notice, this list of conditions and the following disclaimer. |
- * * Redistributions in binary form must reproduce the above |
- * copyright notice, this list of conditions and the following disclaimer |
- * in the documentation and/or other materials provided with the |
- * distribution. |
- * * Neither the name of Google Inc. nor the names of its |
- * contributors may be used to endorse or promote products derived from |
- * this software without specific prior written permission. |
- * |
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- */ |
- |
-#include "platform/JSONParser.h" |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "platform/inspector_protocol/Parser.h" |
#include "platform/Decimal.h" |
-#include "platform/JSONValues.h" |
+#include "platform/inspector_protocol/Values.h" |
#include "wtf/text/StringBuilder.h" |
#include "wtf/text/UTF8.h" |
namespace blink { |
+namespace protocol { |
namespace { |
@@ -444,12 +419,12 @@ bool decodeString(const CharType* start, const CharType* end, String* output) |
} |
template<typename CharType> |
-PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, const CharType** valueTokenEnd, int depth) |
+PassRefPtr<Value> buildValue(const CharType* start, const CharType* end, const CharType** valueTokenEnd, int depth) |
{ |
if (depth > stackLimit) |
return nullptr; |
- RefPtr<JSONValue> result; |
+ RefPtr<Value> result; |
const CharType* tokenStart; |
const CharType* tokenEnd; |
Token token = parseToken(start, end, &tokenStart, &tokenEnd); |
@@ -457,13 +432,13 @@ PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, con |
case InvalidToken: |
return nullptr; |
case NullToken: |
- result = JSONValue::null(); |
+ result = Value::null(); |
break; |
case BoolTrue: |
- result = JSONBasicValue::create(true); |
+ result = FundamentalValue::create(true); |
break; |
case BoolFalse: |
- result = JSONBasicValue::create(false); |
+ result = FundamentalValue::create(false); |
break; |
case Number: { |
bool ok; |
@@ -472,7 +447,7 @@ PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, con |
ok = false; |
if (!ok) |
return nullptr; |
- result = JSONBasicValue::create(value); |
+ result = FundamentalValue::create(value); |
break; |
} |
case StringLiteral: { |
@@ -480,15 +455,15 @@ PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, con |
bool ok = decodeString(tokenStart + 1, tokenEnd - 1, &value); |
if (!ok) |
return nullptr; |
- result = JSONString::create(value); |
+ result = StringValue::create(value); |
break; |
} |
case ArrayBegin: { |
- RefPtr<JSONArray> array = JSONArray::create(); |
+ RefPtr<ListValue> array = ListValue::create(); |
start = tokenEnd; |
token = parseToken(start, end, &tokenStart, &tokenEnd); |
while (token != ArrayEnd) { |
- RefPtr<JSONValue> arrayNode = buildValue(start, end, &tokenEnd, depth + 1); |
+ RefPtr<Value> arrayNode = buildValue(start, end, &tokenEnd, depth + 1); |
if (!arrayNode) |
return nullptr; |
array->pushValue(arrayNode); |
@@ -512,7 +487,7 @@ PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, con |
break; |
} |
case ObjectBegin: { |
- RefPtr<JSONObject> object = JSONObject::create(); |
+ RefPtr<DictionaryValue> object = DictionaryValue::create(); |
start = tokenEnd; |
token = parseToken(start, end, &tokenStart, &tokenEnd); |
while (token != ObjectEnd) { |
@@ -528,7 +503,7 @@ PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, con |
return nullptr; |
start = tokenEnd; |
- RefPtr<JSONValue> value = buildValue(start, end, &tokenEnd, depth + 1); |
+ RefPtr<Value> value = buildValue(start, end, &tokenEnd, depth + 1); |
if (!value) |
return nullptr; |
object->setValue(key, value); |
@@ -563,11 +538,11 @@ PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, con |
} |
template<typename CharType> |
-PassRefPtr<JSONValue> parseJSONInternal(const CharType* start, unsigned length) |
+PassRefPtr<Value> parseJSONInternal(const CharType* start, unsigned length) |
{ |
const CharType* end = start + length; |
const CharType *tokenEnd; |
- RefPtr<JSONValue> value = buildValue(start, end, &tokenEnd, 0); |
+ RefPtr<Value> value = buildValue(start, end, &tokenEnd, 0); |
if (!value || tokenEnd != end) |
return nullptr; |
return value.release(); |
@@ -575,7 +550,7 @@ PassRefPtr<JSONValue> parseJSONInternal(const CharType* start, unsigned length) |
} // anonymous namespace |
-PassRefPtr<JSONValue> parseJSON(const String& json) |
+PassRefPtr<Value> parseJSON(const String& json) |
{ |
if (json.isEmpty()) |
return nullptr; |
@@ -584,4 +559,5 @@ PassRefPtr<JSONValue> parseJSON(const String& json) |
return parseJSONInternal(json.characters16(), json.length()); |
} |
+} // namespace protocol |
} // namespace blink |