gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r12246: Documentation and cleanups o


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r12246: Documentation and cleanups only: move tags to their own files, document
Date: Sat, 12 Jun 2010 11:41:10 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 12246 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sat 2010-06-12 11:41:10 +0200
message:
  Documentation and cleanups only: move tags to their own files, document
  id and how it is used.
added:
  libcore/swf/ExportAssetsTag.h
  libcore/swf/ImportAssetsTag.h
modified:
  libcore/Makefile.am
  libcore/parser/SWFMovieDefinition.cpp
  libcore/parser/movie_definition.h
  libcore/swf/DefaultTagLoaders.cpp
  libcore/swf/DefinitionTag.h
  libcore/swf/tag_loaders.cpp
  libcore/swf/tag_loaders.h
=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am       2010-06-11 09:32:36 +0000
+++ b/libcore/Makefile.am       2010-06-12 06:44:22 +0000
@@ -181,6 +181,8 @@
        ExternalInterface.h \
        swf/tag_loaders.h \
        swf/DefaultTagLoaders.h \
+       swf/ImportAssetsTag.h \
+       swf/ExportAssetsTag.h \
        swf/VideoFrameTag.h \
        swf/DefineVideoStreamTag.h \
        swf/DefineFontAlignZonesTag.h \

=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp     2010-06-11 15:43:47 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp     2010-06-12 08:41:04 +0000
@@ -727,6 +727,8 @@
         log_debug("Exporting symbol %s imported from source %s",
             symbolName, source->get_url());
 #endif
