[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/avm2 r9683: Have SWFStream::read_d64() use
From: |
Tom Stellard |
Subject: |
[Gnash-commit] /srv/bzr/gnash/avm2 r9683: Have SWFStream::read_d64() use the convert_double_wacky function to correctly return a double. |
Date: |
Fri, 14 Nov 2008 13:32:10 +0800 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9683
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Fri 2008-11-14 13:32:10 +0800
message:
Have SWFStream::read_d64() use the convert_double_wacky function to correctly
return a double.
modified:
libcore/SWFStream.cpp
libcore/SWFStream.h
libcore/parser/abc_block.cpp
libcore/parser/action_buffer.cpp
libcore/parser/action_buffer.h
libcore/vm/Machine.cpp
=== modified file 'libcore/SWFStream.cpp'
--- a/libcore/SWFStream.cpp 2008-10-20 17:06:14 +0000
+++ b/libcore/SWFStream.cpp 2008-11-14 05:32:10 +0000
@@ -23,6 +23,7 @@
#include "IOChannel.h"
#include "swf.h"
#include "Property.h"
+#include "action_buffer.h"
#include <cstring>
#include <climits>
@@ -300,7 +301,7 @@
}
// Read a 64-bit double value
-long double SWFStream::read_d64()
+double SWFStream::read_d64()
{
#ifdef USE_TU_FILE_BYTESWAPPING
align();
@@ -308,26 +309,25 @@
#else
using boost::uint32_t;
- const unsigned short dataLength = 8;
- unsigned char buf[dataLength];
+// const unsigned short dataLength = 8;
+// unsigned char buf[dataLength];
// Should align:
- if (read(reinterpret_cast<char*>(buf), dataLength) < dataLength)
- {
- throw ParserException(_("Unexpected end of stream while reading"));
- }
-
- uint64_t low = buf[0];
- low |= buf[1] << 8;
- low |= buf[2] << 16;
- low |= buf[3] << 24;
-
- uint64_t hi = buf[4];
- hi |= buf[5] << 8;
- hi |= buf[6] << 16;
- hi |= buf[7] << 24;
-
- return static_cast<long double> ( low | (hi<<32) );
+// if (read(reinterpret_cast<boost::uint8_t*>(buf), dataLength) <
dataLength)
+// {
+// throw ParserException(_("Unexpected end of stream while reading"));
+// }
+
+ //Swap words so we can pass m_buffer to convert_double_wacky.
+ boost::uint8_t m_buffer[8];
+ for(int i=0;i<4;i++){
+ m_buffer[i+4] = read_u8();
+ }
+ for(int j=0;j<4;j++){
+ m_buffer[j] = read_u8();
+ }
+
+ return convert_double_wacky(&m_buffer);
#endif
}
=== modified file 'libcore/SWFStream.h'
--- a/libcore/SWFStream.h 2008-10-02 16:12:12 +0000
+++ b/libcore/SWFStream.h 2008-11-14 05:32:10 +0000
@@ -126,7 +126,7 @@
//
/// aligned read
///
- long double read_d64();
+ double read_d64();
/// Consume all bits of current byte
//
=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp 2008-10-27 03:18:37 +0000
+++ b/libcore/parser/abc_block.cpp 2008-11-14 05:32:10 +0000
@@ -27,6 +27,7 @@
#include "asClass.h"
#include "namedStrings.h"
#include "CodeStream.h"
+#include "action_buffer.h"
//#define ERR(x) IF_VERBOSE_MALFORMED_SWF(log_swferror x;);
#define ERR(x) printf x; fflush(stdout);
@@ -435,6 +436,7 @@
for (unsigned int i = 1; i < count; ++i)
{
mDoublePool[i] = mS->read_d64();
+ LOG_DEBUG_ABC("Double %u=%lf",i,mDoublePool[i]);
}
return true;
}
=== modified file 'libcore/parser/action_buffer.cpp'
--- a/libcore/parser/action_buffer.cpp 2008-09-29 13:34:41 +0000
+++ b/libcore/parser/action_buffer.cpp 2008-11-14 05:32:10 +0000
@@ -42,7 +42,6 @@
// Forward declarations
static float convert_float_little(const void *p);
-static double convert_double_wacky(const void *p);
action_buffer::action_buffer(const movie_definition& md)
:
@@ -531,7 +530,7 @@
// Read a 64-bit double from memory, stored in word-swapped little-endian
// format and return it as a host-endian double.
// "Wacky format" is 45670123.
-static double
+double
convert_double_wacky(const void *p)
{
const boost::uint8_t *cp = (const boost::uint8_t *)p; // Handy uchar
version
=== modified file 'libcore/parser/action_buffer.h'
--- a/libcore/parser/action_buffer.h 2008-09-29 14:49:51 +0000
+++ b/libcore/parser/action_buffer.h 2008-11-14 05:32:10 +0000
@@ -39,6 +39,8 @@
class ActionExec;
+double convert_double_wacky(const void *p);
+
/// A code segment.
//
/// This currently holds the actions in a memory
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2008-11-13 16:16:04 +0000
+++ b/libcore/vm/Machine.cpp 2008-11-14 05:32:10 +0000
@@ -81,6 +81,7 @@
{
if (!pool)
throw ASException();
+ LOG_DEBUG_AVM("Getting double from pool at index %u",index);
return pool->mDoublePool.at(index);
}
@@ -935,8 +936,7 @@
/// value -- Double object from double_pool[index]
case SWF::ABC_ACTION_PUSHDOUBLE:
{
- mStack.grow(1);
- mStack.top(0) = pool_double(mStream->read_V32(), mPoolObject);
+ push_stack(as_value(pool_double(mStream->read_V32(),
mPoolObject)));
break;
}
/// 0x31 ABC_ACTION_PUSHNAMESPACE
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/avm2 r9683: Have SWFStream::read_d64() use the convert_double_wacky function to correctly return a double.,
Tom Stellard <=