Example #1
0
    void ParseNamespace(LexSection section, ref int caret, ref ProtectLevel protectionLevel)
    {
        int begin = caret;

        caret += "namespace".Length;

        string namespaceName  = ReadWord(section.data, ref caret);
        int    namespaceBegin = section.data.IndexOf('{', caret) + 1;
        string block          = ReadBlock(section.data, ref caret).Trim(' ', '\r', '\t', '\n');
        string body           = block.Substring(1, block.Length - 2).Trim(' ', '\r', '\t', '\n');

        LexNamespace newNamespace = new LexNamespace()
        {
            begin            = begin,
            end              = caret,
            data             = body,
            name             = namespaceName,
            source           = source,
            parentLexSection = section
        };

        section.childSections.Add(newNamespace);

        ParseLexSection(newNamespace, ProtectLevel.Public);
    }
Example #2
0
    void CopyNamespace(LexNamespace source, LexNamespace target)
    {
        target.name = source.name;

        target.classes.AddRange(source.classes);
        target.childSections.AddRange(source.classes);
        target.functions.AddRange(source.functions);
        target.variables.AddRange(source.variables);
        target.unknownBlocks.AddRange(source.unknownBlocks);
        target.typedefs.AddRange(source.typedefs);
        target.enums.AddRange(source.enums);

        source.usingNamespaces.ForEach(x =>
        {
            if (target.usingNamespaces.Find(y => y.name == x.name) == null)
            {
                target.usingNamespaces.Add(x);
            }
        });

        target.classes.ForEach(x => x.parentLexSection = target);

        foreach (var chSource in source.childSections)
        {
            if (chSource.GetType() != typeof(LexNamespace))
            {
                continue;
            }

            var chTarget = target.childSections.Find(x =>
            {
                return(x.GetType() == typeof(LexNamespace) && (x as LexNamespace).name == (chSource as LexNamespace).name);
            });

            if (chTarget == null)
            {
                chTarget = new LexNamespace();
                (chTarget as LexNamespace).name = (chSource as LexNamespace).name;
                target.childSections.Add(chTarget);
            }

            chTarget.parentLexSection = target;

            CopyNamespace(chSource as LexNamespace, chTarget as LexNamespace);
        }
    }
Example #3
0
    void ParseNamespace(LexSection section, ref int caret, ref ProtectLevel protectionLevel)
    {
        int begin = caret;
        caret += "namespace".Length;

        string namespaceName = ReadWord(section.data, ref caret);
        int namespaceBegin = section.data.IndexOf('{', caret) + 1;
        string block = ReadBlock(section.data, ref caret).Trim(' ', '\r', '\t', '\n');
        string body = block.Substring(1, block.Length - 2).Trim(' ', '\r', '\t', '\n');

        LexNamespace newNamespace = new LexNamespace()
        {
            begin = begin,
            end = caret,
            data = body,
            name = namespaceName,
            source = source,
            parentLexSection = section
        };
        section.childSections.Add(newNamespace);

        ParseLexSection(newNamespace, ProtectLevel.Public);
    }
Example #4
0
    void CopyNamespace(LexNamespace source, LexNamespace target)
    {
        target.name = source.name;

        target.classes.AddRange(source.classes);
        target.childSections.AddRange(source.classes);
        target.functions.AddRange(source.functions);
        target.variables.AddRange(source.variables);
        target.unknownBlocks.AddRange(source.unknownBlocks);
        target.typedefs.AddRange(source.typedefs);
        target.enums.AddRange(source.enums);

        source.usingNamespaces.ForEach(x =>
        {
            if (target.usingNamespaces.Find(y => y.name == x.name) == null)
                target.usingNamespaces.Add(x);
        });

        target.classes.ForEach(x => x.parentLexSection = target);

        foreach (var chSource in source.childSections)
        {
            if (chSource.GetType() != typeof(LexNamespace))
                continue;

            var chTarget = target.childSections.Find(x =>
            {
                return x.GetType() == typeof(LexNamespace) && (x as LexNamespace).name == (chSource as LexNamespace).name;
            });

            if (chTarget == null)
            {
                chTarget = new LexNamespace();
                (chTarget as LexNamespace).name = (chSource as LexNamespace).name;
                target.childSections.Add(chTarget);
            }

            chTarget.parentLexSection = target;

            CopyNamespace(chSource as LexNamespace, chTarget as LexNamespace);
        }
    }