gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10880: Don't use a separate naming


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10880: Don't use a separate naming style for AVM2 names in VM.
Date: Mon, 18 May 2009 15:41:45 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 10880
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-05-18 15:41:45 +0200
message:
  Don't use a separate naming style for AVM2 names in VM.
  
  Implement SymbolClassTag fully (but not tested properly).
  
  Check file attributes for whether to use AVM2, and notify when the wrong
  tags are present. Currently we also throw a parsing exception to avoid
  adding code of the wrong type, but whether the file attribute is definitive
  needs more testing. This attribute should also be used for other VM-specific
  code (e.g. TextField constructor) in place of SWF version, which is wrong.
modified:
  libcore/impl.cpp
  libcore/parser/SWFMovieDefinition.cpp
  libcore/parser/SWFMovieDefinition.h
  libcore/parser/movie_definition.h
  libcore/parser/sprite_definition.h
  libcore/swf/DoABCTag.h
  libcore/swf/DoActionTag.h
  libcore/swf/DoInitActionTag.h
  libcore/swf/SymbolClassTag.h
  libcore/swf/tag_loaders.cpp
  libcore/vm/VM.cpp
  libcore/vm/VM.h
=== modified file 'libcore/impl.cpp'
--- a/libcore/impl.cpp  2009-05-14 12:34:16 +0000
+++ b/libcore/impl.cpp  2009-05-18 13:41:45 +0000
@@ -127,7 +127,7 @@
     register_tag_loader(SWF::SETBACKGROUNDCOLOR, 
SetBackgroundColorTag::loader);
     register_tag_loader(SWF::DEFINEFONT, DefineFontTag::loader);
     register_tag_loader(SWF::DEFINETEXT, DefineTextTag::loader);
-    register_tag_loader(SWF::DOACTION,  DoActionTag::doActionLoader);
+    register_tag_loader(SWF::DOACTION,  DoActionTag::loader);
     register_tag_loader(SWF::DEFINEFONTINFO, DefineFontInfoTag::loader);
     // 62
     register_tag_loader(SWF::DEFINEFONTINFO2, DefineFontInfoTag::loader);
@@ -198,8 +198,8 @@
     // (might be nice to dump the password instead..)
     register_tag_loader(SWF::ENABLEDEBUGGER, null_loader);    // 58
 
-    register_tag_loader(SWF::INITACTION, DoInitActionTag::doInitActionLoader); 
 // 59  
-
+    // 59
+    register_tag_loader(SWF::INITACTION, DoInitActionTag::loader); 
     // 60
     register_tag_loader(SWF::DEFINEVIDEOSTREAM, DefineVideoStreamTag::loader);
     // 61
@@ -252,11 +252,11 @@
 
 #ifdef ENABLE_AVM2
     // 72 -- AS3 codeblock.
-    register_tag_loader(SWF::DOABC, DoABCTag::doABCLoader); 
+    register_tag_loader(SWF::DOABC, DoABCTag::loader); 
     // 76
     register_tag_loader(SWF::SYMBOLCLASS, SymbolClassTag::loader);
     // 82
-    register_tag_loader(SWF::DOABCDEFINE, DoABCTag::doABCLoader);
+    register_tag_loader(SWF::DOABCDEFINE, DoABCTag::loader);
     // 86
     register_tag_loader(SWF::DEFINESCENEANDFRAMELABELDATA,
             define_scene_frame_label_loader);

=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp     2009-05-14 11:45:23 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp     2009-05-18 13:41:45 +0000
@@ -199,7 +199,8 @@
        m_jpeg_in(0),
        _loader(*this),
        _loadingCanceled(false),
-    _runInfo(runInfo)
+    _runInfo(runInfo),
+    _as3(false)
 {
 }
 

