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