remove revno.h for distclean
[gnash.git] / libcore / swf / DoInitActionTag.h
blobde5d59479c6d7b60af5fee84f472ad84c8601459
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef GNASH_SWF_DOINITACTIONTAG_H
19 #define GNASH_SWF_DOINITACTIONTAG_H
21 #include "ControlTag.h" // for inheritance
22 #include "SWF.h" // for TagType definition
23 #include "action_buffer.h" // for composition
24 #include "MovieClip.h" // for inlines
25 #include "SWFStream.h" // for inlines
27 // Forward declarations
28 namespace gnash {
29 class movie_definition;
32 namespace gnash {
33 namespace SWF {
35 /// SWF Tag DoInitAction (59)
37 /// Thin wrapper around action_buffer.
38 ///
39 class DoInitActionTag : public ControlTag
41 public:
43 DoInitActionTag(SWFStream& in, movie_definition& md, int cid)
45 _buf(md),
46 _cid(cid)
48 read(in);
51 /// Execute 'state' tags.
53 /// State tags change the current state of a MovieClip. They are executed
54 /// even for skipped frames to ensure that the state is consistent.
56 /// Even though DoInitAction tags contain ActionScript, they are considered
57 /// to be state tags. They are executed only once.
58 virtual void executeState(MovieClip* m, DisplayList& /*dlist*/) const {
59 m->execute_init_action_buffer(_buf, _cid);
62 static void loader(SWFStream& in, TagType tag, movie_definition& m,
63 const RunResources& /*r*/)
65 if (m.isAS3()) {
66 IF_VERBOSE_MALFORMED_SWF(
67 log_swferror("SWF contains DoInitAction tag, but is an "
68 "AS3 SWF!");
70 throw ParserException("DoInitAction tag found in AS3 SWF!");
73 in.ensureBytes(2);
74 const boost::uint16_t cid = in.read_u16();
76 IF_VERBOSE_PARSE(
77 log_parse(_(" tag %d: do_init_action_loader"), tag);
78 log_parse(_(" -- init actions for sprite %d"), cid);
81 // TODO: Currently, tags are only be executed for already parsed
82 // character ids. This is known to be wrong: a more accurate
83 // description is:
85 // The DoInitAction tag is executed only for characters on the stage
86 // or exported characters. It is only executed once.
88 // It's not known whether characters that were placed on the stage
89 // but then removed before the InitAction tag is encountered cause
90 // the actions to be executed.
92 // Gnash currently doesn't know which characters are on the stage, or
93 // which IDs have been exported.
94 boost::intrusive_ptr<ControlTag> da(new DoInitActionTag(in, m, cid));
95 m.addControlTag(da); // ownership transferred
98 private:
100 /// Read a DoInitAction block from the SWFStream
102 void read(SWFStream& in)
104 _buf.read(in, in.get_tag_end_position());
108 action_buffer _buf;
110 // id of referenced DisplayObject definition
111 int _cid;
114 } // namespace gnash::SWF
115 } // namespace gnash
118 #endif // GNASH_SWF_DOINITACTIONTAG_H
121 // Local Variables:
122 // mode: C++
123 // indent-tabs-mode: t
124 // End: