summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bindings/ScriptValue.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
commita4e969f4965059196ca948db781e52f7cfebf19e (patch)
tree6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/bindings/ScriptValue.cpp
parent41386e9cb918eed93b3f13648cbef387e371e451 (diff)
downloadWebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/bindings/ScriptValue.cpp')
-rw-r--r--Source/JavaScriptCore/bindings/ScriptValue.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/Source/JavaScriptCore/bindings/ScriptValue.cpp b/Source/JavaScriptCore/bindings/ScriptValue.cpp
index c72ab4634..3e560dcc3 100644
--- a/Source/JavaScriptCore/bindings/ScriptValue.cpp
+++ b/Source/JavaScriptCore/bindings/ScriptValue.cpp
@@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -33,6 +33,7 @@
#include "APICast.h"
#include "InspectorValues.h"
#include "JSLock.h"
+#include "StructureInlines.h"
using namespace JSC;
using namespace Inspector;
@@ -96,8 +97,7 @@ bool ScriptValue::isFunction() const
return getCallData(m_value.get(), callData) != CallTypeNone;
}
-#if ENABLE(INSPECTOR)
-static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSValue value, int maxDepth)
+static RefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSValue value, int maxDepth)
{
if (!value) {
ASSERT_NOT_REACHED();
@@ -113,16 +113,16 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV
return InspectorValue::null();
if (value.isBoolean())
return InspectorBasicValue::create(value.asBoolean());
- if (value.isNumber())
+ if (value.isNumber() && value.isDouble())
return InspectorBasicValue::create(value.asNumber());
- if (value.isString()) {
- String s = value.getString(scriptState);
- return InspectorString::create(String(s.deprecatedCharacters(), s.length()));
- }
+ if (value.isNumber() && value.isMachineInt())
+ return InspectorBasicValue::create(static_cast<int>(value.asMachineInt()));
+ if (value.isString())
+ return InspectorString::create(value.getString(scriptState));
if (value.isObject()) {
if (isJSArray(value)) {
- RefPtr<InspectorArray> inspectorArray = InspectorArray::create();
+ Ref<InspectorArray> inspectorArray = InspectorArray::create();
JSArray* array = asArray(value);
unsigned length = array->length();
for (unsigned i = 0; i < length; i++) {
@@ -130,34 +130,33 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV
RefPtr<InspectorValue> elementValue = jsToInspectorValue(scriptState, element, maxDepth);
if (!elementValue)
return nullptr;
- inspectorArray->pushValue(elementValue);
+ inspectorArray->pushValue(WTFMove(elementValue));
}
- return inspectorArray;
+ return WTFMove(inspectorArray);
}
- RefPtr<InspectorObject> inspectorObject = InspectorObject::create();
+ Ref<InspectorObject> inspectorObject = InspectorObject::create();
JSObject* object = value.getObject();
- PropertyNameArray propertyNames(scriptState);
- object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, ExcludeDontEnumProperties);
+ PropertyNameArray propertyNames(scriptState, PropertyNameMode::Strings);
+ object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, EnumerationMode());
for (size_t i = 0; i < propertyNames.size(); i++) {
- const Identifier& name = propertyNames[i];
+ const Identifier& name = propertyNames[i];
JSValue propertyValue = object->get(scriptState, name);
RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth);
if (!inspectorValue)
return nullptr;
- inspectorObject->setValue(String(name.deprecatedCharacters(), name.length()), inspectorValue);
+ inspectorObject->setValue(name.string(), WTFMove(inspectorValue));
}
- return inspectorObject;
+ return WTFMove(inspectorObject);
}
ASSERT_NOT_REACHED();
return nullptr;
}
-PassRefPtr<InspectorValue> ScriptValue::toInspectorValue(ExecState* scriptState) const
+RefPtr<InspectorValue> ScriptValue::toInspectorValue(ExecState* scriptState) const
{
JSLockHolder holder(scriptState);
return jsToInspectorValue(scriptState, m_value.get(), InspectorValue::maxDepth);
}
-#endif // ENABLE(INSPECTOR)
} // namespace Deprecated