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  std::uint16_t _recursionLimit;
78  std::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:
Definition: SWF.h:95
std::uint16_t read_u16()
Read a aligned unsigned 16-bit value from the stream.
Definition: SWFStream.cpp:332
Client program&#39;s interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
A MovieClip is a container for DisplayObjects.
Definition: MovieClip.h:83
Sets the desired limits for recursion and timeout for AS scripts.
Definition: ScriptLimitsTag.h:36
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
virtual ~ScriptLimitsTag()
Definition: ScriptLimitsTag.h:40
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
#define IF_VERBOSE_PARSE(x)
Definition: log.h:378
Control tags are swf tags that control the operation of the movie.
Definition: ControlTag.h:43
void log_parse(StringType msg, Args... args)
Definition: log.h:313
virtual void executeState(MovieClip *m, DisplayList &) const
Execute "state" or "DisplayList" tags.
Definition: ScriptLimitsTag.h:42
#define _(String)
Definition: log.h:44
void setScriptLimits(std::uint16_t recursion, std::uint16_t timeout)
Definition: movie_root.cpp:2285
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:53
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &)
Definition: ScriptLimitsTag.h:51
Definition: GnashKey.h:159
Definition: GnashKey.h:165
void log_debug(StringType msg, Args... args)
Definition: log.h:301
virtual void addControlTag(boost::intrusive_ptr< SWF::ControlTag >)
Add an ControlTag to this movie_definition&#39;s playlist.
Definition: movie_definition.h:273
A list of on-stage DisplayObjects, ordered by depth.
Definition: DisplayList.h:64
Definition: GnashKey.h:331
as_object * getObject(const DisplayObject *d)
Return the as_object associated with a DisplayObject if it exists.
Definition: DisplayObject.h:1160
SWF stream wrapper class.
Definition: SWFStream.h:58
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645
#define LOG_ONCE(x)
Definition: log.h:49
void ensureBytes(unsigned long needed)
Ensure the requested number of bytes are available for an aligned read in the currently opened tag...
Definition: SWFStream.cpp:50