gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r9632: Progress in making tu_file re


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9632: Progress in making tu_file redundant. It is now an ordinary derived class
Date: Fri, 22 Aug 2008 15:13:27 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9632
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2008-08-22 15:13:27 +0200
message:
  Progress in making tu_file redundant. It is now an ordinary derived class
  of IOChannel, with no custom callbacks, and is only used for opening
  files or file descriptors so can be replaced easily with anything 
  suitable.
modified:
  libbase/tu_file.cpp
  libbase/tu_file.h
  libcore/fontlib.cpp
  libcore/swf/tag_loaders.cpp
  testsuite/libbase/NoSeekFileTest.cpp
  testsuite/libcore.all/StreamTest.cpp
=== modified file 'libbase/tu_file.cpp'
--- a/libbase/tu_file.cpp       2008-08-18 23:53:04 +0000
+++ b/libbase/tu_file.cpp       2008-08-22 13:13:27 +0000
@@ -26,52 +26,39 @@
 // tu_file functions using FILE
 //
 
-using namespace gnash;
-
 namespace gnash {
 
-static int std_read_func(void* dst, int bytes, void* appdata);
-static int std_write_func(const void* src, int bytes, void* appdata);
-static int std_seek_func(int pos, void *appdata);
-static int std_seek_to_end_func(void *appdata);
-static int std_tell_func(void *appdata);
-static bool std_get_eof_func(void *appdata);
-static int std_get_err_func(void *appdata);
-static long std_get_stream_size_func(void *appdata);
 
-static int
-std_read_func(void* dst, int bytes, void* appdata) 
+int
+tu_file::read(void* dst, int bytes) 
 // Return the number of bytes actually read.  EOF or an error would
 // cause that to not be equal to "bytes".
 {
 //    GNASH_REPORT_FUNCTION;
     
-    assert(appdata);
     assert(dst);
-    return fread( dst, 1, bytes, static_cast<FILE*>(appdata) );
+    return fread( dst, 1, bytes, static_cast<FILE*>(m_data) );
 }
 
-static int
-std_write_func(const void* src, int bytes, void* appdata)
+int
+tu_file::write(const void* src, int bytes)
 // Return the number of bytes actually written.
 {
-    assert(appdata);
     assert(src);
-    return std::fwrite( src, 1, bytes, static_cast<FILE*>(appdata));
+    return std::fwrite( src, 1, bytes, static_cast<FILE*>(m_data));
 }
 
-static int
-std_seek_func(int pos, void *appdata)
+int
+tu_file::seek(int pos)
 {
-    assert(appdata);
 
     // TODO: optimize this by caching total stream size ?
-    if (pos > std_get_stream_size_func(appdata))
+    if (pos > size())
     {
            return TU_FILE_SEEK_ERROR;
     }
 
-    FILE* file = static_cast<FILE*>(appdata);
+    FILE* file = static_cast<FILE*>(m_data);
 
     clearerr(file); // make sure EOF flag is cleared.
     int        result = fseek(file, pos, SEEK_SET);
@@ -85,61 +72,58 @@
     return 0;
 }
 
-static int
-std_seek_to_end_func(void *appdata)
+void
+tu_file::go_to_end()
 // Return 0 on success, TU_FILE_SEEK_ERROR on failure.
 {
-    assert(appdata);
-    int        result = fseek(static_cast<FILE*>(appdata), 0, SEEK_END);
+
+    int        result = fseek(static_cast<FILE*>(m_data), 0, SEEK_END);
     if (result == EOF) {
-       // @@ TODO should set m_error to something relevant based on errno.
-       return TU_FILE_SEEK_ERROR;
+           // Can't do anything here
     }
-    return 0;
+
 }
 
-static int
-std_tell_func(void *appdata)
+int
+tu_file::tell() const
 // Return the file position, or -1 on failure.
 {
-    assert(appdata);
-    FILE* f = static_cast<FILE*>(appdata);
+    FILE* f = static_cast<FILE*>(m_data);
 
     //if ( feof(f) )
     //assert ( ! feof(f) ); // I guess it's legal to call tell() while at eof.
 
     int ret = ftell(f);
-    assert(ret <= std_get_stream_size_func(appdata));
+    assert(ret <= size());
     return ret;
 }
 
-static bool
-std_get_eof_func(void *appdata)
+bool
+tu_file::eof() const
 // Return true if we're at EOF.
 {
-    assert(appdata);
-    if (feof((FILE*) appdata)) {
+    if (feof((FILE*) m_data)) {
        return true;
     } else {
        return false;
     }
 }
 
-static int
-std_get_err_func(void *appdata)
+int
+tu_file::get_error() const
 // Return true if we're at EOF.
 {
-    if ( ! appdata ) return TU_FILE_OPEN_ERROR;
-    return (ferror((FILE*) appdata));
+    if ( ! m_data ) return TU_FILE_OPEN_ERROR;
+    return (ferror((FILE*) m_data));
 }
 
-static long
-std_get_stream_size_func(void *appdata)
+int
+tu_file::size() const
 // Return -1 on failure, or the size
 {
-    assert(appdata);
+    assert(m_data);
 
-    FILE* f = static_cast<FILE*>(appdata);
+    FILE* f = static_cast<FILE*>(m_data);
 
     struct stat statbuf;
     if ( -1 == fstat(fileno(f), &statbuf) )
@@ -151,146 +135,35 @@
 }
 
 
-static int
-std_close_func(void *appdata)
+void
+tu_file::close()
 // Return 0 on success, or TU_FILE_CLOSE_ERROR on failure.
 {
-    assert(appdata);
-    int        result = std::fclose(static_cast<FILE*>(appdata));
+    assert(m_data);
+    int        result = std::fclose(static_cast<FILE*>(m_data));
     if (result == EOF) {
-       // @@ TODO should set m_error to something relevant based on errno.
-       return TU_FILE_CLOSE_ERROR;
+           // @@ TODO should set m_error to something relevant based on errno.
     }
-    return 0;
-}
-
-
-} // end namespace gnash
-
-//
-// generic functionality
-//
-
-// Create a file using the custom callbacks.
-tu_file::tu_file(void * appdata, read_func rf, write_func wf,
-                seek_func sf, seek_to_end_func ef, tell_func tf,
-                get_eof_func gef, get_err_func ger, get_stream_size_func gss, 
close_func cf)
-{
-    m_data = appdata;
-    m_read = rf;
-    m_write = wf;
-    m_seek = sf;
-    m_seek_to_end = ef;
-    m_tell = tf;
-    m_get_eof = gef;
-    m_get_err = ger;
-    m_get_stream_size = gss;
-    m_close = cf;
-}
+}
+
 
 //// Create a file from a standard file pointer.
-tu_file::tu_file(FILE* fp, bool autoclose=false)
+tu_file::tu_file(FILE* fp, bool autoclose=false) :
+    m_data(fp),
+    _autoclose(autoclose)
 {
     //GNASH_REPORT_FUNCTION;
-
-    m_data = static_cast<void*>(fp);
-    m_read = std_read_func;
-    m_write = std_write_func;
-    m_seek = std_seek_func;
-    m_seek_to_end = std_seek_to_end_func;
-    m_tell = std_tell_func;
-    m_get_eof = std_get_eof_func;
-    m_get_err = std_get_err_func;
-    m_get_stream_size = std_get_stream_size_func;
-    m_close = autoclose ? std_close_func : NULL;
-}
-
-// Create a file from the given name and the given mode.
-tu_file::tu_file(const char * name, const char * mode)
-{
-       GNASH_REPORT_RETURN;
-
-       m_data = fopen(name, mode);
-    
-       m_read = std_read_func;
-       m_write = std_write_func;
-       m_seek = std_seek_func;
-       m_seek_to_end = std_seek_to_end_func;
-       m_tell = std_tell_func;
-       m_get_eof = std_get_eof_func;
-       m_get_err = std_get_err_func;
-       m_get_stream_size = std_get_stream_size_func;
-       m_close = std_close_func;
-}
+}
+
 
 tu_file::~tu_file()
 // Close this file when destroyed.
 {
-    close();
-}
-
-void
-tu_file::close() 
-// Close this file.
-{ 
-    if (m_close && m_data) {
-       m_close(m_data);
-    }
-    m_data = NULL; 
-    m_read = NULL; 
-    m_write = NULL; 
-    m_seek = NULL; 
-    m_tell = NULL; 
-    m_close = NULL; 
-}
-
-
-void
-tu_file::copy_from(tu_file* src)
-// Copy remaining contents of *src into *this.
-{
-    // @@ bah, should buffer this!
-    while (src->eof() == false) {
-       boost::uint8_t  b = src->read8();
-       if (src->get_error()) {
-           break;
-       }
-       
-       write8(b);
-    }
-}
-
-
-int
-tu_file::copy_bytes(tu_file* src, int byte_count)
-// Copy a fixed number of bytes from *src into *this.  Return the
-// number of bytes copied.
-{
-    static const int   BUFSIZE = 4096;
-    char       buffer[BUFSIZE];
-    
-    int        bytes_left = byte_count;
-    while (bytes_left) {
-       int     to_copy = std::min<int>(bytes_left, BUFSIZE);
-       
-       int     read_count = src->read(buffer, to_copy);
-       int     write_count = write(buffer, read_count);
-       
-       assert(write_count <= read_count);
-       assert(read_count <= to_copy);
-       assert(to_copy <= bytes_left);
-       
-       bytes_left -= write_count;
-       if (write_count < to_copy) {
-           // Some kind of error; abort.
-           return byte_count - bytes_left;
-       }
-    }
-    
-    assert(bytes_left == 0);
-    
-    return byte_count;
-}
+    if (_autoclose) close();
+}
+
+
+} // end namespace gnash
 
 // Local Variables:
 // mode: C++

=== modified file 'libbase/tu_file.h'
--- a/libbase/tu_file.h 2008-06-09 18:08:25 +0000
+++ b/libbase/tu_file.h 2008-08-22 13:13:27 +0000
@@ -15,6 +15,8 @@
 
 #include <cstdio>
 
+namespace gnash {
+
 // a file abstraction that can be customized with callbacks.
 // Designed to be easy to hook up to FILE*, SDL_RWops*, or
 // whatever stream type(s) you might use in your game or
@@ -22,55 +24,12 @@
 class DSOEXPORT tu_file : public gnash::IOChannel
 {
 public:
-    typedef int (* read_func)(void* dst, int bytes, void* appdata);
-    typedef int (* write_func)(const void* src, int bytes, void* appdata);
-    typedef int (* seek_func)(int pos, void* appdata);
-    typedef int (* seek_to_end_func)(void* appdata);
-    typedef int (* tell_func)(void* appdata);
-    typedef bool (* get_eof_func)(void* appdata);
-    typedef int (* get_err_func)(void* appdata);
-    typedef long (* get_stream_size_func)(void* appdata);
-    typedef int (* close_func)(void* appdata);
-    
-    // The generic constructor; supply functions for the implementation.
-    tu_file(
-       void * appdata,
-       read_func rf,
-       write_func wf,
-       seek_func sf,
-       seek_to_end_func ef,
-       tell_func tf,
-       get_eof_func gef,
-       get_err_func ger,
-       get_stream_size_func gss,
-       close_func cf=NULL);
-    
+
     // Make a file from an ordinary FILE*.
     tu_file(FILE* fp, bool autoclose);
     
-    // Open a file using ordinary fopen().  Automatically closes the
-    // file when we are destroyed.
-    tu_file(const char* name, const char* mode);
-   
     ~tu_file();
     
-    /// Copy remaining contents of *in into *this.
-    //
-    /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
-    ///
-    void copy_from(tu_file* in);
-    
-    /// Copy a fixed number of bytes from *in to *this.
-    //
-    /// Returns number of bytes copied.
-    ///
-    /// TODO: define what happens when either one of the streams
-    ///       is in error condition, see get_error().
-    ///
-    int        copy_bytes(tu_file* in, int bytes);
-    
-
     /// \brief Read a 32-bit word from a little-endian stream.
     ///        returning it as a native-endian word.
     //
@@ -156,27 +115,21 @@
     /// TODO: define what happens when the stream
     ///       is in error condition, see get_error().
     ///
-    int read(void* dst, int num)
-    {
-        return m_read(dst, num, m_data);
-    }
+    int read(void* dst, int num);
 
     /// \brief Write the given number of bytes to the stream
     //
     /// TODO: define what happens when the stream
     ///       is in error condition, see get_error().
     ///
-    int write(const void* src, int num)
-    {
-        return m_write(src, num, m_data);
-    }
+    int write(const void* src, int num);
 
     /// \brief Return current stream position
     //
     /// TODO: define what to return when the stream
     ///       is in error condition, see get_error().
     ///
-    int        tell() const { return m_tell(m_data); }
+    int        tell() const;
 
     /// \brief Seek to the specified position
     //
@@ -186,20 +139,20 @@
     ///
     /// @return 0 on success, or TU_FILE_SEEK_ERROR on failure.
     ///
-    int        seek(int p) { return m_seek(p, m_data); }
+    int        seek(int p);
 
     /// \brief Seek to the end of the stream
     //
     /// TODO: define what happens when an error occurs
     ///
-    void       go_to_end() { m_seek_to_end(m_data); }
+    void go_to_end();
 
     /// \brief Return true if the end of the stream has been reached.
     //
     /// TODO: define what to return when in error condition
     /// see get_error().
     ///
-    bool eof() const { return m_get_eof(m_data); }
+    bool eof() const;
     
     /// \brief Return non-zero if the stream is in an error state
     //
@@ -209,80 +162,72 @@
     /// There are some rough meaning for possible returned values
     /// but I don't think they make much sense currently.
     ///
-    int        get_error() const { return m_get_err(m_data); }
+    int        get_error() const;
     
 
     /// \brief Get the size of the stream
-    int size() const { return m_get_stream_size(m_data); }
-    
-    // \brief UNSAFE back door, for testing only.
-    void* get_app_data_DEBUG() { return m_data; }
-    
+    int size() const;
     
 private:
 
     boost::uint64_t    read64()
     {
         boost::uint64_t u;
-        m_read(&u, 8, m_data);
+        read(&u, 8);
         return u;
     }
 
     boost::uint32_t    read32()
     {
         boost::uint32_t u;
-        m_read(&u, 4, m_data);
+        read(&u, 4);
         return u;
     }
 
     boost::uint16_t read16()
     {
         boost::uint16_t u;
-        m_read(&u, 2, m_data);
+        read(&u, 2);
         return u;
     }
     
     boost::uint8_t     read8()
     {
         boost::uint8_t u;
-        m_read(&u, 1, m_data);
+        read(&u, 1);
         return u;
     }
     
     void write64(boost::uint64_t u)
     {
-        m_write(&u, 8, m_data);
+        write(&u, 8);
     }
 
     void write32(boost::uint32_t u)
     {
-        m_write(&u, 4, m_data);
+        write(&u, 4);
     }
 
     void write16(boost::uint16_t u)
     {
-        m_write(&u, 2, m_data);
+        write(&u, 2);
     }
 
     void write8(boost::uint8_t u)
     {
-        m_write(&u, 1, m_data);
+        write(&u, 1);
     }
     
     void close();
     
-    void *             m_data;
-    read_func          m_read;
-    write_func         m_write;
-    seek_func          m_seek;
-    seek_to_end_func   m_seek_to_end;
-    tell_func          m_tell;
-    get_eof_func       m_get_eof;
-    get_err_func       m_get_err;
-    get_stream_size_func       m_get_stream_size;
-    close_func         m_close;
+    void *     m_data;
+
+    bool _autoclose;
+
 };
 
+
+} // namespace gnash
 #endif // TU_FILE_H
 
 