+
+        // NB: we add this symbol with a new id, not its original one.
         registerExport(symbolName, id);
 
         if (Font* f = dynamic_cast<Font*>(res.get())) {
@@ -737,6 +739,8 @@
         else if (SWF::DefinitionTag* ch =
                 dynamic_cast<SWF::DefinitionTag*>(res.get())) {
             // Add this DisplayObject to the loading movie.
+
+            // NB: we add this character with a new id, not its original one.
             addDisplayObject(id, ch);
             ++importedSyms;
         }

=== modified file 'libcore/parser/movie_definition.h'
--- a/libcore/parser/movie_definition.h 2010-06-11 14:03:55 +0000
+++ b/libcore/parser/movie_definition.h 2010-06-12 08:32:05 +0000
@@ -223,8 +223,12 @@
        /// Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded
        virtual size_t  get_loading_frame() const = 0;
 
-       /// Add a DisplayObject with given ID to the CharactersDictionary.
+       /// Add a DefinitionTag with given ID to the CharactersDictionary.
        //
+    /// @param id   The id of the tag. All tags store their own id, but
+    ///             imported characters receive a new id in the importing
+    ///             movie.
+    //
        /// This method is here to be called by DEFINE tags loaders.
        /// The default implementation does nothing.
        virtual void addDisplayObject(boost::uint16_t /*id*/, DefinitionTag* 
/*c*/)

=== modified file 'libcore/swf/DefaultTagLoaders.cpp'
--- a/libcore/swf/DefaultTagLoaders.cpp 2010-01-11 06:41:38 +0000
+++ b/libcore/swf/DefaultTagLoaders.cpp 2010-06-12 06:44:22 +0000
@@ -47,6 +47,8 @@
 #include "DefineVideoStreamTag.h"
 #include "DefineFontNameTag.h"
 #include "VideoFrameTag.h"
+#include "ImportAssetsTag.h"
+#include "ExportAssetsTag.h"
 #ifdef ENABLE_AVM2
 # include "SymbolClassTag.h"
 # include "DoABCTag.h"
@@ -163,8 +165,8 @@
         (TagPair(SWF::PLACEFUNCTION, fixme_loader)) // 54 
         (TagPair(SWF::GENTAGOBJECT, fixme_loader)) // 55 
 
-        (TagPair(SWF::EXPORTASSETS, export_loader)) // 56
-        (TagPair(SWF::IMPORTASSETS, import_loader)) // 57
+        (TagPair(SWF::EXPORTASSETS, ExportAssetsTag::loader)) // 56
+        (TagPair(SWF::IMPORTASSETS, ImportAssetsTag::loader)) // 57
 
         //  We're not an authoring tool so we don't care.
         // (might be nice to dump the password instead..)
@@ -200,7 +202,7 @@
         // 70
         (TagPair(SWF::PLACEOBJECT3, PlaceObject2Tag::loader))
         // 71
-        (TagPair(SWF::IMPORTASSETS2, import_loader))
+        (TagPair(SWF::IMPORTASSETS2, ImportAssetsTag::loader))
         // 73
         (TagPair(SWF::DEFINEALIGNZONES, DefineFontAlignZonesTag::loader))
         // 74

=== modified file 'libcore/swf/DefinitionTag.h'
--- a/libcore/swf/DefinitionTag.h       2010-06-11 10:15:49 +0000
+++ b/libcore/swf/DefinitionTag.h       2010-06-12 08:41:04 +0000
@@ -64,8 +64,15 @@
        virtual DisplayObject* createDisplayObject(Global_as& gl,
             DisplayObject* parent) const = 0;
 
+    /// Executing a DefinitionTag adds its id to list of known characters
+    //
+    /// The process is different for imported DefinitionTags, which are added
+    /// with a new id.
        virtual void executeState(MovieClip* m,  DisplayList& /*dlist*/) const;
 
+    /// The immutable id of the DefinitionTag.
+    //
+    /// @return     the id of the DefinitionTag as parsed from a SWF.
     boost::uint16_t id() const {
         return _id;
     }

=== added file 'libcore/swf/ExportAssetsTag.h'
--- a/libcore/swf/ExportAssetsTag.h     1970-01-01 00:00:00 +0000
+++ b/libcore/swf/ExportAssetsTag.h     2010-06-12 08:30:16 +0000
@@ -0,0 +1,115 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef GNASH_SWF_EXPORTASSETSTAG_H
+#define GNASH_SWF_EXPORTASSETSTAG_H
+
+#include <vector>
+#include <utility>
+#include <string>
+#include <memory>
+
+#include "ControlTag.h"
+#include "Movie.h"
+#include "MovieClip.h"
+#include "SWFStream.h"
+#include "MovieFactory.h"
+#include "log.h"
+
+namespace gnash {
+namespace SWF {
+
+class ExportAssetsTag : public ControlTag
+{
+public:
+
+    typedef std::vector<std::string> Exports;
+
+    // Load an export tag (for exposing internal resources of m)
+    static void loader(SWFStream& in, TagType tag, movie_definition& m,
+            const RunResources& /*r*/)
+    {
+        assert(tag == SWF::EXPORTASSETS); // 56
+
+        std::auto_ptr<ControlTag> t(new ExportAssetsTag(in, m));
+        m.addControlTag(t.release());
+    }
+
+
+    // TODO: use Movie to store the actual exports.
+    virtual void executeState(MovieClip* m, DisplayList& /*l*/) const {
+        Movie* mov = m->get_root();
+        for (Exports::const_iterator it = _exports.begin(), e = _exports.end();
+                it != e; ++it) {
+            const boost::uint16_t id = mov->definition()->exportID(*it);
+
+            // We exported it, so we assume it is known.
+            assert(id);
+            mov->addCharacter(id);
+        }
+    }
+
+private:
+
+    ExportAssetsTag(SWFStream& in, movie_definition& m)
+    {
+        read(in, m);
+    }
+
+    void read(SWFStream& in, movie_definition& m) {
+        
+        in.ensureBytes(2);
+        const boost::uint16_t count = in.read_u16();
+
+        IF_VERBOSE_PARSE(
+            log_parse(_("  export: count = %d"), count);
+        );
+
+        // Read the exports.
+        for (size_t i = 0; i < count; ++i) {
+            in.ensureBytes(2);
+            const boost::uint16_t id = in.read_u16();
+
+            if (!id) continue;
+
+            std::string symbolName;
+            in.read_string(symbolName);
+
+            IF_VERBOSE_PARSE (
+                log_parse(_("  export: id = %d, name = %s"), id, symbolName);
+            );
+
+            // Register export with global map
+            m.registerExport(symbolName, id);
+
+            // Store export for later execution.
+            _exports.push_back(symbolName);
+        }
+
+    }
+
+private:
+
+    Exports _exports;
+
+};
+
+} // namespace SWF
+} // namespace gnash
+
+#endif

=== added file 'libcore/swf/ImportAssetsTag.h'
--- a/libcore/swf/ImportAssetsTag.h     1970-01-01 00:00:00 +0000
+++ b/libcore/swf/ImportAssetsTag.h     2010-06-12 08:41:04 +0000
@@ -0,0 +1,157 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef GNASH_SWF_IMPORTASSETSTAG_H
+#define GNASH_SWF_IMPORTASSETSTAG_H
+
+#include <vector>
+#include <utility>
+#include <string>
+#include <memory>
+
+#include "ControlTag.h"
+#include "Movie.h"
+#include "MovieClip.h"
+#include "SWFStream.h"
+#include "MovieFactory.h"
+#include "log.h"
+
+namespace gnash {
+namespace SWF {
+
+class ImportAssetsTag : public ControlTag
+{
+public:
+
+    typedef std::pair<int, std::string> Import;
+    typedef std::vector<Import> Imports;
+    
+    static void loader(SWFStream& in, TagType tag, movie_definition& m,
+            const RunResources& r)
+    {
+        assert(tag == SWF::IMPORTASSETS || tag == SWF::IMPORTASSETS2);
+
+        std::auto_ptr<ControlTag> p(new ImportAssetsTag(tag, in, m, r));
+        m.addControlTag(p.release());
+    }
+
+
+    /// Execute an ImportAssetsTag.
+    //
+    /// Executing this tag adds the imported definition with an id to the 
+    /// list of known characters. This id may be different from the
+    /// genuine id of the DefinitionTag.
+    virtual void executeState(MovieClip* m, DisplayList& /*l*/) const {
+        Movie* mov = m->get_root();
+        for (Imports::const_iterator it = _imports.begin(), e = _imports.end();
+                it != e; ++it) {
+            mov->addCharacter(it->first);
+        }
+    }
+
+private:
+
+    ImportAssetsTag(TagType t, SWFStream& in, movie_definition& m,
+            const RunResources& r)
+    {
+        read(t, in, m, r);
+    }
+
+    void read(TagType t, SWFStream& in, movie_definition& m,
+            const RunResources& r) {
+
+        std::string source_url;
+        in.read_string(source_url);
+
+        // Resolve relative urls against baseurl
+        URL abs_url(source_url, r.baseURL());
+
+        unsigned char import_version = 0;
+
+        if (t == SWF::IMPORTASSETS2) {
+            in.ensureBytes(2);
+            import_version = in.read_uint(8);
+            boost::uint8_t reserved = in.read_uint(8);
+            UNUSED(reserved);
+        }
+
+        in.ensureBytes(2);
+        const boost::uint16_t count = in.read_u16();
+
+        IF_VERBOSE_PARSE(
+            log_parse(_("  import: version = %u, source_url = %s (%s), "
+                "count = %d"), import_version, abs_url.str(), source_url,
+                count);
+        );
+
+        // Try to load the source movie into the movie library.
+        boost::intrusive_ptr<movie_definition> source_movie;
+
+        try {
+            source_movie = MovieFactory::makeMovie(abs_url, r);
+        }
+        catch (gnash::GnashException& e) {
+            log_error(_("Exception: %s"), e.what());
+        }
+
+        if (!source_movie) {
+            // Give up on imports.
+            log_error(_("can't import movie from url %s"), abs_url.str());
+            return;
+        }
+
+        // Quick consistency check, we might as well do
+        // something smarter, if we agree on semantic
+        if (source_movie == &m) {
+            IF_VERBOSE_MALFORMED_SWF(
+                log_swferror(_("Movie attempts to import symbols from "
+                        "itself."));
+            );
+            return;
+        }
+        
+        // Get the imports.
+        for (size_t i = 0; i < count; ++i)
+        {
+            in.ensureBytes(2);
+            const boost::uint16_t id = in.read_u16();
+
+            // We don't consider 0 valid.
+            if (!id) continue;
+
+            std::string symbolName;
+            in.read_string(symbolName);
+            IF_VERBOSE_PARSE (
+                log_parse(_("  import: id = %d, name = %s"), id, symbolName);
+            );
+            _imports.push_back(std::make_pair(id, symbolName));
+        }
+        
+        m.importResources(source_movie, _imports);
+    }
+
+private:
+
+    Imports _imports;
+
+};
+
+} // namespace SWF
+} // namespace gnash
+
+#endif

=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp       2010-06-11 12:21:46 +0000
+++ b/libcore/swf/tag_loaders.cpp       2010-06-12 06:45:03 +0000
@@ -795,217 +795,6 @@
 
 
 //
-// export
-//
-
-class ExportTag : public ControlTag
-{
-public:
-
-    typedef std::vector<std::string> Exports;
-
-    ExportTag(SWFStream& in, movie_definition& m)
-    {
-        read(in, m);
-    }
-
-    // TODO: use Movie to store the actual exports.
-    virtual void executeState(MovieClip* m, DisplayList& /*l*/) const {
-        Movie* mov = m->get_root();
-        for (Exports::const_iterator it = _exports.begin(), e = _exports.end();
-                it != e; ++it) {
-            const boost::uint16_t id = mov->definition()->exportID(*it);
-
-            // We exported it, so we assume it is known.
-            assert(id);
-            mov->addCharacter(id);
-        }
-    }
-
-private:
-    void read(SWFStream& in, movie_definition& m) {
-        
-        // An EXPORT tag as part of a DEFINESPRITE
-        // would be a malformed SWF, anyway to be compatible
-        // we should still allow that. See bug #22468.
-        IF_VERBOSE_MALFORMED_SWF(
-            try {
-                dynamic_cast<SWFMovieDefinition&>(m);
-            }
-            catch (std::bad_cast& e) {
-                log_swferror(_("EXPORT tag inside DEFINESPRITE. Will export in 
"
-                        "top-level symbol table."));
-            }
-        );
-
-        in.ensureBytes(2);
-        const boost::uint16_t count = in.read_u16();
-
-        IF_VERBOSE_PARSE(
-            log_parse(_("  export: count = %d"), count);
-        );
-
-        // Read the exports.
-        for (size_t i = 0; i < count; ++i) {
-            in.ensureBytes(2);
-            const boost::uint16_t id = in.read_u16();
-
-            if (!id) continue;
-
-            std::string symbolName;
-            in.read_string(symbolName);
-
-            IF_VERBOSE_PARSE (
-                log_parse(_("  export: id = %d, name = %s"), id, symbolName);
-            );
-
-            // Register export with global map
-            m.registerExport(symbolName, id);
-
-            // Store export for later execution.
-            _exports.push_back(symbolName);
-        }
-
-    }
-private:
-    Exports _exports;
-};
-
-// Load an export tag (for exposing internal resources of m)
-void export_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& /*r*/)
-{
-    assert(tag == SWF::EXPORTASSETS); // 56
-
-    std::auto_ptr<ControlTag> t(new ExportTag(in, m));
-    m.addControlTag(t.release());
-}
-
-//
-// import
-//
-
-class ImportTag : public ControlTag
-{
-public:
-
-    typedef std::pair<int, std::string> Import;
-    typedef std::vector<Import> Imports;
-
-    ImportTag(TagType t, SWFStream& in, movie_definition& m,
-            const RunResources& r)
-    {
-        read(t, in, m, r);
-    }
-
-    virtual void executeState(MovieClip* m, DisplayList& /*l*/) const {
-        Movie* mov = m->get_root();
-        for (Imports::const_iterator it = _imports.begin(), e = _imports.end();
-                it != e; ++it) {
-            mov->addCharacter(it->first);
-        }
-    }
-
-    void read(TagType t, SWFStream& in, movie_definition& m,
-            const RunResources& r) {
-
-        std::string source_url;
-        in.read_string(source_url);
-
-        // Resolve relative urls against baseurl
-        URL abs_url(source_url, r.baseURL());
-
-        unsigned char import_version = 0;
-
-        if (t == SWF::IMPORTASSETS2) {
-            in.ensureBytes(2);
-            import_version = in.read_uint(8);
-            boost::uint8_t reserved = in.read_uint(8);
-            UNUSED(reserved);
-        }
-
-        in.ensureBytes(2);
-        const boost::uint16_t count = in.read_u16();
-
-        IF_VERBOSE_PARSE(
-            log_parse(_("  import: version = %u, source_url = %s (%s), "
-                "count = %d"), import_version, abs_url.str(), source_url,
-                count);
-        );
-
-        // Try to load the source movie into the movie library.
-        boost::intrusive_ptr<movie_definition> source_movie;
-
-        try {
-            source_movie = MovieFactory::makeMovie(abs_url, r);
-        }
-        catch (gnash::GnashException& e) {
-            log_error(_("Exception: %s"), e.what());
-        }
-
-        if (!source_movie) {
-            // Give up on imports.
-            log_error(_("can't import movie from url %s"), abs_url.str());
-            return;
-        }
-
-        // Quick consistency check, we might as well do
-        // something smarter, if we agree on semantic
-        if (source_movie == &m) {
-            IF_VERBOSE_MALFORMED_SWF(
-                log_swferror(_("Movie attempts to import symbols from "
-                        "itself."));
-            );
-            return;
-        }
-        
-        // Get the imports.
-        for (size_t i = 0; i < count; ++i)
-        {
-            in.ensureBytes(2);
-            const boost::uint16_t id = in.read_u16();
-
-            // We don't consider 0 valid.
-            if (!id) continue;
-
-            std::string symbolName;
-            in.read_string(symbolName);
-            IF_VERBOSE_PARSE (
-                log_parse(_("  import: id = %d, name = %s"), id, symbolName);
-            );
-            _imports.push_back(std::make_pair(id, symbolName));
-        }
-        // An EXPORT tag as part of a DEFINESPRITE
-        // would be a malformed SWF, anyway to be compatible
-        // we should still allow that. See bug #22468.
-        IF_VERBOSE_MALFORMED_SWF(
-            try {
-                dynamic_cast<SWFMovieDefinition&>(m);
-            }
-            catch (std::bad_cast& e) {
-                log_swferror(_("EXPORT tag inside DEFINESPRITE. Will export in 
"
-                        "top-level symbol table."));
-            }
-        );
-        m.importResources(source_movie, _imports);
-    }
-
-private:
-
-    Imports _imports;
-
-};
-
-void import_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
-{
-    assert(tag == SWF::IMPORTASSETS || tag == SWF::IMPORTASSETS2);
-
-    std::auto_ptr<ControlTag> p(new ImportTag(tag, in, m, r));
-    m.addControlTag(p.release());
-}
-
-//
 // Sound
 //
 

=== modified file 'libcore/swf/tag_loaders.h'
--- a/libcore/swf/tag_loaders.h 2010-05-20 10:21:58 +0000
+++ b/libcore/swf/tag_loaders.h 2010-06-12 06:44:22 +0000
@@ -94,11 +94,6 @@
 void frame_label_loader(SWFStream&, TagType, movie_definition&,
                const RunResources&);
 
-void export_loader(SWFStream&, TagType, movie_definition&, const 
RunResources&);
-
-/// Load an SWF::IMPORTASSETS or SWF::IMPORTASSETS2 tag (for pulling in 
external resources)
-void import_loader(SWFStream&, TagType, movie_definition&, const 
RunResources&);
-
 /// Load a SWF::DEFINESOUND tag.
 void define_sound_loader(SWFStream&, TagType, movie_definition&,
                const RunResources&);


reply via email to

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