=== modified file 'libcore/parser/SWFMovieDefinition.h'
--- a/libcore/parser/SWFMovieDefinition.h       2009-04-15 09:08:37 +0000
+++ b/libcore/parser/SWFMovieDefinition.h       2009-05-18 13:41:45 +0000
@@ -149,7 +149,8 @@
        /// Return a const_iterator to one-past last dictionary element
        CharacterConstIterator end() const { return _map.end(); }
 
-    friend std::ostream& operator<<(std::ostream& o, const 
CharacterDictionary& cd);
+    friend std::ostream& operator<<(std::ostream& o,
+            const CharacterDictionary& cd);
 
 #ifdef GNASH_USE_GC
        /// Mark all dictionary items to be reachable (for GC)
@@ -202,6 +203,16 @@
                return std::ceil(twipsToPixels(m_frame_size.height()));
        }
 
+    /// Call this to inform callers that tags should be executed using AVM2
+    void setAS3() {
+        _as3 = true;
+    }
+    
+    /// Check whether tags should be executed using AVM2
+    bool isAS3() const {
+        return _as3;
+    }
+
        virtual int     get_version() const { return m_version; }
 
        /// Get the number of fully loaded frames
@@ -249,7 +260,7 @@
 
        /// \brief
        /// Return a DisplayObject from the dictionary
-    SWF::DefinitionTag* getDefinitionTag(int DisplayObject_id) const;
+    SWF::DefinitionTag* getDefinitionTag(int id) const;
 
        // See dox in movie_definition
        //
@@ -565,6 +576,8 @@
     ///         movie_root with the same RunInfo as its first definition.
     const RunInfo& _runInfo;
 
+    bool _as3;
+
 };
 
 } // namespace gnash

=== modified file 'libcore/parser/movie_definition.h'
--- a/libcore/parser/movie_definition.h 2009-04-28 15:22:32 +0000
+++ b/libcore/parser/movie_definition.h 2009-05-18 13:41:45 +0000
@@ -407,6 +407,19 @@
        {
        }
 
+    /// Set whether the SWFMovie should use AVM2 or AVM1.
+    //
+    /// This is only sensible for SWFMovieDefinitions, so is a no-op here.
+    virtual void setAS3() {
+    }
+
+    /// True if the SWFMovie should use AVM2.
+    //
+    /// This is only sensible for SWFMovieDefinitions, and shouldn't be
+    /// here once this inheritance mess is cleaned up.
+    virtual bool isAS3() const {
+        return false;
+    }
 
        /// \brief
        /// Return the URL of the SWF stream this definition has been read

=== modified file 'libcore/parser/sprite_definition.h'
--- a/libcore/parser/sprite_definition.h        2009-05-14 11:45:23 +0000
+++ b/libcore/parser/sprite_definition.h        2009-05-18 13:41:45 +0000
@@ -235,6 +235,11 @@
        virtual DisplayObject* createDisplayObject(DisplayObject* parent, int 
id)
         const;
 
+       // See dox in movie_definition.h
+       virtual void addControlTag(SWF::ControlTag* c)
+       {
+               m_playlist[m_loading_frame].push_back(c);
+       }
 
 private:
 
@@ -264,11 +269,6 @@
        size_t m_loading_frame;
 
 
-       // See dox in movie_definition.h
-       virtual void addControlTag(SWF::ControlTag* c)
-       {
-               m_playlist[m_loading_frame].push_back(c);
-       }
 
        // See dox in movie_definition.h
        virtual void add_frame_name(const std::string& name);

=== modified file 'libcore/swf/DoABCTag.h'
--- a/libcore/swf/DoABCTag.h    2009-03-25 11:02:48 +0000
+++ b/libcore/swf/DoABCTag.h    2009-05-18 13:41:45 +0000
@@ -75,9 +75,18 @@
     {
     }
        
