Gnash 0.8.9

ScriptLimitsTag.h

Go to the documentation of this file.
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_SCRIPTLIMITSTAG_H
00019 #define GNASH_SWF_SCRIPTLIMITSTAG_H
00020 
00021 #include "SWF.h" // for TagType definition
00022 #include "SWFStream.h" // for inlines
00023 #include "movie_root.h"
00024 #include "movie_definition.h"
00025 #include "ControlTag.h"
00026 
00027 namespace gnash {
00028 namespace SWF {
00029 
00031 //
00035 class ScriptLimitsTag : public ControlTag
00036 {
00037 public:
00038 
00039     virtual ~ScriptLimitsTag() {}
00040 
00041     virtual void executeState(MovieClip* m, DisplayList& /*dl*/) const {
00042 
00043         LOG_ONCE( // movie_root will always log on change
00044         log_debug("Setting script limits: recursion %s, timeout %s",
00045                 _recursionLimit, _timeoutLimit);
00046         );
00047         getRoot(*getObject(m)).setScriptLimits(_recursionLimit, _timeoutLimit);
00048     }
00049 
00050     static void loader(SWFStream& in, TagType tag, movie_definition& m,
00051             const RunResources& /*r*/)
00052     {
00053         assert(tag = SWF::SCRIPTLIMITS);
00054         boost::intrusive_ptr<ControlTag> s(new ScriptLimitsTag(in));
00055         m.addControlTag(s);
00056     }
00057 
00058 private:
00059 
00060     ScriptLimitsTag(SWFStream& in)
00061         :
00062         _recursionLimit(0),
00063         _timeoutLimit(0)
00064     {
00065         in.ensureBytes(4); 
00066         _recursionLimit = in.read_u16();
00067         _timeoutLimit = in.read_u16();      
00068 
00069         IF_VERBOSE_PARSE (
00070             log_parse(_("  ScriptLimits tag: recursion: %d, timeout: %d"),
00071                     _recursionLimit, _timeoutLimit);
00072             );
00073 
00074     }
00075     
00076     boost::uint16_t _recursionLimit;
00077     boost::uint16_t _timeoutLimit;
00078 };
00079 
00080 } // namespace gnash::SWF
00081 } // namespace gnash
00082 
00083 
00084 #endif // GNASH_SWF_SCRIPTLIMITSTAG_H
00085 
00086 
00087 // Local Variables:
00088 // mode: C++
00089 // indent-tabs-mode: t
00090 // End: