예제 #1
0
        public ParsedStruct(List<string> lines, List<ParsedTypedef> typedefs)
        {
            members = new List<Member>();
            inheritsFrom = new List<string>();

            string line = lines[0];
            attributes = new ParsedAttributes(line);

            line = string.Join(" ", line.Split(' ').Where(str => !str.Contains("__attribute__")));
            line = SymbolParser.handleTemplatedName(SymbolParser.preprocessTemplate(line));

            if (line.Contains(":"))
            {
                // We inherit from something.
                string[] split = line.Split(':');
                line = split[0];

                string[] multipleInheritance = split[1].Split(',');

                foreach (string inh in multipleInheritance)
                {
                    inheritsFrom.Add(inh.Replace(" ", ""));
                }
            }

            name = line.Replace("struct", "").Trim();
            int placeholderCount = 0;

            for (int i = 1; i < lines.Count; ++i)
            {
                line = lines[i];

                if (line.Contains('{') || line.Contains('}'))
                {
                    continue;
                }

                string[] split = line.Split(' ');

                foreach (string section in split)
                {
                    if (section.Contains("**_vptr"))
                    {
                        line = "void** m_vtable";
                        break;
                    }
                    else if (section.Contains('(') && !section.Contains("__attribute__"))
                    {
                        line = "void** m_funcPtrPlaceholder__" + placeholderCount.ToString();
                        ++placeholderCount;
                        break;
                    }
                }

                members.Add(new Member(line.TrimStart(), typedefs));
            }
        }
예제 #2
0
        public NamedCppType(string rawType, List<ParsedTypedef> typedefs = null)
        {
            rawType = SymbolParser.handleTemplatedName(SymbolParser.preprocessTemplate(rawType));

            attributes = new ParsedAttributes(rawType);
            rawType = string.Join(" ", rawType.Split(' ').Where(str => !str.Contains("__attribute__")));

            string[] bitFieldSplit = rawType.Split(':');
            string[] typeSplit = bitFieldSplit[0].Trim().Split(' ');

            string unprocessedType = "";
            for (int i = 0; i < typeSplit.Length - 1; ++i)
            {
                unprocessedType += typeSplit[i] + " ";
            }

            if (bitFieldSplit.Length > 1)
            {
                unprocessedType += ": " + bitFieldSplit[1].Trim();
            }

            string unprocessedName = typeSplit[typeSplit.Length-1];

            var arraySplit = unprocessedName.Split('[', ']');

            if (arraySplit.Length > 1)
            {
                for (int i = 1; i < arraySplit.Length; i += 2)
                {
                    unprocessedType = unprocessedType + '[' + arraySplit[i] + ']';
                }

                unprocessedName = unprocessedName.Substring(0, unprocessedName.IndexOf('['));
            }

            name = unprocessedName;

            // Replace reserved keywords.
            switch (name)
            {
                case "class":     name = "_class"; break;
                case "struct":    name = "_struct"; break;
                case "private":   name = "_private"; break;
                case "protected": name = "_protected"; break;
                case "public":    name = "_public"; break;
                case "new":       name = "_new"; break;
                case "delete":    name = "_delete"; break;;
                default: break;
            }

            type = new CppType(unprocessedType, typedefs);
        }
예제 #3
0
 public void addAttributes(ParsedAttributes newAttributes)
 {
     attributes = newAttributes;
 }