Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GNASH_SWF_SYMBOLCLASSTAG_H
00019 #define GNASH_SWF_SYMBOLCLASSTAG_H
00020
00021 #include <string>
00022 #include "ControlTag.h"
00023 #include "SWF.h"
00024 #include "MovieClip.h"
00025 #include "SWFStream.h"
00026 #include "Machine.h"
00027 #include "VM.h"
00028 #include "sprite_definition.h"
00029 #include "Global_as.h"
00030
00031
00032 namespace gnash {
00033 class movie_definition;
00034 }
00035
00036 namespace gnash {
00037 namespace SWF {
00038
00040
00041 class SymbolClassTag : public ControlTag
00042 {
00043 public:
00044
00045 virtual void executeActions(MovieClip* m, DisplayList& ) const
00046 {
00047 VM& vm = getVM(*getObject(m));
00048 abc::Machine* mach = vm.getMachine();
00049 log_debug("SymbolClassTag: Creating class %s.", _rootClass);
00050 mach->instantiateClass(_rootClass, vm.getGlobal());
00051 }
00052
00053 static void loader(SWFStream& in, TagType tag, movie_definition& m,
00054 const RunResources& )
00055 {
00056 assert(tag == SYMBOLCLASS);
00057
00058 if (!m.isAS3()) {
00059 IF_VERBOSE_MALFORMED_SWF(
00060 log_swferror("SWF contains SymbolClass tag, but is not an "
00061 "AS3 SWF!");
00062 );
00063 throw ParserException("SymbolClass tag found in non-AS3 SWF!");
00064 }
00065
00066 in.ensureBytes(2);
00067 boost::uint16_t num_symbols = in.read_u16();
00068 log_debug("There are %u symbols.", num_symbols);
00069 for (unsigned int i = 0; i < num_symbols; ++i) {
00070 in.ensureBytes(2);
00071 boost::uint16_t id = in.read_u16();
00072 std::string name;
00073 in.read_string(name);
00074 IF_VERBOSE_PARSE(
00075 log_parse("Symbol %u name %s, character %u", i, name, id);
00076 );
00077
00078 SymbolClassTag* st = new SymbolClassTag(name);
00079
00080 if (id == 0) m.addControlTag(st);
00081 else {
00082 sprite_definition* s =
00083 dynamic_cast<sprite_definition*>(m.getDefinitionTag(id));
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 if (s) s->addControlTag(st);
00098
00099 }
00100 }
00101 }
00102
00103 private:
00104
00105 SymbolClassTag(std::string name)
00106 :
00107 _rootClass(name)
00108 {}
00109
00110 const std::string _rootClass;
00111 };
00112
00113 }
00114 }
00115
00116
00117 #endif // GNASH_SWF_SYMBOLCLASSTAG_H
00118
00119
00120
00121
00122
00123