Title: [174094] trunk/Source
Revision
174094
Author
b...@cs.washington.edu
Date
2014-09-29 20:30:54 -0700 (Mon, 29 Sep 2014)

Log Message

Web Inspector: InspectorValues should use references for out parameters
https://bugs.webkit.org/show_bug.cgi?id=137190

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

Use references for out parameters in asType() and getType() methods.
Also convert to references in some miscellaneous code where we don't
expect or handle null values.

Remove variants of asObject() and asArray() that return a nullable RefPtr.
Now, client code is forced to use out parameters and check for cast failure.

Iron out control flow in some functions and fix some style issues.

* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::wrapObject):
(Inspector::InjectedScript::wrapTable):
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId): Simplify control flow.
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::InspectorBackendDispatcher::dispatch):
(Inspector::getPropertyValue):
(Inspector::AsMethodBridges::asInteger):
(Inspector::AsMethodBridges::asDouble):
(Inspector::AsMethodBridges::asString):
(Inspector::AsMethodBridges::asBoolean):
(Inspector::AsMethodBridges::asObject):
(Inspector::AsMethodBridges::asArray):
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<Protocol::Array<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<Protocol::Array<T>>::assertValueHasExpectedType):
* inspector/InspectorValues.cpp: Use more by-reference out parameters. Add more spacing.
(Inspector::InspectorValue::asBoolean):
(Inspector::InspectorValue::asDouble):
(Inspector::InspectorValue::asInteger):
(Inspector::InspectorValue::asString):
(Inspector::InspectorValue::asValue):
(Inspector::InspectorValue::asObject):
(Inspector::InspectorValue::asArray):
(Inspector::InspectorValue::parseJSON):
(Inspector::InspectorValue::toJSONString):
(Inspector::InspectorValue::writeJSON):
(Inspector::InspectorBasicValue::asBoolean):
(Inspector::InspectorBasicValue::asDouble):
(Inspector::InspectorBasicValue::asInteger):
(Inspector::InspectorBasicValue::writeJSON):
(Inspector::InspectorString::asString):
(Inspector::InspectorString::writeJSON):
(Inspector::InspectorObjectBase::asObject):
(Inspector::InspectorObjectBase::openAccessors):
(Inspector::InspectorObjectBase::getBoolean):
(Inspector::InspectorObjectBase::getString):
(Inspector::InspectorObjectBase::getObject):
(Inspector::InspectorObjectBase::getArray):
(Inspector::InspectorObjectBase::writeJSON):
(Inspector::InspectorArrayBase::asArray):
(Inspector::InspectorArrayBase::writeJSON):
* inspector/InspectorValues.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::breakpointActionsFromProtocol):
(Inspector::InspectorDebuggerAgent::setBreakpointByUrl):
(Inspector::parseLocation):
(Inspector::InspectorDebuggerAgent::setBreakpoint):
(Inspector::InspectorDebuggerAgent::continueToLocation):
(Inspector::InspectorDebuggerAgent::didParseSource):
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
* inspector/scripts/codegen/generate_protocol_types_implementation.py:
(ProtocolTypesImplementationGenerator):
(ProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generator_templates.py:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* replay/EncodedValue.cpp:
(JSC::EncodedValue::asObject):
(JSC::EncodedValue::asArray):
(JSC::EncodedValue::convertTo<bool>):
(JSC::EncodedValue::convertTo<double>):
(JSC::EncodedValue::convertTo<float>):
(JSC::EncodedValue::convertTo<int32_t>):
(JSC::EncodedValue::convertTo<int64_t>):
(JSC::EncodedValue::convertTo<uint32_t>):
(JSC::EncodedValue::convertTo<uint64_t>):
(JSC::EncodedValue::convertTo<String>):

Source/WebCore:

Clean up some call sites to explicitly check for cast success, and simplify
some exceptional control flows.

No new tests, no behavior changed.

* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspectImpl):
* inspector/InspectorCSSAgent.cpp:
(WebCore::computePseudoClassMask):
* inspector/InspectorDOMAgent.cpp:
(WebCore::parseColor):
(WebCore::parseConfigColor):
(WebCore::parseQuad):
(WebCore::InspectorDOMAgent::performSearch):
(WebCore::InspectorDOMAgent::highlightConfigFromInspectorObject):
(WebCore::InspectorDOMAgent::innerHighlightQuad):
(WebCore::InspectorDOMAgent::highlightFrame):
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::findStorageArea):
* inspector/InspectorIndexedDBAgent.cpp: Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL.
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
* inspector/InspectorReplayAgent.cpp:
(WebCore::InspectorReplayAgent::replayToPosition):
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::willSendRequest):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::styleWithProperties):
* inspector/InspectorStyleSheet.h:
(WebCore::InspectorCSSId::InspectorCSSId):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::startFromConsole):
(WebCore::InspectorTimelineAgent::stopFromConsole):
* inspector/InspectorWorkerAgent.cpp:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (174093 => 174094)


--- trunk/Source/_javascript_Core/ChangeLog	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-09-30 03:30:54 UTC (rev 174094)
@@ -1,3 +1,92 @@
+2014-09-29  Brian J. Burg  <b...@cs.washington.edu>
+
+        Web Inspector: InspectorValues should use references for out parameters
+        https://bugs.webkit.org/show_bug.cgi?id=137190
+
+        Reviewed by Joseph Pecoraro.
+
+        Use references for out parameters in asType() and getType() methods.
+        Also convert to references in some miscellaneous code where we don't
+        expect or handle null values.
+
+        Remove variants of asObject() and asArray() that return a nullable RefPtr.
+        Now, client code is forced to use out parameters and check for cast failure.
+
+        Iron out control flow in some functions and fix some style issues.
+
+        * inspector/InjectedScript.cpp:
+        (Inspector::InjectedScript::getFunctionDetails):
+        (Inspector::InjectedScript::wrapObject):
+        (Inspector::InjectedScript::wrapTable):
+        * inspector/InjectedScriptBase.cpp:
+        (Inspector::InjectedScriptBase::makeEvalCall):
+        * inspector/InjectedScriptManager.cpp:
+        (Inspector::InjectedScriptManager::injectedScriptForObjectId): Simplify control flow.
+        * inspector/InspectorBackendDispatcher.cpp:
+        (Inspector::InspectorBackendDispatcher::dispatch):
+        (Inspector::getPropertyValue):
+        (Inspector::AsMethodBridges::asInteger):
+        (Inspector::AsMethodBridges::asDouble):
+        (Inspector::AsMethodBridges::asString):
+        (Inspector::AsMethodBridges::asBoolean):
+        (Inspector::AsMethodBridges::asObject):
+        (Inspector::AsMethodBridges::asArray):
+        * inspector/InspectorProtocolTypes.h:
+        (Inspector::Protocol::BindingTraits<Protocol::Array<T>>::runtimeCast):
+        (Inspector::Protocol::BindingTraits<Protocol::Array<T>>::assertValueHasExpectedType):
+        * inspector/InspectorValues.cpp: Use more by-reference out parameters. Add more spacing.
+        (Inspector::InspectorValue::asBoolean):
+        (Inspector::InspectorValue::asDouble):
+        (Inspector::InspectorValue::asInteger):
+        (Inspector::InspectorValue::asString):
+        (Inspector::InspectorValue::asValue):
+        (Inspector::InspectorValue::asObject):
+        (Inspector::InspectorValue::asArray):
+        (Inspector::InspectorValue::parseJSON):
+        (Inspector::InspectorValue::toJSONString):
+        (Inspector::InspectorValue::writeJSON):
+        (Inspector::InspectorBasicValue::asBoolean):
+        (Inspector::InspectorBasicValue::asDouble):
+        (Inspector::InspectorBasicValue::asInteger):
+        (Inspector::InspectorBasicValue::writeJSON):
+        (Inspector::InspectorString::asString):
+        (Inspector::InspectorString::writeJSON):
+        (Inspector::InspectorObjectBase::asObject):
+        (Inspector::InspectorObjectBase::openAccessors):
+        (Inspector::InspectorObjectBase::getBoolean):
+        (Inspector::InspectorObjectBase::getString):
+        (Inspector::InspectorObjectBase::getObject):
+        (Inspector::InspectorObjectBase::getArray):
+        (Inspector::InspectorObjectBase::writeJSON):
+        (Inspector::InspectorArrayBase::asArray):
+        (Inspector::InspectorArrayBase::writeJSON):
+        * inspector/InspectorValues.h:
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::breakpointActionsFromProtocol):
+        (Inspector::InspectorDebuggerAgent::setBreakpointByUrl):
+        (Inspector::parseLocation):
+        (Inspector::InspectorDebuggerAgent::setBreakpoint):
+        (Inspector::InspectorDebuggerAgent::continueToLocation):
+        (Inspector::InspectorDebuggerAgent::didParseSource):
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
+        * inspector/scripts/codegen/generate_protocol_types_implementation.py:
+        (ProtocolTypesImplementationGenerator):
+        (ProtocolTypesImplementationGenerator._generate_assertion_for_enum):
+        * inspector/scripts/codegen/generator_templates.py:
+        * inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
+        * replay/EncodedValue.cpp:
+        (JSC::EncodedValue::asObject):
+        (JSC::EncodedValue::asArray):
+        (JSC::EncodedValue::convertTo<bool>):
+        (JSC::EncodedValue::convertTo<double>):
+        (JSC::EncodedValue::convertTo<float>):
+        (JSC::EncodedValue::convertTo<int32_t>):
+        (JSC::EncodedValue::convertTo<int64_t>):
+        (JSC::EncodedValue::convertTo<uint32_t>):
+        (JSC::EncodedValue::convertTo<uint64_t>):
+        (JSC::EncodedValue::convertTo<String>):
+
 2014-09-29  Filip Pizlo  <fpi...@apple.com>
 
         DFG HasStructureProperty codegen should use one fewer registers

