コード例 #1
0
        private static void AddSpecialTag(MemberModel member)
        {
            if (groups.ContainsKey(member.Name))
            {
                return;
            }
            TypeInfos infos = new TypeInfos(member.Name);

            infos.isLeaf        = false;
            infos.ns            = "mx";
            groups[member.Name] = infos;
        }
コード例 #2
0
        private static void AddCustomTag(string name, string attributes)
        {
            TypeInfos infos = new TypeInfos(name);

            infos.ns        = "mx";
            infos.isLeaf    = false;
            infos.isBuiltIn = true;
            infos.declAt    = attributes;
            infos.isEmpty   = attributes.Length == 0;
            infos.declInc   = "id,@" + name;
            groups[name]    = infos;
        }
コード例 #3
0
 private static void GenerateGroupsDeclarations()
 {
     output.WriteLine("<groups>");
     foreach (string name in names)
     {
         TypeInfos infos = groups[name];
         if (infos.isEmpty)
         {
             continue;
         }
         output.WriteLine(String.Format("\t<group id=\"@{0}\" at=\"{1}\"/>", infos.name, infos.declAt));
     }
     output.WriteLine("</groups>");
 }
コード例 #4
0
 private static void ExpandInheritance()
 {
     foreach (TypeInfos infos in groups.Values)
     {
         TypeInfos extInfos = GetExtends(infos);
         while (extInfos != null)
         {
             if (!extInfos.isEmpty)
             {
                 infos.includes.Add(extInfos);
             }
             extInfos = GetExtends(extInfos);
         }
     }
 }
コード例 #5
0
 private static void ForceMXNamespace()
 {
     foreach (string cname in config.ForceMxNamespace)
     {
         if (groups.ContainsKey(cname))
         {
             TypeInfos info = groups[cname];
             info.ns = "mx";
         }
         else
         {
             Console.WriteLine(String.Format("Force mx namespace on '{0}' failed - type not found", cname));
         }
     }
 }
コード例 #6
0
 private static void GenerateTagsDeclarations()
 {
     output.WriteLine("<tags defaultNS=\"mx\">");
     foreach (string name in names)
     {
         TypeInfos infos = groups[name];
         if (infos.ignore || infos.isAbstract)
         {
             continue;
         }
         string isLeaf = (GetIsLeaf(infos)) ? " isLeaf=\"yes\"" : "";
         output.WriteLine(String.Format("\t<{0} ns=\"{1}\"{2} at=\"{3}\"/>",
                                        infos.name, infos.ns, isLeaf, infos.declInc));
     }
     output.WriteLine("</tags>");
 }