-       static void doABCLoader(SWFStream& in, TagType tag,
-                       movie_definition& m, const gnash::RunInfo&)
+       static void loader(SWFStream& in, TagType tag, movie_definition& m,
+            const gnash::RunInfo&)
        {
+
+        if (!m.isAS3()) {
+            IF_VERBOSE_MALFORMED_SWF(
+                log_swferror("SWF contains ABC tag, but is not an "
+                    "AS3 SWF!");
+            );
+            throw ParserException("ABC tag found in non-AS3 SWF!");
+        }
+
                if (tag == SWF::DOABCDEFINE) {
                        in.ensureBytes(4);
                        static_cast<void> (in.read_u32());
@@ -87,14 +96,13 @@
 
                abc_block* block = new abc_block();
                block->read(in);
-//             mABC = block;
-               DoABCTag *ABCtag = new DoABCTag(block);
+        // mABC = block;
+               DoABCTag* ABCtag = new DoABCTag(block);
                
-/*
                IF_VERBOSE_PARSE (
-               log_parse(_("tag %d: do_action_loader"), tag);
-               log_parse(_("-- actions in frame %d"), m->get_loading_frame());
-               );*/
+            log_parse(_("tag %d: DoABCDefine"), tag);
+            log_parse(_("-- actions in frame %d"), m.get_loading_frame());
+               );
 
                m.addControlTag(ABCtag); // ownership transferred
        }

=== modified file 'libcore/swf/DoActionTag.h'
--- a/libcore/swf/DoActionTag.h 2009-02-20 12:24:00 +0000
+++ b/libcore/swf/DoActionTag.h 2009-05-18 13:41:45 +0000
@@ -63,9 +63,17 @@
            return true;
        }
 
-       static void doActionLoader(SWFStream& in, TagType tag,
-            movie_definition& m, const RunInfo& /*r*/)
+       static void loader(SWFStream& in, TagType tag, movie_definition& m,
+            const RunInfo& /*r*/)
        {
+        if (m.isAS3()) {
+            IF_VERBOSE_MALFORMED_SWF(
+                log_swferror("SWF contains DoAction tag, but is an "
+                    "AS3 SWF!");
+            );
+            throw ParserException("DoAction tag found in AS3 SWF!");
+        }
+        
                DoActionTag* da = new DoActionTag(m);
                da->read(in);
 

=== modified file 'libcore/swf/DoInitActionTag.h'
--- a/libcore/swf/DoInitActionTag.h     2009-05-14 11:45:23 +0000
+++ b/libcore/swf/DoInitActionTag.h     2009-05-18 13:41:45 +0000
@@ -64,9 +64,17 @@
         return true;
     }
 