Modified: trunk/Source/_javascript_Core/inspector/InjectedScript.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/InjectedScript.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/InjectedScript.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -101,7 +101,7 @@
     RefPtr<InspectorValue> resultValue;
     makeCall(function, &resultValue);
     if (!resultValue || resultValue->type() != InspectorValue::Type::Object) {
-        if (!resultValue->asString(errorString))
+        if (!resultValue->asString(*errorString))
             *errorString = ASCIILiteral("Internal error");
         return;
     }
@@ -172,8 +172,11 @@
     if (hadException)
         return nullptr;
 
-    RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
-    return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(rawResult);
+    RefPtr<InspectorObject> resultObject;
+    bool castSucceeded = r.toInspectorValue(scriptState())->asObject(resultObject);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);
+
+    return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
 }
 
 PassRefPtr<Inspector::Protocol::Runtime::RemoteObject> InjectedScript::wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const
@@ -192,8 +195,11 @@
     if (hadException)
         return nullptr;
 
-    RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
-    return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(rawResult);
+    RefPtr<InspectorObject> resultObject;
+    bool castSucceeded = r.toInspectorValue(scriptState())->asObject(resultObject);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);
+
+    return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
 }
 
 Deprecated::ScriptValue InjectedScript::findObjectById(const String& objectId) const

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -124,25 +124,25 @@
     }
 
     if (result->type() == InspectorValue::Type::String) {
-        result->asString(errorString);
+        result->asString(*errorString);
         ASSERT(errorString->length());
         return;
     }
 
-    RefPtr<InspectorObject> resultPair = result->asObject();
-    if (!resultPair) {
+    RefPtr<InspectorObject> resultPair;
+    if (!result->asObject(resultPair)) {
         *errorString = ASCIILiteral("Internal error: result is not an Object");
         return;
     }
 
-    RefPtr<InspectorObject> resultObj = resultPair->getObject(ASCIILiteral("result"));
+    RefPtr<InspectorObject> resultObject = resultPair->getObject(ASCIILiteral("result"));
     bool wasThrownVal = false;
-    if (!resultObj || !resultPair->getBoolean(ASCIILiteral("wasThrown"), &wasThrownVal)) {
+    if (!resultObject || !resultPair->getBoolean(ASCIILiteral("wasThrown"), wasThrownVal)) {
         *errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag");
         return;
     }
 
-    *objectResult = BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObj);
+    *objectResult = BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
     *wasThrown = wasThrownVal;
 }
 

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptManager.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptManager.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptManager.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -94,15 +94,19 @@
 
 InjectedScript InjectedScriptManager::injectedScriptForObjectId(const String& objectId)
 {
-    RefPtr<InspectorValue> parsedObjectId = InspectorValue::parseJSON(objectId);
-    if (parsedObjectId && parsedObjectId->type() == InspectorValue::Type::Object) {
-        long injectedScriptId = 0;
-        bool success = parsedObjectId->asObject()->getInteger(ASCIILiteral("injectedScriptId"), &injectedScriptId);
-        if (success)
-            return m_idToInjectedScript.get(injectedScriptId);
-    }
+    RefPtr<InspectorValue> parsedObjectId;
+    if (!InspectorValue::parseJSON(objectId, parsedObjectId))
+        return InjectedScript();
 
-    return InjectedScript();
+    RefPtr<InspectorObject> resultObject;
+    if (!parsedObjectId->asObject(resultObject))
+        return InjectedScript();
+
+    long injectedScriptId = 0;
+    if (!resultObject->getInteger(ASCIILiteral("injectedScriptId"), injectedScriptId))
+        return InjectedScript();
+
+    return m_idToInjectedScript.get(injectedScriptId);
 }
 
 void InjectedScriptManager::discardInjectedScripts()

Modified: trunk/Source/_javascript_Core/inspector/InspectorBackendDispatcher.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/InspectorBackendDispatcher.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/InspectorBackendDispatcher.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -78,14 +78,14 @@
 {
     Ref<InspectorBackendDispatcher> protect(*this);
 
-    RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
-    if (!parsedMessage) {
+    RefPtr<InspectorValue> parsedMessage;
+    if (!InspectorValue::parseJSON(message, parsedMessage)) {
         reportProtocolError(nullptr, ParseError, ASCIILiteral("Message must be in JSON format"));
         return;
     }
 
-    RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
-    if (!messageObject) {
+    RefPtr<InspectorObject> messageObject;
+    if (!parsedMessage->asObject(messageObject)) {
         reportProtocolError(nullptr, InvalidRequest, ASCIILiteral("Message must be a JSONified object"));
         return;
     }
@@ -97,7 +97,7 @@
     }
 
     long callId = 0;
-    if (!callIdValue->asInteger(&callId)) {
+    if (!callIdValue->asInteger(callId)) {
         reportProtocolError(nullptr, InvalidRequest, ASCIILiteral("The type of 'id' property must be integer"));
         return;
     }
@@ -109,7 +109,7 @@
     }
 
     String method;
-    if (!methodValue->asString(&method)) {
+    if (!methodValue->asString(method)) {
         reportProtocolError(&callId, InvalidRequest, ASCIILiteral("The type of 'method' property must be string"));
         return;
     }
@@ -187,7 +187,7 @@
 }
 
 template<typename ReturnValueType, typename ValueType, typename DefaultValueType>
-static ReturnValueType getPropertyValue(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors, DefaultValueType defaultValue, bool (*asMethod)(InspectorValue*, ValueType*), const char* typeName)
+static ReturnValueType getPropertyValue(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors, DefaultValueType defaultValue, bool (*asMethod)(InspectorValue&, ValueType&), const char* typeName)
 {
     ASSERT(protocolErrors);
 
@@ -209,7 +209,7 @@
         return value;
     }
 
-    if (!asMethod(valueIterator->value.get(), &value)) {
+    if (!asMethod(*valueIterator->value, value)) {
         protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be '%s'.", name.utf8().data(), typeName));
         return value;
     }
@@ -221,12 +221,12 @@
 }
 
 struct AsMethodBridges {
-    static bool asInteger(InspectorValue* value, int* output) { return value->asInteger(output); }
-    static bool asDouble(InspectorValue* value, double* output) { return value->asDouble(output); }
-    static bool asString(InspectorValue* value, String* output) { return value->asString(output); }
-    static bool asBoolean(InspectorValue* value, bool* output) { return value->asBoolean(output); }
-    static bool asObject(InspectorValue* value, RefPtr<InspectorObject>* output) { return value->asObject(output); }
-    static bool asArray(InspectorValue* value, RefPtr<InspectorArray>* output) { return value->asArray(output); }
+    static bool asInteger(InspectorValue& value, int& output) { return value.asInteger(output); }
+    static bool asDouble(InspectorValue& value, double& output) { return value.asDouble(output); }
+    static bool asString(InspectorValue& value, String& output) { return value.asString(output); }
+    static bool asBoolean(InspectorValue& value, bool& output) { return value.asBoolean(output); }
+    static bool asObject(InspectorValue& value, RefPtr<InspectorObject>& output) { return value.asObject(output); }
+    static bool asArray(InspectorValue& value, RefPtr<InspectorArray>& output) { return value.asArray(output); }
 };
 
 int InspectorBackendDispatcher::getInteger(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)

Modified: trunk/Source/_javascript_Core/inspector/InspectorProtocolTypes.h (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/InspectorProtocolTypes.h	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/InspectorProtocolTypes.h	2014-09-30 03:30:54 UTC (rev 174094)
@@ -214,8 +214,8 @@
     static PassRefPtr<Array<T>> runtimeCast(PassRefPtr<InspectorValue> value)
     {
         RefPtr<InspectorArray> array;
-        bool castRes = value->asArray(&array);
-        ASSERT_UNUSED(castRes, castRes);
+        bool castSucceeded = value->asArray(array);
+        ASSERT_UNUSED(castSucceeded, castSucceeded);
 #if !ASSERT_DISABLED
         assertValueHasExpectedType(array.get());
 #endif // !ASSERT_DISABLED
@@ -227,8 +227,8 @@
     static void assertValueHasExpectedType(InspectorValue* value)
     {
         RefPtr<InspectorArray> array;
-        bool castRes = value->asArray(&array);
-        ASSERT_UNUSED(castRes, castRes);
+        bool castSucceeded = value->asArray(array);
+        ASSERT_UNUSED(castSucceeded, castSucceeded);
         for (unsigned i = 0; i < array->length(); i++)
             BindingTraits<T>::assertValueHasExpectedType(array->get(i).get());
     }

Modified: trunk/Source/_javascript_Core/inspector/InspectorValues.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/InspectorValues.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/InspectorValues.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2014 University of Washington. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -63,8 +64,10 @@
 bool parseConstToken(const UChar* start, const UChar* end, const UChar** tokenEnd, const char* token)
 {
     while (start < end && *token != '\0' && *start++ == *token++) { }
+
     if (*token != '\0')
         return false;
+
     *tokenEnd = start;
     return true;
 }
@@ -73,16 +76,20 @@
 {
     if (start == end)
         return false;
+
     bool haveLeadingZero = '0' == *start;
     int length = 0;
     while (start < end && '0' <= *start && *start <= '9') {
         ++start;
         ++length;
     }
+
     if (!length)
         return false;
+
     if (!canHaveLeadingZeros && length > 1 && haveLeadingZero)
         return false;
+
     *tokenEnd = start;
     return true;
 }
@@ -93,12 +100,14 @@
     // According   to RFC4627, a valid number is: [minus] int [frac] [exp]
     if (start == end)
         return false;
+
     UChar c = *start;
     if ('-' == c)
         ++start;
 
     if (!readInt(start, end, &start, false))
         return false;
+
     if (start == end) {
         *tokenEnd = start;
         return true;
@@ -140,11 +149,13 @@
 {
     if (end - start < digits)
         return false;
+
     for (int i = 0; i < digits; ++i) {
         UChar c = *start++;
         if (!(('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')))
             return false;
     }
+
     *tokenEnd = start;
     return true;
 }
@@ -183,6 +194,7 @@
             return true;
         }
     }
+
     return false;
 }
 
@@ -246,6 +258,7 @@
             return STRING;
         break;
     }
+
     return INVALID_TOKEN;
 }
 
