[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10500: Implement and test encoding/
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10500: Implement and test encoding/decoding of LONG STRING amf0 type. pp 10 for lnx fails, pp 9 and gnash succeed. |
Date: |
Thu, 01 Jan 2009 00:18:11 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10500
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Thu 2009-01-01 00:18:11 +0100
message:
Implement and test encoding/decoding of LONG STRING amf0 type. pp 10 for lnx
fails, pp 9 and gnash succeed.
modified:
libcore/as_value.cpp
testsuite/misc-ming.all/SharedObjectTest.as
testsuite/misc-ming.all/SharedObjectTest.sol/sol1.sol
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2008-12-30 20:03:02 +0000
+++ b/libcore/as_value.cpp 2008-12-31 23:18:11 +0000
@@ -2187,6 +2187,32 @@
break;
}
+ case amf::Element::LONG_STRING_AMF0:
+ {
+ if (b + 4 > end) {
+ log_error(_("AMF0 read: premature end of input "
+ "reading Long String type"));
+ return false;
+ }
+ boost::uint32_t si = readNetworkLong(b); b += 4;
+ if (b + si > end) {
+ log_error(_("AMF0 read: premature end of input "
+ "reading Long String type"));
+ return false;
+ }
+
+ {
+ std::string str(reinterpret_cast<char *>(b),
si); b += si;
+#ifdef GNASH_DEBUG_AMF_DESERIALIZE
+ log_debug("amf0 read long string: %s", str);
+#endif
+ ret.set_string(str);
+ return true;
+
+ }
+ break;
+ }
+
case amf::Element::STRICT_ARRAY_AMF0:
{
boost::intrusive_ptr<Array_as> array(new
Array_as());
@@ -2517,13 +2543,26 @@
case STRING:
{
- buf.appendByte(amf::Element::STRING_AMF0);
const std::string& str = getStr();
-#ifdef GNASH_DEBUG_AMF_SERIALIZE
- log_debug(_("writeAMF0: serializing string '%s'"), str);
-#endif
- buf.appendNetworkShort(str.size());
- buf.append(str.c_str(), str.size());
+ size_t strlen = str.size();
+ if ( strlen <= 65535 )
+ {
+#ifdef GNASH_DEBUG_AMF_SERIALIZE
+ log_debug(_("writeAMF0: serializing string '%s'"), str);
+#endif
+ buf.appendByte(amf::Element::STRING_AMF0);
+ buf.appendNetworkShort(strlen);
+ buf.append(str.c_str(), strlen);
+ }
+ else
+ {
+#ifdef GNASH_DEBUG_AMF_SERIALIZE
+ log_debug(_("writeAMF0: serializing long string '%s'"), str);
+#endif
+ buf.appendByte(amf::Element::LONG_STRING_AMF0);
+ buf.appendNetworkLong(strlen);
+ buf.append(str.c_str(), strlen);
+ }
return true;
}
=== modified file 'testsuite/misc-ming.all/SharedObjectTest.as'
--- a/testsuite/misc-ming.all/SharedObjectTest.as 2008-12-30 19:08:52
+0000
+++ b/testsuite/misc-ming.all/SharedObjectTest.as 2008-12-31 23:18:11
+0000
@@ -129,6 +129,12 @@
check_equals(so1.data.dat.getSeconds(), 0);
check_equals(so1.data.dat.getMilliseconds(), 0);
+// Test reading LONG STRING
+lstr = 'a';
+for (var i=0; i<16; ++i) lstr = lstr+lstr; // 65536 long
+check_equals(so1.data.lstr, lstr);
+
+
// force writing the sol or the adobe player won't save it
// again. This will also serve as a kind of reference for
// how the sol file was produced in the first place
@@ -178,6 +184,8 @@
so1.data.dat = new Date(70,0); // 1 Jan 1970 00:00:00 localtime
+so1.data.lstr = lstr;
+
so1.flush();
quit = function()
@@ -191,4 +199,4 @@
setInterval(quit, 5000);
stop();
-check_totals(52);
+check_totals(53);
=== modified file 'testsuite/misc-ming.all/SharedObjectTest.sol/sol1.sol'
Binary files a/testsuite/misc-ming.all/SharedObjectTest.sol/sol1.sol
2008-12-30 20:03:02 +0000 and
b/testsuite/misc-ming.all/SharedObjectTest.sol/sol1.sol 2008-12-31 23:18:11
+0000 differ
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10500: Implement and test encoding/decoding of LONG STRING amf0 type. pp 10 for lnx fails, pp 9 and gnash succeed.,
Sandro Santilli <=