Ejemplo n.º 1
0
        void ParseDumpEnum(string line, StringReader rdr, Globals globals)
        {
            string[]      nameparts  = line.Split(' ');
            string        enumName   = nameparts[1];
            List <string> enumValues = new List <string>();

            while ((line = rdr.ReadLine()) != null)
            {
                if (line.Equals("};"))
                {
                    EnumInfo ret = new EnumInfo {
                        Name = enumName
                    };
                    ret.Values.AddRange(enumValues);
                    globals.AddTypeInfo(enumName, ret);
                    return;
                }
                else if (line.Contains(','))
                {
                    int sub = line.IndexOf(',');
                    enumValues.Add(line.Substring(0, sub));
                }
            }
        }
Ejemplo n.º 2
0
        void ParseDumpClass(string line, StringReader rdr, Globals globals)
        {
            bool isTemplate = false;

            if (line.Contains("template <class T> "))
            {
                isTemplate = true;
            }
            string[] nameparts = line.Replace(",", "").Replace("template <class T> ", "").Split(' '); //dump the commas
            string   classname = nameparts[1];                                                        //class is first
            string   classtype = nameparts[0];                                                        //it might be an interface

            TypeInfo classInfo = new TypeInfo()
            {
                IsTemplate = isTemplate
            };

            classInfo.Name = classname;
            globals.AddTypeInfo(classInfo.Name, classInfo);

            for (int i = 3; i < nameparts.Length; ++i)   //list bases 2 would be :, 3 will be first basetype
            {
                classInfo.BaseTypeStr.Add(nameparts[i]); //add a base class
            }

            bool inprops       = false;
            bool nextReadOnly  = false;
            bool nextProtected = false;

            while ((line = rdr.ReadLine()) != null)
            {
                if (line.Length == 0) //empty line
                {
                    continue;
                }
                if (line.StartsWith("{"))
                {
                    continue;
                }
                if (line.Equals("};"))
                {
                    //TODO: push our class
                    return;
                }
                else if (line.StartsWith("/* readonly */"))
                {
                    nextReadOnly = true;
                    continue;
                }
                else if (line.StartsWith("/* protected */"))
                {
                    nextProtected = true;
                    continue;
                }
                else if (line.StartsWith("/*"))
                {
                    continue;
                }
                else if (line.Contains("// Properties:"))
                {
                    inprops = true;
                }
                else if (line.StartsWith("//"))     // // Methods:
                {
                    continue;
                }
                else if (inprops)                                      //property
                {
                    string[] parts = line.Replace(";", "").Split(' '); //[TypeName] [PropertyName]
                    if (parts[0].Contains('<'))
                    {
                        string       templateType  = parts[0].Substring(0, parts[0].IndexOf('<'));
                        string       containedType = parts[0].Extract('<', '>');
                        TypeInfo     wrapped       = globals.GetTypeInfo(containedType);
                        TemplateInst ti            = new TemplateInst()
                        {
                            Name = templateType, IsTemplate = true, WrappedType = wrapped != null ? wrapped : new TypeInfo {
                                Name = containedType, IsComplete = false
                            }
                        };
                        classInfo.Properties[parts[1]]    = ti;
                        classInfo.PropertyLines[parts[1]] = -1;
                        if (nextReadOnly)
                        {
                            classInfo.ReadonlyProperties.Add(parts[1]);
                        }
                        else if (nextProtected)
                        {
                            classInfo.ProtectedProperties.Add(parts[1]);
                        }
                    }
                    else
                    {
                        string   pname = parts[0].EndsWith("@") ? parts[0].Substring(0, parts[0].Length - 1) : parts[0]; //handle
                        TypeInfo pType = null;
                        if (globals.ContainsTypeInfo(pname))
                        {
                            pType = globals.GetTypeInfo(pname);
                        }
                        if (pType == null)   //create temp type to resolve later
                        {
                            pType = new TypeInfo()
                            {
                                Name = pname, IsComplete = false
                            };
                        }
                        classInfo.Properties[parts[1]]    = pType;
                        classInfo.PropertyLines[parts[1]] = -1;
                        if (nextReadOnly)
                        {
                            classInfo.ReadonlyProperties.Add(parts[1]);
                        }
                        else if (nextProtected)
                        {
                            classInfo.ProtectedProperties.Add(parts[1]);
                        }
                    }
                    nextReadOnly  = false;
                    nextProtected = false;
                }
                else     //function
                {
                    classInfo.Functions.Add(_parseFunction(line, globals));
                    nextReadOnly  = false;
                    nextProtected = false;
                }
            }
        }
Ejemplo n.º 3
0
        void ParseDumpClass(string line, StringReader rdr, Globals globals)
        {
            bool isTemplate = false;
            if (line.Contains("template <class T> "))
                isTemplate = true;
            string[] nameparts = line.Replace(",","").Replace("template <class T> ","").Split(' '); //dump the commas
            string classname = nameparts[1]; //class is first
            string classtype = nameparts[0]; //it might be an interface

            TypeInfo classInfo = new TypeInfo() { IsTemplate = isTemplate };
            classInfo.Name = classname;
            globals.AddTypeInfo(classInfo.Name, classInfo);

            for (int i = 3; i < nameparts.Length; ++i) { //list bases 2 would be :, 3 will be first basetype
                classInfo.BaseTypeStr.Add(nameparts[i]); //add a base class
            }

            bool inprops = false;
            bool nextReadOnly = false;
            bool nextProtected = false;
            while ((line = rdr.ReadLine()) != null) {
                if (line.Length == 0) //empty line
                    continue;
                if (line.StartsWith("{"))
                    continue;
                if (line.Equals("};")) {
                    //TODO: push our class
                    return;
                } else if (line.StartsWith("/* readonly */")) {
                    nextReadOnly = true;
                    continue;
                } else if (line.StartsWith("/* protected */")) {
                    nextProtected = true;
                    continue;
                } else if (line.StartsWith("/*")) {
                    continue;
                } else if (line.Contains("// Properties:")) {
                    inprops = true;
                } else if (line.StartsWith("//")) { // // Methods:
                    continue;
                } else if (inprops) { //property
                    string[] parts = line.Replace(";", "").Split(' '); //[TypeName] [PropertyName]
                    if (parts[0].Contains('<')) {
                        string templateType = parts[0].Substring(0, parts[0].IndexOf('<'));
                        string containedType = parts[0].Extract('<', '>');
                        TypeInfo wrapped = globals.GetTypeInfo(containedType);
                        TemplateInst ti = new TemplateInst() { Name = templateType, IsTemplate = true, WrappedType = wrapped != null ? wrapped : new TypeInfo { Name = containedType, IsComplete = false } };
                        classInfo.Properties[parts[1]] = ti;
                        classInfo.PropertyLines[parts[1]] = -1;
                        if (nextReadOnly)
                            classInfo.ReadonlyProperties.Add(parts[1]);
                        else if (nextProtected)
                            classInfo.ProtectedProperties.Add(parts[1]);
                    } else {
                        string pname = parts[0].EndsWith("@") ? parts[0].Substring(0, parts[0].Length - 1) : parts[0]; //handle
                        TypeInfo pType = null;
                        if (globals.ContainsTypeInfo(pname))
                            pType = globals.GetTypeInfo(pname);
                        if (pType == null) { //create temp type to resolve later
                            pType = new TypeInfo() { Name = pname, IsComplete = false };
                        }
                        classInfo.Properties[parts[1]] = pType;
                        classInfo.PropertyLines[parts[1]] = -1;
                        if (nextReadOnly)
                            classInfo.ReadonlyProperties.Add(parts[1]);
                        else if (nextProtected)
                            classInfo.ProtectedProperties.Add(parts[1]);
                    }
                    nextReadOnly = false;
                    nextProtected = false;

                } else { //function
                    classInfo.Functions.Add(_parseFunction(line, globals));
                    nextReadOnly = false;
                    nextProtected = false;
                }
            }
        }
Ejemplo n.º 4
0
 void ParseDumpEnum(string line, StringReader rdr, Globals globals)
 {
     string[] nameparts = line.Split(' ');
     string enumName = nameparts[1];
     List<string> enumValues = new List<string>();
     while ((line = rdr.ReadLine()) != null) {
         if (line.Equals("};")) {
             EnumInfo ret = new EnumInfo { Name = enumName };
             ret.Values.AddRange(enumValues);
             globals.AddTypeInfo(enumName, ret);
             return;
         } else if (line.Contains(',')) {
             int sub = line.IndexOf(',');
             enumValues.Add(line.Substring(0, sub));
         }
     }
 }