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); }
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)); }
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; }