コード例 #7
0
 private static bool CheckIsContainer(TypeInfos infos, ClassModel model)
 {
     if (config.ContainerTags.Contains <string>(infos.name))
     {
         return(true);
     }
     if (model.Implements != null)
     {
         foreach (string cname in model.Implements)
         {
             if (config.ContainerTags.Contains <string>(cname))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #8
0
        private static TypeInfos GetExtends(TypeInfos infos)
        {
            string ext = infos.extends;

            if (ext == null || ext.Length == 0 || ext == "Object" || ext == infos.name)
            {
                return(null);
            }
            if (ext.IndexOf('.') > 0)
            {
                ext = ext.Substring(ext.LastIndexOf('.') + 1);
            }
            if (!groups.ContainsKey(ext))
            {
                return(null);
            }
            else
            {
                return(groups[ext]);
            }
        }
コード例 #9
0
        /*private static void AddBuiltInEvents()
         * {
         *  // TODO add missing built-in events
         *  // http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/EventDispatcher.html
         *  AddParams("EventDispatcher", "activate:e,deactivate:e");
         *  AddParams("DisplayObject", "added:e,addedToStage:e,enterFrame:e,removed:e,removedFromStage:e,render:e");
         *  AddParams("InteractiveObject",
         *      "click:e,contextMenu:e,doubleClick:e,focusIn:e,focusOut:e,"
         + "keyDown:e,keyFocusChange:e,keyUp:e,middleClick:e,middleMouseDown:e,middleMouseUp:e,"
         + "mouseDown:e,mouseFocusChange:e,mouseMove:e,mouseOut:e,mouseOver:e,mouseUp:e,"
         + "mouseWheel:e,nativeDragComplete:e,nativeDragDrop:e,nativeDragEnter:e,nativeDragExit:e,"
         + "nativeDragOver:e,nativeDragStart:e,nativeDragUpdate:e,"
         + "render:e,rightClick:e,rightMouseDown:e,rightMouseUp:e,rollOut:e,rollOver:e,"
         + "tabChildrenChange:e,tabEnabledChange:e,tabIndexChange");
         +  AddParams("URLLoader", "complete:e,httpResponseStatus:e,httpStatus:e,ioError:e,open:e,progress:e,securityError:e");
         +  AddParams("LoaderInfo", "complete:e,httpStatus:e,init:e,ioError:e,open:e,progress:e,unload:e");
         +  AddParams("Timer", "timer:e,timerComplete:e");
         + }*/

        private static void AddParams(string tagName, string add)
        {
            if (groups.Keys.Contains(tagName))
            {
                TypeInfos info = groups[tagName];
                info.isEmpty = false;
                if (info.declAt == null)
                {
                    info.declAt = "";
                }
                else if (info.declAt.Length > 0)
                {
                    info.declAt += ",";
                }
                info.declAt += add;
            }
            else
            {
                Console.WriteLine("AddParams failed: '" + tagName + "' not found");
            }
        }
コード例 #10
0
        private static TypeInfos GetSubGroup(string relPath, string fromFile)
        {
            string name = Path.GetFileNameWithoutExtension(relPath);

            if (name == "Version")
            {
                return(null);
            }
            if (groups.ContainsKey(name))
            {
                return(groups[name]);
            }

            string    fileName = Path.Combine(Path.GetDirectoryName(fromFile), relPath);
            TypeInfos infos    = new TypeInfos(name);

            infos.isAbstract = true;
            infos.ignore     = true;
            ReadMetaData(fileName, infos);
            groups[name] = infos;
            return(infos);
        }
コード例 #11
0
        private static void AddMembers(TypeInfos infos, ClassModel type)
        {
            FlagType mask = FlagType.Variable | FlagType.Setter;

            foreach (MemberModel member in type.Members)
            {
                if (member.Access == Visibility.Public &&
                    (member.Flags & FlagType.Dynamic) > 0 && (member.Flags & mask) > 0 &&
                    infos.excludes.IndexOf(member.Name) < 0)
                {
                    string paramType = ((member.Flags & FlagType.Setter) > 0) ? member.Parameters[0].Type : member.Type;
                    if (paramType == "Array")
                    {
                        AddSpecialTag(member);
                    }
                    else
                    {
                        infos.members.Add(member.Name);
                    }
                }
            }
        }
コード例 #12
0
        private static bool GetIsLeaf(TypeInfos infos)
        {
            if (!infos.isLeaf)
            {
                return(false); // we already know it isn't a leaf
            }
            TypeInfos extInfos = infos;

            while (extInfos != null)
            {
                if (!extInfos.isLeaf)
                {
                    return(false);
                }
                else if (config.LeafTags.Contains <string>(extInfos.name))
                {
                    return(true);
                }
                extInfos = GetExtends(extInfos);
            }
            return(false);
        }
コード例 #13
0
 private static void AddCustomTag(string name, string attributes)
 {
     TypeInfos infos = new TypeInfos(name);
     infos.ns = "mx";
     infos.isLeaf = false;
     infos.isBuiltIn = true;
     infos.declAt = attributes;
     infos.isEmpty = attributes.Length == 0;
     infos.declInc = "id,@" + name;
     groups[name] = infos;
 }
コード例 #14
0
        private static bool ReadMetaData(string fileName, TypeInfos infos)
        {
            string src = File.ReadAllText(fileName);

            if (src.IndexOf("[ExcludeClass]") > 0)
            {
                return(false);
            }
            MatchCollection eventMatches   = reMatchEvents.Matches(src);
            MatchCollection stylesMatches  = reMatchStyles.Matches(src);
            MatchCollection effectsMatches = reMatchEffects.Matches(src);
            MatchCollection exMatches      = reMatchExcludes.Matches(src);
            Match           defaultProp    = reMatchDefaultProperty.Match(src);

            if (defaultProp.Success)
            {
                infos.excludes.Add(defaultProp.Groups[1].Value);
                infos.isLeaf = false;
            }
            foreach (Match m in eventMatches)
            {
                infos.events.Add(m.Groups[2].Value);
            }
            foreach (Match m in stylesMatches)
            {
                infos.styles.Add(m.Groups[2].Value);
            }
            foreach (Match m in effectsMatches)
            {
                infos.effects.Add(m.Groups[2].Value);
            }
            foreach (Match m in exMatches)
            {
                infos.excludes.Add(m.Groups[2].Value);
            }

            string          path       = Path.GetDirectoryName(fileName);
            MatchCollection incMatches = reMatchIncludes.Matches(src);

            foreach (Match m in incMatches)
            {
                TypeInfos subInfos = GetSubGroup(m.Groups[1].Value, fileName);
                if (subInfos == null)
                {
                    continue;
                }
                else
                {
                    foreach (string p in subInfos.events)
                    {
                        infos.events.Add(p);
                    }
                    foreach (string p in subInfos.styles)
                    {
                        infos.styles.Add(p);
                    }
                    foreach (string p in subInfos.effects)
                    {
                        infos.effects.Add(p);
                    }
                    foreach (string p in subInfos.members)
                    {
                        infos.members.Add(p);
                    }
                }
            }
            return(true);
        }
コード例 #15
0
 private static TypeInfos GetExtends(TypeInfos infos)
 {
     string ext = infos.extends;
     if (ext == null || ext.Length == 0 || ext == "Object" || ext == infos.name) return null;
     if (ext.IndexOf('.') > 0) ext = ext.Substring(ext.LastIndexOf('.') + 1);
     if (!groups.ContainsKey(ext)) return null;
     else return groups[ext];
 }
コード例 #16
0
        static void explorer_OnExplorationDone(string path)
        {
            foreach (FileModel model in pathModel.Files.Values)
            {
                ClassModel type = model.GetPublicClass();
                if (type.IsVoid() || (type.Flags & FlagType.Interface) > 0)
                {
                    // silently ignore
                    continue;
                }
                string package = model.Package;
                string typeName = type.Name;

                TypeInfos infos;
                if (groups.ContainsKey(typeName))
                {
                    Log("-- merging classes with same name: " + type.Name);
                    infos = groups[typeName]; // merge blocs with same name
                }
                else infos = new TypeInfos(type.Name);

                if (mxTags.Contains(type.QualifiedName))
                {
                    infos.ns = "mx";
                    infos.ignore = false;
                }
                else if (package.StartsWith("mx."))
                {
                    infos.ns = "mx";
                    infos.ignore = true;
                }
                else if ((type.Flags & FlagType.Interface) > 0 || package.Length == 0
                    || !config.IncludePackage.ContainsKey(package))
                {
                    Log("ignore " + type.QualifiedName);
                    continue;
                }
                else infos.ns = config.IncludePackage[package];

                if (type.ExtendsType != null && !type.ExtendsType.EndsWith(type.Name))
                    infos.extends = type.ExtendsType;
                infos.isAbstract = (type.Members.Search(type.Constructor, 0, 0) == null);

                if (CheckIsContainer(infos, type))
                    infos.isLeaf = false;

                if (!ReadMetaData(model.FileName, infos))
                {
                    Log("excluded " + type.QualifiedName);
                    continue;
                }
                AddMembers(infos, type);
                groups[type.Name] = infos;
            }
            ExploreNext();
        }
コード例 #17
0
        static void explorer_OnExplorationDone(string path)
        {
            foreach (FileModel model in pathModel.Files.Values)
            {
                ClassModel type = model.GetPublicClass();
                if (type.IsVoid() || (type.Flags & FlagType.Interface) > 0)
                {
                    // silently ignore
                    continue;
                }
                string package  = model.Package;
                string typeName = type.Name;

                TypeInfos infos;
                if (groups.ContainsKey(typeName))
                {
                    Log("-- merging classes with same name: " + type.Name);
                    infos = groups[typeName]; // merge blocs with same name
                }
                else
                {
                    infos = new TypeInfos(type.Name);
                }

                if (mxTags.Contains(type.QualifiedName))
                {
                    infos.ns     = "mx";
                    infos.ignore = false;
                }
                else if (package.StartsWith("mx."))
                {
                    infos.ns     = "mx";
                    infos.ignore = true;
                }
                else if ((type.Flags & FlagType.Interface) > 0 || package.Length == 0 ||
                         !config.IncludePackage.ContainsKey(package))
                {
                    Log("ignore " + type.QualifiedName);
                    continue;
                }
                else
                {
                    infos.ns = config.IncludePackage[package];
                }

                if (type.ExtendsType != null && !type.ExtendsType.EndsWith(type.Name))
                {
                    infos.extends = type.ExtendsType;
                }
                infos.isAbstract = (type.Members.Search(type.Constructor, 0, 0) == null);

                if (CheckIsContainer(infos, type))
                {
                    infos.isLeaf = false;
                }

                if (!ReadMetaData(model.FileName, infos))
                {
                    Log("excluded " + type.QualifiedName);
                    continue;
                }
                AddMembers(infos, type);
                groups[type.Name] = infos;
            }
            ExploreNext();
        }
コード例 #18
0
 private static bool CheckIsContainer(TypeInfos infos, ClassModel model)
 {
     if (config.ContainerTags.Contains<string>(infos.name))
         return true;
     if (model.Implements != null)
     {
         foreach (string cname in model.Implements)
             if (config.ContainerTags.Contains<string>(cname))
                 return true;
     }
     return false;
 }
コード例 #19
0
 private static void AddMembers(TypeInfos infos, ClassModel type)
 {
     FlagType mask = FlagType.Variable | FlagType.Setter;
     foreach (MemberModel member in type.Members)
     {
         if (member.Access == Visibility.Public
             && (member.Flags & FlagType.Dynamic) > 0 && (member.Flags & mask) > 0
             && infos.excludes.IndexOf(member.Name) < 0)
         {
             string paramType = ((member.Flags & FlagType.Setter) > 0) ? member.Parameters[0].Type : member.Type;
             if (paramType == "Array") AddSpecialTag(member);
             else infos.members.Add(member.Name);
         }
     }
 }
コード例 #20
0
 private static void AddSpecialTag(MemberModel member)
 {
     if (groups.ContainsKey(member.Name)) return;
     TypeInfos infos = new TypeInfos(member.Name);
     infos.isLeaf = false;
     infos.ns = "mx";
     groups[member.Name] = infos;
 }
コード例 #21
0
        private static bool ReadMetaData(string fileName, TypeInfos infos)
        {
            string src = File.ReadAllText(fileName);
            if (src.IndexOf("[ExcludeClass]") > 0) 
                return false;
            MatchCollection eventMatches = reMatchEvents.Matches(src);
            MatchCollection stylesMatches = reMatchStyles.Matches(src);
            MatchCollection effectsMatches = reMatchEffects.Matches(src);
            MatchCollection exMatches = reMatchExcludes.Matches(src);
            Match defaultProp = reMatchDefaultProperty.Match(src);
            if (defaultProp.Success)
            {
                infos.excludes.Add(defaultProp.Groups[1].Value);
                infos.isLeaf = false;
            }
            foreach (Match m in eventMatches) infos.events.Add(m.Groups[2].Value);
            foreach (Match m in stylesMatches) infos.styles.Add(m.Groups[2].Value);
            foreach (Match m in effectsMatches) infos.effects.Add(m.Groups[2].Value);
            foreach (Match m in exMatches) infos.excludes.Add(m.Groups[2].Value);

            string path = Path.GetDirectoryName(fileName);
            MatchCollection incMatches = reMatchIncludes.Matches(src);
            foreach (Match m in incMatches)
            {
                TypeInfos subInfos = GetSubGroup(m.Groups[1].Value, fileName);
                if (subInfos == null) continue;
                else
                {
                    foreach (string p in subInfos.events) infos.events.Add(p);
                    foreach (string p in subInfos.styles) infos.styles.Add(p);
                    foreach (string p in subInfos.effects) infos.effects.Add(p);
                    foreach (string p in subInfos.members) infos.members.Add(p);
                }
            }
            return true;
        }
コード例 #22
0
 private static bool GetIsLeaf(TypeInfos infos)
 {
     if (!infos.isLeaf) 
         return false; // we already know it isn't a leaf
     TypeInfos extInfos = infos;
     while (extInfos != null)
     {
         if (!extInfos.isLeaf) return false;
         else if (config.LeafTags.Contains<string>(extInfos.name)) return true;
         extInfos = GetExtends(extInfos);
     }
     return false;
 }
コード例 #23
0
        private static TypeInfos GetSubGroup(string relPath, string fromFile)
        {
            string name = Path.GetFileNameWithoutExtension(relPath);
            if (name == "Version") return null;
            if (groups.ContainsKey(name)) return groups[name];

            string fileName = Path.Combine(Path.GetDirectoryName(fromFile), relPath);
            TypeInfos infos = new TypeInfos(name);
            infos.isAbstract = true;
            infos.ignore = true;
            ReadMetaData(fileName, infos);
            groups[name] = infos;
            return infos;
        }