From 0c97e2632a7c57ac67aebb8b6a6b74b9090ba2e6 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sat, 11 May 2019 08:34:46 -0700 Subject: [PATCH 1/3] Changing the generator to traverse implicit attributes and skip function bodies. --- ClangSharpPInvokeGenerator/CursorVisitor.cs | 2 +- ClangSharpPInvokeGenerator/CursorWriter.cs | 7 ++++++- ClangSharpPInvokeGenerator/Program.cs | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ClangSharpPInvokeGenerator/CursorVisitor.cs b/ClangSharpPInvokeGenerator/CursorVisitor.cs index 6ba5b567..55476a36 100644 --- a/ClangSharpPInvokeGenerator/CursorVisitor.cs +++ b/ClangSharpPInvokeGenerator/CursorVisitor.cs @@ -258,7 +258,7 @@ public CXChildVisitResult VisitTranslationUnit(CXCursor cursor, CXCursor parent, { Debug.Assert(parent.Kind == CXCursorKind.CXCursor_TranslationUnit); - if (cursor.Location.IsInSystemHeader || !cursor.Location.IsFromMainFile) + if (!cursor.Location.IsFromMainFile) { return CXChildVisitResult.CXChildVisit_Continue; } diff --git a/ClangSharpPInvokeGenerator/CursorWriter.cs b/ClangSharpPInvokeGenerator/CursorWriter.cs index 385f1155..664502c4 100644 --- a/ClangSharpPInvokeGenerator/CursorWriter.cs +++ b/ClangSharpPInvokeGenerator/CursorWriter.cs @@ -334,7 +334,7 @@ private bool BeginHandleFieldDecl(CXCursor cursor, CXCursor parent) private bool BeginHandleFunctionDecl(CXCursor cursor, CXCursor parent) { Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_FunctionDecl); - Debug.Assert(cursor.Type.kind == CXTypeKind.CXType_FunctionProto); + Debug.Assert((cursor.Type.kind == CXTypeKind.CXType_FunctionProto) || ((cursor.Type.kind == CXTypeKind.CXType_Attributed) && (cursor.Type.ModifierType.kind == CXTypeKind.CXType_FunctionProto))); var type = cursor.Type; var name = GetCursorName(cursor); @@ -1331,6 +1331,11 @@ private string GetTypeNameForPointeeType(CXCursor cursor, CXType pointeeType) return GetTypeNameForPointeeType(cursor, pointeeType.CanonicalType); } + case CXTypeKind.CXType_Attributed: + { + return GetTypeNameForPointeeType(cursor, pointeeType.ModifierType); + } + default: { Unhandled(cursor, pointeeType); diff --git a/ClangSharpPInvokeGenerator/Program.cs b/ClangSharpPInvokeGenerator/Program.cs index 88ed382e..c3ed6ee4 100644 --- a/ClangSharpPInvokeGenerator/Program.cs +++ b/ClangSharpPInvokeGenerator/Program.cs @@ -89,12 +89,17 @@ public static int Run(InvocationContext context) arr = arr.Concat(defines.Select(x => "-D" + x)).ToArray(); arr = arr.Concat(additionalArgs).ToArray(); + var translationFlags = CXTranslationUnit_Flags.CXTranslationUnit_None; + translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_SkipFunctionBodies; // Don't traverse function bodies + translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes; // Include attributed types in CXType + translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes; // Implicit attributes should be visited + using (var createIndex = CXIndex.Create()) using (var writer = new CursorWriter(config)) { foreach (var file in files) { - var translationUnitError = CXTranslationUnit.Parse(createIndex, file, arr, Array.Empty(), CXTranslationUnit_Flags.CXTranslationUnit_None, out CXTranslationUnit translationUnit); + var translationUnitError = CXTranslationUnit.Parse(createIndex, file, arr, Array.Empty(), translationFlags, out CXTranslationUnit translationUnit); if (translationUnitError != CXErrorCode.CXError_Success) { From f2a2e50f3783864f97447844f3052a88c0bb284a Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sat, 11 May 2019 13:16:26 -0700 Subject: [PATCH 2/3] Adding support for parsing expressions attached to EnumConstantDecl --- .../AttachedOperatorData.cs | 30 + ClangSharpPInvokeGenerator/CursorVisitor.cs | 28 + ClangSharpPInvokeGenerator/CursorWriter.cs | 926 ++++++++++++++---- 3 files changed, 768 insertions(+), 216 deletions(-) create mode 100644 ClangSharpPInvokeGenerator/AttachedOperatorData.cs diff --git a/ClangSharpPInvokeGenerator/AttachedOperatorData.cs b/ClangSharpPInvokeGenerator/AttachedOperatorData.cs new file mode 100644 index 00000000..5a3558d9 --- /dev/null +++ b/ClangSharpPInvokeGenerator/AttachedOperatorData.cs @@ -0,0 +1,30 @@ +using ClangSharp; +using System.Diagnostics; + +namespace ClangSharpPInvokeGenerator +{ + public struct AttachedOperatorData + { + public AttachedOperatorData(CXCursorKind kind, string @operator) + { + Kind = kind; + Operator = @operator; + + if (kind == CXCursorKind.CXCursor_UnaryOperator) + { + RemainingOperandCount = 1; + } + else + { + Debug.Assert(kind == CXCursorKind.CXCursor_BinaryOperator); + RemainingOperandCount = 2; + } + } + + public CXCursorKind Kind { get; } + + public string Operator { get; } + + public int RemainingOperandCount { get; set; } + } +} diff --git a/ClangSharpPInvokeGenerator/CursorVisitor.cs b/ClangSharpPInvokeGenerator/CursorVisitor.cs index 55476a36..78f75ed6 100644 --- a/ClangSharpPInvokeGenerator/CursorVisitor.cs +++ b/ClangSharpPInvokeGenerator/CursorVisitor.cs @@ -27,6 +27,11 @@ public CXChildVisitResult VisitBinaryOperator(CXCursor cursor, CXCursor parent, return Handle(VisitParenExpr, cursor, parent, data); } + case CXCursorKind.CXCursor_BinaryOperator: + { + return Handle(VisitBinaryOperator, cursor, parent, data); + } + default: { return Unhandled(cursor, parent); @@ -91,6 +96,11 @@ public CXChildVisitResult VisitEnumConstantDecl(CXCursor cursor, CXCursor parent return Handle(VisitBinaryOperator, cursor, parent, data); } + case CXCursorKind.CXCursor_UnexposedExpr: + { + return Handle(VisitUnexposedExpr, cursor, parent, data); + } + default: { return Unhandled(cursor, parent); @@ -412,6 +422,24 @@ public CXChildVisitResult VisitUnexposedDecl(CXCursor cursor, CXCursor parent, C } } + public CXChildVisitResult VisitUnexposedExpr(CXCursor cursor, CXCursor parent, CXClientData data) + { + Debug.Assert(parent.Kind == CXCursorKind.CXCursor_UnexposedExpr); + + switch (cursor.Kind) + { + case CXCursorKind.CXCursor_IntegerLiteral: + { + return Handle(VisitIntegerLiteral, cursor, parent, data); + } + + default: + { + return Unhandled(cursor, parent); + } + } + } + protected virtual bool BeginHandle(CXCursor cursor, CXCursor parent) { return true; diff --git a/ClangSharpPInvokeGenerator/CursorWriter.cs b/ClangSharpPInvokeGenerator/CursorWriter.cs index 664502c4..022934a0 100644 --- a/ClangSharpPInvokeGenerator/CursorWriter.cs +++ b/ClangSharpPInvokeGenerator/CursorWriter.cs @@ -67,11 +67,7 @@ protected override bool BeginHandle(CXCursor cursor, CXCursor parent) { case CXCursorKind.CXCursor_UnexposedDecl: { - if (_predicatedCursors.TryPeek(out var activeCursor) && activeCursor.Equals(cursor)) - { - _predicatedCursors.Pop(); - } - return true; + return BeginHandleUnexposedDecl(cursor, parent); } case CXCursorKind.CXCursor_StructDecl: @@ -114,6 +110,36 @@ protected override bool BeginHandle(CXCursor cursor, CXCursor parent) return BeginHandleTypeRef(cursor, parent); } + case CXCursorKind.CXCursor_UnexposedExpr: + { + return BeginHandleUnexposedExpr(cursor, parent); + } + + case CXCursorKind.CXCursor_DeclRefExpr: + { + return BeginHandleDeclRefExpr(cursor, parent); + } + + case CXCursorKind.CXCursor_IntegerLiteral: + { + return BeginHandleIntegerLiteral(cursor, parent); + } + + case CXCursorKind.CXCursor_ParenExpr: + { + return BeginHandleParenExpr(cursor, parent); + } + + case CXCursorKind.CXCursor_UnaryOperator: + { + return BeginHandleUnaryOperator(cursor, parent); + } + + case CXCursorKind.CXCursor_BinaryOperator: + { + return BeginHandleBinaryOperator(cursor, parent); + } + case CXCursorKind.CXCursor_UnexposedAttr: case CXCursorKind.CXCursor_DLLImport: { @@ -149,6 +175,9 @@ protected override void EndHandle(CXCursor cursor, CXCursor parent) { case CXCursorKind.CXCursor_UnexposedDecl: case CXCursorKind.CXCursor_TypeRef: + case CXCursorKind.CXCursor_UnexposedExpr: + case CXCursorKind.CXCursor_DeclRefExpr: + case CXCursorKind.CXCursor_IntegerLiteral: case CXCursorKind.CXCursor_UnexposedAttr: case CXCursorKind.CXCursor_DLLImport: { @@ -174,7 +203,6 @@ protected override void EndHandle(CXCursor cursor, CXCursor parent) case CXCursorKind.CXCursor_EnumConstantDecl: { _outputBuilder.WriteLine(','); - clearOutputBuilder = false; break; } @@ -208,7 +236,7 @@ protected override void EndHandle(CXCursor cursor, CXCursor parent) } _attachedData[parent] = functionDeclData; } - else if (parent.Kind != CXCursorKind.CXCursor_ParmDecl) + else if ((parent.Kind != CXCursorKind.CXCursor_FieldDecl) && (parent.Kind != CXCursorKind.CXCursor_ParmDecl)) { Unhandled(cursor, parent); } @@ -226,6 +254,32 @@ protected override void EndHandle(CXCursor cursor, CXCursor parent) break; } + case CXCursorKind.CXCursor_ParenExpr: + { + _outputBuilder.Write(')'); + clearOutputBuilder = false; + break; + } + + case CXCursorKind.CXCursor_UnaryOperator: + case CXCursorKind.CXCursor_BinaryOperator: + { + // Clang currently uses the PostChildrenVisitor which clears data0 + cursor.data0 = IntPtr.Zero; + + if (_attachedData.TryGetValue(cursor, out var data) && (data is AttachedOperatorData operatorData)) + { + Debug.Assert(operatorData.RemainingOperandCount == 0); + _attachedData.Remove(cursor); + } + else + { + Unhandled(cursor, parent); + } + clearOutputBuilder = false; + break; + } + default: { Unhandled(cursor, parent); @@ -239,96 +293,199 @@ protected override void EndHandle(CXCursor cursor, CXCursor parent) } } - private bool BeginHandleEnumConstantDecl(CXCursor cursor, CXCursor parent) + private bool BeginHandleBinaryOperator(CXCursor cursor, CXCursor parent) { - Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_EnumConstantDecl); + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_BinaryOperator); + + if (_attachedData.TryGetValue(parent, out var data) && !(data is AttachedOperatorData)) + { + Unhandled(cursor, parent); + return false; + } - var name = GetCursorName(cursor); + if (parent.Kind == CXCursorKind.CXCursor_EnumConstantDecl) + { + _outputBuilder.Write(" = "); + } + else if (parent.Kind == CXCursorKind.CXCursor_BinaryOperator) + { + var operatorData = (AttachedOperatorData)(_attachedData[parent]); + operatorData.RemainingOperandCount--; + _attachedData[parent] = operatorData; + } + else if (parent.Kind != CXCursorKind.CXCursor_ParenExpr) + { + Unhandled(cursor, parent); + return false; + } - _outputBuilder.WriteIndentation(); - _outputBuilder.Write(EscapeName(name)); - _outputBuilder.Write(" = "); - _outputBuilder.Write(cursor.EnumConstantDeclValue); + var translationUnit = cursor.TranslationUnit; + translationUnit.Tokenize(cursor.Extent, out CXToken[] tokens); - return false; + Debug.Assert(tokens.Length >= 3); + + var operatorIndex = GetOperatorIndex(cursor, tokens); + Debug.Assert(tokens[operatorIndex].Kind == CXTokenKind.CXToken_Punctuation); + var @operator = tokens[operatorIndex].GetSpelling(translationUnit).ToString(); + + // Clang currently uses the PostChildrenVisitor which clears data0 + cursor.data0 = IntPtr.Zero; + + _attachedData.Add(cursor, new AttachedOperatorData(cursor.Kind, @operator)); + return true; } - private bool BeginHandleEnumDecl(CXCursor cursor, CXCursor parent) + private bool BeginHandleDeclRefExpr(CXCursor cursor, CXCursor parent) { - Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_EnumDecl); + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_DeclRefExpr); - var name = GetCursorName(cursor); - InitializeOutputBuilder(name); + var translationUnit = cursor.TranslationUnit; + translationUnit.Tokenize(cursor.Extent, out CXToken[] tokens); - _outputBuilder.WriteIndented("public enum"); - _outputBuilder.Write(' '); - _outputBuilder.Write(EscapeName(name)); + Debug.Assert(tokens.Length == 1); + Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Identifier); - var integerTypeName = GetTypeName(cursor, cursor.EnumDecl_IntegerType); + var identifier = tokens[0].GetSpelling(translationUnit).ToString(); - if (!integerTypeName.Equals("int")) + if (!_attachedData.TryGetValue(parent, out var data)) { - _outputBuilder.Write(" : "); - _outputBuilder.Write(integerTypeName); + if (parent.Kind == CXCursorKind.CXCursor_EnumConstantDecl) + { + _outputBuilder.Write(" = "); + _outputBuilder.Write(identifier); + return true; + } + else + { + Unhandled(cursor, parent); + return false; + } } - _outputBuilder.WriteLine(); - _outputBuilder.WriteBlockStart(); - - return true; + if (data is AttachedOperatorData operatorData) + { + return HandleAttachedOperatorData(parent, identifier, operatorData); + } + else + { + Unhandled(cursor, parent); + return false; + } } - private bool BeginHandleFieldDecl(CXCursor cursor, CXCursor parent) + private bool BeginHandleEnumConstantDecl(CXCursor cursor, CXCursor parent) { - Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_FieldDecl); + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_EnumConstantDecl); - _outputBuilder.WriteIndentation(); + if (_attachedData.TryGetValue(parent, out var data)) + { + Unhandled(cursor, parent); + return false; + } + else + { + var name = GetCursorName(cursor); + + _outputBuilder.WriteIndentation(); + _outputBuilder.Write(EscapeName(name)); + + return true; + } + } - var marshalAttribute = GetMarshalAttribute(cursor, cursor.Type); + private bool BeginHandleEnumDecl(CXCursor cursor, CXCursor parent) + { + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_EnumDecl); - if (!string.IsNullOrWhiteSpace(marshalAttribute)) + if (_attachedData.TryGetValue(parent, out var data)) { - _outputBuilder.AddUsing("System.Runtime.InteropServices"); + Unhandled(cursor, parent); + return false; + } + else + { + var name = GetCursorName(cursor); + InitializeOutputBuilder(name); - _outputBuilder.Write('['); - _outputBuilder.Write(marshalAttribute); - _outputBuilder.Write(']'); + _outputBuilder.WriteIndented("public enum"); _outputBuilder.Write(' '); - } + _outputBuilder.Write(EscapeName(name)); + + var integerTypeName = GetTypeName(cursor, cursor.EnumDecl_IntegerType); - long lastElement = -1; + if (!integerTypeName.Equals("int")) + { + _outputBuilder.Write(" : "); + _outputBuilder.Write(integerTypeName); + } + + _outputBuilder.WriteLine(); + _outputBuilder.WriteBlockStart(); - var name = GetCursorName(cursor); - var escapedName = EscapeName(name); + return true; + } + } - if (cursor.Type.kind == CXTypeKind.CXType_ConstantArray) + private bool BeginHandleFieldDecl(CXCursor cursor, CXCursor parent) + { + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_FieldDecl); + + if (_attachedData.TryGetValue(parent, out var data)) + { + Unhandled(cursor, parent); + return false; + } + else { - lastElement = cursor.Type.NumElements - 1; + _outputBuilder.WriteIndentation(); + + var marshalAttribute = GetMarshalAttribute(cursor, cursor.Type); - for (int i = 0; i < lastElement; i++) + if (!string.IsNullOrWhiteSpace(marshalAttribute)) { - _outputBuilder.Write("public"); - _outputBuilder.Write(' '); - _outputBuilder.Write(GetTypeName(cursor, cursor.Type)); - _outputBuilder.Write(' '); - _outputBuilder.Write(escapedName); - _outputBuilder.Write(i); - _outputBuilder.Write(';'); + _outputBuilder.AddUsing("System.Runtime.InteropServices"); + + _outputBuilder.Write('['); + _outputBuilder.Write(marshalAttribute); + _outputBuilder.Write(']'); _outputBuilder.Write(' '); } - } - _outputBuilder.Write("public"); - _outputBuilder.Write(' '); - _outputBuilder.Write(GetTypeName(cursor, cursor.Type)); - _outputBuilder.Write(' '); - _outputBuilder.Write(escapedName); + long lastElement = -1; - if (lastElement != -1) - { - _outputBuilder.Write(lastElement); + var name = GetCursorName(cursor); + var escapedName = EscapeName(name); + + if (cursor.Type.kind == CXTypeKind.CXType_ConstantArray) + { + lastElement = cursor.Type.NumElements - 1; + + for (int i = 0; i < lastElement; i++) + { + _outputBuilder.Write("public"); + _outputBuilder.Write(' '); + _outputBuilder.Write(GetTypeName(cursor, cursor.Type)); + _outputBuilder.Write(' '); + _outputBuilder.Write(escapedName); + _outputBuilder.Write(i); + _outputBuilder.Write(';'); + _outputBuilder.Write(' '); + } + } + + _outputBuilder.Write("public"); + _outputBuilder.Write(' '); + _outputBuilder.Write(GetTypeName(cursor, cursor.Type)); + _outputBuilder.Write(' '); + _outputBuilder.Write(escapedName); + + if (lastElement != -1) + { + _outputBuilder.Write(lastElement); + } + + return true; } - return false; } private bool BeginHandleFunctionDecl(CXCursor cursor, CXCursor parent) @@ -336,49 +493,135 @@ private bool BeginHandleFunctionDecl(CXCursor cursor, CXCursor parent) Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_FunctionDecl); Debug.Assert((cursor.Type.kind == CXTypeKind.CXType_FunctionProto) || ((cursor.Type.kind == CXTypeKind.CXType_Attributed) && (cursor.Type.ModifierType.kind == CXTypeKind.CXType_FunctionProto))); - var type = cursor.Type; - var name = GetCursorName(cursor); - - if (_config.ExcludedFunctions.Contains(name)) + if (_attachedData.TryGetValue(parent, out var data)) { + Unhandled(cursor, parent); return false; } - InitializeOutputBuilder(_config.MethodClassName); + else + { + var type = cursor.Type; + var name = GetCursorName(cursor); + + if (_config.ExcludedFunctions.Contains(name)) + { + return false; + } + InitializeOutputBuilder(_config.MethodClassName); + + _attachedData.Add(cursor, new AttachedFunctionDeclData(type.NumArgTypes)); + + _outputBuilder.AddUsing("System.Runtime.InteropServices"); + + _outputBuilder.WriteIndented("[DllImport(libraryPath, EntryPoint = \""); + _outputBuilder.Write(name); + _outputBuilder.Write("\", CallingConvention = CallingConvention."); + _outputBuilder.Write(GetCallingConventionName(cursor, type.FunctionTypeCallingConv)); + _outputBuilder.WriteLine(")]"); + + var marshalAttribute = GetMarshalAttribute(cursor, type.ResultType); + + if (!string.IsNullOrWhiteSpace(marshalAttribute)) + { + _outputBuilder.WriteIndented("[return: "); + _outputBuilder.Write(marshalAttribute); + _outputBuilder.Write(']'); + _outputBuilder.WriteLine(); + } - _attachedData.Add(cursor, new AttachedFunctionDeclData(type.NumArgTypes)); + if (name.StartsWith(_config.MethodPrefixToStrip)) + { + name = name.Substring(_config.MethodPrefixToStrip.Length); + } + name = EscapeName(name); - _outputBuilder.AddUsing("System.Runtime.InteropServices"); + _outputBuilder.WriteIndented("public static extern"); + _outputBuilder.Write(' '); + _outputBuilder.Write(GetTypeName(cursor, type.ResultType)); + _outputBuilder.Write(' '); + _outputBuilder.Write(name); + _outputBuilder.Write('('); - _outputBuilder.WriteIndented("[DllImport(libraryPath, EntryPoint = \""); - _outputBuilder.Write(name); - _outputBuilder.Write("\", CallingConvention = CallingConvention."); - _outputBuilder.Write(GetCallingConventionName(cursor, type.FunctionTypeCallingConv)); - _outputBuilder.WriteLine(")]"); + return true; + } + } - var marshalAttribute = GetMarshalAttribute(cursor, type.ResultType); + private bool BeginHandleIntegerLiteral(CXCursor cursor, CXCursor parent) + { + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_IntegerLiteral); - if (!string.IsNullOrWhiteSpace(marshalAttribute)) + if (parent.Kind == CXCursorKind.CXCursor_FieldDecl) { - _outputBuilder.WriteIndented("[return: "); - _outputBuilder.Write(marshalAttribute); - _outputBuilder.Write(']'); - _outputBuilder.WriteLine(); + return false; } - if (name.StartsWith(_config.MethodPrefixToStrip)) + var translationUnit = cursor.TranslationUnit; + translationUnit.Tokenize(cursor.Extent, out CXToken[] tokens); + + Debug.Assert(tokens.Length == 1); + Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Literal); + + var literal = tokens[0].GetSpelling(translationUnit).ToString(); + + if (!_attachedData.TryGetValue(parent, out var data)) + { + if (parent.Kind == CXCursorKind.CXCursor_EnumConstantDecl) + { + _outputBuilder.Write(" = "); + _outputBuilder.Write(literal); + return true; + } + else if (parent.Kind == CXCursorKind.CXCursor_UnexposedExpr) + { + _outputBuilder.Write(literal); + return true; + } + else + { + Unhandled(cursor, parent); + return false; + } + } + + if (data is AttachedOperatorData operatorData) + { + return HandleAttachedOperatorData(parent, literal, operatorData); + } + else { - name = name.Substring(_config.MethodPrefixToStrip.Length); + Unhandled(cursor, parent); + return false; } - name = EscapeName(name); + } - _outputBuilder.WriteIndented("public static extern"); - _outputBuilder.Write(' '); - _outputBuilder.Write(GetTypeName(cursor, type.ResultType)); - _outputBuilder.Write(' '); - _outputBuilder.Write(name); - _outputBuilder.Write('('); + private bool BeginHandleParenExpr(CXCursor cursor, CXCursor parent) + { + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_ParenExpr); - return true; + if (!_attachedData.TryGetValue(parent, out var data)) + { + if (parent.Kind == CXCursorKind.CXCursor_EnumConstantDecl) + { + _outputBuilder.Write(" = "); + _outputBuilder.Write('('); + return true; + } + else + { + Unhandled(cursor, parent); + return false; + } + } + + if (data is AttachedOperatorData operatorData) + { + return HandleAttachedOperatorData(parent, "(", operatorData); + } + else + { + Unhandled(cursor, parent); + return false; + } } private bool BeginHandleParmDecl(CXCursor cursor, CXCursor parent) @@ -417,116 +660,136 @@ private bool BeginHandleParmDecl(CXCursor cursor, CXCursor parent) } return true; } - else if (parent.Kind != CXCursorKind.CXCursor_ParmDecl) + else if ((parent.Kind == CXCursorKind.CXCursor_FieldDecl) || (parent.Kind == CXCursorKind.CXCursor_ParmDecl)) + { + return true; + } + else { Unhandled(cursor, parent); + return false; } - - return false; } private bool BeginHandleStructDecl(CXCursor cursor, CXCursor parent) { Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_StructDecl); - var name = GetCursorName(cursor); - InitializeOutputBuilder(name); + if (_attachedData.TryGetValue(parent, out var data)) + { + Unhandled(cursor, parent); + return false; + } + else + { + var name = GetCursorName(cursor); + InitializeOutputBuilder(name); - _outputBuilder.WriteIndented("public"); + _outputBuilder.WriteIndented("public"); - if (_config.GenerateUnsafeCode) - { + if (_config.GenerateUnsafeCode) + { + _outputBuilder.Write(' '); + _outputBuilder.Write("unsafe"); + } _outputBuilder.Write(' '); - _outputBuilder.Write("unsafe"); - } - _outputBuilder.Write(' '); - _outputBuilder.Write("partial struct"); - _outputBuilder.Write(' '); - _outputBuilder.WriteLine(EscapeName(name)); - _outputBuilder.WriteBlockStart(); + _outputBuilder.Write("partial struct"); + _outputBuilder.Write(' '); + _outputBuilder.WriteLine(EscapeName(name)); + _outputBuilder.WriteBlockStart(); - return true; + return true; + } } private bool BeginHandleTypedefDecl(CXCursor cursor, CXCursor parent, CXType underlyingType) { Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_TypedefDecl); - switch (underlyingType.kind) + if (_attachedData.TryGetValue(parent, out var data)) { - case CXTypeKind.CXType_Bool: - case CXTypeKind.CXType_UShort: - case CXTypeKind.CXType_UInt: - case CXTypeKind.CXType_ULong: - case CXTypeKind.CXType_ULongLong: - case CXTypeKind.CXType_Short: - case CXTypeKind.CXType_Int: - case CXTypeKind.CXType_Long: - case CXTypeKind.CXType_LongLong: - case CXTypeKind.CXType_Double: - { - if (!_config.GenerateUnsafeCode) + Unhandled(cursor, parent); + return false; + } + else + { + switch (underlyingType.kind) + { + case CXTypeKind.CXType_Bool: + case CXTypeKind.CXType_UShort: + case CXTypeKind.CXType_UInt: + case CXTypeKind.CXType_ULong: + case CXTypeKind.CXType_ULongLong: + case CXTypeKind.CXType_Short: + case CXTypeKind.CXType_Int: + case CXTypeKind.CXType_Long: + case CXTypeKind.CXType_LongLong: + case CXTypeKind.CXType_Double: { - var name = GetCursorName(cursor); - InitializeOutputBuilder(name); - - var escapedName = EscapeName(name); - - _outputBuilder.WriteIndented("public partial struct"); - _outputBuilder.Write(' '); - _outputBuilder.WriteLine(escapedName); - _outputBuilder.WriteBlockStart(); + if (!_config.GenerateUnsafeCode) { - var typeName = GetTypeName(cursor, underlyingType); + var name = GetCursorName(cursor); + InitializeOutputBuilder(name); - _outputBuilder.WriteIndented("public"); - _outputBuilder.Write(' '); - _outputBuilder.Write(escapedName); - _outputBuilder.Write('('); - _outputBuilder.Write(typeName); + var escapedName = EscapeName(name); + + _outputBuilder.WriteIndented("public partial struct"); _outputBuilder.Write(' '); - _outputBuilder.Write("value"); - _outputBuilder.WriteLine(')'); + _outputBuilder.WriteLine(escapedName); _outputBuilder.WriteBlockStart(); { - _outputBuilder.WriteIndentedLine("Value = value;"); + var typeName = GetTypeName(cursor, underlyingType); + + _outputBuilder.WriteIndented("public"); + _outputBuilder.Write(' '); + _outputBuilder.Write(escapedName); + _outputBuilder.Write('('); + _outputBuilder.Write(typeName); + _outputBuilder.Write(' '); + _outputBuilder.Write("value"); + _outputBuilder.WriteLine(')'); + _outputBuilder.WriteBlockStart(); + { + _outputBuilder.WriteIndentedLine("Value = value;"); + } + _outputBuilder.WriteBlockEnd(); + _outputBuilder.WriteLine(); + _outputBuilder.WriteIndented("public"); + _outputBuilder.Write(' '); + _outputBuilder.Write(typeName); + _outputBuilder.Write(' '); + _outputBuilder.Write("Value"); + _outputBuilder.WriteLine(';'); } _outputBuilder.WriteBlockEnd(); - _outputBuilder.WriteLine(); - _outputBuilder.WriteIndented("public"); - _outputBuilder.Write(' '); - _outputBuilder.Write(typeName); - _outputBuilder.Write(' '); - _outputBuilder.Write("Value"); - _outputBuilder.WriteLine(';'); } - _outputBuilder.WriteBlockEnd(); + return true; } - return true; - } - case CXTypeKind.CXType_Pointer: - { - return BeginHandleTypedefDeclForPointer(cursor, parent, underlyingType.PointeeType); - } + case CXTypeKind.CXType_Pointer: + { + return BeginHandleTypedefDeclForPointer(cursor, parent, underlyingType.PointeeType); + } - case CXTypeKind.CXType_Record: - case CXTypeKind.CXType_Enum: - { - return false; - } + case CXTypeKind.CXType_Record: + case CXTypeKind.CXType_Enum: + { + // We recurse the struct and record declarations directly + return false; + } - case CXTypeKind.CXType_Typedef: - case CXTypeKind.CXType_Elaborated: - { - return BeginHandleTypedefDecl(cursor, parent, underlyingType.CanonicalType); - } + case CXTypeKind.CXType_Typedef: + case CXTypeKind.CXType_Elaborated: + { + return BeginHandleTypedefDecl(cursor, parent, underlyingType.CanonicalType); + } - default: - { - Unhandled(cursor, underlyingType); - return false; + default: + { + Unhandled(cursor, underlyingType); + return false; + } } } } @@ -535,82 +798,179 @@ private bool BeginHandleTypedefDeclForPointer(CXCursor cursor, CXCursor parent, { Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_TypedefDecl); - switch (pointeeType.kind) + if (_attachedData.TryGetValue(parent, out var data)) { - case CXTypeKind.CXType_Void: - case CXTypeKind.CXType_Record: + Unhandled(cursor, parent); + return false; + } + else + { + switch (pointeeType.kind) { - if (!_config.GenerateUnsafeCode) + case CXTypeKind.CXType_Void: + case CXTypeKind.CXType_Record: { - var name = GetCursorName(cursor); - InitializeOutputBuilder(name); + if (!_config.GenerateUnsafeCode) + { + var name = GetCursorName(cursor); + InitializeOutputBuilder(name); - var escapedName = EscapeName(name); + var escapedName = EscapeName(name); - _outputBuilder.AddUsing("System"); + _outputBuilder.AddUsing("System"); - _outputBuilder.WriteIndented("public partial struct"); - _outputBuilder.Write(' '); - _outputBuilder.WriteLine(escapedName); - _outputBuilder.WriteBlockStart(); - { - _outputBuilder.WriteIndented("public"); + _outputBuilder.WriteIndented("public partial struct"); _outputBuilder.Write(' '); - _outputBuilder.Write(escapedName); - _outputBuilder.WriteLine("(IntPtr pointer)"); + _outputBuilder.WriteLine(escapedName); _outputBuilder.WriteBlockStart(); { - _outputBuilder.WriteIndentedLine("Pointer = pointer;"); + _outputBuilder.WriteIndented("public"); + _outputBuilder.Write(' '); + _outputBuilder.Write(escapedName); + _outputBuilder.WriteLine("(IntPtr pointer)"); + _outputBuilder.WriteBlockStart(); + { + _outputBuilder.WriteIndentedLine("Pointer = pointer;"); + } + _outputBuilder.WriteBlockEnd(); + _outputBuilder.WriteLine(); + _outputBuilder.WriteIndentedLine("public IntPtr Pointer;"); } _outputBuilder.WriteBlockEnd(); - _outputBuilder.WriteLine(); - _outputBuilder.WriteIndentedLine("public IntPtr Pointer;"); } - _outputBuilder.WriteBlockEnd(); + return true; } - return true; - } - case CXTypeKind.CXType_FunctionProto: - { - var name = GetCursorName(cursor); - InitializeOutputBuilder(name); + case CXTypeKind.CXType_FunctionProto: + { + var name = GetCursorName(cursor); + InitializeOutputBuilder(name); - _attachedData.Add(cursor, new AttachedFunctionDeclData(pointeeType.NumArgTypes)); - var escapedName = EscapeName(name); + _attachedData.Add(cursor, new AttachedFunctionDeclData(pointeeType.NumArgTypes)); + var escapedName = EscapeName(name); - _outputBuilder.AddUsing("System.Runtime.InteropServices"); + _outputBuilder.AddUsing("System.Runtime.InteropServices"); - _outputBuilder.WriteIndented("[UnmanagedFunctionPointer(CallingConvention."); - _outputBuilder.Write(GetCallingConventionName(cursor, pointeeType.FunctionTypeCallingConv)); - _outputBuilder.WriteLine(")]"); - _outputBuilder.WriteIndented("public delegate"); - _outputBuilder.Write(' '); - _outputBuilder.Write(GetTypeName(cursor, pointeeType.ResultType)); - _outputBuilder.Write(' '); - _outputBuilder.Write(escapedName); - _outputBuilder.Write('('); + _outputBuilder.WriteIndented("[UnmanagedFunctionPointer(CallingConvention."); + _outputBuilder.Write(GetCallingConventionName(cursor, pointeeType.FunctionTypeCallingConv)); + _outputBuilder.WriteLine(")]"); + _outputBuilder.WriteIndented("public delegate"); + _outputBuilder.Write(' '); + _outputBuilder.Write(GetTypeName(cursor, pointeeType.ResultType)); + _outputBuilder.Write(' '); + _outputBuilder.Write(escapedName); + _outputBuilder.Write('('); - return true; + return true; + } + + case CXTypeKind.CXType_Elaborated: + { + return BeginHandleTypedefDeclForPointer(cursor, parent, pointeeType.CanonicalType); + } + + default: + { + Unhandled(cursor, pointeeType); + return false; + } } + } + } - case CXTypeKind.CXType_Elaborated: + private bool BeginHandleTypeRef(CXCursor cursor, CXCursor parent) + { + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_TypeRef); + + if (_attachedData.TryGetValue(parent, out var data) && !(data is AttachedFunctionDeclData)) + { + Unhandled(cursor, parent); + return false; + } + else + { + return true; + } + } + + private bool BeginHandleUnaryOperator(CXCursor cursor, CXCursor parent) + { + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_UnaryOperator); + + if (_attachedData.TryGetValue(parent, out var data)) + { + Unhandled(cursor, parent); + return false; + } + else + { + if (parent.Kind == CXCursorKind.CXCursor_EnumConstantDecl) { - return BeginHandleTypedefDeclForPointer(cursor, parent, pointeeType.CanonicalType); + _outputBuilder.Write(" = "); } - - default: + else { - Unhandled(cursor, pointeeType); + Unhandled(cursor, parent); return false; } + + var translationUnit = cursor.TranslationUnit; + translationUnit.Tokenize(cursor.Extent, out CXToken[] tokens); + + Debug.Assert(tokens.Length >= 2); + + var operatorIndex = GetOperatorIndex(cursor, tokens); + Debug.Assert(tokens[operatorIndex].Kind == CXTokenKind.CXToken_Punctuation); + var @operator = tokens[operatorIndex].GetSpelling(translationUnit).ToString(); + + // Clang currently uses the PostChildrenVisitor which clears data0 + cursor.data0 = IntPtr.Zero; + + _attachedData.Add(cursor, new AttachedOperatorData(cursor.Kind, @operator)); + + return true; } } - private bool BeginHandleTypeRef(CXCursor cursor, CXCursor parent) + private bool BeginHandleUnexposedDecl(CXCursor cursor, CXCursor parent) { - Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_TypeRef); - return true; + if (_attachedData.TryGetValue(parent, out var data)) + { + Unhandled(cursor, parent); + return false; + } + else + { + if (_predicatedCursors.TryPeek(out var activeCursor) && activeCursor.Equals(cursor)) + { + _predicatedCursors.Pop(); + } + + return true; + } + } + + private bool BeginHandleUnexposedExpr(CXCursor cursor, CXCursor parent) + { + if (_attachedData.TryGetValue(parent, out var data)) + { + Unhandled(cursor, parent); + return false; + } + else + { + if (parent.Kind == CXCursorKind.CXCursor_EnumConstantDecl) + { + _outputBuilder.Write(" = "); + } + else + { + Unhandled(cursor, parent); + return false; + } + + return true; + } } private string EscapeName(string name) @@ -736,7 +1096,16 @@ private string GetCursorName(CXCursor cursor) if (string.IsNullOrWhiteSpace(name)) { - name = GetTypeName(cursor, cursor.Type); + if (cursor.IsAnonymous) + { + cursor.Location.GetFileLocation(out var file, out var _, out var _, out var offset); + var fileName = Path.GetFileNameWithoutExtension(file.Name.ToString()); + name = $"__Anonymous{cursor.Type.KindSpelling}_{fileName}_{offset}"; + } + else + { + name = GetTypeName(cursor, cursor.Type); + } } Debug.Assert(!string.IsNullOrWhiteSpace(name)); @@ -995,6 +1364,76 @@ private string GetMarshalAttributeForPointeeType(CXCursor cursor, CXType pointee } } + private int GetOperatorIndex(CXCursor cursor, CXToken[] tokens) + { + Debug.Assert((cursor.Kind == CXCursorKind.CXCursor_UnaryOperator) || (cursor.Kind == CXCursorKind.CXCursor_BinaryOperator)); + + int operatorIndex = -1; + int parenDepth = 0; + + var translationUnit = cursor.TranslationUnit; + + for (int index = 0; index < tokens.Length; index++) + { + var token = tokens[index]; + + if (token.Kind != CXTokenKind.CXToken_Punctuation) + { + continue; + } + + var punctuation = tokens[index].GetSpelling(translationUnit).ToString(); + + switch (punctuation) + { + case "(": + { + parenDepth++; + break; + } + + case ")": + { + parenDepth--; + break; + } + + case "-": + { + if (parenDepth == 0) + { + return index; + } + + break; + } + + case "|": + case "<<": + { + Debug.Assert(cursor.Kind == CXCursorKind.CXCursor_BinaryOperator); + + if (parenDepth == 0) + { + return index; + } + + break; + } + + default: + { + Debug.WriteLine($"Unhandled punctuation kind: {punctuation}."); + Debugger.Break(); + break; + } + } + } + + Debug.Assert(operatorIndex != -1); + return operatorIndex; + } + private string GetParmModifier(CXCursor cursor, CXType type) { if (_config.GenerateUnsafeCode) @@ -1344,6 +1783,45 @@ private string GetTypeNameForPointeeType(CXCursor cursor, CXType pointeeType) } } + private bool HandleAttachedOperatorData(CXCursor parent, string token, AttachedOperatorData operatorData) + { + if (operatorData.Kind == CXCursorKind.CXCursor_UnaryOperator) + { + if (IsUnaryPrefixOperator(operatorData.Operator)) + { + _outputBuilder.Write(operatorData.Operator); + _outputBuilder.Write(token); + } + else + { + _outputBuilder.Write(token); + _outputBuilder.Write(operatorData.Operator); + } + } + else + { + Debug.Assert(operatorData.Kind == CXCursorKind.CXCursor_BinaryOperator); + + if (operatorData.RemainingOperandCount == 1) + { + _outputBuilder.Write(' '); + _outputBuilder.Write(operatorData.Operator); + _outputBuilder.Write(' '); + } + else + { + Debug.Assert(operatorData.RemainingOperandCount == 2); + } + + _outputBuilder.Write(token); + } + + operatorData.RemainingOperandCount--; + _attachedData[parent] = operatorData; + + return true; + } + private void InitializeOutputBuilder(string name) { if (_outputBuilder != null) @@ -1363,8 +1841,6 @@ private void InitializeOutputBuilder(string name) outputFile = Path.ChangeExtension(outputFile, $"{_config.MethodClassName}{Path.GetExtension(outputFile)}"); } - outputFile = outputFile.Replace(':', '_'); - if (!_outputBuilders.TryGetValue(outputFile, out _outputBuilder)) { _outputBuilder = new OutputBuilder(outputFile, _config, isMethodClass); @@ -1378,6 +1854,24 @@ private void InitializeOutputBuilder(string name) Debug.Assert(outputFile.Equals(_outputBuilder.OutputFile)); } + private bool IsUnaryPrefixOperator(string @operator) + { + switch (@operator) + { + case "-": + { + return true; + } + + default: + { + Debug.WriteLine($"Unhandled operator kind: {@operator}."); + Debugger.Break(); + return false; + } + } + } + private void Unhandled(CXCursor cursor) { Debug.WriteLine($"Unhandled cursor kind: {cursor.KindSpelling}"); From cb10fbf64bf6bdc7a49d95749529b9cf76ab59fc Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sat, 11 May 2019 13:18:07 -0700 Subject: [PATCH 3/3] Regenerating ClangSharp --- ClangSharp/Generated/CXAvailabilityKind.cs | 8 +-- ClangSharp/Generated/CXCallingConv.cs | 2 +- ClangSharp/Generated/CXChildVisitResult.cs | 6 +-- ClangSharp/Generated/CXCodeComplete_Flags.cs | 10 ++-- .../CXCommentInlineCommandRenderKind.cs | 8 +-- .../Generated/CXCommentParamPassDirection.cs | 6 +-- ClangSharp/Generated/CXCompletionChunkKind.cs | 42 +++++++-------- ClangSharp/Generated/CXCompletionContext.cs | 48 ++++++++--------- ClangSharp/Generated/CXCursorKind.cs | 26 ++++----- .../CXCursor_ExceptionSpecificationKind.cs | 18 +++---- .../Generated/CXDiagnosticDisplayOptions.cs | 12 ++--- ClangSharp/Generated/CXGlobalOptFlags.cs | 8 +-- ClangSharp/Generated/CXIdxDeclInfoFlags.cs | 2 +- ClangSharp/Generated/CXIndexOptFlags.cs | 12 ++--- ClangSharp/Generated/CXLanguageKind.cs | 6 +-- ClangSharp/Generated/CXLinkageKind.cs | 10 ++-- ClangSharp/Generated/CXNameRefFlags.cs | 6 +-- .../Generated/CXObjCDeclQualifierKind.cs | 14 ++--- .../Generated/CXObjCPropertyAttrKind.cs | 28 +++++----- .../Generated/CXPrintingPolicyProperty.cs | 54 +++++++++---------- ClangSharp/Generated/CXRefQualifierKind.cs | 4 +- ClangSharp/Generated/CXReparse_Flags.cs | 2 +- .../Generated/CXSaveTranslationUnit_Flags.cs | 2 +- ClangSharp/Generated/CXSymbolRole.cs | 18 +++---- ClangSharp/Generated/CXTLSKind.cs | 4 +- ClangSharp/Generated/CXTUResourceUsageKind.cs | 8 +-- .../Generated/CXTemplateArgumentKind.cs | 20 +++---- ClangSharp/Generated/CXTokenKind.cs | 10 ++-- .../Generated/CXTranslationUnit_Flags.cs | 30 +++++------ ClangSharp/Generated/CXTypeKind.cs | 4 +- ClangSharp/Generated/CXVisibilityKind.cs | 8 +-- ClangSharp/Generated/CXVisitorResult.cs | 4 +- ClangSharp/Generated/CX_CXXAccessSpecifier.cs | 8 +-- ClangSharp/Generated/CX_StorageClass.cs | 16 +++--- 34 files changed, 232 insertions(+), 232 deletions(-) diff --git a/ClangSharp/Generated/CXAvailabilityKind.cs b/ClangSharp/Generated/CXAvailabilityKind.cs index db5c59bb..5f31c27c 100644 --- a/ClangSharp/Generated/CXAvailabilityKind.cs +++ b/ClangSharp/Generated/CXAvailabilityKind.cs @@ -2,9 +2,9 @@ namespace ClangSharp { public enum CXAvailabilityKind { - CXAvailability_Available = 0, - CXAvailability_Deprecated = 1, - CXAvailability_NotAvailable = 2, - CXAvailability_NotAccessible = 3, + CXAvailability_Available, + CXAvailability_Deprecated, + CXAvailability_NotAvailable, + CXAvailability_NotAccessible, } } diff --git a/ClangSharp/Generated/CXCallingConv.cs b/ClangSharp/Generated/CXCallingConv.cs index 803b215e..3a6d67d3 100644 --- a/ClangSharp/Generated/CXCallingConv.cs +++ b/ClangSharp/Generated/CXCallingConv.cs @@ -13,7 +13,7 @@ public enum CXCallingConv CXCallingConv_X86RegCall = 8, CXCallingConv_IntelOclBicc = 9, CXCallingConv_Win64 = 10, - CXCallingConv_X86_64Win64 = 10, + CXCallingConv_X86_64Win64 = CXCallingConv_Win64, CXCallingConv_X86_64SysV = 11, CXCallingConv_X86VectorCall = 12, CXCallingConv_Swift = 13, diff --git a/ClangSharp/Generated/CXChildVisitResult.cs b/ClangSharp/Generated/CXChildVisitResult.cs index b4d571a6..3ea88d2a 100644 --- a/ClangSharp/Generated/CXChildVisitResult.cs +++ b/ClangSharp/Generated/CXChildVisitResult.cs @@ -2,8 +2,8 @@ namespace ClangSharp { public enum CXChildVisitResult { - CXChildVisit_Break = 0, - CXChildVisit_Continue = 1, - CXChildVisit_Recurse = 2, + CXChildVisit_Break, + CXChildVisit_Continue, + CXChildVisit_Recurse, } } diff --git a/ClangSharp/Generated/CXCodeComplete_Flags.cs b/ClangSharp/Generated/CXCodeComplete_Flags.cs index 96d61a35..14cb411a 100644 --- a/ClangSharp/Generated/CXCodeComplete_Flags.cs +++ b/ClangSharp/Generated/CXCodeComplete_Flags.cs @@ -2,10 +2,10 @@ namespace ClangSharp { public enum CXCodeComplete_Flags { - CXCodeComplete_IncludeMacros = 1, - CXCodeComplete_IncludeCodePatterns = 2, - CXCodeComplete_IncludeBriefComments = 4, - CXCodeComplete_SkipPreamble = 8, - CXCodeComplete_IncludeCompletionsWithFixIts = 16, + CXCodeComplete_IncludeMacros = 0x01, + CXCodeComplete_IncludeCodePatterns = 0x02, + CXCodeComplete_IncludeBriefComments = 0x04, + CXCodeComplete_SkipPreamble = 0x08, + CXCodeComplete_IncludeCompletionsWithFixIts = 0x10, } } diff --git a/ClangSharp/Generated/CXCommentInlineCommandRenderKind.cs b/ClangSharp/Generated/CXCommentInlineCommandRenderKind.cs index 5b93d877..7e11d32a 100644 --- a/ClangSharp/Generated/CXCommentInlineCommandRenderKind.cs +++ b/ClangSharp/Generated/CXCommentInlineCommandRenderKind.cs @@ -2,9 +2,9 @@ namespace ClangSharp { public enum CXCommentInlineCommandRenderKind { - CXCommentInlineCommandRenderKind_Normal = 0, - CXCommentInlineCommandRenderKind_Bold = 1, - CXCommentInlineCommandRenderKind_Monospaced = 2, - CXCommentInlineCommandRenderKind_Emphasized = 3, + CXCommentInlineCommandRenderKind_Normal, + CXCommentInlineCommandRenderKind_Bold, + CXCommentInlineCommandRenderKind_Monospaced, + CXCommentInlineCommandRenderKind_Emphasized, } } diff --git a/ClangSharp/Generated/CXCommentParamPassDirection.cs b/ClangSharp/Generated/CXCommentParamPassDirection.cs index 10f14080..bb84a719 100644 --- a/ClangSharp/Generated/CXCommentParamPassDirection.cs +++ b/ClangSharp/Generated/CXCommentParamPassDirection.cs @@ -2,8 +2,8 @@ namespace ClangSharp { public enum CXCommentParamPassDirection { - CXCommentParamPassDirection_In = 0, - CXCommentParamPassDirection_Out = 1, - CXCommentParamPassDirection_InOut = 2, + CXCommentParamPassDirection_In, + CXCommentParamPassDirection_Out, + CXCommentParamPassDirection_InOut, } } diff --git a/ClangSharp/Generated/CXCompletionChunkKind.cs b/ClangSharp/Generated/CXCompletionChunkKind.cs index 44de9ae8..b1f8f670 100644 --- a/ClangSharp/Generated/CXCompletionChunkKind.cs +++ b/ClangSharp/Generated/CXCompletionChunkKind.cs @@ -2,26 +2,26 @@ namespace ClangSharp { public enum CXCompletionChunkKind { - CXCompletionChunk_Optional = 0, - CXCompletionChunk_TypedText = 1, - CXCompletionChunk_Text = 2, - CXCompletionChunk_Placeholder = 3, - CXCompletionChunk_Informative = 4, - CXCompletionChunk_CurrentParameter = 5, - CXCompletionChunk_LeftParen = 6, - CXCompletionChunk_RightParen = 7, - CXCompletionChunk_LeftBracket = 8, - CXCompletionChunk_RightBracket = 9, - CXCompletionChunk_LeftBrace = 10, - CXCompletionChunk_RightBrace = 11, - CXCompletionChunk_LeftAngle = 12, - CXCompletionChunk_RightAngle = 13, - CXCompletionChunk_Comma = 14, - CXCompletionChunk_ResultType = 15, - CXCompletionChunk_Colon = 16, - CXCompletionChunk_SemiColon = 17, - CXCompletionChunk_Equal = 18, - CXCompletionChunk_HorizontalSpace = 19, - CXCompletionChunk_VerticalSpace = 20, + CXCompletionChunk_Optional, + CXCompletionChunk_TypedText, + CXCompletionChunk_Text, + CXCompletionChunk_Placeholder, + CXCompletionChunk_Informative, + CXCompletionChunk_CurrentParameter, + CXCompletionChunk_LeftParen, + CXCompletionChunk_RightParen, + CXCompletionChunk_LeftBracket, + CXCompletionChunk_RightBracket, + CXCompletionChunk_LeftBrace, + CXCompletionChunk_RightBrace, + CXCompletionChunk_LeftAngle, + CXCompletionChunk_RightAngle, + CXCompletionChunk_Comma, + CXCompletionChunk_ResultType, + CXCompletionChunk_Colon, + CXCompletionChunk_SemiColon, + CXCompletionChunk_Equal, + CXCompletionChunk_HorizontalSpace, + CXCompletionChunk_VerticalSpace, } } diff --git a/ClangSharp/Generated/CXCompletionContext.cs b/ClangSharp/Generated/CXCompletionContext.cs index 9a3907d5..505a0653 100644 --- a/ClangSharp/Generated/CXCompletionContext.cs +++ b/ClangSharp/Generated/CXCompletionContext.cs @@ -3,29 +3,29 @@ namespace ClangSharp public enum CXCompletionContext { CXCompletionContext_Unexposed = 0, - CXCompletionContext_AnyType = 1, - CXCompletionContext_AnyValue = 2, - CXCompletionContext_ObjCObjectValue = 4, - CXCompletionContext_ObjCSelectorValue = 8, - CXCompletionContext_CXXClassTypeValue = 16, - CXCompletionContext_DotMemberAccess = 32, - CXCompletionContext_ArrowMemberAccess = 64, - CXCompletionContext_ObjCPropertyAccess = 128, - CXCompletionContext_EnumTag = 256, - CXCompletionContext_UnionTag = 512, - CXCompletionContext_StructTag = 1024, - CXCompletionContext_ClassTag = 2048, - CXCompletionContext_Namespace = 4096, - CXCompletionContext_NestedNameSpecifier = 8192, - CXCompletionContext_ObjCInterface = 16384, - CXCompletionContext_ObjCProtocol = 32768, - CXCompletionContext_ObjCCategory = 65536, - CXCompletionContext_ObjCInstanceMessage = 131072, - CXCompletionContext_ObjCClassMessage = 262144, - CXCompletionContext_ObjCSelectorName = 524288, - CXCompletionContext_MacroName = 1048576, - CXCompletionContext_NaturalLanguage = 2097152, - CXCompletionContext_IncludedFile = 4194304, - CXCompletionContext_Unknown = 8388607, + CXCompletionContext_AnyType = 1 << 0, + CXCompletionContext_AnyValue = 1 << 1, + CXCompletionContext_ObjCObjectValue = 1 << 2, + CXCompletionContext_ObjCSelectorValue = 1 << 3, + CXCompletionContext_CXXClassTypeValue = 1 << 4, + CXCompletionContext_DotMemberAccess = 1 << 5, + CXCompletionContext_ArrowMemberAccess = 1 << 6, + CXCompletionContext_ObjCPropertyAccess = 1 << 7, + CXCompletionContext_EnumTag = 1 << 8, + CXCompletionContext_UnionTag = 1 << 9, + CXCompletionContext_StructTag = 1 << 10, + CXCompletionContext_ClassTag = 1 << 11, + CXCompletionContext_Namespace = 1 << 12, + CXCompletionContext_NestedNameSpecifier = 1 << 13, + CXCompletionContext_ObjCInterface = 1 << 14, + CXCompletionContext_ObjCProtocol = 1 << 15, + CXCompletionContext_ObjCCategory = 1 << 16, + CXCompletionContext_ObjCInstanceMessage = 1 << 17, + CXCompletionContext_ObjCClassMessage = 1 << 18, + CXCompletionContext_ObjCSelectorName = 1 << 19, + CXCompletionContext_MacroName = 1 << 20, + CXCompletionContext_NaturalLanguage = 1 << 21, + CXCompletionContext_IncludedFile = 1 << 22, + CXCompletionContext_Unknown = ((1 << 23) - 1), } } diff --git a/ClangSharp/Generated/CXCursorKind.cs b/ClangSharp/Generated/CXCursorKind.cs index 29652565..bf9937e1 100644 --- a/ClangSharp/Generated/CXCursorKind.cs +++ b/ClangSharp/Generated/CXCursorKind.cs @@ -41,8 +41,8 @@ public enum CXCursorKind CXCursor_ObjCSynthesizeDecl = 37, CXCursor_ObjCDynamicDecl = 38, CXCursor_CXXAccessSpecifier = 39, - CXCursor_FirstDecl = 1, - CXCursor_LastDecl = 39, + CXCursor_FirstDecl = CXCursor_UnexposedDecl, + CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, CXCursor_FirstRef = 40, CXCursor_ObjCSuperClassRef = 40, CXCursor_ObjCProtocolRef = 41, @@ -55,13 +55,13 @@ public enum CXCursorKind CXCursor_LabelRef = 48, CXCursor_OverloadedDeclRef = 49, CXCursor_VariableRef = 50, - CXCursor_LastRef = 50, + CXCursor_LastRef = CXCursor_VariableRef, CXCursor_FirstInvalid = 70, CXCursor_InvalidFile = 70, CXCursor_NoDeclFound = 71, CXCursor_NotImplemented = 72, CXCursor_InvalidCode = 73, - CXCursor_LastInvalid = 73, + CXCursor_LastInvalid = CXCursor_InvalidCode, CXCursor_FirstExpr = 100, CXCursor_UnexposedExpr = 100, CXCursor_DeclRefExpr = 101, @@ -113,7 +113,7 @@ public enum CXCursorKind CXCursor_OMPArraySectionExpr = 147, CXCursor_ObjCAvailabilityCheckExpr = 148, CXCursor_FixedPointLiteral = 149, - CXCursor_LastExpr = 149, + CXCursor_LastExpr = CXCursor_FixedPointLiteral, CXCursor_FirstStmt = 200, CXCursor_UnexposedStmt = 200, CXCursor_LabelStmt = 201, @@ -131,7 +131,7 @@ public enum CXCursorKind CXCursor_BreakStmt = 213, CXCursor_ReturnStmt = 214, CXCursor_GCCAsmStmt = 215, - CXCursor_AsmStmt = 215, + CXCursor_AsmStmt = CXCursor_GCCAsmStmt, CXCursor_ObjCAtTryStmt = 216, CXCursor_ObjCAtCatchStmt = 217, CXCursor_ObjCAtFinallyStmt = 218, @@ -196,7 +196,7 @@ public enum CXCursorKind CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, - CXCursor_LastStmt = 279, + CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective, CXCursor_TranslationUnit = 300, CXCursor_FirstAttr = 400, CXCursor_UnexposedAttr = 400, @@ -237,20 +237,20 @@ public enum CXCursorKind CXCursor_ObjCRuntimeVisible = 435, CXCursor_ObjCBoxable = 436, CXCursor_FlagEnum = 437, - CXCursor_LastAttr = 437, + CXCursor_LastAttr = CXCursor_FlagEnum, CXCursor_PreprocessingDirective = 500, CXCursor_MacroDefinition = 501, CXCursor_MacroExpansion = 502, - CXCursor_MacroInstantiation = 502, + CXCursor_MacroInstantiation = CXCursor_MacroExpansion, CXCursor_InclusionDirective = 503, - CXCursor_FirstPreprocessing = 500, - CXCursor_LastPreprocessing = 503, + CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, + CXCursor_LastPreprocessing = CXCursor_InclusionDirective, CXCursor_ModuleImportDecl = 600, CXCursor_TypeAliasTemplateDecl = 601, CXCursor_StaticAssert = 602, CXCursor_FriendDecl = 603, - CXCursor_FirstExtraDecl = 600, - CXCursor_LastExtraDecl = 603, + CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, + CXCursor_LastExtraDecl = CXCursor_FriendDecl, CXCursor_OverloadCandidate = 700, } } diff --git a/ClangSharp/Generated/CXCursor_ExceptionSpecificationKind.cs b/ClangSharp/Generated/CXCursor_ExceptionSpecificationKind.cs index 01579292..79d70608 100644 --- a/ClangSharp/Generated/CXCursor_ExceptionSpecificationKind.cs +++ b/ClangSharp/Generated/CXCursor_ExceptionSpecificationKind.cs @@ -2,14 +2,14 @@ namespace ClangSharp { public enum CXCursor_ExceptionSpecificationKind { - CXCursor_ExceptionSpecificationKind_None = 0, - CXCursor_ExceptionSpecificationKind_DynamicNone = 1, - CXCursor_ExceptionSpecificationKind_Dynamic = 2, - CXCursor_ExceptionSpecificationKind_MSAny = 3, - CXCursor_ExceptionSpecificationKind_BasicNoexcept = 4, - CXCursor_ExceptionSpecificationKind_ComputedNoexcept = 5, - CXCursor_ExceptionSpecificationKind_Unevaluated = 6, - CXCursor_ExceptionSpecificationKind_Uninstantiated = 7, - CXCursor_ExceptionSpecificationKind_Unparsed = 8, + CXCursor_ExceptionSpecificationKind_None, + CXCursor_ExceptionSpecificationKind_DynamicNone, + CXCursor_ExceptionSpecificationKind_Dynamic, + CXCursor_ExceptionSpecificationKind_MSAny, + CXCursor_ExceptionSpecificationKind_BasicNoexcept, + CXCursor_ExceptionSpecificationKind_ComputedNoexcept, + CXCursor_ExceptionSpecificationKind_Unevaluated, + CXCursor_ExceptionSpecificationKind_Uninstantiated, + CXCursor_ExceptionSpecificationKind_Unparsed, } } diff --git a/ClangSharp/Generated/CXDiagnosticDisplayOptions.cs b/ClangSharp/Generated/CXDiagnosticDisplayOptions.cs index d1186da1..ca2bac42 100644 --- a/ClangSharp/Generated/CXDiagnosticDisplayOptions.cs +++ b/ClangSharp/Generated/CXDiagnosticDisplayOptions.cs @@ -2,11 +2,11 @@ namespace ClangSharp { public enum CXDiagnosticDisplayOptions { - CXDiagnostic_DisplaySourceLocation = 1, - CXDiagnostic_DisplayColumn = 2, - CXDiagnostic_DisplaySourceRanges = 4, - CXDiagnostic_DisplayOption = 8, - CXDiagnostic_DisplayCategoryId = 16, - CXDiagnostic_DisplayCategoryName = 32, + CXDiagnostic_DisplaySourceLocation = 0x01, + CXDiagnostic_DisplayColumn = 0x02, + CXDiagnostic_DisplaySourceRanges = 0x04, + CXDiagnostic_DisplayOption = 0x08, + CXDiagnostic_DisplayCategoryId = 0x10, + CXDiagnostic_DisplayCategoryName = 0x20, } } diff --git a/ClangSharp/Generated/CXGlobalOptFlags.cs b/ClangSharp/Generated/CXGlobalOptFlags.cs index acc69e99..970a4aec 100644 --- a/ClangSharp/Generated/CXGlobalOptFlags.cs +++ b/ClangSharp/Generated/CXGlobalOptFlags.cs @@ -2,9 +2,9 @@ namespace ClangSharp { public enum CXGlobalOptFlags { - CXGlobalOpt_None = 0, - CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 1, - CXGlobalOpt_ThreadBackgroundPriorityForEditing = 2, - CXGlobalOpt_ThreadBackgroundPriorityForAll = 3, + CXGlobalOpt_None = 0x0, + CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, + CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, + CXGlobalOpt_ThreadBackgroundPriorityForAll = CXGlobalOpt_ThreadBackgroundPriorityForIndexing | CXGlobalOpt_ThreadBackgroundPriorityForEditing, } } diff --git a/ClangSharp/Generated/CXIdxDeclInfoFlags.cs b/ClangSharp/Generated/CXIdxDeclInfoFlags.cs index 2b14d08a..622fcc1e 100644 --- a/ClangSharp/Generated/CXIdxDeclInfoFlags.cs +++ b/ClangSharp/Generated/CXIdxDeclInfoFlags.cs @@ -2,6 +2,6 @@ namespace ClangSharp { public enum CXIdxDeclInfoFlags { - CXIdxDeclFlag_Skipped = 1, + CXIdxDeclFlag_Skipped = 0x1, } } diff --git a/ClangSharp/Generated/CXIndexOptFlags.cs b/ClangSharp/Generated/CXIndexOptFlags.cs index 160e2aac..f8c009d5 100644 --- a/ClangSharp/Generated/CXIndexOptFlags.cs +++ b/ClangSharp/Generated/CXIndexOptFlags.cs @@ -2,11 +2,11 @@ namespace ClangSharp { public enum CXIndexOptFlags { - CXIndexOpt_None = 0, - CXIndexOpt_SuppressRedundantRefs = 1, - CXIndexOpt_IndexFunctionLocalSymbols = 2, - CXIndexOpt_IndexImplicitTemplateInstantiations = 4, - CXIndexOpt_SuppressWarnings = 8, - CXIndexOpt_SkipParsedBodiesInSession = 16, + CXIndexOpt_None = 0x0, + CXIndexOpt_SuppressRedundantRefs = 0x1, + CXIndexOpt_IndexFunctionLocalSymbols = 0x2, + CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, + CXIndexOpt_SuppressWarnings = 0x8, + CXIndexOpt_SkipParsedBodiesInSession = 0x10, } } diff --git a/ClangSharp/Generated/CXLanguageKind.cs b/ClangSharp/Generated/CXLanguageKind.cs index 8bf783c8..aa641d5d 100644 --- a/ClangSharp/Generated/CXLanguageKind.cs +++ b/ClangSharp/Generated/CXLanguageKind.cs @@ -3,8 +3,8 @@ namespace ClangSharp public enum CXLanguageKind { CXLanguage_Invalid = 0, - CXLanguage_C = 1, - CXLanguage_ObjC = 2, - CXLanguage_CPlusPlus = 3, + CXLanguage_C, + CXLanguage_ObjC, + CXLanguage_CPlusPlus, } } diff --git a/ClangSharp/Generated/CXLinkageKind.cs b/ClangSharp/Generated/CXLinkageKind.cs index a9b5e52c..3575e6ce 100644 --- a/ClangSharp/Generated/CXLinkageKind.cs +++ b/ClangSharp/Generated/CXLinkageKind.cs @@ -2,10 +2,10 @@ namespace ClangSharp { public enum CXLinkageKind { - CXLinkage_Invalid = 0, - CXLinkage_NoLinkage = 1, - CXLinkage_Internal = 2, - CXLinkage_UniqueExternal = 3, - CXLinkage_External = 4, + CXLinkage_Invalid, + CXLinkage_NoLinkage, + CXLinkage_Internal, + CXLinkage_UniqueExternal, + CXLinkage_External, } } diff --git a/ClangSharp/Generated/CXNameRefFlags.cs b/ClangSharp/Generated/CXNameRefFlags.cs index 3eb776c2..dec33ed6 100644 --- a/ClangSharp/Generated/CXNameRefFlags.cs +++ b/ClangSharp/Generated/CXNameRefFlags.cs @@ -2,8 +2,8 @@ namespace ClangSharp { public enum CXNameRefFlags { - CXNameRange_WantQualifier = 1, - CXNameRange_WantTemplateArgs = 2, - CXNameRange_WantSinglePiece = 4, + CXNameRange_WantQualifier = 0x1, + CXNameRange_WantTemplateArgs = 0x2, + CXNameRange_WantSinglePiece = 0x4, } } diff --git a/ClangSharp/Generated/CXObjCDeclQualifierKind.cs b/ClangSharp/Generated/CXObjCDeclQualifierKind.cs index 7005a6ca..b7204a27 100644 --- a/ClangSharp/Generated/CXObjCDeclQualifierKind.cs +++ b/ClangSharp/Generated/CXObjCDeclQualifierKind.cs @@ -2,12 +2,12 @@ namespace ClangSharp { public enum CXObjCDeclQualifierKind { - CXObjCDeclQualifier_None = 0, - CXObjCDeclQualifier_In = 1, - CXObjCDeclQualifier_Inout = 2, - CXObjCDeclQualifier_Out = 4, - CXObjCDeclQualifier_Bycopy = 8, - CXObjCDeclQualifier_Byref = 16, - CXObjCDeclQualifier_Oneway = 32, + CXObjCDeclQualifier_None = 0x0, + CXObjCDeclQualifier_In = 0x1, + CXObjCDeclQualifier_Inout = 0x2, + CXObjCDeclQualifier_Out = 0x4, + CXObjCDeclQualifier_Bycopy = 0x8, + CXObjCDeclQualifier_Byref = 0x10, + CXObjCDeclQualifier_Oneway = 0x20, } } diff --git a/ClangSharp/Generated/CXObjCPropertyAttrKind.cs b/ClangSharp/Generated/CXObjCPropertyAttrKind.cs index 72ce1d2e..e6e17978 100644 --- a/ClangSharp/Generated/CXObjCPropertyAttrKind.cs +++ b/ClangSharp/Generated/CXObjCPropertyAttrKind.cs @@ -2,19 +2,19 @@ namespace ClangSharp { public enum CXObjCPropertyAttrKind { - CXObjCPropertyAttr_noattr = 0, - CXObjCPropertyAttr_readonly = 1, - CXObjCPropertyAttr_getter = 2, - CXObjCPropertyAttr_assign = 4, - CXObjCPropertyAttr_readwrite = 8, - CXObjCPropertyAttr_retain = 16, - CXObjCPropertyAttr_copy = 32, - CXObjCPropertyAttr_nonatomic = 64, - CXObjCPropertyAttr_setter = 128, - CXObjCPropertyAttr_atomic = 256, - CXObjCPropertyAttr_weak = 512, - CXObjCPropertyAttr_strong = 1024, - CXObjCPropertyAttr_unsafe_unretained = 2048, - CXObjCPropertyAttr_class = 4096, + CXObjCPropertyAttr_noattr = 0x00, + CXObjCPropertyAttr_readonly = 0x01, + CXObjCPropertyAttr_getter = 0x02, + CXObjCPropertyAttr_assign = 0x04, + CXObjCPropertyAttr_readwrite = 0x08, + CXObjCPropertyAttr_retain = 0x10, + CXObjCPropertyAttr_copy = 0x20, + CXObjCPropertyAttr_nonatomic = 0x40, + CXObjCPropertyAttr_setter = 0x80, + CXObjCPropertyAttr_atomic = 0x100, + CXObjCPropertyAttr_weak = 0x200, + CXObjCPropertyAttr_strong = 0x400, + CXObjCPropertyAttr_unsafe_unretained = 0x800, + CXObjCPropertyAttr_class = 0x1000, } } diff --git a/ClangSharp/Generated/CXPrintingPolicyProperty.cs b/ClangSharp/Generated/CXPrintingPolicyProperty.cs index ca4af828..a42f1504 100644 --- a/ClangSharp/Generated/CXPrintingPolicyProperty.cs +++ b/ClangSharp/Generated/CXPrintingPolicyProperty.cs @@ -2,32 +2,32 @@ namespace ClangSharp { public enum CXPrintingPolicyProperty { - CXPrintingPolicy_Indentation = 0, - CXPrintingPolicy_SuppressSpecifiers = 1, - CXPrintingPolicy_SuppressTagKeyword = 2, - CXPrintingPolicy_IncludeTagDefinition = 3, - CXPrintingPolicy_SuppressScope = 4, - CXPrintingPolicy_SuppressUnwrittenScope = 5, - CXPrintingPolicy_SuppressInitializers = 6, - CXPrintingPolicy_ConstantArraySizeAsWritten = 7, - CXPrintingPolicy_AnonymousTagLocations = 8, - CXPrintingPolicy_SuppressStrongLifetime = 9, - CXPrintingPolicy_SuppressLifetimeQualifiers = 10, - CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors = 11, - CXPrintingPolicy_Bool = 12, - CXPrintingPolicy_Restrict = 13, - CXPrintingPolicy_Alignof = 14, - CXPrintingPolicy_UnderscoreAlignof = 15, - CXPrintingPolicy_UseVoidForZeroParams = 16, - CXPrintingPolicy_TerseOutput = 17, - CXPrintingPolicy_PolishForDeclaration = 18, - CXPrintingPolicy_Half = 19, - CXPrintingPolicy_MSWChar = 20, - CXPrintingPolicy_IncludeNewlines = 21, - CXPrintingPolicy_MSVCFormatting = 22, - CXPrintingPolicy_ConstantsAsWritten = 23, - CXPrintingPolicy_SuppressImplicitBase = 24, - CXPrintingPolicy_FullyQualifiedName = 25, - CXPrintingPolicy_LastProperty = 25, + CXPrintingPolicy_Indentation, + CXPrintingPolicy_SuppressSpecifiers, + CXPrintingPolicy_SuppressTagKeyword, + CXPrintingPolicy_IncludeTagDefinition, + CXPrintingPolicy_SuppressScope, + CXPrintingPolicy_SuppressUnwrittenScope, + CXPrintingPolicy_SuppressInitializers, + CXPrintingPolicy_ConstantArraySizeAsWritten, + CXPrintingPolicy_AnonymousTagLocations, + CXPrintingPolicy_SuppressStrongLifetime, + CXPrintingPolicy_SuppressLifetimeQualifiers, + CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + CXPrintingPolicy_Bool, + CXPrintingPolicy_Restrict, + CXPrintingPolicy_Alignof, + CXPrintingPolicy_UnderscoreAlignof, + CXPrintingPolicy_UseVoidForZeroParams, + CXPrintingPolicy_TerseOutput, + CXPrintingPolicy_PolishForDeclaration, + CXPrintingPolicy_Half, + CXPrintingPolicy_MSWChar, + CXPrintingPolicy_IncludeNewlines, + CXPrintingPolicy_MSVCFormatting, + CXPrintingPolicy_ConstantsAsWritten, + CXPrintingPolicy_SuppressImplicitBase, + CXPrintingPolicy_FullyQualifiedName, + CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName, } } diff --git a/ClangSharp/Generated/CXRefQualifierKind.cs b/ClangSharp/Generated/CXRefQualifierKind.cs index 43004eed..b40f5a23 100644 --- a/ClangSharp/Generated/CXRefQualifierKind.cs +++ b/ClangSharp/Generated/CXRefQualifierKind.cs @@ -3,7 +3,7 @@ namespace ClangSharp public enum CXRefQualifierKind { CXRefQualifier_None = 0, - CXRefQualifier_LValue = 1, - CXRefQualifier_RValue = 2, + CXRefQualifier_LValue, + CXRefQualifier_RValue, } } diff --git a/ClangSharp/Generated/CXReparse_Flags.cs b/ClangSharp/Generated/CXReparse_Flags.cs index 129993e9..0e8c6538 100644 --- a/ClangSharp/Generated/CXReparse_Flags.cs +++ b/ClangSharp/Generated/CXReparse_Flags.cs @@ -2,6 +2,6 @@ namespace ClangSharp { public enum CXReparse_Flags { - CXReparse_None = 0, + CXReparse_None = 0x0, } } diff --git a/ClangSharp/Generated/CXSaveTranslationUnit_Flags.cs b/ClangSharp/Generated/CXSaveTranslationUnit_Flags.cs index 82a6674f..85eaf27a 100644 --- a/ClangSharp/Generated/CXSaveTranslationUnit_Flags.cs +++ b/ClangSharp/Generated/CXSaveTranslationUnit_Flags.cs @@ -2,6 +2,6 @@ namespace ClangSharp { public enum CXSaveTranslationUnit_Flags { - CXSaveTranslationUnit_None = 0, + CXSaveTranslationUnit_None = 0x0, } } diff --git a/ClangSharp/Generated/CXSymbolRole.cs b/ClangSharp/Generated/CXSymbolRole.cs index b123795d..6a51694a 100644 --- a/ClangSharp/Generated/CXSymbolRole.cs +++ b/ClangSharp/Generated/CXSymbolRole.cs @@ -3,14 +3,14 @@ namespace ClangSharp public enum CXSymbolRole { CXSymbolRole_None = 0, - CXSymbolRole_Declaration = 1, - CXSymbolRole_Definition = 2, - CXSymbolRole_Reference = 4, - CXSymbolRole_Read = 8, - CXSymbolRole_Write = 16, - CXSymbolRole_Call = 32, - CXSymbolRole_Dynamic = 64, - CXSymbolRole_AddressOf = 128, - CXSymbolRole_Implicit = 256, + CXSymbolRole_Declaration = 1 << 0, + CXSymbolRole_Definition = 1 << 1, + CXSymbolRole_Reference = 1 << 2, + CXSymbolRole_Read = 1 << 3, + CXSymbolRole_Write = 1 << 4, + CXSymbolRole_Call = 1 << 5, + CXSymbolRole_Dynamic = 1 << 6, + CXSymbolRole_AddressOf = 1 << 7, + CXSymbolRole_Implicit = 1 << 8, } } diff --git a/ClangSharp/Generated/CXTLSKind.cs b/ClangSharp/Generated/CXTLSKind.cs index 4943fe00..3523992f 100644 --- a/ClangSharp/Generated/CXTLSKind.cs +++ b/ClangSharp/Generated/CXTLSKind.cs @@ -3,7 +3,7 @@ namespace ClangSharp public enum CXTLSKind { CXTLS_None = 0, - CXTLS_Dynamic = 1, - CXTLS_Static = 2, + CXTLS_Dynamic, + CXTLS_Static, } } diff --git a/ClangSharp/Generated/CXTUResourceUsageKind.cs b/ClangSharp/Generated/CXTUResourceUsageKind.cs index eb8fa2bb..ca1bd136 100644 --- a/ClangSharp/Generated/CXTUResourceUsageKind.cs +++ b/ClangSharp/Generated/CXTUResourceUsageKind.cs @@ -16,9 +16,9 @@ public enum CXTUResourceUsageKind CXTUResourceUsage_PreprocessingRecord = 12, CXTUResourceUsage_SourceManager_DataStructures = 13, CXTUResourceUsage_Preprocessor_HeaderSearch = 14, - CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = 1, - CXTUResourceUsage_MEMORY_IN_BYTES_END = 14, - CXTUResourceUsage_First = 1, - CXTUResourceUsage_Last = 14, + CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, + CXTUResourceUsage_MEMORY_IN_BYTES_END = CXTUResourceUsage_Preprocessor_HeaderSearch, + CXTUResourceUsage_First = CXTUResourceUsage_AST, + CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch, } } diff --git a/ClangSharp/Generated/CXTemplateArgumentKind.cs b/ClangSharp/Generated/CXTemplateArgumentKind.cs index 3bbaffa6..b78917a6 100644 --- a/ClangSharp/Generated/CXTemplateArgumentKind.cs +++ b/ClangSharp/Generated/CXTemplateArgumentKind.cs @@ -2,15 +2,15 @@ namespace ClangSharp { public enum CXTemplateArgumentKind { - CXTemplateArgumentKind_Null = 0, - CXTemplateArgumentKind_Type = 1, - CXTemplateArgumentKind_Declaration = 2, - CXTemplateArgumentKind_NullPtr = 3, - CXTemplateArgumentKind_Integral = 4, - CXTemplateArgumentKind_Template = 5, - CXTemplateArgumentKind_TemplateExpansion = 6, - CXTemplateArgumentKind_Expression = 7, - CXTemplateArgumentKind_Pack = 8, - CXTemplateArgumentKind_Invalid = 9, + CXTemplateArgumentKind_Null, + CXTemplateArgumentKind_Type, + CXTemplateArgumentKind_Declaration, + CXTemplateArgumentKind_NullPtr, + CXTemplateArgumentKind_Integral, + CXTemplateArgumentKind_Template, + CXTemplateArgumentKind_TemplateExpansion, + CXTemplateArgumentKind_Expression, + CXTemplateArgumentKind_Pack, + CXTemplateArgumentKind_Invalid, } } diff --git a/ClangSharp/Generated/CXTokenKind.cs b/ClangSharp/Generated/CXTokenKind.cs index dc2c090e..419e4e15 100644 --- a/ClangSharp/Generated/CXTokenKind.cs +++ b/ClangSharp/Generated/CXTokenKind.cs @@ -2,10 +2,10 @@ namespace ClangSharp { public enum CXTokenKind { - CXToken_Punctuation = 0, - CXToken_Keyword = 1, - CXToken_Identifier = 2, - CXToken_Literal = 3, - CXToken_Comment = 4, + CXToken_Punctuation, + CXToken_Keyword, + CXToken_Identifier, + CXToken_Literal, + CXToken_Comment, } } diff --git a/ClangSharp/Generated/CXTranslationUnit_Flags.cs b/ClangSharp/Generated/CXTranslationUnit_Flags.cs index f0969fed..b4266ec3 100644 --- a/ClangSharp/Generated/CXTranslationUnit_Flags.cs +++ b/ClangSharp/Generated/CXTranslationUnit_Flags.cs @@ -2,20 +2,20 @@ namespace ClangSharp { public enum CXTranslationUnit_Flags { - CXTranslationUnit_None = 0, - CXTranslationUnit_DetailedPreprocessingRecord = 1, - CXTranslationUnit_Incomplete = 2, - CXTranslationUnit_PrecompiledPreamble = 4, - CXTranslationUnit_CacheCompletionResults = 8, - CXTranslationUnit_ForSerialization = 16, - CXTranslationUnit_CXXChainedPCH = 32, - CXTranslationUnit_SkipFunctionBodies = 64, - CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 128, - CXTranslationUnit_CreatePreambleOnFirstParse = 256, - CXTranslationUnit_KeepGoing = 512, - CXTranslationUnit_SingleFileParse = 1024, - CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 2048, - CXTranslationUnit_IncludeAttributedTypes = 4096, - CXTranslationUnit_VisitImplicitAttributes = 8192, + CXTranslationUnit_None = 0x0, + CXTranslationUnit_DetailedPreprocessingRecord = 0x01, + CXTranslationUnit_Incomplete = 0x02, + CXTranslationUnit_PrecompiledPreamble = 0x04, + CXTranslationUnit_CacheCompletionResults = 0x08, + CXTranslationUnit_ForSerialization = 0x10, + CXTranslationUnit_CXXChainedPCH = 0x20, + CXTranslationUnit_SkipFunctionBodies = 0x40, + CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, + CXTranslationUnit_CreatePreambleOnFirstParse = 0x100, + CXTranslationUnit_KeepGoing = 0x200, + CXTranslationUnit_SingleFileParse = 0x400, + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, + CXTranslationUnit_IncludeAttributedTypes = 0x1000, + CXTranslationUnit_VisitImplicitAttributes = 0x2000, } } diff --git a/ClangSharp/Generated/CXTypeKind.cs b/ClangSharp/Generated/CXTypeKind.cs index b425ae34..61b8a227 100644 --- a/ClangSharp/Generated/CXTypeKind.cs +++ b/ClangSharp/Generated/CXTypeKind.cs @@ -41,8 +41,8 @@ public enum CXTypeKind CXType_UShortAccum = 36, CXType_UAccum = 37, CXType_ULongAccum = 38, - CXType_FirstBuiltin = 2, - CXType_LastBuiltin = 38, + CXType_FirstBuiltin = CXType_Void, + CXType_LastBuiltin = CXType_ULongAccum, CXType_Complex = 100, CXType_Pointer = 101, CXType_BlockPointer = 102, diff --git a/ClangSharp/Generated/CXVisibilityKind.cs b/ClangSharp/Generated/CXVisibilityKind.cs index 7026f64d..5d38e40f 100644 --- a/ClangSharp/Generated/CXVisibilityKind.cs +++ b/ClangSharp/Generated/CXVisibilityKind.cs @@ -2,9 +2,9 @@ namespace ClangSharp { public enum CXVisibilityKind { - CXVisibility_Invalid = 0, - CXVisibility_Hidden = 1, - CXVisibility_Protected = 2, - CXVisibility_Default = 3, + CXVisibility_Invalid, + CXVisibility_Hidden, + CXVisibility_Protected, + CXVisibility_Default, } } diff --git a/ClangSharp/Generated/CXVisitorResult.cs b/ClangSharp/Generated/CXVisitorResult.cs index b5c651a4..5ab9d2c0 100644 --- a/ClangSharp/Generated/CXVisitorResult.cs +++ b/ClangSharp/Generated/CXVisitorResult.cs @@ -2,7 +2,7 @@ namespace ClangSharp { public enum CXVisitorResult { - CXVisit_Break = 0, - CXVisit_Continue = 1, + CXVisit_Break, + CXVisit_Continue, } } diff --git a/ClangSharp/Generated/CX_CXXAccessSpecifier.cs b/ClangSharp/Generated/CX_CXXAccessSpecifier.cs index 5206dbd3..92a17e70 100644 --- a/ClangSharp/Generated/CX_CXXAccessSpecifier.cs +++ b/ClangSharp/Generated/CX_CXXAccessSpecifier.cs @@ -2,9 +2,9 @@ namespace ClangSharp { public enum CX_CXXAccessSpecifier { - CX_CXXInvalidAccessSpecifier = 0, - CX_CXXPublic = 1, - CX_CXXProtected = 2, - CX_CXXPrivate = 3, + CX_CXXInvalidAccessSpecifier, + CX_CXXPublic, + CX_CXXProtected, + CX_CXXPrivate, } } diff --git a/ClangSharp/Generated/CX_StorageClass.cs b/ClangSharp/Generated/CX_StorageClass.cs index 525f21ec..d5f6d3ce 100644 --- a/ClangSharp/Generated/CX_StorageClass.cs +++ b/ClangSharp/Generated/CX_StorageClass.cs @@ -2,13 +2,13 @@ namespace ClangSharp { public enum CX_StorageClass { - CX_SC_Invalid = 0, - CX_SC_None = 1, - CX_SC_Extern = 2, - CX_SC_Static = 3, - CX_SC_PrivateExtern = 4, - CX_SC_OpenCLWorkGroupLocal = 5, - CX_SC_Auto = 6, - CX_SC_Register = 7, + CX_SC_Invalid, + CX_SC_None, + CX_SC_Extern, + CX_SC_Static, + CX_SC_PrivateExtern, + CX_SC_OpenCLWorkGroupLocal, + CX_SC_Auto, + CX_SC_Register, } }