Gnash 0.8.9
|
00001 // 00002 // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00017 00018 #ifndef GNASH_SWF_DOABCTAG_H 00019 #define GNASH_SWF_DOABCTAG_H 00020 00021 #include <string> 00022 #include "ControlTag.h" // for inheritance 00023 #include "SWF.h" // for tag_type definition 00024 #include "MovieClip.h" // for inlines 00025 #include "SWFStream.h" // for inlines 00026 #include "AbcBlock.h" 00027 #include "Machine.h" 00028 #include "VM.h" 00029 00030 // Forward declarations 00031 namespace gnash { 00032 class movie_definition; 00033 } 00034 00035 namespace gnash { 00036 namespace SWF { 00037 00039 // 00041 class DoABCTag : public ControlTag 00042 { 00043 public: 00044 00045 virtual void executeActions(MovieClip* m, DisplayList& /* dlist */) const 00046 { 00047 00048 if (!_abc) { 00049 log_debug("Not executing ABC tag because we failed to parse it"); 00050 return; 00051 } 00052 00053 VM& vm = getVM(*getObject(m)); 00054 00055 log_debug("getting machine."); 00056 abc::Machine *mach = vm.getMachine(); 00057 00058 _abc->prepare(mach); 00059 00060 log_debug("Begin execute AbcBlock."); 00061 mach->initMachine(_abc); 00062 log_debug("Executing machine..."); 00063 mach->execute(); 00064 } 00065 00066 void read(SWFStream* /*in*/) 00067 { 00068 } 00069 00070 static void loader(SWFStream& in, TagType tag, movie_definition& m, 00071 const gnash::RunResources&) 00072 { 00073 00074 if (!m.isAS3()) { 00075 IF_VERBOSE_MALFORMED_SWF( 00076 log_swferror("SWF contains ABC tag, but is not an " 00077 "AS3 SWF!"); 00078 ); 00079 throw ParserException("ABC tag found in non-AS3 SWF!"); 00080 } 00081 00082 if (tag == SWF::DOABCDEFINE) { 00083 in.ensureBytes(4); 00084 static_cast<void> (in.read_u32()); 00085 std::string name; 00086 in.read_string(name); 00087 } 00088 00089 std::auto_ptr<abc::AbcBlock> block(new abc::AbcBlock()); 00090 if (!block->read(in)) { 00091 log_error("ABC parsing error while processing DoABCTag. This " 00092 "tag will never be executed"); 00093 return; 00094 } 00095 00096 // _abc = block; 00097 boost::intrusive_ptr<DoABCTag> ABCtag(new DoABCTag(block.release())); 00098 00099 IF_VERBOSE_PARSE ( 00100 log_parse(_("tag %d: DoABCDefine"), tag); 00101 log_parse(_("-- actions in frame %d"), m.get_loading_frame()); 00102 ); 00103 00104 m.addControlTag(ABCtag); // ownership transferred 00105 } 00106 00107 private: 00108 00109 DoABCTag(abc::AbcBlock* block) : _abc(block) {} 00110 00111 abc::AbcBlock* _abc; 00112 00113 }; 00114 00115 } // namespace gnash::SWF 00116 } // namespace gnash 00117 00118 00119 #endif // GNASH_SWF_DOABCTAG_H 00120 00121 00122 // Local Variables: 00123 // mode: C++ 00124 // indent-tabs-mode: t 00125 // End: