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


C# CXCursor.ToString方法代码示例

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


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

示例1: PortParameter

        public ParameterSyntax PortParameter(CXCursor paramDecl)
        {
            string paramName = paramDecl.ToString ();
            CXType type = clang.getCursorType (paramDecl);

            // We can't pass void as function parameter
            if (type.kind == CXTypeKind.CXType_Void)
                throw new ArgumentException ();

            var paramId = SF.Identifier (paramName);
            ParameterSyntax paramSyntax = SF.Parameter (paramId);

            if (type.kind == CXTypeKind.CXType_ObjCObjectPointer) {
                type = type.GetPointee ();
                TypeSyntax typeSyntax = PortType (type);
                return paramSyntax.WithType (typeSyntax);
            }

            if (type.kind == CXTypeKind.CXType_Pointer) {
                type = type.GetPointee ();

                if(type.kind == CXTypeKind.CXType_Void) // original type was void*
                    return paramSyntax.WithType(CommonTypes.IntPtrTypeSyntax);

                TypeSyntax typeSyntax = PortType (type);
                return paramSyntax.WithType (typeSyntax).WithModifiers (SF.TokenList (SF.Token (SyntaxKind.OutKeyword)));
            }

            TypeSyntax ts = PortType (type);
            return paramSyntax.WithType (ts);
        }
开发者ID:newky2k,项目名称:sample-translator,代码行数:31,代码来源:ObjCTypePorter.cs

示例2: Dump

        static void Dump(CXCursor cursor, StringBuilder sb, int level, int mask)
        {
            for (int i = 1; i <= level; i++) {
                if (IsSet (mask, level - i)) {
                    if (i == level)
                        sb.Append ("|-");
                    else
                        sb.Append ("| ");
                } else {
                    if (i == level)
                        sb.Append ("`-");
                    else
                        sb.Append ("  ");
                }
            }
            sb.AppendFormat ("{0} {1}\n", cursor.kind, cursor.ToString ());

            CXCursor[] children = cursor.GetChildren ().ToArray();
            for (int i = 0; i < children.Length; i++)
                Dump (children[i], sb, level + 1, (mask << 1) | (i == children.Length - 1 ? 0 : 1));
        }
开发者ID:newky2k,项目名称:sample-translator,代码行数:21,代码来源:CXCursorExtensions.cs

示例3: CreatePropertyFromPropertyDecl

        PropertyDeclarationSyntax CreatePropertyFromPropertyDecl(CXCursor propDecl)
        {
            CXType propType = clang.getCursorType (propDecl);
            TypeSyntax propTypeSyntax = TypePorter.PortType (propType);

            PropertyDeclarationSyntax propSyntax = SF.PropertyDeclaration (propTypeSyntax, propDecl.ToString())
                .AddModifiers (SF.Token (SyntaxKind.PublicKeyword));

            propSyntax = propSyntax.AddAccessorListAccessors (
                SF.AccessorDeclaration (SyntaxKind.GetAccessorDeclaration)
                .WithSemicolonToken (SF.Token (SyntaxKind.SemicolonToken)),

                SF.AccessorDeclaration (SyntaxKind.SetAccessorDeclaration)
                .WithSemicolonToken (SF.Token (SyntaxKind.SemicolonToken))
            );

            return propSyntax;
        }
开发者ID:newky2k,项目名称:sample-translator,代码行数:18,代码来源:TranslationUnitPorter.cs


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