gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. f1a5afd33fb8e2edfcc7


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. f1a5afd33fb8e2edfcc7c2a8acdac4c42a89d317
Date: Sat, 30 Oct 2010 11:51:32 +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  f1a5afd33fb8e2edfcc7c2a8acdac4c42a89d317 (commit)
       via  c522ad21e3ee0cef596c475d198272b04417ef2e (commit)
      from  74106c6ef47f572350f64e2f556a4a0e41575367 (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=f1a5afd33fb8e2edfcc7c2a8acdac4c42a89d317


commit f1a5afd33fb8e2edfcc7c2a8acdac4c42a89d317
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 30 12:18:44 2010 +0200

    Fix testsuite.

diff --git a/testsuite/libcore.all/AsValueTest.cpp 
b/testsuite/libcore.all/AsValueTest.cpp
index 9a90314..bf46fd5 100644
--- a/testsuite/libcore.all/AsValueTest.cpp
+++ b/testsuite/libcore.all/AsValueTest.cpp
@@ -40,13 +40,6 @@
 #include <iostream>
 #include <boost/shared_ptr.hpp>
 
-#if 0
-#include "buffer.h"
-#include "network.h"
-#include "amf.h"
-#include "element.h"
-#endif
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -59,17 +52,9 @@ using namespace std;
 
 static void usage (void);
 
-// Prototypes for test cases
-#if 0                           // this needs libamf and libnet
-static void test_el();
-static void test_obj(const as_object* o);
-#endif
 static void test_isnan();
 static void test_conversion();
 
-// Enable the display of memory allocation and timing data
-static bool memdebug = false;
-
 TestState runtest;
 LogFile& dbglogfile = LogFile::getDefaultInstance();
 RcInitFile& rcfile = RcInitFile::getDefaultInstance();
@@ -126,14 +111,10 @@ main(int argc, char *argv[])
     MovieClip::MovieVariables v;
     // We pass 'v' twice, as the second one is for scriptable
     // Variables, which isn't fully implemented yet.
-    Movie* m = stage.init(md, v, v);
+    stage.init(md, v, v);
 
     // run the tests
     test_isnan();
-#if 0                           // this needs libamf and libnet
-    test_el();
-    test_obj(getObject(m));
-#endif
     test_conversion();
    
 }
@@ -202,8 +183,6 @@ test_isnan()
 {
        float num = 0;
 
-//     std::cout << "sizeof(as_value): " << (sizeof(as_value)) << std::endl;
-
        if(!isNaN(num)) {
             runtest.pass("isNaN(0)");
         } else {
diff --git a/testsuite/libcore.all/StreamTest.cpp 
b/testsuite/libcore.all/StreamTest.cpp
index a086aff..49c9dc1 100644
--- a/testsuite/libcore.all/StreamTest.cpp
+++ b/testsuite/libcore.all/StreamTest.cpp
@@ -30,7 +30,7 @@
 
 #include <boost/thread/mutex.hpp>
 
-#include "tu_file.h"
+#include "IOChannel.h"
 #include "SWFStream.h"
 #include "log.h"
 

http://git.savannah.gnu.org/cgit//commit/?id=c522ad21e3ee0cef596c475d198272b04417ef2e


commit c522ad21e3ee0cef596c475d198272b04417ef2e
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 30 11:44:13 2010 +0200

    Hide tu_file.

diff --git a/gui/ScreenShotter.cpp b/gui/ScreenShotter.cpp
index dc2a529..4aafcb1 100644
--- a/gui/ScreenShotter.cpp
+++ b/gui/ScreenShotter.cpp
@@ -19,12 +19,14 @@
 //
 
 #include "ScreenShotter.h"
-#include "tu_file.h" // still here ?
 
 #include <cstdio>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/lexical_cast.hpp>
 
+#include "tu_file.h" 
+#include "IOChannel.h"
+
 namespace gnash {
 
 void
@@ -36,7 +38,7 @@ ScreenShotter::saveImage(const std::string& id) const
     
     FILE* f = std::fopen(outfile.c_str(), "wb");
     if (f) {
-        boost::shared_ptr<IOChannel> t(new tu_file(f, true));
+        boost::shared_ptr<IOChannel> t(makeFileChannel(f, true).release());
         _renderer->renderToImage(t, GNASH_FILETYPE_PNG);
     } else {
         log_error("Failed to open screenshot file \"%s\"!", outfile);
diff --git a/libbase/tu_file.cpp b/libbase/tu_file.cpp
index c28b2fd..17159d0 100644
--- a/libbase/tu_file.cpp
+++ b/libbase/tu_file.cpp
@@ -7,15 +7,134 @@
 
 #include "tu_file.h"
 
+#include <cstdio>
 #include <boost/format.hpp>
 #include <cerrno>
-#include <cstdio>
 
 #include "GnashFileUtilities.h"
+#include "utility.h"
+#include "IOChannel.h" 
 #include "log.h"
 
 namespace gnash {
 
+/// An IOChannel that works on a C stdio file.
+class tu_file : public IOChannel
+{
+public:
+
+    // Make a file from an ordinary FILE*.
+    tu_file(FILE* fp, bool autoclose);
+    
+    ~tu_file();
+    
+    /// \brief Read a 32-bit word from a little-endian stream.
+    ///        returning it as a native-endian word.
+    //
+    /// TODO: define what happens when the stream
+    ///       is in error condition.
+    ///
+    boost::uint32_t read_le32() 
+    {
+           // read_byte() is boost::uint8_t, so no masks with 0xff are 
required.
+           boost::uint32_t result = static_cast<boost::uint32_t>(read_byte());
+           result |= static_cast<boost::uint32_t>(read_byte()) << 8;
+           result |= static_cast<boost::uint32_t>(read_byte()) << 16;
+           result |= static_cast<boost::uint32_t>(read_byte()) << 24;
+           return(result);
+    }
+       
+    /// \brief Read a 16-bit word from a little-endian stream.
+    //
+    /// TODO: define what happens when the stream
+    ///       is in error condition, see bad().
+    ///
+    boost::uint16_t read_le16()
+    {
+           boost::uint16_t result = static_cast<boost::uint16_t>(read_byte());
+           result |= static_cast<boost::uint16_t>(read_byte()) << 8;
+           return(result);
+    }
+    
+    /// \brief Read a single byte from the stream
+    //
+    /// TODO: define what happens when the stream
+    ///       is in error condition, see bad().
+    ///
+    boost::uint8_t read_byte() {
+        boost::uint8_t u;
+        read(&u, 1);
+        return u;
+    }
+    
+    /// \brief Read the given number of bytes from the stream
+    //
+    /// TODO: define what happens when the stream
+    ///       is in error condition, see bad().
+    ///
+    std::streamsize read(void* dst, std::streamsize num);
+
+    /// \brief Write the given number of bytes to the stream
+    //
+    /// TODO: define what happens when the stream
+    ///       is in error condition, see bad().
+    ///
+    std::streamsize write(const void* src, std::streamsize num);
+
+    /// \brief Return current stream position
+    //
+    /// TODO: define what to return when the stream
+    ///       is in error condition, see bad().
+    ///
+    std::streampos tell() const;
+
+    /// \brief Seek to the specified position
+    //
+    /// 
+    /// TODO: define what happens when an error occurs, or
+    ///       when we're already in an error condition
+    ///
+    /// @return true on success, or false on failure.
+    ///
+    bool seek(std::streampos p);
+
+    /// \brief Seek to the end of the stream
+    //
+    /// TODO: define what happens when an error occurs
+    ///
+    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 bad().
+    ///
+    bool eof() const;
+    
+    /// \brief Return non-zero if the stream is in an error state
+    //
+    /// When the stream is in an error state there's nothing
+    /// you can do about it, just delete it and log the error.
+    ///
+    /// There are some rough meaning for possible returned values
+    /// but I don't think they make much sense currently.
+    ///
+    bool bad() const;
+    
+    /// Get the size of the stream
+    size_t size() const;
+    
+private:
+    
+    void close();
+    
+    FILE* _data;
+
+    bool _autoclose;
+
+};
+
+
 //// Create a file from a standard file pointer.
 tu_file::tu_file(FILE* fp, bool autoclose = false)
     :
@@ -121,6 +240,13 @@ tu_file::close()
     std::fclose(_data);
 }
 
+std::auto_ptr<IOChannel>
+makeFileChannel(FILE* fp, bool close)
+{
+    std::auto_ptr<IOChannel> ret(new tu_file(fp, close));
+    return ret;
+}
+
 } // end namespace gnash
 
 // Local Variables:
diff --git a/libbase/tu_file.h b/libbase/tu_file.h
index 5412218..6406e02 100644
--- a/libbase/tu_file.h
+++ b/libbase/tu_file.h
@@ -10,134 +10,19 @@
 #define TU_FILE_H
 
 #include <cstdio>
-
-#include "dsodefs.h" // DSOEXPORT
-#include "utility.h"
-#include "IOChannel.h" // for inheritance
-
+#include <memory>
+#include "dsodefs.h"
 
 namespace gnash {
+    class IOChannel;
+}
 
-/// An IOChannel that works on a C stdio file.
-class DSOEXPORT tu_file : public gnash::IOChannel
-{
-public:
-
-    // Make a file from an ordinary FILE*.
-    tu_file(FILE* fp, bool autoclose);
-    
-    ~tu_file();
-    
-    /// \brief Read a 32-bit word from a little-endian stream.
-    ///        returning it as a native-endian word.
-    //
-    /// TODO: define what happens when the stream
-    ///       is in error condition.
-    ///
-    boost::uint32_t read_le32() 
-    {
-           // read_byte() is boost::uint8_t, so no masks with 0xff are 
required.
-           boost::uint32_t result = static_cast<boost::uint32_t>(read_byte());
-           result |= static_cast<boost::uint32_t>(read_byte()) << 8;
-           result |= static_cast<boost::uint32_t>(read_byte()) << 16;
-           result |= static_cast<boost::uint32_t>(read_byte()) << 24;
-           return(result);
-    }
-       
-    /// \brief Read a 16-bit word from a little-endian stream.
-    //
-    /// TODO: define what happens when the stream
-    ///       is in error condition, see bad().
-    ///
-    boost::uint16_t read_le16()
-    {
-           boost::uint16_t result = static_cast<boost::uint16_t>(read_byte());
-           result |= static_cast<boost::uint16_t>(read_byte()) << 8;
-           return(result);
-    }
-    
-    /// \brief Read a single byte from the stream
-    //
-    /// TODO: define what happens when the stream
-    ///       is in error condition, see bad().
-    ///
-    boost::uint8_t read_byte() {
-        boost::uint8_t u;
-        read(&u, 1);
-        return u;
-    }
-    
-    /// \brief Read the given number of bytes from the stream
-    //
-    /// TODO: define what happens when the stream
-    ///       is in error condition, see bad().
-    ///
-    std::streamsize read(void* dst, std::streamsize num);
-
-    /// \brief Write the given number of bytes to the stream
-    //
-    /// TODO: define what happens when the stream
-    ///       is in error condition, see bad().
-    ///
-    std::streamsize write(const void* src, std::streamsize num);
-
-    /// \brief Return current stream position
-    //
-    /// TODO: define what to return when the stream
-    ///       is in error condition, see bad().
-    ///
-    std::streampos tell() const;
-
-    /// \brief Seek to the specified position
-    //
-    /// 
-    /// TODO: define what happens when an error occurs, or
-    ///       when we're already in an error condition
-    ///
-    /// @return true on success, or false on failure.
-    ///
-    bool seek(std::streampos p);
-
-    /// \brief Seek to the end of the stream
-    //
-    /// TODO: define what happens when an error occurs
-    ///
-    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 bad().
-    ///
-    bool eof() const;
-    
-    /// \brief Return non-zero if the stream is in an error state
-    //
-    /// When the stream is in an error state there's nothing
-    /// you can do about it, just delete it and log the error.
-    ///
-    /// There are some rough meaning for possible returned values
-    /// but I don't think they make much sense currently.
-    ///
-    bool bad() const;
-    
-    /// Get the size of the stream
-    size_t size() const;
-    
-private:
-    
-    void close();
-    
-    FILE* _data;
-
-    bool _autoclose;
-
-};
+namespace gnash {
 
+DSOEXPORT std::auto_ptr<IOChannel> makeFileChannel(FILE* fp, bool close);
 
 } // namespace gnash
-#endif // TU_FILE_H
-
+#endif 
 
 // Local Variables:
 // mode: C++
diff --git a/libcore/StreamProvider.cpp b/libcore/StreamProvider.cpp
index 53203fc..a07867b 100644
--- a/libcore/StreamProvider.cpp
+++ b/libcore/StreamProvider.cpp
@@ -55,11 +55,10 @@ StreamProvider::getStream(const URL& url, bool 
namedCacheFile) const
 
     std::auto_ptr<IOChannel> stream;
 
-       if (url.protocol() == "file")
-       {
+       if (url.protocol() == "file") {
+
                std::string path = url.path();
-               if ( path == "-" )
-               {
+               if (path == "-") {
             // TODO: only allow this as the *very first* call ?
             //       Rationale is a movie might request load of
             //       standard input, being a security issue.
@@ -69,11 +68,10 @@ StreamProvider::getStream(const URL& url, bool 
namedCacheFile) const
                        FILE *newin = fdopen(dup(0), "rb");
 
                        // Close on destruction.
-                       stream.reset(new tu_file(newin, true));
+                       stream = makeFileChannel(newin, true);
                        return stream;
                }
-               else
-               {
+               else {
             // check security here !!
                    if (!allow(url)) return stream;
 
@@ -82,7 +80,7 @@ StreamProvider::getStream(const URL& url, bool 
namedCacheFile) const
                                return stream;
                        }
                        // Close on destruction
-                       stream.reset(new tu_file(newin, true));
+                       stream = makeFileChannel(newin, true);
                        return stream;
                }
        }
@@ -138,10 +136,9 @@ StreamProvider::getStream(const URL& url, const 
std::string& postdata,
                         "from file: uri"));
         }
                std::string path = url.path();
-               if ( path == "-" )
-               {
+               if (path == "-") {
                        FILE *newin = fdopen(dup(0), "rb");
-                       stream.reset(new tu_file(newin, false));
+                       stream = makeFileChannel(newin, false);
                        return stream;
                }
                else
@@ -152,7 +149,7 @@ StreamProvider::getStream(const URL& url, const 
std::string& postdata,
                        if (!newin)  { 
                                return stream;
                        }
-                       stream.reset(new tu_file(newin, false));
+                       stream = makeFileChannel(newin, false);
                        return stream;
                }
        }
diff --git a/testsuite/libbase.all/CurlStreamTest.cpp 
b/testsuite/libbase.all/CurlStreamTest.cpp
index da018eb..c20f180 100644
--- a/testsuite/libbase.all/CurlStreamTest.cpp
+++ b/testsuite/libbase.all/CurlStreamTest.cpp
@@ -22,6 +22,7 @@
 
 #include "NetworkAdapter.h"
 #include "tu_file.h"
+#include "IOChannel.h"
 
 #include <memory>               // for auto_ptr
 #include <cstdio>
@@ -63,7 +64,7 @@ dump_curl(const char* url, ostream& os)
 static void
 dump_tu_file(const char* url, ostream& os)
 {
-       tu_file* reader = new tu_file(url, "r");
+    std::auto_ptr<IOChannel> reader = makeFileChannel(url, true);
        assert(reader);
        if (reader->bad()) return;
 
diff --git a/testsuite/libbase.all/NoSeekFileTest.cpp 
b/testsuite/libbase.all/NoSeekFileTest.cpp
index d5bacee..bca1476 100644
--- a/testsuite/libbase.all/NoSeekFileTest.cpp
+++ b/testsuite/libbase.all/NoSeekFileTest.cpp
@@ -27,11 +27,13 @@
 #endif
 
 #include "noseek_fd_adapter.h"
+#include "IOChannel.h"
 #include "tu_file.h"
 
 #include <cstdio>
 #include <iostream>
 #include <cassert>
+#include <memory>
 
 #include "GnashSystemIOHeaders.h"
 #include <sys/types.h>
@@ -147,9 +149,9 @@ main(int /*argc*/, char** /*argv*/)
 
 
     FILE* f = std::fopen(cachename, "r");
-       gnash::tu_file orig(f, false);
+    std::auto_ptr<gnash::IOChannel> orig = gnash::makeFileChannel(f, false);
        lseek(raw, 0, SEEK_SET);
-       compare_reads(&orig, raw, "cache", "raw");
+       compare_reads(orig.get(), raw, "cache", "raw");
 
        return 0;
 }

-----------------------------------------------------------------------

Summary of changes:
 gui/ScreenShotter.cpp                    |    6 +-
 libbase/tu_file.cpp                      |  128 +++++++++++++++++++++++++++++-
 libbase/tu_file.h                        |  129 ++----------------------------
 libcore/StreamProvider.cpp               |   21 ++---
 testsuite/libbase.all/CurlStreamTest.cpp |    3 +-
 testsuite/libbase.all/NoSeekFileTest.cpp |    6 +-
 testsuite/libcore.all/AsValueTest.cpp    |   23 +-----
 testsuite/libcore.all/StreamTest.cpp     |    2 +-
 8 files changed, 155 insertions(+), 163 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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