=== modified file 'libcore/fontlib.cpp'
--- a/libcore/fontlib.cpp       2008-08-18 23:53:04 +0000
+++ b/libcore/fontlib.cpp       2008-08-22 13:13:27 +0000
@@ -13,7 +13,6 @@
 #include <pthread.h>
 #endif
 
-#include "tu_file.h"
 #include "font.h"
 #include "impl.h"
 #include "log.h"

=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp       2008-08-18 23:53:04 +0000
+++ b/libcore/swf/tag_loaders.cpp       2008-08-22 13:13:27 +0000
@@ -26,7 +26,7 @@
 #include <pthread.h>
 #endif
 
-#include "tu_file.h" // for StreamAdapter (bitmap tag loaders)
+#include "IOChannel.h" // for StreamAdapter inheritance
 #include "utility.h"
 #include "action.h"
 #include "action_buffer.h"
@@ -38,7 +38,6 @@
 #include "shape.h"
 #include "SWFStream.h"
 #include "styles.h"
-//#include "dlist.h"
 #include "timers.h"
 #include "image.h"
 #include "zlib_adapter.h"
@@ -74,14 +73,12 @@
 namespace tag_loaders {
 
 
-namespace { // anonymous
-
-///
-/// tu_file adapter using a stream underneath
-///
-
-/// Provide a tu_file interface around a gnash::stream
-class StreamAdapter
+/// Anonymous namespace
+namespace {
+
+/// Provide an IOChannel interface around a SWFStream for reading 
+/// embedded image data
+class StreamAdapter : public IOChannel
 {
        SWFStream& s;
        unsigned long startPos;
@@ -98,71 +95,74 @@
                assert(endPos > startPos);
        }
 
-       static int readFunc(void* dst, int bytes, void* appdata) 
+    virtual ~StreamAdapter()
+    {
+    }
+
+       virtual int read(void* dst, int bytes) 
        {
-               StreamAdapter* br = (StreamAdapter*) appdata;
-
-               unsigned bytesLeft = br->endPos - br->currPos;
+               unsigned bytesLeft = endPos - currPos;
                if ( bytesLeft < (unsigned)bytes )
                {
                        if ( ! bytesLeft ) return 0;
                        //log_debug("Requested to read past end of stream 
range");
                        bytes = bytesLeft;
                }
-               unsigned actuallyRead = br->s.read((char*)dst, bytes);
-               br->currPos += actuallyRead;
+               unsigned actuallyRead = s.read((char*)dst, bytes);
+               currPos += actuallyRead;
                return actuallyRead;
        }
 
-       static long int getStreamSizeFunc(void* appdata)
-       {
-               StreamAdapter* br = (StreamAdapter*) appdata;
-               return (br->endPos - br->startPos);
-       }
-
-       static int tellFunc(void* appdata)
-       {
-               StreamAdapter* br = (StreamAdapter*) appdata;
-               return br->currPos;
-       }
-
-       static int closeFunc(void* appdata)
-       {
-               StreamAdapter* br = (StreamAdapter*) appdata;
-               delete br;
-               return 0; // ok ? or TU_FILE_CLOSE_ERROR ?
+    virtual void go_to_end()
+    {
+        s.seek(endPos);
+    }
+
+    virtual bool eof() const
+    {
+        return (currPos == endPos);
+    }
+
+    // Return -1 on failure, 0 on success
+    virtual int seek(int pos)
+    {
+        // SWFStream::seek() returns true on success
+        if (s.seek(pos))
+        {
+            currPos = pos;
+            return 0;
+        }
+        return -1;
+    }
+
+       virtual int size() const
+       {
+               return (endPos - startPos);
+       }
+
+       virtual int tell() const
+       {
+               return currPos;
+       }
+       
+       virtual int get_error() const
+       {
+           // Is there any point in this?
+           return TU_FILE_NO_ERROR;
        }
 
 public:
 
-       /// Get a tu_file from a gnash::SWFStream
-       static std::auto_ptr<tu_file> getFile(SWFStream& str, unsigned long 
endPos)
+       /// Get an IOChannel from a gnash::SWFStream
+       static std::auto_ptr<IOChannel> getFile(SWFStream& str, unsigned long 
endPos)
        {
-               std::auto_ptr<tu_file> ret ( 
-                       new tu_file (
-                               new StreamAdapter(str, endPos),
-                               readFunc,
-                               0, // write_func wf,
-                               0, //seek_func sf,
-                               0, //seek_to_end_func ef,
-                               tellFunc, //tell_func tf,
-                               0, //get_eof_func gef,
-                               0, //get_err_func ger
-                               getStreamSizeFunc, // get_stream_size_func gss,
-                               closeFunc
-                       )
-               );
-
+               std::auto_ptr<IOChannel> ret (new StreamAdapter(str, endPos));
                return ret;
        }
 };
 
 } // anonymous namespace
 
-//
-// Some tag implementations
-//
-
 
 //
 // Tag loaders
@@ -191,7 +191,7 @@
     // if it is 1 this label can be accessed by #name and it's
     // entrance sets the browser URL with anchor appended
     //
-    // To avoid relaying on SWFStream::tell (see task #5838)
+    // To avoid relying on SWFStream::tell (see task #5838)
     // we should add a new method to that class
     // (ie: SWFStream::current_tag_length)
     //
@@ -252,7 +252,7 @@
        // Anyway the actual reads are limited to currently opened tag as 
        // of gnash::SWFStream::read(), so this is not a problem.
        //
-        boost::shared_ptr<tu_file> ad(StreamAdapter::getFile(in, 
std::numeric_limits<unsigned long>::max()).release());
+        boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in, 
std::numeric_limits<unsigned long>::max()).release());
         //  transfer ownership to the JpegImageInput
         j_in = JpegImageInput::createSWFJpeg2HeaderOnly(ad, jpegHeaderSize);
 