@@ -257,16 +270,17 @@
         return c - 'A' + 10;
     if ('a' <= c && c <= 'f')
         return c - 'a' + 10;
+
     ASSERT_NOT_REACHED();
     return 0;
 }
 
-bool decodeString(const UChar* start, const UChar* end, StringBuilder* output)
+bool decodeString(const UChar* start, const UChar* end, StringBuilder& output)
 {
     while (start < end) {
         UChar c = *start++;
         if ('\\' != c) {
-            output->append(c);
+            output.append(c);
             continue;
         }
         c = *start++;
@@ -308,24 +322,28 @@
         default:
             return false;
         }
-        output->append(c);
+        output.append(c);
     }
+
     return true;
 }
 
-bool decodeString(const UChar* start, const UChar* end, String* output)
+bool decodeString(const UChar* start, const UChar* end, String& output)
 {
     if (start == end) {
-        *output = "";
+        output = emptyString();
         return true;
     }
+
     if (start > end)
         return false;
+
     StringBuilder buffer;
     buffer.reserveCapacity(end - start);
-    if (!decodeString(start, end, &buffer))
+    if (!decodeString(start, end, buffer))
         return false;
-    *output = buffer.toString();
+
+    output = buffer.toString();
     return true;
 }
 
@@ -360,7 +378,7 @@
     }
     case STRING: {
         String value;
-        bool ok = decodeString(tokenStart + 1, tokenEnd - 1, &value);
+        bool ok = decodeString(tokenStart + 1, tokenEnd - 1, value);
         if (!ok)
             return nullptr;
         result = InspectorString::create(value);
@@ -402,7 +420,7 @@
             if (token != STRING)
                 return nullptr;
             String key;
-            if (!decodeString(tokenStart + 1, tokenEnd - 1, &key))
+            if (!decodeString(tokenStart + 1, tokenEnd - 1, key))
                 return nullptr;
             start = tokenEnd;
 
@@ -444,25 +462,25 @@
     return result.release();
 }
 
-inline bool escapeChar(UChar c, StringBuilder* dst)
+inline bool escapeChar(UChar c, StringBuilder& dst)
 {
     switch (c) {
-    case '\b': dst->append("\\b", 2); break;
-    case '\f': dst->append("\\f", 2); break;
-    case '\n': dst->append("\\n", 2); break;
-    case '\r': dst->append("\\r", 2); break;
-    case '\t': dst->append("\\t", 2); break;
-    case '\\': dst->append("\\\\", 2); break;
-    case '"': dst->append("\\\"", 2); break;
+    case '\b': dst.appendLiteral("\\b"); break;
+    case '\f': dst.appendLiteral("\\f"); break;
+    case '\n': dst.appendLiteral("\\n"); break;
+    case '\r': dst.appendLiteral("\\r"); break;
+    case '\t': dst.appendLiteral("\\t"); break;
+    case '\\': dst.appendLiteral("\\\\"); break;
+    case '"': dst.appendLiteral("\\\""); break;
     default:
         return false;
     }
     return true;
 }
 
-inline void doubleQuoteString(const String& str, StringBuilder* dst)
+inline void doubleQuoteString(const String& str, StringBuilder& dst)
 {
-    dst->append('"');
+    dst.append('"');
     for (unsigned i = 0; i < str.length(); ++i) {
         UChar c = str[i];
         if (!escapeChar(c, dst)) {
@@ -470,203 +488,206 @@
                 // 1. Escaping <, > to prevent script execution.
                 // 2. Technically, we could also pass through c > 126 as UTF8, but this
                 //    is also optional.  It would also be a pain to implement here.
-                dst->append(String::format("\\u%04X", c));
+                dst.append(String::format("\\u%04X", c));
             } else
-                dst->append(c);
+                dst.append(c);
         }
     }
-    dst->append('"');
+    dst.append('"');
 }
 
 } // anonymous namespace
 
-bool InspectorValue::asBoolean(bool*) const
+bool InspectorValue::asBoolean(bool&) const
 {
     return false;
 }
 
-bool InspectorValue::asDouble(double*) const
+bool InspectorValue::asDouble(double&) const
 {
     return false;
 }
 
-bool InspectorValue::asDouble(float*) const
+bool InspectorValue::asDouble(float&) const
 {
     return false;
 }
 
-bool InspectorValue::asInteger(int*) const
+bool InspectorValue::asInteger(int&) const
 {
     return false;
 }
 
-bool InspectorValue::asInteger(unsigned*) const
+bool InspectorValue::asInteger(unsigned&) const
 {
     return false;
 }
 
-bool InspectorValue::asInteger(long*) const
+bool InspectorValue::asInteger(long&) const
 {
     return false;
 }
 
-bool InspectorValue::asInteger(long long*) const
+bool InspectorValue::asInteger(long long&) const
 {
     return false;
 }
 
-bool InspectorValue::asInteger(unsigned long*) const
+bool InspectorValue::asInteger(unsigned long&) const
 {
     return false;
 }
 
-bool InspectorValue::asInteger(unsigned long long*) const
+bool InspectorValue::asInteger(unsigned long long&) const
 {
     return false;
 }
 
-bool InspectorValue::asString(String*) const
+bool InspectorValue::asString(String&) const
 {
     return false;
 }
 
-bool InspectorValue::asValue(RefPtr<InspectorValue>* output)
+bool InspectorValue::asValue(RefPtr<InspectorValue>& output)
 {
-    *output = this;
+    output = this;
     return true;
 }
 
-bool InspectorValue::asObject(RefPtr<InspectorObject>*)
+bool InspectorValue::asObject(RefPtr<InspectorObject>&)
 {
     return false;
 }
 
-bool InspectorValue::asArray(RefPtr<InspectorArray>*)
+bool InspectorValue::asArray(RefPtr<InspectorArray>&)
 {
     return false;
 }
 
-PassRefPtr<InspectorObject> InspectorValue::asObject()
+bool InspectorValue::parseJSON(const String& jsonInput, RefPtr<InspectorValue>& output)
 {
-    return nullptr;
-}
-
-PassRefPtr<InspectorArray> InspectorValue::asArray()
-{
-    return nullptr;
-}
-
-PassRefPtr<InspectorValue> InspectorValue::parseJSON(const String& json)
-{
     // FIXME: This whole file should just use StringView instead of UChar/length and avoid upconverting.
-    auto characters = StringView(json).upconvertedCharacters();
+    auto characters = StringView(jsonInput).upconvertedCharacters();
     const UChar* start = characters;
-    const UChar* end = start + json.length();
+    const UChar* end = start + jsonInput.length();
     const UChar* tokenEnd;
-    RefPtr<InspectorValue> value = buildValue(start, end, &tokenEnd, 0);
-    if (!value || tokenEnd != end)
-        return nullptr;
-    return value.release();
+    RefPtr<InspectorValue> result = buildValue(start, end, &tokenEnd, 0);
+    if (!result || tokenEnd != end)
+        return false;
+
+    output = result.release();
+    return true;
 }
 
 String InspectorValue::toJSONString() const
 {
     StringBuilder result;
     result.reserveCapacity(512);
-    writeJSON(&result);
+    writeJSON(result);
     return result.toString();
 }
 
-void InspectorValue::writeJSON(StringBuilder* output) const
+void InspectorValue::writeJSON(StringBuilder& output) const
 {
     ASSERT(m_type == Type::Null);
-    output->append(nullString, 4);
+
+    output.appendLiteral("null");
 }
 
-bool InspectorBasicValue::asBoolean(bool* output) const
+bool InspectorBasicValue::asBoolean(bool& output) const
 {
     if (type() != Type::Boolean)
         return false;
-    *output = m_boolValue;
+
+    output = m_booleanValue;
     return true;
 }
 
-bool InspectorBasicValue::asDouble(double* output) const
+bool InspectorBasicValue::asDouble(double& output) const
 {
     if (type() != Type::Double)
         return false;
-    *output = m_doubleValue;
+
+    output = m_doubleValue;
     return true;
 }
 
-bool InspectorBasicValue::asDouble(float* output) const
+bool InspectorBasicValue::asDouble(float& output) const
 {
     if (type() != Type::Double)
         return false;
-    *output = static_cast<float>(m_doubleValue);
+
+    output = static_cast<float>(m_doubleValue);
     return true;
 }
 
-bool InspectorBasicValue::asInteger(int* output) const
+bool InspectorBasicValue::asInteger(int& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
-    *output = static_cast<int>(m_doubleValue);
+
+    output = static_cast<int>(m_doubleValue);
     return true;
 }
 
-bool InspectorBasicValue::asInteger(unsigned* output) const
+bool InspectorBasicValue::asInteger(unsigned& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
-    *output = static_cast<unsigned>(m_doubleValue);
+
+    output = static_cast<unsigned>(m_doubleValue);
     return true;
 }
 
-bool InspectorBasicValue::asInteger(long* output) const
+bool InspectorBasicValue::asInteger(long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
-    *output = static_cast<long>(m_doubleValue);
+
+    output = static_cast<long>(m_doubleValue);
     return true;
 }
 
-bool InspectorBasicValue::asInteger(long long* output) const
+bool InspectorBasicValue::asInteger(long long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
-    *output = static_cast<long long>(m_doubleValue);
+
+    output = static_cast<long long>(m_doubleValue);
     return true;
 }
 
-bool InspectorBasicValue::asInteger(unsigned long* output) const
+bool InspectorBasicValue::asInteger(unsigned long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
-    *output = static_cast<unsigned long>(m_doubleValue);
+
+    output = static_cast<unsigned long>(m_doubleValue);
     return true;
 }
 
-bool InspectorBasicValue::asInteger(unsigned long long* output) const
+bool InspectorBasicValue::asInteger(unsigned long long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
-    *output = static_cast<unsigned long long>(m_doubleValue);
+
+    output = static_cast<unsigned long long>(m_doubleValue);
     return true;
 }
 
-void InspectorBasicValue::writeJSON(StringBuilder* output) const
+void InspectorBasicValue::writeJSON(StringBuilder& output) const
 {
     ASSERT(type() == Type::Boolean || type() == Type::Double || type() == Type::Integer);
+
     if (type() == Type::Boolean) {
-        if (m_boolValue)
-            output->append(trueString, 4);
+        if (m_booleanValue)
+            output.appendLiteral("true");
         else
-            output->append(falseString, 5);
+            output.appendLiteral("false");
     } else if (type() == Type::Double || type() == Type::Integer) {
         NumberToLStringBuffer buffer;
         if (!std::isfinite(m_doubleValue)) {
-            output->append(nullString, 4);
+            output.appendLiteral("null");
             return;
         }
         DecimalNumber decimal = m_doubleValue;
@@ -675,23 +696,23 @@
             // Not enough room for decimal. Use exponential format.
             if (decimal.bufferLengthForStringExponential() > WTF::NumberToStringBufferLength) {
                 // Fallback for an abnormal case if it's too little even for exponential.
-                output->append("NaN", 3);
+                output.appendLiteral("NaN");
                 return;
             }
             length = decimal.toStringExponential(buffer, WTF::NumberToStringBufferLength);
         } else
             length = decimal.toStringDecimal(buffer, WTF::NumberToStringBufferLength);
-        output->append(buffer, length);
+        output.append(buffer, length);
     }
 }
 
-bool InspectorString::asString(String* output) const
+bool InspectorString::asString(String& output) const
 {
-    *output = m_stringValue;
+    output = m_stringValue;
     return true;
 }
 
-void InspectorString::writeJSON(StringBuilder* output) const
+void InspectorString::writeJSON(StringBuilder& output) const
 {
     ASSERT(type() == Type::String);
     doubleQuoteString(m_stringValue, output);
@@ -701,33 +722,31 @@
 {
 }
 
-bool InspectorObjectBase::asObject(RefPtr<InspectorObject>* output)
+bool InspectorObjectBase::asObject(RefPtr<InspectorObject>& output)
 {
     COMPILE_ASSERT(sizeof(InspectorObject) == sizeof(InspectorObjectBase), cannot_cast);
-    *output = static_cast<InspectorObject*>(this);
+
+    output = static_cast<InspectorObject*>(this);
     return true;
 }
 
-PassRefPtr<InspectorObject> InspectorObjectBase::asObject()
-{
-    return openAccessors();
-}
-
 InspectorObject* InspectorObjectBase::openAccessors()
 {
     COMPILE_ASSERT(sizeof(InspectorObject) == sizeof(InspectorObjectBase), cannot_cast);
+
     return static_cast<InspectorObject*>(this);
 }
 
-bool InspectorObjectBase::getBoolean(const String& name, bool* output) const
+bool InspectorObjectBase::getBoolean(const String& name, bool& output) const
 {
     RefPtr<InspectorValue> value = get(name);
     if (!value)
         return false;
+
     return value->asBoolean(output);
 }
 
-bool InspectorObjectBase::getString(const String& name, String* output) const
+bool InspectorObjectBase::getString(const String& name, String& output) const
 {
     RefPtr<InspectorValue> value = get(name);
     if (!value)
@@ -740,7 +759,10 @@
     PassRefPtr<InspectorValue> value = get(name);
     if (!value)
         return nullptr;
-    return value->asObject();
+
+    RefPtr<InspectorObject> result;
+    value->asObject(result);
+    return result.release();
 }
 
 PassRefPtr<InspectorArray> InspectorObjectBase::getArray(const String& name) const
@@ -748,7 +770,10 @@
     PassRefPtr<InspectorValue> value = get(name);
     if (!value)
         return nullptr;
-    return value->asArray();
+
+    RefPtr<InspectorArray> result;
+    value->asArray(result);
+    return result.release();
 }
 
 PassRefPtr<InspectorValue> InspectorObjectBase::get(const String& name) const
@@ -770,19 +795,19 @@
     }
 }
 
-void InspectorObjectBase::writeJSON(StringBuilder* output) const
+void InspectorObjectBase::writeJSON(StringBuilder& output) const
 {
-    output->append('{');
+    output.append('{');
     for (size_t i = 0; i < m_order.size(); ++i) {
         Dictionary::const_iterator it = m_data.find(m_order[i]);
         ASSERT(it != m_data.end());
         if (i)
-            output->append(',');
+            output.append(',');
         doubleQuoteString(it->key, output);
-        output->append(':');
+        output.append(':');
         it->value->writeJSON(output);
     }
-    output->append('}');
+    output.append('}');
 }
 
 InspectorObjectBase::InspectorObjectBase()
@@ -796,28 +821,22 @@
 {
 }
 
-bool InspectorArrayBase::asArray(RefPtr<InspectorArray>* output)
+bool InspectorArrayBase::asArray(RefPtr<InspectorArray>& output)
 {
     COMPILE_ASSERT(sizeof(InspectorArrayBase) == sizeof(InspectorArray), cannot_cast);
-    *output = static_cast<InspectorArray*>(this);
+    output = static_cast<InspectorArray*>(this);
     return true;
 }
 
-PassRefPtr<InspectorArray> InspectorArrayBase::asArray()
+void InspectorArrayBase::writeJSON(StringBuilder& output) const
 {
-    COMPILE_ASSERT(sizeof(InspectorArrayBase) == sizeof(InspectorArray), cannot_cast);
-    return static_cast<InspectorArray*>(this);
-}
-
-void InspectorArrayBase::writeJSON(StringBuilder* output) const
-{
-    output->append('[');
+    output.append('[');
     for (Vector<RefPtr<InspectorValue>>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) {
         if (it != m_data.begin())
-            output->append(',');
+            output.append(',');
         (*it)->writeJSON(output);
     }
-    output->append(']');
+    output.append(']');
 }
 
 InspectorArrayBase::InspectorArrayBase()

Modified: trunk/Source/_javascript_Core/inspector/InspectorValues.h (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/InspectorValues.h	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/InspectorValues.h	2014-09-30 03:30:54 UTC (rev 174094)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2014 University of Washington. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -69,26 +70,24 @@
 
     bool isNull() const { return m_type == Type::Null; }
 
-    virtual bool asBoolean(bool* output) const;
-    virtual bool asInteger(int* output) const;
-    virtual bool asInteger(unsigned* output) const;
-    virtual bool asInteger(long* output) const;
-    virtual bool asInteger(long long* output) const;
-    virtual bool asInteger(unsigned long* output) const;
-    virtual bool asInteger(unsigned long long* output) const;
-    virtual bool asDouble(double* output) const;
-    virtual bool asDouble(float* output) const;
-    virtual bool asString(String* output) const;
-    virtual bool asValue(RefPtr<InspectorValue>* output);
-    virtual bool asObject(RefPtr<InspectorObject>* output);
-    virtual bool asArray(RefPtr<InspectorArray>* output);
-    virtual PassRefPtr<InspectorObject> asObject();
-    virtual PassRefPtr<InspectorArray> asArray();
+    virtual bool asBoolean(bool&) const;
+    virtual bool asInteger(int&) const;
+    virtual bool asInteger(unsigned&) const;
+    virtual bool asInteger(long&) const;
+    virtual bool asInteger(long long&) const;
+    virtual bool asInteger(unsigned long&) const;
+    virtual bool asInteger(unsigned long long&) const;
+    virtual bool asDouble(double&) const;
+    virtual bool asDouble(float&) const;
+    virtual bool asString(String&) const;
+    virtual bool asValue(RefPtr<InspectorValue>&);
+    virtual bool asObject(RefPtr<InspectorObject>&);
+    virtual bool asArray(RefPtr<InspectorArray>&);
 
-    static PassRefPtr<InspectorValue> parseJSON(const String& json);
+    static bool parseJSON(const String& jsonInput, RefPtr<InspectorValue>& output);
 
     String toJSONString() const;
-    virtual void writeJSON(StringBuilder* output) const;
+    virtual void writeJSON(StringBuilder& output) const;
 
 protected:
     explicit InspectorValue(Type type) : m_type(type) { }
@@ -104,24 +103,24 @@
     static PassRefPtr<InspectorBasicValue> create(int);
     static PassRefPtr<InspectorBasicValue> create(double);
 
-    virtual bool asBoolean(bool* output) const override;
+    virtual bool asBoolean(bool&) const override;
     // Numbers from the frontend are always parsed as doubles, so we allow
     // clients to convert to integral values with this function.
-    virtual bool asInteger(int* output) const override;
-    virtual bool asInteger(unsigned* output) const override;
-    virtual bool asInteger(long* output) const override;
-    virtual bool asInteger(long long* output) const override;
-    virtual bool asInteger(unsigned long* output) const override;
-    virtual bool asInteger(unsigned long long* output) const override;
-    virtual bool asDouble(double* output) const override;
-    virtual bool asDouble(float* output) const override;
+    virtual bool asInteger(int&) const override;
+    virtual bool asInteger(unsigned&) const override;
+    virtual bool asInteger(long&) const override;
+    virtual bool asInteger(long long&) const override;
+    virtual bool asInteger(unsigned long&) const override;
+    virtual bool asInteger(unsigned long long&) const override;
+    virtual bool asDouble(double&) const override;
+    virtual bool asDouble(float&) const override;
 
-    virtual void writeJSON(StringBuilder* output) const override;
+    virtual void writeJSON(StringBuilder& output) const override;
 
 private:
     explicit InspectorBasicValue(bool value)
         : InspectorValue(Type::Boolean)
-        , m_boolValue(value) { }
+        , m_booleanValue(value) { }
 
     explicit InspectorBasicValue(int value)
         : InspectorValue(Type::Integer)
@@ -132,7 +131,7 @@
         , m_doubleValue(value) { }
 
     union {
-        bool m_boolValue;
+        bool m_booleanValue;
         double m_doubleValue;
     };
 };
