Пример #1
0
        private static IEnumerable <AbcFile> GetAbcFiles(string path)
        {
            string ext = Utils.GetExt(path);

            if (ext == "abc")
            {
                var abc  = new AbcFile(path);
                var list = new List <AbcFile> {
                    abc
                };
                return(list);
            }

            if (ext == "swf")
            {
                var swf  = new SwfMovie(path);
                var list = swf.GetAbcFiles();
                return(list);
            }

            if (ext == "swc")
            {
                var swc  = new SwcFile(path);
                var list = swc.GetAbcFiles();
                return(list);
            }

            return(Enumerable.Empty <AbcFile>());
        }
Пример #2
0
        void ResolveXmlDeps(SwfMovie lib)
        {
            CacheScripts(lib);

            var abcFiles = lib.GetAbcFiles();

            foreach (var abc in abcFiles)
            {
                AbcInstance defInstance = abc.Def;
                if (defInstance == null)
                {
                    continue;
                }

                var scriptElem = abc.SwcElement;

                //if (_linker != null)
                //    _linker.LinkType(defInstance);

                var depElems = GetElements(scriptElem, "dep");
                foreach (var depElem in depElems)
                {
                    string depID = depElem.GetAttribute("id");
                    string type  = depElem.GetAttribute("type");
                    if (type == "n")
                    {
                        ResolveNamespace(defInstance, depID);
                    }
                    else
                    {
                        ResolveDefLink(defInstance, depID);
                    }
                }
            }
        }
Пример #3
0
        public static void LoadExclude(IDictionary filter, string path)
        {
            string ext = Utils.GetExt(path);

            switch (ext)
            {
            case "abc":
            {
                var abc = new AbcFile(path);
                AddExcludes(filter, abc);
            }
            break;

            case "swf":
            {
                var swf  = new SwfMovie(path);
                var list = swf.GetAbcFiles();
                foreach (var abc in list)
                {
                    AddExcludes(filter, abc);
                }
            }
            break;

            case "swc":
            {
                var swc = new SwcFile(path);
                foreach (var abc in swc.GetAbcFiles())
                {
                    AddExcludes(filter, abc);
                }
            }
            break;
            }
        }
Пример #4
0
        public static void MergeSwc(string path, string output)
        {
            var lib  = path.ExtractSwfLibrary();
            var mov  = new SwfMovie(lib);
            var list = mov.GetAbcFiles();

            Merge(list, output);
        }
Пример #5
0
        static bool DumpMethod(string path, string method)
        {
            string ext = Utils.GetExt(path);

            if (ext == "abc")
            {
                int index;
                if (!int.TryParse(method, out index))
                {
                    return(false);
                }
                var abc = new AbcFile(path);
                return(DumpMethod(abc, index, path + "." + method + ".xml"));
            }

            if (ext == "swf")
            {
                int i = method.IndexOf('.');
                if (i < 0)
                {
                    return(false);
                }

                int frame;
                if (!int.TryParse(method.Substring(0, i), out frame))
                {
                    return(false);
                }

                int index;
                if (!int.TryParse(method.Substring(i + 1), out index))
                {
                    return(false);
                }

                if (frame < 0)
                {
                    return(false);
                }
                if (index < 0)
                {
                    return(false);
                }

                var swf  = new SwfMovie(path);
                var list = swf.GetAbcFiles();

                if (frame >= list.Count)
                {
                    return(false);
                }

                return(DumpMethod(list[frame], index, path + "." + method + ".xml"));
            }

            return(false);
        }
Пример #6
0
        static void DumpClassList(string path, bool sort)
        {
            string ext = Utils.GetExt(path);

            if (ext == "abc")
            {
                var abc  = new AbcFile(path);
                var list = new List <string>();
                GetClassList(list, abc);
                WriteClassList(path, "", list, sort);
                return;
            }

            if (ext == "swf")
            {
                var swf = new SwfMovie(path);
                var all = new List <string>();
                int i   = 1;
                foreach (var abc in swf.GetAbcFiles())
                {
                    GetClassList(all, abc);
                    var list = new List <string>();
                    GetClassList(list, abc);
                    WriteClassList(path, ".frame" + i, list, sort);
                    ++i;
                }
                WriteClassList(path, "", all, sort);
                return;
            }

            if (ext == "swc")
            {
                var swc  = new SwcFile(path);
                var list = new List <string>();
                foreach (var abc in swc.GetAbcFiles())
                {
                    GetClassList(list, abc);
                }
                WriteClassList(path, "", list, sort);
                return;
            }
        }
Пример #7
0
        static void DumpFuncs(string path)
        {
            string ext = Utils.GetExt(path);

            if (ext == "abc")
            {
                var abc = new AbcFile(path);
                DumpFuncsCore(abc, path + ".funcs.xml");
                return;
            }

            if (ext == "swf")
            {
                var swf = new SwfMovie(path);
                foreach (var abc in swf.GetAbcFiles())
                {
                    DumpFuncsCore(abc, path + "." + abc.Name + ".funcs.xml");
                }
                return;
            }
        }
Пример #8
0
        static void DumpInstances(CommandLine cl, string path)
        {
            string ext = Utils.GetExt(path);

            if (ext == "abc")
            {
                var abc = new AbcFile(path);
                DumpInstances(path, new[] { abc });
                return;
            }

            bool frames = cl.HasOption("frames");

            if (ext == "swf")
            {
                var swf  = new SwfMovie(path);
                var list = swf.GetAbcFiles();
                int n    = list.Count;
                for (int i = 0; i < n; ++i)
                {
                    var    abc = list[i];
                    string dir = path + ".instances";
                    if (frames)
                    {
                        dir += "\\" + i;
                    }
                    DumpInstancesTo(dir, abc);
                }
                return;
            }

            if (ext == "swc")
            {
                var swc = new SwcFile(path);
                DumpInstances(path, swc.GetAbcFiles());
                return;
            }
        }
Пример #9
0
        static void DumpMain(string path)
        {
            string ext = Utils.GetExt(path);

            AbcDumpService.DumpInitializerCode = true;

            if (ext == "abc")
            {
                var abc = new AbcFile(path);
                DumpMain(abc, path);
                return;
            }

            if (ext == "swf")
            {
                var mov  = new SwfMovie(path);
                var list = mov.GetAbcFiles();
                if (list.Count > 0)
                {
                    DumpMain(list[list.Count - 1], path);
                }
                return;
            }
        }