[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [SCM] Gnash branch, master, updated. 60de066b98de7439e6c1
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] [SCM] Gnash branch, master, updated. 60de066b98de7439e6c1f9549daf1d13708f3d0c |
Date: |
Thu, 09 Dec 2010 13:57:27 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".
The branch, master has been updated
via 60de066b98de7439e6c1f9549daf1d13708f3d0c (commit)
from e69f03edd80905f52755b6db58c69e9c40133971 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=60de066b98de7439e6c1f9549daf1d13708f3d0c
commit 60de066b98de7439e6c1f9549daf1d13708f3d0c
Author: Benjamin Wolsey <address@hidden>
Date: Thu Dec 9 14:47:30 2010 +0100
Hide swapBytes, use writePlainNumber().
diff --git a/libbase/AMF.cpp b/libbase/AMF.cpp
index 5e73ecd..9d4b87f 100644
--- a/libbase/AMF.cpp
+++ b/libbase/AMF.cpp
@@ -34,9 +34,18 @@
// #define GNASH_DEBUG_AMF_SERIALIZE 1
namespace gnash {
-
namespace amf {
+namespace {
+ /// Swap bytes in raw data.
+ //
+ /// This only swaps bytes if the host byte order is little endian.
+ ///
+ /// @param word The address of the data to byte swap.
+ /// @param size The number of bytes in the data.
+ void swapBytes(void* word, size_t size);
+}
+
bool
readBoolean(const boost::uint8_t*& pos, const boost::uint8_t* _end)
{
@@ -142,6 +151,13 @@ writePlainString(SimpleBuffer& buf, const std::string&
str, Type t)
}
void
+writePlainNumber(SimpleBuffer& buf, double d)
+{
+ swapBytes(&d, 8);
+ buf.append(&d, 8);
+}
+
+void
write(SimpleBuffer& buf, const std::string& str)
{
Type t = str.size() < 65536 ? STRING_AMF0 : LONG_STRING_AMF0;
@@ -153,8 +169,7 @@ void
write(SimpleBuffer& buf, double d)
{
buf.appendByte(NUMBER_AMF0);
- swapBytes(&d, 8);
- buf.append(&d, 8);
+ writePlainNumber(buf, d);
}
void
@@ -164,6 +179,8 @@ write(SimpleBuffer& buf, bool b)
buf.appendByte(b ? 1 : 0);
}
+namespace {
+
void
swapBytes(void* word, size_t size)
{
@@ -189,6 +206,7 @@ swapBytes(void* word, size_t size)
std::reverse(x, x + size);
}
+} // unnamed namespace
} // namespace amf
} // namespace gnash
diff --git a/libbase/AMF.h b/libbase/AMF.h
index 9e46cc7..8686d2a 100644
--- a/libbase/AMF.h
+++ b/libbase/AMF.h
@@ -177,6 +177,11 @@ DSOEXPORT void write(SimpleBuffer& buf, bool b);
DSOEXPORT void writePlainString(SimpleBuffer& buf, const std::string& str,
Type t);
+/// Write a number to an AMF buffer.
+//
+/// This function writes the double value without a type byte.
+DSOEXPORT void writePlainNumber(SimpleBuffer& buf, double d);
+
/// Encode a string-value pair.
//
/// This is used for object properties; the string is always encoded with
@@ -189,16 +194,6 @@ writeProperty(SimpleBuffer& buf, const std::string& name,
const T& t)
write(buf, t);
}
-/// Swap bytes in raw data.
-//
-/// This only swaps bytes if the host byte order is little endian.
-///
-/// @param word The address of the data to byte swap.
-/// @param size The number of bytes in the data.
-/// @return A pointer to the raw data.
-DSOEXPORT void swapBytes(void* word, size_t size);
-
-
} // namespace amf
} // namespace gnash
diff --git a/libcore/AMFConverter.cpp b/libcore/AMFConverter.cpp
index 9a3f724..704d37f 100644
--- a/libcore/AMFConverter.cpp
+++ b/libcore/AMFConverter.cpp
@@ -156,10 +156,7 @@ Writer::writeObject(as_object* obj)
"with index %d and value %g"), idx, d);
#endif
_buf.appendByte(DATE_AMF0);
-
- // This actually only swaps on little-endian machines
- swapBytes(&d, 8);
- _buf.append(&d, 8);
+ writePlainNumber(_buf, d);
// This should be timezone
boost::uint16_t tz = 0;
@@ -479,7 +476,7 @@ Reader::readArray()
// followed by an OBJECT_END_AMF0 (0x09) byte
if (!strlen) {
// expect an object terminator here
- if (*_pos != amf::OBJECT_END_AMF0) {
+ if (*_pos != OBJECT_END_AMF0) {
log_error("MALFORMED AMF: empty member name not "
"followed by OBJECT_END_AMF0 byte");
}
@@ -527,7 +524,7 @@ Reader::readObject()
std::string keyString;
for (;;) {
- if (!operator()(tmp, amf::STRING_AMF0)) {
+ if (!operator()(tmp, STRING_AMF0)) {
throw AMFException("Could not read object property name");
}
keyString = tmp.to_string();
@@ -576,7 +573,7 @@ Reader::readReference()
as_value
Reader::readDate()
{
- const double d = amf::readNumber(_pos, _end);
+ const double d = readNumber(_pos, _end);
#ifdef GNASH_DEBUG_AMF_DESERIALIZE
log_debug("amf0 read date: %e", dub);
-----------------------------------------------------------------------
Summary of changes:
libbase/AMF.cpp | 24 +++++++++++++++++++++---
libbase/AMF.h | 15 +++++----------
libcore/AMFConverter.cpp | 11 ++++-------
3 files changed, 30 insertions(+), 20 deletions(-)
hooks/post-receive
--
Gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] [SCM] Gnash branch, master, updated. 60de066b98de7439e6c1f9549daf1d13708f3d0c,
Benjamin Wolsey <=