Exemplo n.º 1
0
        protected override IParsedElement TryParseElement(List <string> lines, int index, out int end)
        {
            end = index + 1;
            var text = lines[index];
            var test = NormalizeType.Replace(text, string.Empty);

            if (IsBlockStart(lines, index, out index))
            {
                end = index;
                return(null);
            }

            if (!FieldRules.IsMatch(test))
            {
                return(null);
            }

            var parts = test.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length < 2)
            {
                return(null);
            }

            var cppType = parts[0];

            if (NotTypeChar.IsMatch(cppType))
            {
                return(null);
            }

            var name = parts[1].Trim(' ', ';');

            if (NotNameChar.IsMatch(name))
            {
                return(null);
            }

            var coment = string.Empty;

            if (parts.Length > 2)
            {
                coment = string.Join(" ", parts.Skip(2)).TrimStart(' ', '/', '<');
            }

            var netType = cppType;

            netType = GetKnownTypeOrDefault(netType);

            var field = new ParsedField
            {
                Type    = netType,
                CppType = cppType,
                Name    = ToTitleCase(name),
                CppName = name,
                Comment = coment
            };

            return(field);
        }
Exemplo n.º 2
0
        protected override PreParsedElement TryParseElement(PreParsedElement preParsedElement, string templateName, ObjectType objectType)
        {
            var test = preParsedElement.CppText;

            if (string.IsNullOrEmpty(test))
            {
                return(null);
            }

            if (test.StartsWith("static "))
            {
                test = test.Remove(0, 7);
            }
            if (test.StartsWith("const "))
            {
                test = test.Remove(0, 6);
            }

            if (!_fieldRules.IsMatch(test))
            {
                return(null);
            }

            var parts = test.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length < 2)
            {
                return(null);
            }

            var cppType = parts[0];

            if (_notTypeChar.IsMatch(cppType))
            {
                return(null);
            }

            var name = parts[1].Trim(' ', ';');

            if (NotNameChar.IsMatch(name))
            {
                return(null);
            }

            var coment = string.Empty;

            if (parts.Length > 2)
            {
                coment = string.Join(" ", parts.Skip(2)).TrimStart(' ', '/', '<');
            }

            var field = new PreParsedElement
            {
                Type        = GetKnownTypeOrDefault(cppType, templateName),
                Name        = _cashParser.ToTitleCase(name),
                CppName     = name,
                Comment     = coment,
                MainComment = preParsedElement.MainComment
            };

            return(field);
        }