update copyright date
[gnash.git] / libcore / swf / DefaultTagLoaders.cpp
blob80ebea795e3c1228a06d93ef1c26941e43c37aac
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 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
19 #ifdef HAVE_CONFIG_H
20 #include "gnashconfig.h"
21 #endif
23 #include "DefaultTagLoaders.h"
25 #include <boost/assign.hpp>
26 #include <set>
28 #include "SWF.h"
29 #include "TagLoadersTable.h"
30 #include "tag_loaders.h"
31 #include "ScriptLimitsTag.h"
32 #include "DefineFontAlignZonesTag.h"
33 #include "DefineShapeTag.h"
34 #include "DefineButtonCxformTag.h"
35 #include "CSMTextSettingsTag.h"
36 #include "DefineFontTag.h"
37 #include "DefineButtonTag.h"
38 #include "DefineScalingGridTag.h"
39 #include "DefineTextTag.h"
40 #include "PlaceObject2Tag.h"
41 #include "RemoveObjectTag.h"
42 #include "DoActionTag.h"
43 #include "DoInitActionTag.h"
44 #include "DefineEditTextTag.h"
45 #include "SetBackgroundColorTag.h"
46 #include "SetTabIndexTag.h"
47 #include "StartSoundTag.h"
48 #include "StreamSoundBlockTag.h"
49 #include "DefineBitsTag.h"
50 #include "DefineButtonSoundTag.h"
51 #include "DefineMorphShapeTag.h"
52 #include "DefineVideoStreamTag.h"
53 #include "DefineFontNameTag.h"
54 #include "VideoFrameTag.h"
55 #include "ImportAssetsTag.h"
56 #include "ExportAssetsTag.h"
57 #ifdef ENABLE_AVM2
58 # include "SymbolClassTag.h"
59 # include "DoABCTag.h"
60 # include "DefineSceneAndFrameLabelDataTag.h"
61 #endif
63 namespace gnash {
64 namespace SWF {
67 namespace {
69 typedef TagLoadersTable::Loaders::value_type TagPair;
71 class AddLoader
73 public:
75 AddLoader(TagLoadersTable& table)
77 _table(table)
80 void operator()(const TagPair& p) {
81 _table.registerLoader(p.first, p.second);
83 private:
84 TagLoadersTable& _table;
87 // This is only for tags mentioned in documentation but thought to to exist.
88 void
89 unexpected(SWFStream&, TagType tag, movie_definition&, const RunResources&)
91 static std::set<TagType> warned;
92 if (warned.insert(tag).second) {
93 log_unimpl(_("Undocumented tag %s encountered. Please report this to "
94 "the Gnash developers!"), tag);
98 // Silently ignore the contents of this tag.
99 void
100 ignore(SWFStream&, TagType, movie_definition&, const RunResources&)
104 } // unnamed namespace
106 void
107 addDefaultLoaders(TagLoadersTable& table)
110 // Note: all the tags given an 'unexpected' here are
111 // expected not to be used. They are generally documented
112 // by Alexis to exist (without any known structure), but not
113 // by Adobe.
114 const std::vector<TagPair> tags = boost::assign::list_of
115 // 01: nothing to do for an end tag.
116 (TagPair(SWF::END, ignore))
117 // 02
118 (TagPair(SWF::DEFINESHAPE, DefineShapeTag::loader))
119 // 03
120 (TagPair(SWF::FREECHARACTER, unexpected))
121 (TagPair(SWF::PLACEOBJECT, PlaceObject2Tag::loader))
122 (TagPair(SWF::REMOVEOBJECT, RemoveObjectTag::loader)) // 05
123 (TagPair(SWF::DEFINEBITS, DefineBitsTag::loader))
124 (TagPair(SWF::DEFINEBUTTON, DefineButtonTag::loader))
125 (TagPair(SWF::JPEGTABLES, jpeg_tables_loader))
126 (TagPair(SWF::SETBACKGROUNDCOLOR, SetBackgroundColorTag::loader))
127 (TagPair(SWF::DEFINEFONT, DefineFontTag::loader))
128 (TagPair(SWF::DEFINETEXT, DefineTextTag::loader))
129 (TagPair(SWF::DOACTION, DoActionTag::loader))
130 (TagPair(SWF::DEFINEFONTINFO, DefineFontInfoTag::loader))
131 (TagPair(SWF::DEFINESOUND, define_sound_loader))
132 (TagPair(SWF::STARTSOUND, StartSoundTag::loader))
133 (TagPair(SWF::STOPSOUND, unexpected)) // 16
134 // 17
135 (TagPair(SWF::DEFINEBUTTONSOUND, DefineButtonSoundTag::loader))
136 // 18
137 (TagPair(SWF::SOUNDSTREAMHEAD, sound_stream_head_loader))
138 // 19
139 (TagPair(SWF::SOUNDSTREAMBLOCK, StreamSoundBlockTag::loader))
140 (TagPair(SWF::DEFINELOSSLESS, DefineBitsTag::loader))
141 (TagPair(SWF::DEFINEBITSJPEG2, DefineBitsTag::loader))
142 (TagPair(SWF::DEFINESHAPE2, DefineShapeTag::loader))
143 (TagPair(SWF::DEFINEBUTTONCXFORM, DefineButtonCxformTag::loader)) // 23
144 (TagPair(SWF::PROTECT, ignore))
145 (TagPair(SWF::PATHSAREPOSTSCRIPT, unexpected)) // 25
146 (TagPair(SWF::PLACEOBJECT2, PlaceObject2Tag::loader))
147 // 28
148 (TagPair(SWF::REMOVEOBJECT2, RemoveObjectTag::loader))
149 (TagPair(SWF::SYNCFRAME, unexpected)) // 29
150 (TagPair(SWF::FREEALL, unexpected)) // 31
151 (TagPair(SWF::DEFINESHAPE3, DefineShapeTag::loader))
152 (TagPair(SWF::DEFINETEXT2, DefineText2Tag::loader))
153 // 37
154 (TagPair(SWF::DEFINEBUTTON2, DefineButton2Tag::loader))
155 (TagPair(SWF::DEFINEBITSJPEG3, DefineBitsTag::loader))
156 (TagPair(SWF::DEFINELOSSLESS2, DefineBitsTag::loader))
157 (TagPair(SWF::DEFINEEDITTEXT, DefineEditTextTag::loader))
158 (TagPair(SWF::DEFINEVIDEO, unexpected)) // 38
159 (TagPair(SWF::DEFINESPRITE, sprite_loader))
160 (TagPair(SWF::NAMECHARACTER, unexpected)) // 40
161 (TagPair(SWF::SERIALNUMBER, serialnumber_loader)) // 41
162 (TagPair(SWF::DEFINETEXTFORMAT, unexpected)) // 42
163 (TagPair(SWF::FRAMELABEL, frame_label_loader)) // 43
164 (TagPair(SWF::DEFINEBEHAVIOR, unexpected)) // 44
165 // 45
166 (TagPair(SWF::SOUNDSTREAMHEAD2, sound_stream_head_loader))
167 // 46
168 (TagPair(SWF::DEFINEMORPHSHAPE, DefineMorphShapeTag::loader))
169 // 47
170 (TagPair(SWF::FRAMETAG, unexpected))
171 // 48
172 (TagPair(SWF::DEFINEFONT2, DefineFontTag::loader))
173 (TagPair(SWF::GENCOMMAND, unexpected)) // 49
174 (TagPair(SWF::DEFINECOMMANDOBJ, unexpected)) // 50
175 (TagPair(SWF::CHARACTERSET, unexpected)) // 51
176 (TagPair(SWF::FONTREF, unexpected)) // 52
177 (TagPair(SWF::DEFINEFUNCTION, unexpected)) // 53
178 (TagPair(SWF::PLACEFUNCTION, unexpected)) // 54
179 (TagPair(SWF::GENTAGOBJECT, unexpected)) // 55
180 (TagPair(SWF::EXPORTASSETS, ExportAssetsTag::loader)) // 56
181 (TagPair(SWF::IMPORTASSETS, ImportAssetsTag::loader)) // 57
182 (TagPair(SWF::ENABLEDEBUGGER, ignore)) // 58
183 // 59
184 (TagPair(SWF::INITACTION, DoInitActionTag::loader))
185 // 60
186 (TagPair(SWF::DEFINEVIDEOSTREAM, DefineVideoStreamTag::loader))
187 // 61
188 (TagPair(SWF::VIDEOFRAME, VideoFrameTag::loader))
189 // 62
190 (TagPair(SWF::DEFINEFONTINFO2, DefineFontInfoTag::loader))
191 // 63
192 (TagPair(SWF::DEBUGID, ignore))
193 // 64
194 (TagPair(SWF::ENABLEDEBUGGER2, ignore))
195 (TagPair(SWF::SCRIPTLIMITS, ScriptLimitsTag::loader)) //65
196 (TagPair(SWF::SETTABINDEX, SetTabIndexTag::loader)) //66
197 // TODO: Alexis reference says these are 83, 84. The 67, 68 comes from
198 // Tamarin. Figure out which one is correct (possibly both are).
199 // 67
200 (TagPair(SWF::DEFINESHAPE4_, DefineShapeTag::loader))
201 // 68
202 (TagPair(SWF::DEFINEMORPHSHAPE2_, DefineMorphShapeTag::loader))
203 // 69
204 (TagPair(SWF::FILEATTRIBUTES, file_attributes_loader))
205 // 70
206 (TagPair(SWF::PLACEOBJECT3, PlaceObject2Tag::loader))
207 // 71
208 (TagPair(SWF::IMPORTASSETS2, ImportAssetsTag::loader))
209 // 73
210 (TagPair(SWF::DEFINEALIGNZONES, DefineFontAlignZonesTag::loader))
211 // 74
212 (TagPair(SWF::CSMTEXTSETTINGS, CSMTextSettingsTag::loader))
213 // 75
214 (TagPair(SWF::DEFINEFONT3, DefineFontTag::loader))
215 // 77
216 (TagPair(SWF::METADATA, metadata_loader))
217 // 78
218 (TagPair(SWF::DEFINESCALINGGRID, DefineScalingGridTag::loader))
219 // 83
220 (TagPair(SWF::DEFINESHAPE4, DefineShapeTag::loader))
221 // 84
222 (TagPair(SWF::DEFINEMORPHSHAPE2, DefineMorphShapeTag::loader))
223 // 88
224 (TagPair(SWF::DEFINEFONTNAME, DefineFontNameTag::loader))
225 // 89
226 (TagPair(SWF::STARTSOUND2, StartSound2Tag::loader))
227 // 90
228 (TagPair(SWF::DEFINEBITSJPEG4, DefineBitsTag::loader))
229 // 777
230 (TagPair(SWF::REFLEX, reflex_loader))
231 #ifdef ENABLE_AVM2
232 // The following tags are AVM2 only.
233 // 72 -- AS3 codeblock.
234 (TagPair(SWF::DOABC, DoABCTag::loader))
235 // 76
236 (TagPair(SWF::SYMBOLCLASS, SymbolClassTag::loader))
237 // 82
238 (TagPair(SWF::DOABCDEFINE, DoABCTag::loader))
239 // 86
240 (TagPair(SWF::DEFINESCENEANDFRAMELABELDATA,
241 DefineSceneAndFrameLabelDataTag::loader))
242 #endif
245 std::for_each(tags.begin(), tags.end(), AddLoader(table));
249 } // namespace SWF
250 } // namespace gnash