@@ -142,9 +141,9 @@
     static PassRefPtr<InspectorString> create(const String&);
     static PassRefPtr<InspectorString> create(const char*);
 
-    virtual bool asString(String* output) const override;
+    virtual bool asString(String& output) const override;
 
-    virtual void writeJSON(StringBuilder* output) const override;
+    virtual void writeJSON(StringBuilder& output) const override;
 
 private:
     explicit InspectorString(const String& value)
@@ -166,13 +165,12 @@
     typedef Dictionary::iterator iterator;
     typedef Dictionary::const_iterator const_iterator;
 
-    virtual PassRefPtr<InspectorObject> asObject() override;
     InspectorObject* openAccessors();
 
 protected:
     virtual ~InspectorObjectBase();
 
-    virtual bool asObject(RefPtr<InspectorObject>* output) override;
+    virtual bool asObject(RefPtr<InspectorObject>& output) override;
 
     // FIXME: use templates to reduce the amount of duplicated set*() methods.
     void setBoolean(const String& name, bool);
@@ -187,15 +185,15 @@
     const_iterator find(const String& name) const;
 
     // FIXME: use templates to reduce the amount of duplicated get*() methods.
-    bool getBoolean(const String& name, bool* output) const;
-    template<class T> bool getDouble(const String& name, T* output) const
+    bool getBoolean(const String& name, bool& output) const;
+    template<class T> bool getDouble(const String& name, T& output) const
     {
         RefPtr<InspectorValue> value = get(name);
         if (!value)
             return false;
         return value->asDouble(output);
     }
-    template<class T> bool getInteger(const String& name, T* output) const
+    template<class T> bool getInteger(const String& name, T& output) const
     {
         RefPtr<InspectorValue> value = get(name);
         if (!value)
@@ -203,14 +201,14 @@
         return value->asInteger(output);
     }
 
-    bool getString(const String& name, String* output) const;
+    bool getString(const String& name, String& output) const;
     PassRefPtr<InspectorObject> getObject(const String& name) const;
     PassRefPtr<InspectorArray> getArray(const String& name) const;
     PassRefPtr<InspectorValue> get(const String& name) const;
 
     void remove(const String& name);
 
-    virtual void writeJSON(StringBuilder* output) const override;
+    virtual void writeJSON(StringBuilder& output) const override;
 
     iterator begin() { return m_data.begin(); }
     iterator end() { return m_data.end(); }
@@ -264,14 +262,12 @@
     typedef Vector<RefPtr<InspectorValue>>::iterator iterator;
     typedef Vector<RefPtr<InspectorValue>>::const_iterator const_iterator;
 
-    virtual PassRefPtr<InspectorArray> asArray() override;
-
     unsigned length() const { return m_data.size(); }
 
 protected:
     virtual ~InspectorArrayBase();
 
-    virtual bool asArray(RefPtr<InspectorArray>* output) override;
+    virtual bool asArray(RefPtr<InspectorArray>&) override;
 
     void pushBoolean(bool);
     void pushInteger(int);
@@ -283,7 +279,7 @@
 
     PassRefPtr<InspectorValue> get(size_t index);
 
-    virtual void writeJSON(StringBuilder* output) const override;
+    virtual void writeJSON(StringBuilder& output) const override;
 
     iterator begin() { return m_data.begin(); }
     iterator end() { return m_data.end(); }

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -208,13 +208,13 @@
     for (unsigned i = 0; i < actionsLength; ++i) {
         RefPtr<InspectorValue> value = actions->get(i);
         RefPtr<InspectorObject> object;
-        if (!value->asObject(&object)) {
+        if (!value->asObject(object)) {
             *errorString = ASCIILiteral("BreakpointAction of incorrect type, expected object");
             return false;
         }
 
         String typeString;
-        if (!object->getString(ASCIILiteral("type"), &typeString)) {
+        if (!object->getString(ASCIILiteral("type"), typeString)) {
             *errorString = ASCIILiteral("BreakpointAction had type missing");
             return false;
         }
@@ -228,10 +228,10 @@
         // Specifying an identifier is optional. They are used to correlate probe samples
         // in the frontend across multiple backend probe actions and segregate object groups.
         int identifier = 0;
-        object->getInteger(ASCIILiteral("id"), &identifier);
+        object->getInteger(ASCIILiteral("id"), identifier);
 
         String data;
-        object->getString(ASCIILiteral("data"), &data);
+        object->getString(ASCIILiteral("data"), data);
 
         result->append(ScriptBreakpointAction(type, identifier, data));
     }
@@ -261,8 +261,8 @@
     bool autoContinue = false;
     RefPtr<InspectorArray> actions;
     if (options) {
-        (*options)->getString(ASCIILiteral("condition"), &condition);
-        (*options)->getBoolean(ASCIILiteral("autoContinue"), &autoContinue);
+        (*options)->getString(ASCIILiteral("condition"), condition);
+        (*options)->getBoolean(ASCIILiteral("autoContinue"), autoContinue);
         actions = (*options)->getArray(ASCIILiteral("actions"));
     }
 
@@ -285,18 +285,18 @@
     *outBreakpointIdentifier = breakpointIdentifier;
 }
 
-static bool parseLocation(ErrorString* errorString, InspectorObject* location, JSC::SourceID* sourceID, unsigned* lineNumber, unsigned* columnNumber)
+static bool parseLocation(ErrorString* errorString, InspectorObject& location, JSC::SourceID& sourceID, unsigned& lineNumber, unsigned& columnNumber)
 {
     String scriptIDStr;
-    if (!location->getString(ASCIILiteral("scriptId"), &scriptIDStr) || !location->getInteger(ASCIILiteral("lineNumber"), lineNumber)) {
-        *sourceID = JSC::noSourceID;
+    if (!location.getString(ASCIILiteral("scriptId"), scriptIDStr) || !location.getInteger(ASCIILiteral("lineNumber"), lineNumber)) {
+        sourceID = JSC::noSourceID;
         *errorString = ASCIILiteral("scriptId and lineNumber are required.");
         return false;
     }
 
-    *sourceID = scriptIDStr.toIntPtr();
-    *columnNumber = 0;
-    location->getInteger(ASCIILiteral("columnNumber"), columnNumber);
+    sourceID = scriptIDStr.toIntPtr();
+    columnNumber = 0;
+    location.getInteger(ASCIILiteral("columnNumber"), columnNumber);
     return true;
 }
 
@@ -305,15 +305,15 @@
     JSC::SourceID sourceID;
     unsigned lineNumber;
     unsigned columnNumber;
-    if (!parseLocation(errorString, location.get(), &sourceID, &lineNumber, &columnNumber))
+    if (!parseLocation(errorString, *location, sourceID, lineNumber, columnNumber))
         return;
 
     String condition = emptyString();
     bool autoContinue = false;
     RefPtr<InspectorArray> actions;
     if (options) {
-        (*options)->getString(ASCIILiteral("condition"), &condition);
-        (*options)->getBoolean(ASCIILiteral("autoContinue"), &autoContinue);
+        (*options)->getString(ASCIILiteral("condition"), condition);
+        (*options)->getBoolean(ASCIILiteral("autoContinue"), autoContinue);
         actions = (*options)->getArray(ASCIILiteral("actions"));
     }
 
@@ -360,7 +360,7 @@
     JSC::SourceID sourceID;
     unsigned lineNumber;
     unsigned columnNumber;
-    if (!parseLocation(errorString, location.get(), &sourceID, &lineNumber, &columnNumber))
+    if (!parseLocation(errorString, *location, sourceID, lineNumber, columnNumber))
         return;
 
     ScriptBreakpoint breakpoint(lineNumber, columnNumber, "", false);
@@ -593,18 +593,22 @@
         return;
 
     for (auto it = m_javaScriptBreakpoints.begin(), end = m_javaScriptBreakpoints.end(); it != end; ++it) {
-        RefPtr<InspectorObject> breakpointObject = it->value->asObject();
+        RefPtr<InspectorObject> breakpointObject;
+        if (!it->value->asObject(breakpointObject))
+            return;
+
         bool isRegex;
-        breakpointObject->getBoolean(ASCIILiteral("isRegex"), &isRegex);
+        breakpointObject->getBoolean(ASCIILiteral("isRegex"), isRegex);
         String url;
-        breakpointObject->getString(ASCIILiteral("url"), &url);
+        breakpointObject->getString(ASCIILiteral("url"), url);
         if (!matches(scriptURL, url, isRegex))
             continue;
+
         ScriptBreakpoint breakpoint;
-        breakpointObject->getInteger(ASCIILiteral("lineNumber"), &breakpoint.lineNumber);
-        breakpointObject->getInteger(ASCIILiteral("columnNumber"), &breakpoint.columnNumber);
-        breakpointObject->getString(ASCIILiteral("condition"), &breakpoint.condition);
-        breakpointObject->getBoolean(ASCIILiteral("autoContinue"), &breakpoint.autoContinue);
+        breakpointObject->getInteger(ASCIILiteral("lineNumber"), breakpoint.lineNumber);
+        breakpointObject->getInteger(ASCIILiteral("columnNumber"), breakpoint.columnNumber);
+        breakpointObject->getString(ASCIILiteral("condition"), breakpoint.condition);
+        breakpointObject->getBoolean(ASCIILiteral("autoContinue"), breakpoint.autoContinue);
         ErrorString errorString;
         RefPtr<InspectorArray> actions = breakpointObject->getArray(ASCIILiteral("actions"));
         if (!breakpointActionsFromProtocol(&errorString, actions, &breakpoint.actions)) {

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -213,7 +213,7 @@
     for (size_t i = 0; i < locations->length(); i++) {
         RefPtr<Inspector::InspectorValue> value = locations->get(i);
         RefPtr<InspectorObject> location;
-        if (!value->asObject(&location)) {
+        if (!value->asObject(location)) {
             *errorString = ASCIILiteral("Array of TypeLocation objects has an object that does not have type of TypeLocation.");
             return;
         }
@@ -221,9 +221,9 @@
         int descriptor;
         String sourceIDAsString;
         int divot;
-        location->getInteger(ASCIILiteral("typeInformationDescriptor"), &descriptor);
-        location->getString(ASCIILiteral("sourceID"), &sourceIDAsString);
-        location->getInteger(ASCIILiteral("divot"), &divot);
+        location->getInteger(ASCIILiteral("typeInformationDescriptor"), descriptor);
+        location->getString(ASCIILiteral("sourceID"), sourceIDAsString);
+        location->getInteger(ASCIILiteral("divot"), divot);
 
         bool okay;
         TypeLocation* typeLocation = vm.typeProfiler()->findLocation(divot, sourceIDAsString.toIntPtrStrict(&okay), static_cast<TypeProfilerSearchDescriptor>(descriptor));

Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_protocol_types_implementation.py (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_protocol_types_implementation.py	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_protocol_types_implementation.py	2014-09-30 03:30:54 UTC (rev 174094)
@@ -126,8 +126,8 @@
         lines.append('void BindingTraits<%s>::assertValueHasExpectedType(Inspector::InspectorValue* value)' % (Generator.protocol_type_string_for_type(object_declaration.type)))
         lines.append("""{
     RefPtr<InspectorObject> object;
-    bool castRes = value->asObject(&object);
-    ASSERT_UNUSED(castRes, castRes);""")
+    bool castSucceeded = value->asObject(object);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);""")
         for type_member in required_members:
             args = {
                 'memberName': type_member.member_name,
@@ -172,11 +172,11 @@
         lines.append('#if !ASSERT_DISABLED')
         lines.append('void %s(Inspector::InspectorValue* value)' % Generator.assertion_method_for_type_member(enum_member, object_declaration))
         lines.append('{')
-        lines.append('    String s;')
-        lines.append('    bool cast_res = value->asString(&s);')
-        lines.append('    ASSERT(cast_res);')
+        lines.append('    String result;')
+        lines.append('    bool castSucceeded = value->asString(result);')
+        lines.append('    ASSERT(castSucceeded);')
 
-        assert_condition = ' || '.join(['s == "%s"' % enum_value for enum_value in enum_member.type.enum_values()])
+        assert_condition = ' || '.join(['result == "%s"' % enum_value for enum_value in enum_member.type.enum_values()])
         lines.append('    ASSERT(%s);' % assert_condition)
         lines.append('}')
         lines.append('#endif // !ASSERT_DISABLED')

Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generator_templates.py (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generator_templates.py	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generator_templates.py	2014-09-30 03:30:54 UTC (rev 174094)
@@ -253,14 +253,14 @@
     ProtocolObjectRuntimeCast = (
 """PassRefPtr<${objectType}> BindingTraits<${objectType}>::runtimeCast(PassRefPtr<Inspector::InspectorValue> value)
 {
-    RefPtr<Inspector::InspectorObject> object;
-    bool castRes = value->asObject(&object);
-    ASSERT_UNUSED(castRes, castRes);
+    RefPtr<Inspector::InspectorObject> result;
+    bool castSucceeded = value->asObject(result);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);
 #if !ASSERT_DISABLED
-    BindingTraits<${objectType}>::assertValueHasExpectedType(object.get());
+    BindingTraits<${objectType}>::assertValueHasExpectedType(result.get());
 #endif  // !ASSERT_DISABLED
     COMPILE_ASSERT(sizeof(${objectType}) == sizeof(Inspector::InspectorObjectBase), type_cast_problem);
-    return static_cast<${objectType}*>(static_cast<Inspector::InspectorObjectBase*>(object.get()));
+    return static_cast<${objectType}*>(static_cast<Inspector::InspectorObjectBase*>(result.get()));
 }
 """
 )

Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result (174093 => 174094)


--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result	2014-09-30 03:30:54 UTC (rev 174094)
@@ -620,10 +620,10 @@
 #if !ASSERT_DISABLED
 void BindingTraits<Inspector::Protocol::Test::CastedAnimals>::assertValueHasExpectedType(Inspector::InspectorValue* value)
 {
-    String s;
-    bool cast_res = value->asString(&s);
-    ASSERT(cast_res);
-    ASSERT(s == "Ducks" || s == "Hens" || s == "Crows" || s == "Flamingos");
+    String result;
+    bool castSucceeded = value->asString(result);
+    ASSERT(castSucceeded);
+    ASSERT(result == "Ducks" || result == "Hens" || result == "Crows" || result == "Flamingos");
 }
 #endif // !ASSERT_DISABLED
 
@@ -631,8 +631,8 @@
 void BindingTraits<Inspector::Protocol::Test::TypeNeedingCast>::assertValueHasExpectedType(Inspector::InspectorValue* value)
 {
     RefPtr<InspectorObject> object;
-    bool castRes = value->asObject(&object);
-    ASSERT_UNUSED(castRes, castRes);
+    bool castSucceeded = value->asObject(object);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);
     {
         InspectorObject::iterator stringPos = object->find(ASCIILiteral("string"));
         ASSERT(stringPos != object->end());
@@ -667,14 +667,14 @@
 
 PassRefPtr<Inspector::Protocol::Test::TypeNeedingCast> BindingTraits<Inspector::Protocol::Test::TypeNeedingCast>::runtimeCast(PassRefPtr<Inspector::InspectorValue> value)
 {
-    RefPtr<Inspector::InspectorObject> object;
-    bool castRes = value->asObject(&object);
-    ASSERT_UNUSED(castRes, castRes);
+    RefPtr<Inspector::InspectorObject> result;
+    bool castSucceeded = value->asObject(result);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);
 #if !ASSERT_DISABLED
-    BindingTraits<Inspector::Protocol::Test::TypeNeedingCast>::assertValueHasExpectedType(object.get());
+    BindingTraits<Inspector::Protocol::Test::TypeNeedingCast>::assertValueHasExpectedType(result.get());
 #endif  // !ASSERT_DISABLED
     COMPILE_ASSERT(sizeof(Inspector::Protocol::Test::TypeNeedingCast) == sizeof(Inspector::InspectorObjectBase), type_cast_problem);
-    return static_cast<Inspector::Protocol::Test::TypeNeedingCast*>(static_cast<Inspector::InspectorObjectBase*>(object.get()));
+    return static_cast<Inspector::Protocol::Test::TypeNeedingCast*>(static_cast<Inspector::InspectorObjectBase*>(result.get()));
 }
 
 
@@ -682,8 +682,8 @@
 void BindingTraits<Inspector::Protocol::Test::RecursiveObject1>::assertValueHasExpectedType(Inspector::InspectorValue* value)
 {
     RefPtr<InspectorObject> object;
-    bool castRes = value->asObject(&object);
-    ASSERT_UNUSED(castRes, castRes);
+    bool castSucceeded = value->asObject(object);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     int foundPropertiesCount = 0;
     {
@@ -702,8 +702,8 @@
 void BindingTraits<Inspector::Protocol::Test::RecursiveObject2>::assertValueHasExpectedType(Inspector::InspectorValue* value)
 {
     RefPtr<InspectorObject> object;
-    bool castRes = value->asObject(&object);
-    ASSERT_UNUSED(castRes, castRes);
+    bool castSucceeded = value->asObject(object);
+    ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     int foundPropertiesCount = 0;
     {

Modified: trunk/Source/_javascript_Core/replay/EncodedValue.cpp (174093 => 174094)


--- trunk/Source/_javascript_Core/replay/EncodedValue.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/_javascript_Core/replay/EncodedValue.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -40,7 +40,7 @@
 PassRefPtr<InspectorObject> EncodedValue::asObject()
 {
     RefPtr<InspectorObject> result;
-    bool castSucceeded = m_value->asObject(&result);
+    bool castSucceeded = m_value->asObject(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result.release();
@@ -49,7 +49,7 @@
 PassRefPtr<InspectorArray> EncodedValue::asArray()
 {
     RefPtr<InspectorArray> result;
-    bool castSucceeded = m_value->asArray(&result);
+    bool castSucceeded = m_value->asArray(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result.release();
@@ -103,7 +103,7 @@
 template<> bool EncodedValue::convertTo<bool>()
 {
     bool result;
-    bool castSucceeded = m_value->asBoolean(&result);
+    bool castSucceeded = m_value->asBoolean(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;
@@ -112,7 +112,7 @@
 template<> double EncodedValue::convertTo<double>()
 {
     double result;
-    bool castSucceeded = m_value->asDouble(&result);
+    bool castSucceeded = m_value->asDouble(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;
@@ -121,7 +121,7 @@
 template<> float EncodedValue::convertTo<float>()
 {
     float result;
-    bool castSucceeded = m_value->asDouble(&result);
+    bool castSucceeded = m_value->asDouble(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;
@@ -130,7 +130,7 @@
 template<> int32_t EncodedValue::convertTo<int32_t>()
 {
     int32_t result;
-    bool castSucceeded = m_value->asInteger(&result);
+    bool castSucceeded = m_value->asInteger(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;
@@ -139,7 +139,7 @@
 template<> int64_t EncodedValue::convertTo<int64_t>()
 {
     int64_t result;
-    bool castSucceeded = m_value->asInteger(&result);
+    bool castSucceeded = m_value->asInteger(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;
@@ -148,7 +148,7 @@
 template<> uint32_t EncodedValue::convertTo<uint32_t>()
 {
     uint32_t result;
-    bool castSucceeded = m_value->asInteger(&result);
+    bool castSucceeded = m_value->asInteger(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;
@@ -157,7 +157,7 @@
 template<> uint64_t EncodedValue::convertTo<uint64_t>()
 {
     uint64_t result;
-    bool castSucceeded = m_value->asInteger(&result);
+    bool castSucceeded = m_value->asInteger(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;
@@ -166,7 +166,7 @@
 template<> String EncodedValue::convertTo<String>()
 {
     String result;
-    bool castSucceeded = m_value->asString(&result);
+    bool castSucceeded = m_value->asString(result);
     ASSERT_UNUSED(castSucceeded, castSucceeded);
 
     return result;

Modified: trunk/Source/WebCore/ChangeLog (174093 => 174094)


--- trunk/Source/WebCore/ChangeLog	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/ChangeLog	2014-09-30 03:30:54 UTC (rev 174094)
@@ -1,3 +1,45 @@
+2014-09-29  Brian J. Burg  <b...@cs.washington.edu>
+
+        Web Inspector: InspectorValues should use references for out parameters
+        https://bugs.webkit.org/show_bug.cgi?id=137190
+
+        Reviewed by Joseph Pecoraro.
+
+        Clean up some call sites to explicitly check for cast success, and simplify
+        some exceptional control flows.
+
+        No new tests, no behavior changed.
+
+        * inspector/CommandLineAPIHost.cpp:
+        (WebCore::CommandLineAPIHost::inspectImpl):
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::computePseudoClassMask):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::parseColor):
+        (WebCore::parseConfigColor):
+        (WebCore::parseQuad):
+        (WebCore::InspectorDOMAgent::performSearch):
+        (WebCore::InspectorDOMAgent::highlightConfigFromInspectorObject):
+        (WebCore::InspectorDOMAgent::innerHighlightQuad):
+        (WebCore::InspectorDOMAgent::highlightFrame):
+        * inspector/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::findStorageArea):
+        * inspector/InspectorIndexedDBAgent.cpp: Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL.
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
+        * inspector/InspectorReplayAgent.cpp:
+        (WebCore::InspectorReplayAgent::replayToPosition):
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::willSendRequest):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyle::styleWithProperties):
+        * inspector/InspectorStyleSheet.h:
+        (WebCore::InspectorCSSId::InspectorCSSId):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::startFromConsole):
+        (WebCore::InspectorTimelineAgent::stopFromConsole):
+        * inspector/InspectorWorkerAgent.cpp:
+
 2014-09-29  Christophe Dumez  <cdu...@apple.com>
 
         Use is<>() / downcast<>() for Document

Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -94,10 +94,15 @@
 
 void CommandLineAPIHost::inspectImpl(PassRefPtr<InspectorValue> object, PassRefPtr<InspectorValue> hints)
 {
-    if (m_inspectorAgent) {
-        RefPtr<Inspector::Protocol::Runtime::RemoteObject> remoteObject = BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(object);
-        m_inspectorAgent->inspect(remoteObject, hints->asObject());
-    }
+    if (!m_inspectorAgent)
+        return;
+
+    RefPtr<InspectorObject> hintsObject;
+    if (!hints->asObject(hintsObject))
+        return;
+
+    RefPtr<Inspector::Protocol::Runtime::RemoteObject> remoteObject = BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(object);
+    m_inspectorAgent->inspect(remoteObject.release(), hintsObject.release());
 }
 
 void CommandLineAPIHost::getEventListenersImpl(Node* node, Vector<EventListenerInfo>& listenersArray)

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -89,7 +89,7 @@
     for (size_t i = 0; i < pseudoClassArray->length(); ++i) {
         RefPtr<InspectorValue> pseudoClassValue = pseudoClassArray->get(i);
         String pseudoClass;
-        bool success = pseudoClassValue->asString(&pseudoClass);
+        bool success = pseudoClassValue->asString(pseudoClass);
         if (!success)
             continue;
         if (pseudoClass == active)

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -111,23 +111,19 @@
 static const size_t maxTextSize = 10000;
 static const UChar ellipsisUChar[] = { 0x2026, 0 };
 
-static Color parseColor(const RefPtr<InspectorObject>* colorObject)
+static Color parseColor(const PassRefPtr<InspectorObject> colorObject)
 {
-    if (!colorObject || !(*colorObject))
+    if (!colorObject)
         return Color::transparent;
 
     int r;
     int g;
     int b;
-    bool success = (*colorObject)->getInteger("r", &r);
-    success |= (*colorObject)->getInteger("g", &g);
-    success |= (*colorObject)->getInteger("b", &b);
-    if (!success)
+    if (!colorObject->getInteger("r", r) || !colorObject->getInteger("g", g) || !colorObject->getInteger("b", b))
         return Color::transparent;
 
     double a;
-    success = (*colorObject)->getDouble("a", &a);
-    if (!success)
+    if (!colorObject->getDouble("a", a))
         return Color(r, g, b);
 
     // Clamp alpha to the [0..1] range.
@@ -142,7 +138,7 @@
 static Color parseConfigColor(const String& fieldName, InspectorObject* configObject)
 {
     const RefPtr<InspectorObject> colorObject = configObject->getObject(fieldName);
-    return parseColor(&colorObject);
+    return parseColor(colorObject);
 }
 
 static bool parseQuad(const RefPtr<InspectorArray>& quadArray, FloatQuad* quad)
@@ -154,7 +150,7 @@
     if (quadArray->length() != coordinatesInQuad)
         return false;
     for (size_t i = 0; i < coordinatesInQuad; ++i) {
-        if (!quadArray->get(i)->asDouble(coordinates + i))
+        if (!quadArray->get(i)->asDouble(*(coordinates + i)))
             return false;
     }
     quad->setP1(FloatPoint(coordinates[0], coordinates[1]));
@@ -899,7 +895,7 @@
                 return;
             }
             int nodeId = 0;
-            if (!nodeValue->asInteger(&nodeId)) {
+            if (!nodeValue->asInteger(nodeId)) {
                 *errorString = "Invalid nodeIds item type. Expecting integer types.";
                 return;
             }
@@ -1045,7 +1041,7 @@
 
     auto highlightConfig = std::make_unique<HighlightConfig>();
     bool showInfo = false; // Default: false (do not show a tooltip).
-    highlightInspectorObject->getBoolean("showInfo", &showInfo);
+    highlightInspectorObject->getBoolean("showInfo", showInfo);
     highlightConfig->showInfo = showInfo;
     highlightConfig->content = parseConfigColor("contentColor", highlightInspectorObject);
     highlightConfig->contentOutline = parseConfigColor("contentOutlineColor", highlightInspectorObject);
@@ -1079,8 +1075,8 @@
 void InspectorDOMAgent::innerHighlightQuad(std::unique_ptr<FloatQuad> quad, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor, const bool* usePageCoordinates)
 {
     auto highlightConfig = std::make_unique<HighlightConfig>();
-    highlightConfig->content = parseColor(color);
-    highlightConfig->contentOutline = parseColor(outlineColor);
+    highlightConfig->content = parseColor(*color);
+    highlightConfig->contentOutline = parseColor(*outlineColor);
     highlightConfig->usePageCoordinates = usePageCoordinates ? *usePageCoordinates : false;
     m_overlay->highlightQuad(WTF::move(quad), *highlightConfig);
 }
@@ -1107,18 +1103,14 @@
     m_overlay->highlightNode(node, *highlightConfig);
 }
 
-void InspectorDOMAgent::highlightFrame(
-    ErrorString*,
-    const String& frameId,
-    const RefPtr<InspectorObject>* color,
-    const RefPtr<InspectorObject>* outlineColor)
+void InspectorDOMAgent::highlightFrame(ErrorString*, const String& frameId, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor)
 {
     Frame* frame = m_pageAgent->frameForId(frameId);
     if (frame && frame->ownerElement()) {
         auto highlightConfig = std::make_unique<HighlightConfig>();
         highlightConfig->showInfo = true; // Always show tooltips for frames.
-        highlightConfig->content = parseColor(color);
-        highlightConfig->contentOutline = parseColor(outlineColor);
+        highlightConfig->content = parseColor(*color);
+        highlightConfig->contentOutline = parseColor(*outlineColor);
         m_overlay->highlightNode(frame->ownerElement(), *highlightConfig);
     }
 }

Modified: trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -186,9 +186,9 @@
 {
     String securityOrigin;
     bool isLocalStorage = false;
-    bool success = storageId->getString("securityOrigin", &securityOrigin);
+    bool success = storageId->getString("securityOrigin", securityOrigin);
     if (success)
-        success = storageId->getBoolean("isLocalStorage", &isLocalStorage);
+        success = storageId->getBoolean("isLocalStorage", isLocalStorage);
     if (!success) {
         if (errorString)
             *errorString = "Invalid storageId format";

Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -65,6 +65,7 @@
 #include <inspector/InjectedScript.h>
 #include <inspector/InjectedScriptManager.h>
 #include <inspector/InspectorValues.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/Vector.h>
 
 using Inspector::Protocol::Array;
@@ -326,36 +327,36 @@
     RefPtr<IDBKey> idbKey;
 
     String type;
-    if (!key->getString("type", &type))
+    if (!key->getString("type", type))
         return nullptr;
 
-    DEPRECATED_DEFINE_STATIC_LOCAL(String, number, (ASCIILiteral("number")));
-    DEPRECATED_DEFINE_STATIC_LOCAL(String, string, (ASCIILiteral("string")));
-    DEPRECATED_DEFINE_STATIC_LOCAL(String, date, (ASCIILiteral("date")));
-    DEPRECATED_DEFINE_STATIC_LOCAL(String, array, (ASCIILiteral("array")));
+    NeverDestroyed<const String> numberType(ASCIILiteral("number"));
+    NeverDestroyed<const String> stringType(ASCIILiteral("string"));
+    NeverDestroyed<const String> dateType(ASCIILiteral("date"));
+    NeverDestroyed<const String> arrayType(ASCIILiteral("array"));
 
-    if (type == number) {
+    if (type == numberType) {
         double number;
-        if (!key->getDouble("number", &number))
+        if (!key->getDouble("number", number))
             return nullptr;
         idbKey = IDBKey::createNumber(number);
-    } else if (type == string) {
+    } else if (type == stringType) {
         String string;
-        if (!key->getString("string", &string))
+        if (!key->getString("string", string))
             return nullptr;
         idbKey = IDBKey::createString(string);
-    } else if (type == date) {
+    } else if (type == dateType) {
         double date;
-        if (!key->getDouble("date", &date))
+        if (!key->getDouble("date", date))
             return nullptr;
         idbKey = IDBKey::createDate(date);
-    } else if (type == array) {
+    } else if (type == arrayType) {
         IDBKey::KeyArray keyArray;
         RefPtr<InspectorArray> array = key->getArray("array");
         for (size_t i = 0; i < array->length(); ++i) {
             RefPtr<InspectorValue> value = array->get(i);
             RefPtr<InspectorObject> object;
-            if (!value->asObject(&object))
+            if (!value->asObject(object))
                 return nullptr;
             keyArray.append(idbKeyFromInspectorObject(object.get()));
         }
@@ -379,12 +380,12 @@
         return nullptr;
 
     bool lowerOpen;
-    if (!keyRange->getBoolean("lowerOpen", &lowerOpen))
+    if (!keyRange->getBoolean("lowerOpen", lowerOpen))
         return nullptr;
     IDBKeyRange::LowerBoundType lowerBoundType = lowerOpen ? IDBKeyRange::LowerBoundOpen : IDBKeyRange::LowerBoundClosed;
 
     bool upperOpen;
-    if (!keyRange->getBoolean("upperOpen", &upperOpen))
+    if (!keyRange->getBoolean("upperOpen", upperOpen))
         return nullptr;
     IDBKeyRange::UpperBoundType upperBoundType = upperOpen ? IDBKeyRange::UpperBoundOpen : IDBKeyRange::UpperBoundClosed;
 

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -739,7 +739,7 @@
     if (m_scriptsToEvaluateOnLoad) {
         for (auto& keyValuePair : *m_scriptsToEvaluateOnLoad) {
             String scriptText;
-            if (keyValuePair.value->asString(&scriptText))
+            if (keyValuePair.value->asString(scriptText))
                 frame->script().executeScript(scriptText);
         }
     }

Modified: trunk/Source/WebCore/inspector/InspectorReplayAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorReplayAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorReplayAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -340,12 +340,12 @@
 void InspectorReplayAgent::replayToPosition(ErrorString* errorString, const RefPtr<InspectorObject>& positionObject, bool fastReplay)
 {
     ReplayPosition position;
-    if (!positionObject->getInteger(ASCIILiteral("segmentOffset"), &position.segmentOffset)) {
+    if (!positionObject->getInteger(ASCIILiteral("segmentOffset"), position.segmentOffset)) {
         *errorString = ASCIILiteral("Couldn't decode ReplayPosition segment offset provided to ReplayAgent.replayToPosition.");
         return;
     }
 
-    if (!positionObject->getInteger(ASCIILiteral("inputOffset"), &position.inputOffset)) {
+    if (!positionObject->getInteger(ASCIILiteral("inputOffset"), position.inputOffset)) {
         *errorString = ASCIILiteral("Couldn't decode ReplayPosition input offset provided to ReplayAgent.replayToPosition.");
         return;
     }

Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -303,7 +303,7 @@
         InspectorObject::const_iterator end = m_extraRequestHeaders->end();
         for (InspectorObject::const_iterator it = m_extraRequestHeaders->begin(); it != end; ++it) {
             String value;
-            if (it->value->asString(&value))
+            if (it->value->asString(value))
                 request.setHTTPHeaderField(it->key, value);
         }
     }

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -572,8 +572,8 @@
                 HashMap<String, RefPtr<Inspector::Protocol::CSS::CSSProperty>>::iterator activeIt = propertyNameToPreviousActiveProperty.find(canonicalPropertyName);
                 if (activeIt != propertyNameToPreviousActiveProperty.end()) {
                     if (propertyEntry.parsedOk) {
-                        bool successPriority = activeIt->value->getString(Inspector::Protocol::CSS::CSSProperty::Priority, &previousPriority);
-                        bool successStatus = activeIt->value->getString(Inspector::Protocol::CSS::CSSProperty::Status, &previousStatus);
+                        bool successPriority = activeIt->value->getString(Inspector::Protocol::CSS::CSSProperty::Priority, previousPriority);
+                        bool successStatus = activeIt->value->getString(Inspector::Protocol::CSS::CSSProperty::Status, previousStatus);
                         if (successStatus && previousStatus != "inactive") {
                             if (propertyEntry.important || !successPriority) // Priority not set == "not important".
                                 shouldInactivate = true;
@@ -584,7 +584,7 @@
                         }
                     } else {
                         bool previousParsedOk;
-                        bool success = activeIt->value->getBoolean(Inspector::Protocol::CSS::CSSProperty::ParsedOk, &previousParsedOk);
+                        bool success = activeIt->value->getBoolean(Inspector::Protocol::CSS::CSSProperty::ParsedOk, previousParsedOk);
                         if (success && !previousParsedOk)
                             shouldInactivate = true;
                     }

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.h (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.h	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.h	2014-09-30 03:30:54 UTC (rev 174094)
@@ -65,11 +65,11 @@
 
     explicit InspectorCSSId(RefPtr<Inspector::InspectorObject> value)
     {
-        if (!value->getString("styleSheetId", &m_styleSheetId))
+        if (!value->getString("styleSheetId", m_styleSheetId))
             return;
-        
+
         RefPtr<Inspector::InspectorValue> ordinalValue = value->get("ordinal");
-        if (!ordinalValue || !ordinalValue->asInteger(&m_ordinal))
+        if (!ordinalValue || !ordinalValue->asInteger(m_ordinal))
             m_styleSheetId = "";
     }
 

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -184,7 +184,7 @@
     if (!title.isEmpty()) {
         for (const TimelineRecordEntry& record : m_pendingConsoleProfileRecords) {
             String recordTitle;
-            record.data->getString(ASCIILiteral("title"), &recordTitle);
+            record.data->getString(ASCIILiteral("title"), recordTitle);
             if (recordTitle == title)
                 return;
         }
@@ -206,7 +206,7 @@
         const TimelineRecordEntry& record = m_pendingConsoleProfileRecords[i];
 
         String recordTitle;
-        record.data->getString(ASCIILiteral("title"), &recordTitle);
+        record.data->getString(ASCIILiteral("title"), recordTitle);
 
         if (title.isEmpty() || recordTitle == title) {
             RefPtr<JSC::Profile> profile = "" title);

Modified: trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp (174093 => 174094)


--- trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp	2014-09-30 02:02:15 UTC (rev 174093)
+++ trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp	2014-09-30 03:30:54 UTC (rev 174094)
@@ -82,14 +82,16 @@
 
 private:
     // WorkerGlobalScopeProxy::PageInspector implementation
-    virtual void dispatchMessageFromWorker(const String& message) override
+    virtual void dispatchMessageFromWorker(const String& messageString) override
     {
-        RefPtr<InspectorValue> value = InspectorValue::parseJSON(message);
-        if (!value)
+        RefPtr<InspectorValue> parsedMessage;
+        if (!InspectorValue::parseJSON(messageString, parsedMessage))
             return;
-        RefPtr<InspectorObject> messageObject = value->asObject();
-        if (!messageObject)
+
+        RefPtr<InspectorObject> messageObject;
+        if (!parsedMessage->asObject(messageObject))
             return;
+
         m_frontendDispatcher->dispatchMessageFromWorker(m_id, messageObject);
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to