-    static void doInitActionLoader(SWFStream& in, TagType tag,
-            movie_definition& m, const RunInfo& /*r*/)
+    static void loader(SWFStream& in, TagType tag, movie_definition& m,
+            const RunInfo& /*r*/)
     {
+        if (m.isAS3()) {
+            IF_VERBOSE_MALFORMED_SWF(
+                log_swferror("SWF contains DoInitAction tag, but is an "
+                    "AS3 SWF!");
+            );
+            throw ParserException("DoInitAction tag found in AS3 SWF!");
+        }
+        
         in.ensureBytes(2);
         int cid = in.read_u16();
         DoInitActionTag* da = new DoInitActionTag(in, m, cid);

=== modified file 'libcore/swf/SymbolClassTag.h'
--- a/libcore/swf/SymbolClassTag.h      2009-05-14 11:41:42 +0000
+++ b/libcore/swf/SymbolClassTag.h      2009-05-18 13:41:45 +0000
@@ -59,25 +59,30 @@
        {
            return true;
        }
-       static void loader(SWFStream& in, TagType tag,
-                       movie_definition& m, const RunInfo& /*r*/)
+
+       static void loader(SWFStream& in, TagType tag, movie_definition& m,
+            const RunInfo& /*r*/)
        {
-               assert(tag == SYMBOLCLASS); //76
+               assert(tag == SYMBOLCLASS); 
 
-               log_unimpl(_("%s tag parsed but not yet used"), "SYMBOLCLASS");
                in.ensureBytes(2);
                boost::uint16_t num_symbols = in.read_u16();
                log_debug("There are %u symbols.", num_symbols);
                for (unsigned int i = 0; i < num_symbols; ++i) {
                        in.ensureBytes(2);
-                       boost::uint16_t character = in.read_u16();
+                       boost::uint16_t id = in.read_u16();
                        std::string name;
                        in.read_string(name);
-                       log_debug("Symbol %u name=%s tag=%u", i, name, 
character);
-                       if (character == 0) {
-                               SymbolClassTag *symbolClassTag = new 
SymbolClassTag(name);
-                               m.addControlTag(symbolClassTag);
-                       }
+                       log_parse("Symbol %u name=%s tag=%u", i, name, id);
+            
+            SymbolClassTag* st = new SymbolClassTag(name);
+                       
+            if (id == 0) m.addControlTag(st);
+            else {
+                sprite_definition* s =
+                    dynamic_cast<sprite_definition*>(m.getDefinitionTag(id));
+                if (s) s->addControlTag(st);
+            }
                }
        }
 

=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp       2009-05-14 11:45:23 +0000
+++ b/libcore/swf/tag_loaders.cpp       2009-05-18 13:41:45 +0000
@@ -1178,16 +1178,17 @@
 
 
 void
-file_attributes_loader(SWFStream& in, TagType tag, movie_definition& /*m*/,
+file_attributes_loader(SWFStream& in, TagType tag, movie_definition& m,
         const RunInfo& /*r*/)
 {
     assert(tag == SWF::FILEATTRIBUTES); // 69
 
     struct file_attrs_flags {
         unsigned reserved1;
-        unsigned has_metadata;
+        bool metadata;
+        bool as3;
         unsigned reserved2;
-        unsigned use_network;
+        bool network;
         unsigned reserved3;
     };
 
@@ -1195,32 +1196,42 @@
 
     in.ensureBytes(1 + 3);
     flags.reserved1 = in.read_uint(3);
-    flags.has_metadata = in.read_bit(); 
-    flags.reserved2 = in.read_uint(3);
-    flags.use_network = in.read_bit(); 
+    flags.metadata = in.read_bit(); 
+    flags.as3 = in.read_bit();
+    flags.reserved2 = in.read_uint(2);
+    flags.network = in.read_bit(); 
     flags.reserved3 = in.read_uint(24);
 
     IF_VERBOSE_PARSE
     (
-    log_parse(_("  file attributes: has_metadata=%s use_network=%s"),
-          flags.has_metadata ? _("true") : _("false"),
-          flags.use_network ? _("true") : _("false"))
+        log_parse(_("File attributes: metadata=%s network=%s"),
+              flags.metadata ? _("true") : _("false"),
+              flags.network ? _("true") : _("false"))
     );
 
-    if ( ! flags.use_network )
-    {
-    log_unimpl(_("FileAttributes tag in the SWF requests that "
-            "network access is not granted to this movie "
-            "(or application?) when loaded from the filesystem. "
-                "Anyway Gnash won't care; "
-            "use white/black listing in your .gnashrc instead"));
-    }
-
-    // TODO:
-    //     - attach info to movie_definition.
-    //     - don't allow later FileAttributes tags in the same movie
-    //       to override the first one used.
-    //     - only use if it is the *first* tag in the SWFStream.
+    if (!flags.network) {
+        log_unimpl(_("FileAttributes tag in the SWF requests that "
+                "network access is not granted to this movie "
+                "(or application?) when loaded from the filesystem. "
+                    "Anyway Gnash won't care; "
+                "use white/black listing in your .gnashrc instead"));
+    }
+
+    if (flags.as3) {
+        log_debug("This SWF uses AVM2 / AS3");
+#ifndef ENABLE_AVM2
+    /// Log an error if this build can't interpret AS3.
+        log_error(_("This SWF file requires AVM2, which was not enabled at "
+                    "compile time."));
+#endif
+    }
+
+    // TODO: - don't allow later FileAttributes tags in the same movie
+    //         to override the first one used.
+    //       - only use if it is the *first* tag in the SWFStream.
+
+    if (flags.as3) m.setAS3();
+
 }
 
 

=== modified file 'libcore/vm/VM.cpp'
--- a/libcore/vm/VM.cpp 2009-05-14 11:45:23 +0000
+++ b/libcore/vm/VM.cpp 2009-05-18 13:41:45 +0000
@@ -64,13 +64,13 @@
        _singleton.reset(new VM(version, root, clock));
 
        assert(_singleton.get());
-       NSV::loadStrings(_singleton->mStringTable, _singleton->getSWFVersion());
+       NSV::loadStrings(_singleton->_stringTable, _singleton->getSWFVersion());
 
-       _singleton->mClassHierarchy.reset(new ClassHierarchy);
-       _singleton->setGlobal(new Global(*_singleton, 
_singleton->mClassHierarchy.get()));
+       _singleton->_classHierarchy.reset(new ClassHierarchy);
+       _singleton->setGlobal(new Global(*_singleton, 
_singleton->_classHierarchy.get()));
 
 #ifdef ENABLE_AVM2
-       _singleton->mMachine = new Machine(*_singleton);
+       _singleton->_machine = new Machine(*_singleton);
        assert(_singleton->getGlobal());
 #endif
 
@@ -96,7 +96,7 @@
        _rootMovie(root),
        _swfversion(version),
 #ifdef ENABLE_AVM2
-    mMachine(0),
+    _machine(0),
 #endif
        _clock(clock),
        _stack(),
@@ -245,7 +245,7 @@
                (*i)->setReachable();
        }
 
-       mClassHierarchy->markReachableResources();
+       _classHierarchy->markReachableResources();
 
     if (_shLib.get()) _shLib->markReachableResources();
 #endif

=== modified file 'libcore/vm/VM.h'
--- a/libcore/vm/VM.h   2009-05-14 10:26:47 +0000
+++ b/libcore/vm/VM.h   2009-05-18 13:41:45 +0000
@@ -166,11 +166,11 @@
        unsigned long int getTime() const;
 
        /// Get a reference to the string table used by the VM.
-       string_table& getStringTable() const { return mStringTable; }
+       string_table& getStringTable() const { return _stringTable; }
 
 #ifdef ENABLE_AVM2
        /// Get a pointer to the machine, if it exists.
-       Machine* getMachine() const { return mMachine; }
+       Machine* getMachine() const { return _machine; }
 #endif
 
        /// Get version of the player, in a compatible representation
@@ -233,7 +233,7 @@
        as_object* getGlobal() const;
 
        /// Get a pointer to this VM's global ClassHierarchy object.
-       ClassHierarchy* getClassHierarchy() const { return 
mClassHierarchy.get(); }
+       ClassHierarchy* getClassHierarchy() const { return 
_classHierarchy.get(); }
        
        /// Mark all reachable resources (for GC)
        //
@@ -296,7 +296,8 @@
        void setGlobal(as_object*);
 
 #ifdef GNASH_USE_GC
-       /// A vector of static GcResources (tipically used for built-in class 
constructors)
+       /// A vector of static GcResources (typically used for built-in
+    /// class constructors)
        //
        /// The resources in this list will always be marked as reachable
        ///
@@ -309,14 +310,14 @@
        AsNativeTable _asNativeTable;
 
        /// Mutable since it should not affect how the VM runs.
-       mutable string_table mStringTable;
+       mutable string_table _stringTable;
 
        /// Not mutable since changing this changes behavior of the VM.
-       std::auto_ptr<ClassHierarchy> mClassHierarchy;
+       std::auto_ptr<ClassHierarchy> _classHierarchy;
 
 #ifdef ENABLE_AVM2
        /// A running execution thread.
-       Machine *mMachine;
+       Machine *_machine;
 #endif
 
        VirtualClock& _clock;


reply via email to

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