Gnash  0.8.11dev
ScriptLimitsTag.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_SWF_SCRIPTLIMITSTAG_H
20 #define GNASH_SWF_SCRIPTLIMITSTAG_H
21 
22 #include "SWF.h" // for TagType definition
23 #include "SWFStream.h" // for inlines
24 #include "movie_root.h"
25 #include "movie_definition.h"
26 #include "ControlTag.h"
27 
28 namespace gnash {
29 namespace SWF {
30 
32 //
37 {
38 public:
39 
40  virtual ~ScriptLimitsTag() {}
41 
42  virtual void executeState(MovieClip* m, DisplayList& /*dl*/) const {
43 
44  LOG_ONCE( // movie_root will always log on change
45  log_debug("Setting script limits: recursion %s, timeout %s",
46  _recursionLimit, _timeoutLimit);
47  );
48  getRoot(*getObject(m)).setScriptLimits(_recursionLimit, _timeoutLimit);
49  }
50 
51  static void loader(SWFStream& in, TagType tag, movie_definition& m,
52  const RunResources& /*r*/)
53  {
54  assert(tag == SWF::SCRIPTLIMITS);
55  boost::intrusive_ptr<ControlTag> s(new ScriptLimitsTag(in));
56  m.addControlTag(s);
57  }
58 
59 private:
60 
62  :
63  _recursionLimit(0),
64  _timeoutLimit(0)
65  {
66  in.ensureBytes(4);
67  _recursionLimit = in.read_u16();
68  _timeoutLimit = in.read_u16();
69 
71  log_parse(_(" ScriptLimits tag: recursion: %d, timeout: %d"),
72  _recursionLimit, _timeoutLimit);
73  );
74 
75  }
76 
77  boost::uint16_t _recursionLimit;
78  boost::uint16_t _timeoutLimit;
79 };
80 
81 } // namespace gnash::SWF
82 } // namespace gnash
83 
84 
85 #endif // GNASH_SWF_SCRIPTLIMITSTAG_H
86 
87 
88 // Local Variables:
89 // mode: C++
90 // indent-tabs-mode: t
91 // End: