Commit 5bf63c34 authored by cwzwarich@webkit.org's avatar cwzwarich@webkit.org

Reviewed by Oliver Hunt.

WebCore fails to build with Clang on ARM
https://bugs.webkit.org/show_bug.cgi?id=56257

Add an explicit instantiation of writeLittleEndian for uint8_t and move it to
namespace scope, since explicit specializations are not allowed at class scope.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::writeLittleEndian):


git-svn-id: svn://svn.chromium.org/blink/trunk@80949 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent caf9248c
2011-03-12 Cameron Zwarich <zwarich@apple.com>
Reviewed by Oliver Hunt.
WebCore fails to build with Clang on ARM
https://bugs.webkit.org/show_bug.cgi?id=56257
Add an explicit instantiation of writeLittleEndian for uint8_t and move it to
namespace scope, since explicit specializations are not allowed at class scope.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::writeLittleEndian):
2011-03-11 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
......
......@@ -206,6 +206,46 @@ protected:
MarkedArgumentBuffer m_gcBuffer;
};
#if ASSUME_LITTLE_ENDIAN
template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
{
buffer.append(reinterpret_cast<uint8_t*>(&value), sizeof(value));
}
#else
template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
{
for (unsigned i = 0; i < sizeof(T); i++) {
buffer.append(value & 0xFF);
value >>= 8;
}
}
#endif
template <> static void writeLittleEndian<uint8_t>(Vector<uint8_t>& buffer, uint8_t value)
{
buffer.append(value);
}
template <typename T> static bool writeLittleEndian(Vector<uint8_t>& buffer, const T* values, uint32_t length)
{
if (length > numeric_limits<uint32_t>::max() / sizeof(T))
return false;
#if ASSUME_LITTLE_ENDIAN
buffer.append(reinterpret_cast<const uint8_t*>(values), length * sizeof(T));
#else
for (unsigned i = 0; i < length; i++) {
T value = values[i];
for (unsigned j = 0; j < sizeof(T); j++) {
buffer.append(static_cast<uint8_t>(value & 0xFF));
value >>= 8;
}
}
#endif
return true;
}
class CloneSerializer : CloneBase {
public:
static bool serialize(ExecState* exec, JSValue value, Vector<uint8_t>& out)
......@@ -444,43 +484,6 @@ private:
writeLittleEndian(m_buffer, c);
}
#if ASSUME_LITTLE_ENDIAN
template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
{
if (sizeof(T) == 1)
buffer.append(value);
else
buffer.append(reinterpret_cast<uint8_t*>(&value), sizeof(value));
}
#else
template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
{
for (unsigned i = 0; i < sizeof(T); i++) {
buffer.append(value & 0xFF);
value >>= 8;
}
}
#endif
template <typename T> static bool writeLittleEndian(Vector<uint8_t>& buffer, const T* values, uint32_t length)
{
if (length > numeric_limits<uint32_t>::max() / sizeof(T))
return false;
#if ASSUME_LITTLE_ENDIAN
buffer.append(reinterpret_cast<const uint8_t*>(values), length * sizeof(T));
#else
for (unsigned i = 0; i < length; i++) {
T value = values[i];
for (unsigned j = 0; j < sizeof(T); j++) {
buffer.append(static_cast<uint8_t>(value & 0xFF));
value >>= 8;
}
}
#endif
return true;
}
void write(uint32_t i)
{
writeLittleEndian(m_buffer, i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment