Ejemplo n.º 1
0
        /// <summary>
        /// Clone member
        /// </summary>
        public Object Clone()
        {
            MemberModel copy = new MemberModel();

            copy.Name           = Name;
            copy.Flags          = Flags;
            copy.Access         = Access;
            copy.Namespace      = Namespace;
            copy.InFile         = InFile;
            copy.IsPackageLevel = IsPackageLevel;
            if (Parameters != null)
            {
                copy.Parameters = new List <MemberModel>();
                foreach (MemberModel param in Parameters)
                {
                    copy.Parameters.Add(param.Clone() as MemberModel);
                }
            }
            copy.Type     = Type;
            copy.Comments = Comments;
            return(copy);
        }
Ejemplo n.º 2
0
 public void Remove(MemberModel value)
 {
     items.Remove(value);
 }
Ejemplo n.º 3
0
 public void Insert(int index, MemberModel value)
 {
     Sorted = false;
     items.Insert(index, value);
 }
Ejemplo n.º 4
0
 public int Add(MemberModel value)
 {
     Sorted = false;
     items.Add(value);
     return(items.Count);
 }
Ejemplo n.º 5
0
        static public string MemberDeclaration(MemberModel member, bool preventVisibility)
        {
            // modifiers
            FlagType   ft        = member.Flags;
            Visibility acc       = member.Access;
            string     modifiers = "";

            if ((ft & FlagType.Intrinsic) > 0)
            {
                if ((ft & FlagType.Extern) > 0)
                {
                    modifiers += "extern ";
                }
                else
                {
                    modifiers += "intrinsic ";
                }
            }
            else if (!string.IsNullOrEmpty(member.Namespace) &&
                     member.Namespace != "internal")
            {
                if ((ft & FlagType.Interface) == 0)
                {
                    modifiers = member.Namespace + " ";
                }
            }
            else if (!preventVisibility)
            {
                if ((member.Flags & FlagType.Interface) == 0)
                {
                    if ((acc & Visibility.Public) > 0)
                    {
                        modifiers += "public ";
                    }
                    //  else if ((acc & Visibility.Internal) > 0) modifiers += "internal "; // AS3 default
                    else if ((acc & Visibility.Protected) > 0)
                    {
                        modifiers += "protected ";
                    }
                    else if ((acc & Visibility.Private) > 0)
                    {
                        modifiers += "private ";
                    }
                }
            }

            if ((ft & FlagType.Final) > 0)
            {
                modifiers += "final ";
            }

            if ((ft & FlagType.Enum) > 0)
            {
                return(member.ToString());
            }
            else if ((ft & FlagType.Class) > 0)
            {
                if ((ft & FlagType.Dynamic) > 0)
                {
                    modifiers += "dynamic ";
                }
                string classType = "class";
                if ((member.Flags & FlagType.Interface) > 0)
                {
                    classType = "interface";
                }
                else if ((member.Flags & FlagType.Enum) > 0)
                {
                    classType = "enum";
                }
                else if ((member.Flags & FlagType.Abstract) > 0)
                {
                    classType = "abstract";
                }
                else if ((member.Flags & FlagType.TypeDef) > 0)
                {
                    classType = "typedef";
                }
                else if ((member.Flags & FlagType.Struct) > 0)
                {
                    classType = "struct";
                }
                else if ((member.Flags & FlagType.Delegate) > 0)
                {
                    classType = "delegate";
                }
                return(String.Format("{0}{1} {2}", modifiers, classType, member.Type));
            }
            else if ((ft & FlagType.Enum) == 0)
            {
                if ((ft & FlagType.Native) > 0)
                {
                    modifiers += "native ";
                }
                if ((ft & FlagType.Static) > 0)
                {
                    modifiers += "static ";
                }
            }

            // signature
            if ((ft & FlagType.Namespace) > 0)
            {
                return(String.Format("{0}namespace {1}", modifiers, member.Name));
            }
            else if ((ft & FlagType.Variable) > 0)
            {
                if ((ft & FlagType.LocalVar) > 0)
                {
                    modifiers = "local ";
                }
                if ((ft & FlagType.Constant) > 0)
                {
                    if (member.Value == null)
                    {
                        return(String.Format("{0}const {1}", modifiers, member.ToDeclarationString()));
                    }
                    else
                    {
                        return(String.Format("{0}const {1} = {2}", modifiers, member.ToDeclarationString(), member.Value));
                    }
                }
                else
                {
                    return(String.Format("{0}var {1}", modifiers, member.ToDeclarationString()));
                }
            }
            else if ((ft & (FlagType.Getter | FlagType.Setter)) > 0)
            {
                return(String.Format("{0}property {1}", modifiers, member.ToString()));
            }
            else if ((ft & FlagType.Delegate) > 0)
            {
                return(String.Format("{0}delegate {1}", modifiers, member.ToString()));
            }
            else if ((ft & FlagType.Function) > 0)
            {
                return(String.Format("{0}function {1}", modifiers, member.ToString()));
            }
            else if (ft == FlagType.Package)
            {
                return(String.Format("Package {0}", member.Type));
            }
            else if (ft == FlagType.Template)
            {
                return(String.Format("Template {0}", member.Type));
            }
            else if (ft == FlagType.Declaration)
            {
                return(String.Format("Declaration {0}", member.Type));
            }
            else
            {
                return(String.Format("{0}type {1}", modifiers, member.Type));
            }
        }
Ejemplo n.º 6
0
 static public string MemberDeclaration(MemberModel member)
 {
     return(MemberDeclaration(member, false));
 }