当前位置: 首页>>代码示例>>C#>>正文


C# Cursor.VisitChildren方法代码示例

本文整理汇总了C#中Cursor.VisitChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Cursor.VisitChildren方法的具体用法?C# Cursor.VisitChildren怎么用?C# Cursor.VisitChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cursor的用法示例。


在下文中一共展示了Cursor.VisitChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        public void Parse(Cursor cursor)
        {
            if (String.IsNullOrEmpty(cursor.Name))
                return;
            String enumName = cursor.Name.Substring(2).Replace("_", "");
            if (enumName == "ChildVisitResult")
                enumName = "CursorVisitResult";
            if (enumName == "CallingConv")
                enumName = "CallingConvention";
            String filename = Path.Combine(_di.FullName, enumName + ".h");
            var contents = new StringBuilder();
            contents.AppendLine(Template.Template.Header);
            if (enumName.EndsWith("Flags"))
                contents.AppendLine("    [System::Flags]");
            contents.Append("    public enum class ");
            contents.Append(enumName);
            contents.AppendLine("    {");

            // add values
            _sb = contents;
            cursor.VisitChildren(EnumVisitor);

            contents.AppendLine("    };");
            contents.AppendLine(Template.Template.Footer);
            File.WriteAllText(filename, contents.ToString());
        }
开发者ID:jdehaan,项目名称:Clang,代码行数:26,代码来源:EnumWrapper.cs

示例2: CursorVisitor

        private static CursorVisitResult CursorVisitor(Cursor cursor, Cursor parent)
        {
            if (cursor.Location.SpellingPosition.File.Path == FILENAME)
            {

                //_last.Push(parent);
                switch (cursor.Kind)
                {
                case CursorKind.FunctionDeclaration:
                    FunctionVisitor.Parse(cursor);
                    break;
                case CursorKind.VariableDeclaration:
                    Console.WriteLine ("variable {0} -> recurse", cursor.Name);
                    break;
                case CursorKind.EnumerationDeclaration:
                    Console.WriteLine ("enum {0} -> recurse", cursor.Name);
                    break;
                case CursorKind.ClassDeclaration:
                    Console.WriteLine ("class {0} -> recurse", cursor.Name);
                    cursor.VisitChildren(ClassVisitor.Visitor);
                    break;
                case CursorKind.MacroDefinition:
                    Console.WriteLine ("macro {0} -> recurse", cursor.Name);
                    break;

                //case CursorKind.EnumerationConstantDeclaration:
                //    Console.WriteLine ("  {0}", cursor.Name);
                //    break;
                //case CursorKind.CxxAccessSpecifier:
                //    break;
                //case CursorKind.UnexposedExpression:
                //    break;

                //case CursorKind.CharacterLiteral:
                //    Console.Write ("char: {0}", cursor.Spelling);
                //    break;
                //case CursorKind.StringLiteral:
                //    Console.Write ("string: {0}", cursor.Spelling);
                //    break;
                //case CursorKind.IntegerLiteral:
                //    //Console.Write ("intval={0}", cursor.Spelling);
                //    break;

                //case CursorKind.CompoundStatement:
                //    Console.WriteLine ("{");
                //    break;
                //case CursorKind.DeclarationReferenceExpression:
                //    Console.Write (" {0}, ", cursor.Name);
                //    break;
                //case CursorKind.CallExpression:
                //    Console.WriteLine ("{0} ();", cursor.Name);
                //    break;

                default:
                    Console.WriteLine ("{0} (name:{1}) [spelling:{2}] L{3}C{4}",
                        cursor.Kind, cursor.Name, cursor.Spelling,
                        cursor.Location.SpellingPosition.Line,
                        cursor.Location.SpellingPosition.Column);
                    break;
                }
            }
            return CursorVisitResult.Continue;
        }
开发者ID:jdehaan,项目名称:Clang,代码行数:63,代码来源:Program.cs


注:本文中的Cursor.VisitChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。