@@ -351,7 +351,7 @@
     }
     else
     {
-        boost::shared_ptr<tu_file> ad( StreamAdapter::getFile(in, 
in.get_tag_end_position()).release() );
+        boost::shared_ptr<IOChannel> ad( StreamAdapter::getFile(in, 
in.get_tag_end_position()).release() );
 
         std::auto_ptr<image::ImageBase> im (image::readImageData(ad, 
GNASH_FILETYPE_JPEG));
 
@@ -473,7 +473,7 @@
     //
 
     // Read rgb data.
-    boost::shared_ptr<tu_file> ad( StreamAdapter::getFile(in, 
alpha_position).release() );
+    boost::shared_ptr<IOChannel> ad( StreamAdapter::getFile(in, 
alpha_position).release() );
     std::auto_ptr<image::ImageRGBA> im = image::readSWFJpeg3(ad);
     
     /// Failure to read the jpeg.

=== modified file 'testsuite/libbase/NoSeekFileTest.cpp'
--- a/testsuite/libbase/NoSeekFileTest.cpp      2008-06-10 06:03:01 +0000
+++ b/testsuite/libbase/NoSeekFileTest.cpp      2008-08-22 13:13:27 +0000
@@ -144,7 +144,9 @@
        reader->seek(0);
        compare_reads(reader, raw, "wrapped-rewind", "raw-rewind");
 
-       tu_file orig(cachename, "r");
+
+    FILE* f = std::fopen(cachename, "r");
+       gnash::tu_file orig(f, false);
        lseek(raw, 0, SEEK_SET);
        compare_reads(&orig, raw, "cache", "raw");
 

=== modified file 'testsuite/libcore.all/StreamTest.cpp'
--- a/testsuite/libcore.all/StreamTest.cpp      2008-08-18 23:53:04 +0000
+++ b/testsuite/libcore.all/StreamTest.cpp      2008-08-22 13:13:27 +0000
@@ -49,7 +49,7 @@
 
 TestState runtest;
 
-struct ByteReader
+struct ByteReader : public IOChannel
 {
        unsigned char b;
        unsigned int pos;
@@ -65,32 +65,41 @@
                b=by;
        }
 
-       static int readFunc(void* dst, int bytes, void* appdata) 
+       int read(void* dst, int bytes) 
        {
-               ByteReader* br = (ByteReader*) appdata;
 
                unsigned char* ptr = static_cast<unsigned char*>(dst);
                for (int i=0; i<bytes; ++i)
                {
-                       memcpy(ptr+i, &(br->b), sizeof(unsigned char));
+                       memcpy(ptr+i, &b, sizeof(unsigned char));
                }
 
-               br->pos += bytes;
+               pos += bytes;
                return bytes;
        }
 
-       static int tellFunc(void* appdata)
+       int tell() const
        {
-               ByteReader* br = (ByteReader*) appdata;
-               return br->pos;
+               return pos;
        }
 
-       static int seekFunc(int newPos, void* appdata)
+       int seek(int newPos)
        {
-               ByteReader* br = (ByteReader*) appdata;
-               br->pos=newPos;
+               pos=newPos;
                return 0; // ok, no error (urgh)
        }
+       
+       
+       // These here to satisfy the IOChannel interface requirements.
+       // I wouldn't call them, if I were you.
+       void go_to_end() { abort(); }
+
+       bool eof() const { abort(); return false; }
+    
+       int get_error() const { return 0; }
+
+       int size() const { abort(); return -1; }
+       
 };
 
 int
@@ -101,25 +110,25 @@
 
        ByteReader br(0xAA);
 
-       tu_file fakeIn(
-               &br,
-               ByteReader::readFunc,
-               0, // write_func wf,
-               ByteReader::seekFunc, // seek_func sf,
-               0, //seek_to_end_func ef,
-               ByteReader::tellFunc, // tell_func tf,
-               0, //get_eof_func gef,
-               0, //get_err_func ger
-               0, // get_stream_size_func gss,
-               0 // close_func cf
-       );
+//     tu_file fakeIn(
+//             &br,
+//             ByteReader::readFunc,
+//             0, // write_func wf,
+//             ByteReader::seekFunc, // seek_func sf,
+//             0, //seek_to_end_func ef,
+//             ByteReader::tellFunc, // tell_func tf,
+//             0, //get_eof_func gef,
+//             0, //get_err_func ger
+//             0, // get_stream_size_func gss,
+//             0 // close_func cf
+//     );
 
        int ret;
 
        {
        /// bits: 10101010 (0xAA)
        br.setByte(0xAA);
-       SWFStream s(&fakeIn);
+       SWFStream s(&br);
 
 
        check_equals(s.tell(), 0);
@@ -349,7 +358,7 @@
        {
        /// bits: 10011001 (0x99)
        br.setByte(0x99);
-       SWFStream s(&fakeIn);
+       SWFStream s(&br);
        s.seek(27);
 
        s.align();


reply via email to

[Prev in Thread] Current Thread [Next in Thread]