本文整理汇总了C#中ClangSharp.CXCursor.ToMarshalString方法的典型用法代码示例。如果您正苦于以下问题:C# CXCursor.ToMarshalString方法的具体用法?C# CXCursor.ToMarshalString怎么用?C# CXCursor.ToMarshalString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClangSharp.CXCursor
的用法示例。
在下文中一共展示了CXCursor.ToMarshalString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public CXChildVisitResult Visit(CXCursor cursor, CXCursor parent, IntPtr data)
{
if (cursor.IsInSystemHeader())
{
return CXChildVisitResult.CXChildVisit_Continue;
}
CXCursorKind curKind = clang.getCursorKind(cursor);
if (curKind == CXCursorKind.CXCursor_StructDecl)
{
this.fieldPosition = 0;
var structName = clang.getCursorSpelling(cursor).ToString();
// struct names can be empty, and so we visit its sibling to find the name
if (string.IsNullOrEmpty(structName))
{
var forwardDeclaringVisitor = new ForwardDeclarationVisitor(cursor);
clang.visitChildren(clang.getCursorSemanticParent(cursor), forwardDeclaringVisitor.Visit, new CXClientData(IntPtr.Zero));
structName = clang.getCursorSpelling(forwardDeclaringVisitor.ForwardDeclarationCursor).ToString();
if (string.IsNullOrEmpty(structName))
{
structName = "_";
}
}
if (!this.visitedStructs.Contains(structName))
{
this.IndentedWriteLine("public partial struct " + structName);
this.IndentedWriteLine("{");
this.indentLevel++;
clang.visitChildren(cursor, this.Visit, new CXClientData(IntPtr.Zero));
this.indentLevel--;
this.IndentedWriteLine("}");
this.tw.WriteLine();
this.visitedStructs.Add(structName);
}
return CXChildVisitResult.CXChildVisit_Continue;
}
if (curKind == CXCursorKind.CXCursor_FieldDecl)
{
var fieldName = clang.getCursorSpelling(cursor).ToString();
if (string.IsNullOrEmpty(fieldName))
{
fieldName = "field" + this.fieldPosition; // what if they have fields called field*? :)
}
this.fieldPosition++;
this.IndentedWriteLine(cursor.ToMarshalString(fieldName));
return CXChildVisitResult.CXChildVisit_Continue;
}
return CXChildVisitResult.CXChildVisit_Recurse;
}