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_EXPORTASSETSTAG_H
00020 #define GNASH_SWF_EXPORTASSETSTAG_H
00021
00022 #include <vector>
00023 #include <utility>
00024 #include <string>
00025 #include <memory>
00026
00027 #include "ControlTag.h"
00028 #include "Movie.h"
00029 #include "MovieClip.h"
00030 #include "SWFStream.h"
00031 #include "MovieFactory.h"
00032 #include "log.h"
00033
00034 namespace gnash {
00035 namespace SWF {
00036
00037 class ExportAssetsTag : public ControlTag
00038 {
00039 public:
00040
00041 typedef std::vector<std::string> Exports;
00042
00043
00044 static void loader(SWFStream& in, TagType tag, movie_definition& m,
00045 const RunResources& )
00046 {
00047 assert(tag == SWF::EXPORTASSETS);
00048
00049 std::auto_ptr<ControlTag> t(new ExportAssetsTag(in, m));
00050 m.addControlTag(t.release());
00051 }
00052
00053
00054
00055 virtual void executeState(MovieClip* m, DisplayList& ) const {
00056 Movie* mov = m->get_root();
00057 for (Exports::const_iterator it = _exports.begin(), e = _exports.end();
00058 it != e; ++it) {
00059 const boost::uint16_t id = mov->definition()->exportID(*it);
00060
00061
00062 assert(id);
00063 mov->addCharacter(id);
00064 }
00065 }
00066
00067 private:
00068
00069 ExportAssetsTag(SWFStream& in, movie_definition& m)
00070 {
00071 read(in, m);
00072 }
00073
00074 void read(SWFStream& in, movie_definition& m) {
00075
00076 in.ensureBytes(2);
00077 const boost::uint16_t count = in.read_u16();
00078
00079 IF_VERBOSE_PARSE(
00080 log_parse(_(" export: count = %d"), count);
00081 );
00082
00083
00084 for (size_t i = 0; i < count; ++i) {
00085 in.ensureBytes(2);
00086 const boost::uint16_t id = in.read_u16();
00087
00088 if (!id) continue;
00089
00090 std::string symbolName;
00091 in.read_string(symbolName);
00092
00093 IF_VERBOSE_PARSE (
00094 log_parse(_(" export: id = %d, name = %s"), id, symbolName);
00095 );
00096
00097
00098 m.registerExport(symbolName, id);
00099
00100
00101 _exports.push_back(symbolName);
00102 }
00103
00104 }
00105
00106 private:
00107
00108 Exports _exports;
00109
00110 };
00111
00112 }
00113 }
00114
00115 #endif