Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (225803 => 225804)
--- trunk/Source/_javascript_Core/ChangeLog 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-12-12 21:49:13 UTC (rev 225804)
@@ -1,3 +1,60 @@
+2017-12-04 Brian Burg <[email protected]>
+
+ Web Inspector: modernize InjectedScript a bit
+ https://bugs.webkit.org/show_bug.cgi?id=180367
+
+ Reviewed by Timothy Hatcher.
+
+ Stop using out parameters passed by pointer, use references instead.
+ Stop using OptOutput<T> in favor of std::optional where possible.
+ If there is only one out-parameter and a void return type, then return the value.
+
+ * inspector/InjectedScript.h:
+ * inspector/InjectedScript.cpp:
+ (Inspector::InjectedScript::evaluate):
+ (Inspector::InjectedScript::callFunctionOn):
+ (Inspector::InjectedScript::evaluateOnCallFrame):
+ (Inspector::InjectedScript::getFunctionDetails):
+ (Inspector::InjectedScript::functionDetails):
+ (Inspector::InjectedScript::getPreview):
+ (Inspector::InjectedScript::getProperties):
+ (Inspector::InjectedScript::getDisplayableProperties):
+ (Inspector::InjectedScript::getInternalProperties):
+ (Inspector::InjectedScript::getCollectionEntries):
+ (Inspector::InjectedScript::saveResult):
+ (Inspector::InjectedScript::setExceptionValue):
+ (Inspector::InjectedScript::clearExceptionValue):
+ (Inspector::InjectedScript::inspectObject):
+ (Inspector::InjectedScript::releaseObject):
+
+ * inspector/InjectedScriptBase.h:
+ * inspector/InjectedScriptBase.cpp:
+ (Inspector::InjectedScriptBase::InjectedScriptBase):
+ Declare m_environment with a default initializer.
+
+ (Inspector::InjectedScriptBase::makeCall):
+ (Inspector::InjectedScriptBase::makeEvalCall):
+ Just return the result, no need for an out-parameter.
+ Rearrange some code paths now that we can just return a result.
+ Return a Ref<JSON::Value> since it is either a result value or error value.
+ Use out_ prefixes in a few places to improve readability.
+
+ * inspector/agents/InspectorDebuggerAgent.cpp:
+ (Inspector::InspectorDebuggerAgent::getFunctionDetails):
+ (Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):
+ * inspector/agents/InspectorHeapAgent.cpp:
+ (Inspector::InspectorHeapAgent::getPreview):
+ * inspector/agents/InspectorRuntimeAgent.cpp:
+ (Inspector::InspectorRuntimeAgent::evaluate):
+ (Inspector::InspectorRuntimeAgent::callFunctionOn):
+ (Inspector::InspectorRuntimeAgent::getPreview):
+ (Inspector::InspectorRuntimeAgent::getProperties):
+ (Inspector::InspectorRuntimeAgent::getDisplayableProperties):
+ (Inspector::InspectorRuntimeAgent::getCollectionEntries):
+ (Inspector::InspectorRuntimeAgent::saveResult):
+ Adapt to InjectedScript changes. In some cases we need to bridge OptOutput<T>
+ and std::optional until the former is removed from generated method signatures.
+
2017-12-12 Caio Lima <[email protected]>
[ESNext][BigInt] Implement BigInt literals and JSBigInt
Modified: trunk/Source/_javascript_Core/inspector/InjectedScript.cpp (225803 => 225804)
--- trunk/Source/_javascript_Core/inspector/InjectedScript.cpp 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/inspector/InjectedScript.cpp 2017-12-12 21:49:13 UTC (rev 225804)
@@ -54,7 +54,7 @@
{
}
-void InjectedScript::evaluate(ErrorString& errorString, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InjectedScript::evaluate(ErrorString& errorString, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, bool& wasThrown, std::optional<int>& savedResultIndex)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluate"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(_expression_);
@@ -66,7 +66,7 @@
makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
}
-void InjectedScript::callFunctionOn(ErrorString& errorString, const String& objectId, const String& _expression_, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown)
+void InjectedScript::callFunctionOn(ErrorString& errorString, const String& objectId, const String& _expression_, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, bool& wasThrown)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("callFunctionOn"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
@@ -74,10 +74,12 @@
function.appendArgument(arguments);
function.appendArgument(returnByValue);
function.appendArgument(generatePreview);
- makeEvalCall(errorString, function, result, wasThrown);
+
+ std::optional<int> unused;
+ makeEvalCall(errorString, function, result, wasThrown, unused);
}
-void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, JSC::JSValue callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, JSC::JSValue callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, bool& wasThrown, std::optional<int>& savedResultIndex)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluateOnCallFrame"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(callFrames);
@@ -91,13 +93,12 @@
makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
}
-void InjectedScript::getFunctionDetails(ErrorString& errorString, const String& functionId, RefPtr<Inspector::Protocol::Debugger::FunctionDetails>* result)
+void InjectedScript::getFunctionDetails(ErrorString& errorString, const String& functionId, RefPtr<Inspector::Protocol::Debugger::FunctionDetails>& result)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getFunctionDetails"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(functionId);
- RefPtr<JSON::Value> resultValue;
- makeCall(function, &resultValue);
+ RefPtr<JSON::Value> resultValue = makeCall(function);
if (!resultValue || resultValue->type() != JSON::Value::Type::Object) {
if (!resultValue->asString(errorString))
errorString = ASCIILiteral("Internal error");
@@ -104,16 +105,15 @@
return;
}
- *result = BindingTraits<Inspector::Protocol::Debugger::FunctionDetails>::runtimeCast(WTFMove(resultValue));
+ result = BindingTraits<Inspector::Protocol::Debugger::FunctionDetails>::runtimeCast(WTFMove(resultValue));
}
-void InjectedScript::functionDetails(ErrorString& errorString, JSC::JSValue value, RefPtr<Protocol::Debugger::FunctionDetails>* result)
+void InjectedScript::functionDetails(ErrorString& errorString, JSC::JSValue value, RefPtr<Protocol::Debugger::FunctionDetails>& result)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("functionDetails"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(value);
- RefPtr<JSON::Value> resultValue;
- makeCall(function, &resultValue);
+ RefPtr<JSON::Value> resultValue = makeCall(function);
if (!resultValue || resultValue->type() != JSON::Value::Type::Object) {
if (!resultValue->asString(errorString))
errorString = ASCIILiteral("Internal error");
@@ -120,16 +120,15 @@
return;
}
- *result = BindingTraits<Inspector::Protocol::Debugger::FunctionDetails>::runtimeCast(WTFMove(resultValue));
+ result = BindingTraits<Inspector::Protocol::Debugger::FunctionDetails>::runtimeCast(WTFMove(resultValue));
}
-void InjectedScript::getPreview(ErrorString& errorString, const String& objectId, RefPtr<Protocol::Runtime::ObjectPreview>* result)
+void InjectedScript::getPreview(ErrorString& errorString, const String& objectId, RefPtr<Protocol::Runtime::ObjectPreview>& result)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getPreview"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
- RefPtr<JSON::Value> resultValue;
- makeCall(function, &resultValue);
+ RefPtr<JSON::Value> resultValue = makeCall(function);
if (!resultValue || resultValue->type() != JSON::Value::Type::Object) {
if (!resultValue->asString(errorString))
errorString = ASCIILiteral("Internal error");
@@ -136,10 +135,10 @@
return;
}
- *result = BindingTraits<Inspector::Protocol::Runtime::ObjectPreview>::runtimeCast(WTFMove(resultValue));
+ result = BindingTraits<Inspector::Protocol::Runtime::ObjectPreview>::runtimeCast(WTFMove(resultValue));
}
-void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, bool generatePreview, RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
+void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, bool generatePreview, RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>& properties)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getProperties"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
@@ -146,40 +145,37 @@
function.appendArgument(ownProperties);
function.appendArgument(generatePreview);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ RefPtr<JSON::Value> result = makeCall(function);
if (!result || result->type() != JSON::Value::Type::Array) {
errorString = ASCIILiteral("Internal error");
return;
}
- *properties = BindingTraits<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTFMove(result));
+ properties = BindingTraits<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTFMove(result));
}
-void InjectedScript::getDisplayableProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
+void InjectedScript::getDisplayableProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>& properties)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getDisplayableProperties"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
function.appendArgument(generatePreview);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ RefPtr<JSON::Value> result = makeCall(function);
if (!result || result->type() != JSON::Value::Type::Array) {
errorString = ASCIILiteral("Internal error");
return;
}
- *properties = BindingTraits<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTFMove(result));
+ properties = BindingTraits<JSON::ArrayOf<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTFMove(result));
}
-void InjectedScript::getInternalProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>* properties)
+void InjectedScript::getInternalProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& properties)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getInternalProperties"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
function.appendArgument(generatePreview);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ RefPtr<JSON::Value> result = makeCall(function);
if (!result || result->type() != JSON::Value::Type::Array) {
errorString = ASCIILiteral("Internal error");
return;
@@ -186,10 +182,10 @@
}
auto array = BindingTraits<JSON::ArrayOf<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>::runtimeCast(WTFMove(result));
- *properties = array->length() > 0 ? array : nullptr;
+ properties = array->length() > 0 ? array : nullptr;
}
-void InjectedScript::getCollectionEntries(ErrorString& errorString, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>* entries)
+void InjectedScript::getCollectionEntries(ErrorString& errorString, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>& entries)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getCollectionEntries"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
@@ -197,31 +193,29 @@
function.appendArgument(startIndex);
function.appendArgument(numberToFetch);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ RefPtr<JSON::Value> result = makeCall(function);
if (!result || result->type() != JSON::Value::Type::Array) {
errorString = ASCIILiteral("Internal error");
return;
}
- *entries = BindingTraits<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>::runtimeCast(WTFMove(result));
+ entries = BindingTraits<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>::runtimeCast(WTFMove(result));
}
-void InjectedScript::saveResult(ErrorString& errorString, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InjectedScript::saveResult(ErrorString& errorString, const String& callArgumentJSON, std::optional<int>& savedResultIndex)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("saveResult"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(callArgumentJSON);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ RefPtr<JSON::Value> result = makeCall(function);
if (!result || result->type() != JSON::Value::Type::Integer) {
errorString = ASCIILiteral("Internal error");
return;
}
- int savedResultIndexInt = 0;
- if (result->asInteger(savedResultIndexInt) && savedResultIndexInt > 0)
- *savedResultIndex = savedResultIndexInt;
+ int resultIndex = 0;
+ if (result->asInteger(resultIndex) && resultIndex > 0)
+ savedResultIndex = resultIndex;
}
Ref<JSON::ArrayOf<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(JSC::JSValue callFrames) const
@@ -332,8 +326,7 @@
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("setExceptionValue"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(value);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ makeCall(function);
}
void InjectedScript::clearExceptionValue()
@@ -340,8 +333,7 @@
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("clearExceptionValue"), inspectorEnvironment()->functionCallHandler());
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ makeCall(function);
}
JSC::JSValue InjectedScript::findObjectById(const String& objectId) const
@@ -362,8 +354,7 @@
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("inspectObject"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(value);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ makeCall(function);
}
void InjectedScript::releaseObject(const String& objectId)
@@ -370,8 +361,7 @@
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("releaseObject"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ makeCall(function);
}
void InjectedScript::releaseObjectGroup(const String& objectGroup)
Modified: trunk/Source/_javascript_Core/inspector/InjectedScript.h (225803 => 225804)
--- trunk/Source/_javascript_Core/inspector/InjectedScript.h 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/inspector/InjectedScript.h 2017-12-12 21:49:13 UTC (rev 225804)
@@ -50,17 +50,17 @@
InjectedScript(Deprecated::ScriptObject, InspectorEnvironment*);
virtual ~InjectedScript();
- void evaluate(ErrorString&, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex);
- void evaluateOnCallFrame(ErrorString&, JSC::JSValue callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex);
- void callFunctionOn(ErrorString&, const String& objectId, const String& _expression_, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown);
- void getFunctionDetails(ErrorString&, const String& functionId, RefPtr<Protocol::Debugger::FunctionDetails>* result);
- void functionDetails(ErrorString&, JSC::JSValue, RefPtr<Protocol::Debugger::FunctionDetails>* result);
- void getPreview(ErrorString&, const String& objectId, RefPtr<Protocol::Runtime::ObjectPreview>* result);
- void getProperties(ErrorString&, const String& objectId, bool ownProperties, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>* result);
- void getDisplayableProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>* result);
- void getInternalProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::InternalPropertyDescriptor>>* result);
- void getCollectionEntries(ErrorString&, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>* entries);
- void saveResult(ErrorString&, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex);
+ void evaluate(ErrorString&, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>& result, bool& wasThrown, std::optional<int>& savedResultIndex);
+ void evaluateOnCallFrame(ErrorString&, JSC::JSValue callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>& result, bool& wasThrown, std::optional<int>& savedResultIndex);
+ void callFunctionOn(ErrorString&, const String& objectId, const String& _expression_, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>& result, bool& wasThrown);
+ void getFunctionDetails(ErrorString&, const String& functionId, RefPtr<Protocol::Debugger::FunctionDetails>& result);
+ void functionDetails(ErrorString&, JSC::JSValue, RefPtr<Protocol::Debugger::FunctionDetails>& result);
+ void getPreview(ErrorString&, const String& objectId, RefPtr<Protocol::Runtime::ObjectPreview>& result);
+ void getProperties(ErrorString&, const String& objectId, bool ownProperties, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>& result);
+ void getDisplayableProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>& result);
+ void getInternalProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::InternalPropertyDescriptor>>& result);
+ void getCollectionEntries(ErrorString&, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>& entries);
+ void saveResult(ErrorString&, const String& callArgumentJSON, std::optional<int>& savedResultIndex);
Ref<JSON::ArrayOf<Protocol::Debugger::CallFrame>> wrapCallFrames(JSC::JSValue) const;
RefPtr<Protocol::Runtime::RemoteObject> wrapObject(JSC::JSValue, const String& groupName, bool generatePreview = false) const;
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp (225803 => 225804)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp 2017-12-12 21:49:13 UTC (rev 225804)
@@ -43,7 +43,6 @@
InjectedScriptBase::InjectedScriptBase(const String& name)
: m_name(name)
- , m_environment(nullptr)
{
}
@@ -75,29 +74,28 @@
return function.call(hadException);
}
-void InjectedScriptBase::makeCall(Deprecated::ScriptFunctionCall& function, RefPtr<JSON::Value>* result)
+Ref<JSON::Value> InjectedScriptBase::makeCall(Deprecated::ScriptFunctionCall& function)
{
- if (hasNoValue() || !hasAccessToInspectedScriptState()) {
- *result = JSON::Value::null();
- return;
- }
+ if (hasNoValue() || !hasAccessToInspectedScriptState())
+ return JSON::Value::null();
bool hadException = false;
- auto resultValue = callFunctionWithEvalEnabled(function, hadException);
+ auto resultJSValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
- if (!hadException) {
- *result = toInspectorValue(*m_injectedScriptObject.scriptState(), resultValue);
- if (!*result)
- *result = JSON::Value::create(String::format("Object has too long reference chain (must not be longer than %d)", JSON::Value::maxDepth));
- } else
- *result = JSON::Value::create("Exception while making a call.");
+ if (hadException)
+ return JSON::Value::create("Exception while making a call.");
+
+ RefPtr<JSON::Value> resultJSONValue = toInspectorValue(*m_injectedScriptObject.scriptState(), resultJSValue);
+ if (!resultJSONValue)
+ return JSON::Value::create(String::format("Object has too long reference chain (must not be longer than %d)", JSON::Value::maxDepth));
+
+ return resultJSONValue.releaseNonNull();
}
-void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr<Protocol::Runtime::RemoteObject>* objectResult, Protocol::OptOutput<bool>* wasThrown, Protocol::OptOutput<int>* savedResultIndex)
+void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr<Protocol::Runtime::RemoteObject>& out_resultObject, bool& out_wasThrown, std::optional<int>& out_savedResultIndex)
{
- RefPtr<JSON::Value> result;
- makeCall(function, &result);
+ RefPtr<JSON::Value> result = makeCall(function);
if (!result) {
errorString = ASCIILiteral("Internal error: result value is empty");
return;
@@ -121,20 +119,18 @@
return;
}
- bool wasThrownValue = false;
- if (!resultTuple->getBoolean(ASCIILiteral("wasThrown"), wasThrownValue)) {
+ bool wasThrown = false;
+ if (!resultTuple->getBoolean(ASCIILiteral("wasThrown"), wasThrown)) {
errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag");
return;
}
- *objectResult = BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
- *wasThrown = wasThrownValue;
+ out_resultObject = BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
+ out_wasThrown = wasThrown;
- if (savedResultIndex) {
- int savedIndex = 0;
- if (resultTuple->getInteger(ASCIILiteral("savedResultIndex"), savedIndex))
- *savedResultIndex = savedIndex;
- }
+ int savedResultIndex;
+ if (resultTuple->getInteger(ASCIILiteral("savedResultIndex"), savedResultIndex))
+ out_savedResultIndex = savedResultIndex;
}
} // namespace Inspector
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptBase.h (225803 => 225804)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptBase.h 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptBase.h 2017-12-12 21:49:13 UTC (rev 225804)
@@ -63,13 +63,13 @@
const Deprecated::ScriptObject& injectedScriptObject() const;
JSC::JSValue callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall&, bool& hadException) const;
- void makeCall(Deprecated::ScriptFunctionCall&, RefPtr<JSON::Value>* result);
- void makeEvalCall(ErrorString&, Deprecated::ScriptFunctionCall&, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown, Protocol::OptOutput<int>* savedResult = nullptr);
+ Ref<JSON::Value> makeCall(Deprecated::ScriptFunctionCall&);
+ void makeEvalCall(ErrorString&, Deprecated::ScriptFunctionCall&, RefPtr<Protocol::Runtime::RemoteObject>& resultObject, bool& wasThrown, std::optional<int>& savedResultIndex);
private:
String m_name;
Deprecated::ScriptObject m_injectedScriptObject;
- InspectorEnvironment* m_environment;
+ InspectorEnvironment* m_environment { nullptr };
};
} // namespace Inspector
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (225803 => 225804)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2017-12-12 21:49:13 UTC (rev 225804)
@@ -692,7 +692,7 @@
return;
}
- injectedScript.getFunctionDetails(errorString, functionId, &details);
+ injectedScript.getFunctionDetails(errorString, functionId, details);
}
void InspectorDebuggerAgent::schedulePauseOnNextStatement(DebuggerFrontendDispatcher::Reason breakReason, RefPtr<JSON::Object>&& data)
@@ -827,7 +827,7 @@
m_pauseOnAssertionFailures = enabled;
}
-void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* out_wasThrown, Inspector::Protocol::OptOutput<int>* out_savedResultIndex)
{
if (m_currentCallStack.hasNoValue()) {
errorString = ASCIILiteral("Not paused");
@@ -847,8 +847,16 @@
muteConsole();
}
- injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, _expression_, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePreview ? *generatePreview : false, saveResult ? *saveResult : false, &result, wasThrown, savedResultIndex);
+ // FIXME: remove this bridging code when generated protocol commands no longer use OptOutput<T>.
+ bool wasThrown;
+ std::optional<int> savedResultIndex;
+ injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, _expression_, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePreview ? *generatePreview : false, saveResult ? *saveResult : false, result, wasThrown, savedResultIndex);
+
+ *out_wasThrown = wasThrown;
+ if (savedResultIndex.has_value())
+ *out_savedResultIndex = savedResultIndex.value();
+
if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) {
unmuteConsole();
if (m_scriptDebugServer.pauseOnExceptionsState() != previousPauseOnExceptionsState)
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.cpp (225803 => 225804)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.cpp 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.cpp 2017-12-12 21:49:13 UTC (rev 225804)
@@ -207,7 +207,7 @@
// Function preview.
if (cell->inherits(vm, JSFunction::info())) {
- injectedScript.functionDetails(errorString, cell, &functionDetails);
+ injectedScript.functionDetails(errorString, cell, functionDetails);
return;
}
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (225803 => 225804)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2017-12-12 21:36:48 UTC (rev 225803)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2017-12-12 21:49:13 UTC (rev 225804)
@@ -112,7 +112,7 @@
}
}
-void InspectorRuntimeAgent::evaluate(ErrorString& errorString, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InspectorRuntimeAgent::evaluate(ErrorString& errorString, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* out_wasThrown, Inspector::Protocol::OptOutput<int>* out_savedResultIndex)
{
InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
if (injectedScript.hasNoValue())
@@ -124,7 +124,15 @@
if (asBool(doNotPauseOnExceptionsAndMuteConsole))
muteConsole();
- injectedScript.evaluate(errorString, _expression_, objectGroup ? *objectGroup : String(), asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), asBool(saveResult), &result, wasThrown, savedResultIndex);
+ // FIXME: remove this bridging code when generated protocol commands no longer use OptOutput<T>.
+ // <https://www.webkit.org/b/180607>
+ bool wasThrown;
+ std::optional<int> savedResultIndex;
+ injectedScript.evaluate(errorString, _expression_, objectGroup ? *objectGroup : String(), asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), asBool(saveResult), result, wasThrown, savedResultIndex);
+
+ *out_wasThrown = wasThrown;
+ if (savedResultIndex.has_value())
+ *out_savedResultIndex = savedResultIndex.value();
if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
unmuteConsole();
@@ -132,7 +140,7 @@
}
}
-void InspectorRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& objectId, const String& _expression_, const JSON::Array* optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown)
+void InspectorRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& objectId, const String& _expression_, const JSON::Array* optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* out_wasThrown)
{
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
@@ -150,8 +158,12 @@
if (asBool(doNotPauseOnExceptionsAndMuteConsole))
muteConsole();
- injectedScript.callFunctionOn(errorString, objectId, _expression_, arguments, asBool(returnByValue), asBool(generatePreview), &result, wasThrown);
+ bool wasThrown;
+ injectedScript.callFunctionOn(errorString, objectId, _expression_, arguments, asBool(returnByValue), asBool(generatePreview), result, wasThrown);
+
+ *out_wasThrown = wasThrown;
+
if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
unmuteConsole();
setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
@@ -169,7 +181,7 @@
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
muteConsole();
- injectedScript.getPreview(errorString, objectId, &preview);
+ injectedScript.getPreview(errorString, objectId, preview);
unmuteConsole();
setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
@@ -186,8 +198,8 @@
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
muteConsole();
- injectedScript.getProperties(errorString, objectId, asBool(ownProperties), asBool(generatePreview), &result);
- injectedScript.getInternalProperties(errorString, objectId, asBool(generatePreview), &internalProperties);
+ injectedScript.getProperties(errorString, objectId, asBool(ownProperties), asBool(generatePreview), result);
+ injectedScript.getInternalProperties(errorString, objectId, asBool(generatePreview), internalProperties);
unmuteConsole();
setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
@@ -204,8 +216,8 @@
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
muteConsole();
- injectedScript.getDisplayableProperties(errorString, objectId, asBool(generatePreview), &result);
- injectedScript.getInternalProperties(errorString, objectId, asBool(generatePreview), &internalProperties);
+ injectedScript.getDisplayableProperties(errorString, objectId, asBool(generatePreview), result);
+ injectedScript.getInternalProperties(errorString, objectId, asBool(generatePreview), internalProperties);
unmuteConsole();
setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
@@ -222,10 +234,10 @@
int start = startIndex && *startIndex >= 0 ? *startIndex : 0;
int fetch = numberToFetch && *numberToFetch >= 0 ? *numberToFetch : 0;
- injectedScript.getCollectionEntries(errorString, objectId, objectGroup ? *objectGroup : String(), start, fetch, &entries);
+ injectedScript.getCollectionEntries(errorString, objectId, objectGroup ? *objectGroup : String(), start, fetch, entries);
}
-void InspectorRuntimeAgent::saveResult(ErrorString& errorString, const JSON::Object& callArgument, const int* executionContextId, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InspectorRuntimeAgent::saveResult(ErrorString& errorString, const JSON::Object& callArgument, const int* executionContextId, Inspector::Protocol::OptOutput<int>* out_savedResultIndex)
{
InjectedScript injectedScript;
@@ -241,8 +253,15 @@
if (injectedScript.hasNoValue())
return;
}
+
+ // FIXME: remove this bridging code when generated protocol commands no longer use OptOutput<T>.
+ // <https://www.webkit.org/b/180607>
+ std::optional<int> savedResultIndex;
injectedScript.saveResult(errorString, callArgument.toJSONString(), savedResultIndex);
+
+ if (savedResultIndex.has_value())
+ *out_savedResultIndex = savedResultIndex.value();
}
void InspectorRuntimeAgent::releaseObject(ErrorString&, const String& objectId)