diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md index 95fa901e6..29cd32b09 100644 --- a/pkgs/ffigen/CHANGELOG.md +++ b/pkgs/ffigen/CHANGELOG.md @@ -3,10 +3,11 @@ - __Breaking change__: Code-gen the ObjC `id` type to `ObjCObjectBase` rather than `NSObject`, since not all ObjC classes inherit from `NSObject`. Eg `NSProxy`. -- __Breaking change__: Enums are now generated as real Dart enums, instead of - abstract classes. Since Dart enums cannot be empty, empty native enums are - generated as empty sealed classes. Native enum members with duplicate integer - values are handled properly, and are equal to each other in Dart as well. +- __Breaking change__: Native enums are now generated as real Dart enums, instead + of abstract classes with integer constants. Native enum members with the same + integer values are handled properly on the Dart side, and native functions + that use enums in their signatures now accept the generated enums on the Dart + side, instead of integer values. - Rename ObjC interface methods that clash with type names. Fixes https://github.com/dart-lang/native/issues/1007. - __Breaking change__: Enum integer types are implementation-defined and not diff --git a/pkgs/ffigen/example/libclang-example/generated_bindings.dart b/pkgs/ffigen/example/libclang-example/generated_bindings.dart index 3a5b35eb9..01add6dcf 100644 --- a/pkgs/ffigen/example/libclang-example/generated_bindings.dart +++ b/pkgs/ffigen/example/libclang-example/generated_bindings.dart @@ -1051,12 +1051,12 @@ class LibClang { .asFunction(); /// Determine the severity of the given diagnostic. - int clang_getDiagnosticSeverity( + CXDiagnosticSeverity clang_getDiagnosticSeverity( CXDiagnostic arg0, ) { - return _clang_getDiagnosticSeverity( + return CXDiagnosticSeverity.fromValue(_clang_getDiagnosticSeverity( arg0, - ); + )); } late final _clang_getDiagnosticSeverityPtr = @@ -1392,16 +1392,16 @@ class LibClang { /// \c CXTranslationUnit. /// /// \returns Zero on success, otherwise returns an error code. - int clang_createTranslationUnit2( + CXErrorCode clang_createTranslationUnit2( CXIndex CIdx, ffi.Pointer ast_filename, ffi.Pointer out_TU, ) { - return _clang_createTranslationUnit2( + return CXErrorCode.fromValue(_clang_createTranslationUnit2( CIdx, ast_filename, out_TU, - ); + )); } late final _clang_createTranslationUnit2Ptr = @@ -1503,7 +1503,7 @@ class LibClang { /// diagnostics produced by the compiler. /// /// \returns Zero on success, otherwise returns an error code. - int clang_parseTranslationUnit2( + CXErrorCode clang_parseTranslationUnit2( CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, @@ -1513,7 +1513,7 @@ class LibClang { int options, ffi.Pointer out_TU, ) { - return _clang_parseTranslationUnit2( + return CXErrorCode.fromValue(_clang_parseTranslationUnit2( CIdx, source_filename, command_line_args, @@ -1522,7 +1522,7 @@ class LibClang { num_unsaved_files, options, out_TU, - ); + )); } late final _clang_parseTranslationUnit2Ptr = @@ -1534,7 +1534,7 @@ class LibClang { /// Same as clang_parseTranslationUnit2 but requires a full command line /// for \c command_line_args including argv[0]. This is useful if the standard /// library paths are relative to the binary. - int clang_parseTranslationUnit2FullArgv( + CXErrorCode clang_parseTranslationUnit2FullArgv( CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, @@ -1544,7 +1544,7 @@ class LibClang { int options, ffi.Pointer out_TU, ) { - return _clang_parseTranslationUnit2FullArgv( + return CXErrorCode.fromValue(_clang_parseTranslationUnit2FullArgv( CIdx, source_filename, command_line_args, @@ -1553,7 +1553,7 @@ class LibClang { num_unsaved_files, options, out_TU, - ); + )); } late final _clang_parseTranslationUnit2FullArgvPtr = @@ -1739,10 +1739,10 @@ class LibClang { /// Returns the human-readable null-terminated C string that represents /// the name of the memory category. This string should never be freed. ffi.Pointer clang_getTUResourceUsageName( - int kind, + CXTUResourceUsageKind kind, ) { return _clang_getTUResourceUsageName( - kind, + kind.value, ); } @@ -1928,12 +1928,12 @@ class LibClang { _clang_hashCursorPtr.asFunction(); /// Retrieve the kind of the given cursor. - int clang_getCursorKind( + CXCursorKind clang_getCursorKind( CXCursor arg0, ) { - return _clang_getCursorKind( + return CXCursorKind.fromValue(_clang_getCursorKind( arg0, - ); + )); } late final _clang_getCursorKindPtr = @@ -1944,10 +1944,10 @@ class LibClang { /// Determine whether the given cursor kind represents a declaration. int clang_isDeclaration( - int arg0, + CXCursorKind arg0, ) { return _clang_isDeclaration( - arg0, + arg0.value, ); } @@ -1984,10 +1984,10 @@ class LibClang { /// other cursors. Use clang_getCursorReferenced() to determine whether a /// particular cursor refers to another entity. int clang_isReference( - int arg0, + CXCursorKind arg0, ) { return _clang_isReference( - arg0, + arg0.value, ); } @@ -1998,10 +1998,10 @@ class LibClang { /// Determine whether the given cursor kind represents an expression. int clang_isExpression( - int arg0, + CXCursorKind arg0, ) { return _clang_isExpression( - arg0, + arg0.value, ); } @@ -2013,10 +2013,10 @@ class LibClang { /// Determine whether the given cursor kind represents a statement. int clang_isStatement( - int arg0, + CXCursorKind arg0, ) { return _clang_isStatement( - arg0, + arg0.value, ); } @@ -2027,10 +2027,10 @@ class LibClang { /// Determine whether the given cursor kind represents an attribute. int clang_isAttribute( - int arg0, + CXCursorKind arg0, ) { return _clang_isAttribute( - arg0, + arg0.value, ); } @@ -2057,10 +2057,10 @@ class LibClang { /// Determine whether the given cursor kind represents an invalid /// cursor. int clang_isInvalid( - int arg0, + CXCursorKind arg0, ) { return _clang_isInvalid( - arg0, + arg0.value, ); } @@ -2072,10 +2072,10 @@ class LibClang { /// Determine whether the given cursor kind represents a translation /// unit. int clang_isTranslationUnit( - int arg0, + CXCursorKind arg0, ) { return _clang_isTranslationUnit( - arg0, + arg0.value, ); } @@ -2088,10 +2088,10 @@ class LibClang { /// Determine whether the given cursor represents a preprocessing /// element, such as a preprocessor directive or macro instantiation. int clang_isPreprocessing( - int arg0, + CXCursorKind arg0, ) { return _clang_isPreprocessing( - arg0, + arg0.value, ); } @@ -2104,10 +2104,10 @@ class LibClang { /// Determine whether the given cursor represents a currently /// unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). int clang_isUnexposed( - int arg0, + CXCursorKind arg0, ) { return _clang_isUnexposed( - arg0, + arg0.value, ); } @@ -2117,12 +2117,12 @@ class LibClang { _clang_isUnexposedPtr.asFunction(); /// Determine the linkage of the entity referred to by a given cursor. - int clang_getCursorLinkage( + CXLinkageKind clang_getCursorLinkage( CXCursor cursor, ) { - return _clang_getCursorLinkage( + return CXLinkageKind.fromValue(_clang_getCursorLinkage( cursor, - ); + )); } late final _clang_getCursorLinkagePtr = @@ -2140,12 +2140,12 @@ class LibClang { /// \param cursor The cursor to query. /// /// \returns The visibility of the cursor. - int clang_getCursorVisibility( + CXVisibilityKind clang_getCursorVisibility( CXCursor cursor, ) { - return _clang_getCursorVisibility( + return CXVisibilityKind.fromValue(_clang_getCursorVisibility( cursor, - ); + )); } late final _clang_getCursorVisibilityPtr = @@ -2160,12 +2160,12 @@ class LibClang { /// \param cursor The cursor to query. /// /// \returns The availability of the cursor. - int clang_getCursorAvailability( + CXAvailabilityKind clang_getCursorAvailability( CXCursor cursor, ) { - return _clang_getCursorAvailability( + return CXAvailabilityKind.fromValue(_clang_getCursorAvailability( cursor, - ); + )); } late final _clang_getCursorAvailabilityPtr = @@ -2252,12 +2252,12 @@ class LibClang { .asFunction(); /// Determine the "language" of the entity referred to by a given cursor. - int clang_getCursorLanguage( + CXLanguageKind clang_getCursorLanguage( CXCursor cursor, ) { - return _clang_getCursorLanguage( + return CXLanguageKind.fromValue(_clang_getCursorLanguage( cursor, - ); + )); } late final _clang_getCursorLanguagePtr = @@ -2268,12 +2268,12 @@ class LibClang { /// Determine the "thread-local storage (TLS) kind" of the declaration /// referred to by a cursor. - int clang_getCursorTLSKind( + CXTLSKind clang_getCursorTLSKind( CXCursor cursor, ) { - return _clang_getCursorTLSKind( + return CXTLSKind.fromValue(_clang_getCursorTLSKind( cursor, - ); + )); } late final _clang_getCursorTLSKindPtr = @@ -2830,14 +2830,15 @@ class LibClang { /// /// For I = 0, 1, and 2, Type, Integral, and Integral will be returned, /// respectively. - int clang_Cursor_getTemplateArgumentKind( + CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( CXCursor C, int I, ) { - return _clang_Cursor_getTemplateArgumentKind( + return CXTemplateArgumentKind.fromValue( + _clang_Cursor_getTemplateArgumentKind( C, I, - ); + )); } late final _clang_Cursor_getTemplateArgumentKindPtr = @@ -3177,10 +3178,10 @@ class LibClang { /// Retrieve the spelling of a given CXTypeKind. CXString clang_getTypeKindSpelling( - int K, + CXTypeKind K, ) { return _clang_getTypeKindSpelling( - K, + K.value, ); } @@ -3193,12 +3194,12 @@ class LibClang { /// Retrieve the calling convention associated with a function type. /// /// If a non-function type is passed in, CXCallingConv_Invalid is returned. - int clang_getFunctionTypeCallingConv( + CXCallingConv clang_getFunctionTypeCallingConv( CXType T, ) { - return _clang_getFunctionTypeCallingConv( + return CXCallingConv.fromValue(_clang_getFunctionTypeCallingConv( T, - ); + )); } late final _clang_getFunctionTypeCallingConvPtr = @@ -3550,12 +3551,12 @@ class LibClang { .asFunction(); /// Retrieve the nullability kind of a pointer type. - int clang_Type_getNullability( + CXTypeNullabilityKind clang_Type_getNullability( CXType T, ) { - return _clang_Type_getNullability( + return CXTypeNullabilityKind.fromValue(_clang_Type_getNullability( T, - ); + )); } late final _clang_Type_getNullabilityPtr = @@ -3788,12 +3789,12 @@ class LibClang { /// /// The ref-qualifier is returned for C++ functions or methods. For other types /// or non-C++ declarations, CXRefQualifier_None is returned. - int clang_Type_getCXXRefQualifier( + CXRefQualifierKind clang_Type_getCXXRefQualifier( CXType T, ) { - return _clang_Type_getCXXRefQualifier( + return CXRefQualifierKind.fromValue(_clang_Type_getCXXRefQualifier( T, - ); + )); } late final _clang_Type_getCXXRefQualifierPtr = @@ -3839,12 +3840,12 @@ class LibClang { /// If the cursor refers to a C++ declaration, its access control level within its /// parent scope is returned. Otherwise, if the cursor refers to a base specifier or /// access specifier, the specifier itself is returned. - int clang_getCXXAccessSpecifier( + CX_CXXAccessSpecifier clang_getCXXAccessSpecifier( CXCursor arg0, ) { - return _clang_getCXXAccessSpecifier( + return CX_CXXAccessSpecifier.fromValue(_clang_getCXXAccessSpecifier( arg0, - ); + )); } late final _clang_getCXXAccessSpecifierPtr = @@ -3857,12 +3858,12 @@ class LibClang { /// /// If the passed in Cursor is not a function or variable declaration, /// CX_SC_Invalid is returned else the storage class. - int clang_Cursor_getStorageClass( + CX_StorageClass clang_Cursor_getStorageClass( CXCursor arg0, ) { - return _clang_Cursor_getStorageClass( + return CX_StorageClass.fromValue(_clang_Cursor_getStorageClass( arg0, - ); + )); } late final _clang_Cursor_getStorageClassPtr = @@ -4148,11 +4149,11 @@ class LibClang { /// Get a property value for the given printing policy. int clang_PrintingPolicy_getProperty( CXPrintingPolicy Policy, - int Property, + CXPrintingPolicyProperty Property, ) { return _clang_PrintingPolicy_getProperty( Policy, - Property, + Property.value, ); } @@ -4166,12 +4167,12 @@ class LibClang { /// Set a property value for the given printing policy. void clang_PrintingPolicy_setProperty( CXPrintingPolicy Policy, - int Property, + CXPrintingPolicyProperty Property, int Value, ) { return _clang_PrintingPolicy_setProperty( Policy, - Property, + Property.value, Value, ); } @@ -5045,12 +5046,12 @@ class LibClang { /// \returns The cursor kind of the specializations that would be generated /// by instantiating the template \p C. If \p C is not a template, returns /// \c CXCursor_NoDeclFound. - int clang_getTemplateCursorKind( + CXCursorKind clang_getTemplateCursorKind( CXCursor C, ) { - return _clang_getTemplateCursorKind( + return CXCursorKind.fromValue(_clang_getTemplateCursorKind( C, - ); + )); } late final _clang_getTemplateCursorKindPtr = @@ -5160,12 +5161,12 @@ class LibClang { _clang_getTokenPtr.asFunction(); /// Determine the kind of the given token. - int clang_getTokenKind( + CXTokenKind clang_getTokenKind( CXToken arg0, ) { - return _clang_getTokenKind( + return CXTokenKind.fromValue(_clang_getTokenKind( arg0, - ); + )); } late final _clang_getTokenKindPtr = @@ -5335,10 +5336,10 @@ class LibClang { /// /// @{ CXString clang_getCursorKindSpelling( - int Kind, + CXCursorKind Kind, ) { return _clang_getCursorKindSpelling( - Kind, + Kind.value, ); } @@ -5411,14 +5412,14 @@ class LibClang { /// \param chunk_number the 0-based index of the chunk in the completion string. /// /// \returns the kind of the chunk at the index \c chunk_number. - int clang_getCompletionChunkKind( + CXCompletionChunkKind clang_getCompletionChunkKind( CXCompletionString completion_string, int chunk_number, ) { - return _clang_getCompletionChunkKind( + return CXCompletionChunkKind.fromValue(_clang_getCompletionChunkKind( completion_string, chunk_number, - ); + )); } late final _clang_getCompletionChunkKindPtr = @@ -5522,12 +5523,12 @@ class LibClang { /// \param completion_string The completion string to query. /// /// \returns The availability of the completion string. - int clang_getCompletionAvailability( + CXAvailabilityKind clang_getCompletionAvailability( CXCompletionString completion_string, ) { - return _clang_getCompletionAvailability( + return CXAvailabilityKind.fromValue(_clang_getCompletionAvailability( completion_string, - ); + )); } late final _clang_getCompletionAvailabilityPtr = @@ -5960,14 +5961,14 @@ class LibClang { /// /// \returns the container kind, or CXCursor_InvalidCode if there is not a /// container - int clang_codeCompleteGetContainerKind( + CXCursorKind clang_codeCompleteGetContainerKind( ffi.Pointer Results, ffi.Pointer IsIncomplete, ) { - return _clang_codeCompleteGetContainerKind( + return CXCursorKind.fromValue(_clang_codeCompleteGetContainerKind( Results, IsIncomplete, - ); + )); } late final _clang_codeCompleteGetContainerKindPtr = @@ -6093,12 +6094,12 @@ class LibClang { _clang_Cursor_EvaluatePtr.asFunction(); /// Returns the kind of the evaluated result. - int clang_EvalResult_getKind( + CXEvalResultKind clang_EvalResult_getKind( CXEvalResult E, ) { - return _clang_EvalResult_getKind( + return CXEvalResultKind.fromValue(_clang_EvalResult_getKind( E, - ); + )); } late final _clang_EvalResult_getKindPtr = @@ -6337,16 +6338,16 @@ class LibClang { /// a macro (and not a macro argument) the CXSourceRange will be invalid. /// /// \returns one of the CXResult enumerators. - int clang_findReferencesInFile( + CXResult clang_findReferencesInFile( CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor, ) { - return _clang_findReferencesInFile( + return CXResult.fromValue(_clang_findReferencesInFile( cursor, file, visitor, - ); + )); } late final _clang_findReferencesInFilePtr = @@ -6365,16 +6366,16 @@ class LibClang { /// each directive found. /// /// \returns one of the CXResult enumerators. - int clang_findIncludesInFile( + CXResult clang_findIncludesInFile( CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor, ) { - return _clang_findIncludesInFile( + return CXResult.fromValue(_clang_findIncludesInFile( TU, file, visitor, - ); + )); } late final _clang_findIncludesInFilePtr = @@ -6384,10 +6385,10 @@ class LibClang { _clang_findIncludesInFilePtr.asFunction(); int clang_index_isEntityObjCContainerKind( - int arg0, + CXIdxEntityKind arg0, ) { return _clang_index_isEntityObjCContainerKind( - arg0, + arg0.value, ); } @@ -7748,6 +7749,14 @@ enum CXGlobalOptFlags { final int value; const CXGlobalOptFlags(this.value); + + static CXGlobalOptFlags fromValue(int value) => switch (value) { + 0 => CXGlobalOpt_None, + 1 => CXGlobalOpt_ThreadBackgroundPriorityForIndexing, + 2 => CXGlobalOpt_ThreadBackgroundPriorityForEditing, + 3 => CXGlobalOpt_ThreadBackgroundPriorityForAll, + _ => throw ArgumentError("Unknown value for CXGlobalOptFlags: $value"), + }; } typedef NativeClang_CXIndex_setGlobalOptions = ffi.Void Function( @@ -7988,6 +7997,14 @@ enum CXLoadDiag_Error { final int value; const CXLoadDiag_Error(this.value); + + static CXLoadDiag_Error fromValue(int value) => switch (value) { + 0 => CXLoadDiag_None, + 1 => CXLoadDiag_Unknown, + 2 => CXLoadDiag_CannotLoad, + 3 => CXLoadDiag_InvalidFile, + _ => throw ArgumentError("Unknown value for CXLoadDiag_Error: $value"), + }; } typedef NativeClang_loadDiagnostics = CXDiagnosticSet Function( @@ -8051,6 +8068,16 @@ enum CXDiagnosticSeverity { final int value; const CXDiagnosticSeverity(this.value); + + static CXDiagnosticSeverity fromValue(int value) => switch (value) { + 0 => CXDiagnostic_Ignored, + 1 => CXDiagnostic_Note, + 2 => CXDiagnostic_Warning, + 3 => CXDiagnostic_Error, + 4 => CXDiagnostic_Fatal, + _ => + throw ArgumentError("Unknown value for CXDiagnosticSeverity: $value"), + }; } typedef NativeClang_getDiagnosticSeverity = ffi.UnsignedInt Function( @@ -8147,6 +8174,15 @@ enum CXErrorCode { final int value; const CXErrorCode(this.value); + + static CXErrorCode fromValue(int value) => switch (value) { + 0 => CXError_Success, + 1 => CXError_Failure, + 2 => CXError_Crashed, + 3 => CXError_InvalidArguments, + 4 => CXError_ASTReadError, + _ => throw ArgumentError("Unknown value for CXErrorCode: $value"), + }; } typedef NativeClang_createTranslationUnit2 = ffi.UnsignedInt Function( @@ -8265,6 +8301,25 @@ enum CXTUResourceUsageKind { final int value; const CXTUResourceUsageKind(this.value); + static CXTUResourceUsageKind fromValue(int value) => switch (value) { + 1 => CXTUResourceUsage_AST, + 2 => CXTUResourceUsage_Identifiers, + 3 => CXTUResourceUsage_Selectors, + 4 => CXTUResourceUsage_GlobalCompletionResults, + 5 => CXTUResourceUsage_SourceManagerContentCache, + 6 => CXTUResourceUsage_AST_SideTables, + 7 => CXTUResourceUsage_SourceManager_Membuffer_Malloc, + 8 => CXTUResourceUsage_SourceManager_Membuffer_MMap, + 9 => CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc, + 10 => CXTUResourceUsage_ExternalASTSource_Membuffer_MMap, + 11 => CXTUResourceUsage_Preprocessor, + 12 => CXTUResourceUsage_PreprocessingRecord, + 13 => CXTUResourceUsage_SourceManager_DataStructures, + 14 => CXTUResourceUsage_Preprocessor_HeaderSearch, + _ => throw ArgumentError( + "Unknown value for CXTUResourceUsageKind: $value"), + }; + @override String toString() { if (this == CXTUResourceUsage_AST) @@ -9137,6 +9192,252 @@ enum CXCursorKind { final int value; const CXCursorKind(this.value); + static CXCursorKind fromValue(int value) => switch (value) { + 1 => CXCursor_UnexposedDecl, + 2 => CXCursor_StructDecl, + 3 => CXCursor_UnionDecl, + 4 => CXCursor_ClassDecl, + 5 => CXCursor_EnumDecl, + 6 => CXCursor_FieldDecl, + 7 => CXCursor_EnumConstantDecl, + 8 => CXCursor_FunctionDecl, + 9 => CXCursor_VarDecl, + 10 => CXCursor_ParmDecl, + 11 => CXCursor_ObjCInterfaceDecl, + 12 => CXCursor_ObjCCategoryDecl, + 13 => CXCursor_ObjCProtocolDecl, + 14 => CXCursor_ObjCPropertyDecl, + 15 => CXCursor_ObjCIvarDecl, + 16 => CXCursor_ObjCInstanceMethodDecl, + 17 => CXCursor_ObjCClassMethodDecl, + 18 => CXCursor_ObjCImplementationDecl, + 19 => CXCursor_ObjCCategoryImplDecl, + 20 => CXCursor_TypedefDecl, + 21 => CXCursor_CXXMethod, + 22 => CXCursor_Namespace, + 23 => CXCursor_LinkageSpec, + 24 => CXCursor_Constructor, + 25 => CXCursor_Destructor, + 26 => CXCursor_ConversionFunction, + 27 => CXCursor_TemplateTypeParameter, + 28 => CXCursor_NonTypeTemplateParameter, + 29 => CXCursor_TemplateTemplateParameter, + 30 => CXCursor_FunctionTemplate, + 31 => CXCursor_ClassTemplate, + 32 => CXCursor_ClassTemplatePartialSpecialization, + 33 => CXCursor_NamespaceAlias, + 34 => CXCursor_UsingDirective, + 35 => CXCursor_UsingDeclaration, + 36 => CXCursor_TypeAliasDecl, + 37 => CXCursor_ObjCSynthesizeDecl, + 38 => CXCursor_ObjCDynamicDecl, + 39 => CXCursor_CXXAccessSpecifier, + 40 => CXCursor_FirstRef, + 41 => CXCursor_ObjCProtocolRef, + 42 => CXCursor_ObjCClassRef, + 43 => CXCursor_TypeRef, + 44 => CXCursor_CXXBaseSpecifier, + 45 => CXCursor_TemplateRef, + 46 => CXCursor_NamespaceRef, + 47 => CXCursor_MemberRef, + 48 => CXCursor_LabelRef, + 49 => CXCursor_OverloadedDeclRef, + 50 => CXCursor_VariableRef, + 70 => CXCursor_FirstInvalid, + 71 => CXCursor_NoDeclFound, + 72 => CXCursor_NotImplemented, + 73 => CXCursor_InvalidCode, + 100 => CXCursor_FirstExpr, + 101 => CXCursor_DeclRefExpr, + 102 => CXCursor_MemberRefExpr, + 103 => CXCursor_CallExpr, + 104 => CXCursor_ObjCMessageExpr, + 105 => CXCursor_BlockExpr, + 106 => CXCursor_IntegerLiteral, + 107 => CXCursor_FloatingLiteral, + 108 => CXCursor_ImaginaryLiteral, + 109 => CXCursor_StringLiteral, + 110 => CXCursor_CharacterLiteral, + 111 => CXCursor_ParenExpr, + 112 => CXCursor_UnaryOperator, + 113 => CXCursor_ArraySubscriptExpr, + 114 => CXCursor_BinaryOperator, + 115 => CXCursor_CompoundAssignOperator, + 116 => CXCursor_ConditionalOperator, + 117 => CXCursor_CStyleCastExpr, + 118 => CXCursor_CompoundLiteralExpr, + 119 => CXCursor_InitListExpr, + 120 => CXCursor_AddrLabelExpr, + 121 => CXCursor_StmtExpr, + 122 => CXCursor_GenericSelectionExpr, + 123 => CXCursor_GNUNullExpr, + 124 => CXCursor_CXXStaticCastExpr, + 125 => CXCursor_CXXDynamicCastExpr, + 126 => CXCursor_CXXReinterpretCastExpr, + 127 => CXCursor_CXXConstCastExpr, + 128 => CXCursor_CXXFunctionalCastExpr, + 129 => CXCursor_CXXTypeidExpr, + 130 => CXCursor_CXXBoolLiteralExpr, + 131 => CXCursor_CXXNullPtrLiteralExpr, + 132 => CXCursor_CXXThisExpr, + 133 => CXCursor_CXXThrowExpr, + 134 => CXCursor_CXXNewExpr, + 135 => CXCursor_CXXDeleteExpr, + 136 => CXCursor_UnaryExpr, + 137 => CXCursor_ObjCStringLiteral, + 138 => CXCursor_ObjCEncodeExpr, + 139 => CXCursor_ObjCSelectorExpr, + 140 => CXCursor_ObjCProtocolExpr, + 141 => CXCursor_ObjCBridgedCastExpr, + 142 => CXCursor_PackExpansionExpr, + 143 => CXCursor_SizeOfPackExpr, + 144 => CXCursor_LambdaExpr, + 145 => CXCursor_ObjCBoolLiteralExpr, + 146 => CXCursor_ObjCSelfExpr, + 147 => CXCursor_OMPArraySectionExpr, + 148 => CXCursor_ObjCAvailabilityCheckExpr, + 149 => CXCursor_FixedPointLiteral, + 200 => CXCursor_FirstStmt, + 201 => CXCursor_LabelStmt, + 202 => CXCursor_CompoundStmt, + 203 => CXCursor_CaseStmt, + 204 => CXCursor_DefaultStmt, + 205 => CXCursor_IfStmt, + 206 => CXCursor_SwitchStmt, + 207 => CXCursor_WhileStmt, + 208 => CXCursor_DoStmt, + 209 => CXCursor_ForStmt, + 210 => CXCursor_GotoStmt, + 211 => CXCursor_IndirectGotoStmt, + 212 => CXCursor_ContinueStmt, + 213 => CXCursor_BreakStmt, + 214 => CXCursor_ReturnStmt, + 215 => CXCursor_GCCAsmStmt, + 216 => CXCursor_ObjCAtTryStmt, + 217 => CXCursor_ObjCAtCatchStmt, + 218 => CXCursor_ObjCAtFinallyStmt, + 219 => CXCursor_ObjCAtThrowStmt, + 220 => CXCursor_ObjCAtSynchronizedStmt, + 221 => CXCursor_ObjCAutoreleasePoolStmt, + 222 => CXCursor_ObjCForCollectionStmt, + 223 => CXCursor_CXXCatchStmt, + 224 => CXCursor_CXXTryStmt, + 225 => CXCursor_CXXForRangeStmt, + 226 => CXCursor_SEHTryStmt, + 227 => CXCursor_SEHExceptStmt, + 228 => CXCursor_SEHFinallyStmt, + 229 => CXCursor_MSAsmStmt, + 230 => CXCursor_NullStmt, + 231 => CXCursor_DeclStmt, + 232 => CXCursor_OMPParallelDirective, + 233 => CXCursor_OMPSimdDirective, + 234 => CXCursor_OMPForDirective, + 235 => CXCursor_OMPSectionsDirective, + 236 => CXCursor_OMPSectionDirective, + 237 => CXCursor_OMPSingleDirective, + 238 => CXCursor_OMPParallelForDirective, + 239 => CXCursor_OMPParallelSectionsDirective, + 240 => CXCursor_OMPTaskDirective, + 241 => CXCursor_OMPMasterDirective, + 242 => CXCursor_OMPCriticalDirective, + 243 => CXCursor_OMPTaskyieldDirective, + 244 => CXCursor_OMPBarrierDirective, + 245 => CXCursor_OMPTaskwaitDirective, + 246 => CXCursor_OMPFlushDirective, + 247 => CXCursor_SEHLeaveStmt, + 248 => CXCursor_OMPOrderedDirective, + 249 => CXCursor_OMPAtomicDirective, + 250 => CXCursor_OMPForSimdDirective, + 251 => CXCursor_OMPParallelForSimdDirective, + 252 => CXCursor_OMPTargetDirective, + 253 => CXCursor_OMPTeamsDirective, + 254 => CXCursor_OMPTaskgroupDirective, + 255 => CXCursor_OMPCancellationPointDirective, + 256 => CXCursor_OMPCancelDirective, + 257 => CXCursor_OMPTargetDataDirective, + 258 => CXCursor_OMPTaskLoopDirective, + 259 => CXCursor_OMPTaskLoopSimdDirective, + 260 => CXCursor_OMPDistributeDirective, + 261 => CXCursor_OMPTargetEnterDataDirective, + 262 => CXCursor_OMPTargetExitDataDirective, + 263 => CXCursor_OMPTargetParallelDirective, + 264 => CXCursor_OMPTargetParallelForDirective, + 265 => CXCursor_OMPTargetUpdateDirective, + 266 => CXCursor_OMPDistributeParallelForDirective, + 267 => CXCursor_OMPDistributeParallelForSimdDirective, + 268 => CXCursor_OMPDistributeSimdDirective, + 269 => CXCursor_OMPTargetParallelForSimdDirective, + 270 => CXCursor_OMPTargetSimdDirective, + 271 => CXCursor_OMPTeamsDistributeDirective, + 272 => CXCursor_OMPTeamsDistributeSimdDirective, + 273 => CXCursor_OMPTeamsDistributeParallelForSimdDirective, + 274 => CXCursor_OMPTeamsDistributeParallelForDirective, + 275 => CXCursor_OMPTargetTeamsDirective, + 276 => CXCursor_OMPTargetTeamsDistributeDirective, + 277 => CXCursor_OMPTargetTeamsDistributeParallelForDirective, + 278 => CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective, + 279 => CXCursor_OMPTargetTeamsDistributeSimdDirective, + 280 => CXCursor_BuiltinBitCastExpr, + 281 => CXCursor_OMPMasterTaskLoopDirective, + 282 => CXCursor_OMPParallelMasterTaskLoopDirective, + 283 => CXCursor_OMPMasterTaskLoopSimdDirective, + 284 => CXCursor_OMPParallelMasterTaskLoopSimdDirective, + 285 => CXCursor_OMPParallelMasterDirective, + 300 => CXCursor_TranslationUnit, + 400 => CXCursor_FirstAttr, + 401 => CXCursor_IBActionAttr, + 402 => CXCursor_IBOutletAttr, + 403 => CXCursor_IBOutletCollectionAttr, + 404 => CXCursor_CXXFinalAttr, + 405 => CXCursor_CXXOverrideAttr, + 406 => CXCursor_AnnotateAttr, + 407 => CXCursor_AsmLabelAttr, + 408 => CXCursor_PackedAttr, + 409 => CXCursor_PureAttr, + 410 => CXCursor_ConstAttr, + 411 => CXCursor_NoDuplicateAttr, + 412 => CXCursor_CUDAConstantAttr, + 413 => CXCursor_CUDADeviceAttr, + 414 => CXCursor_CUDAGlobalAttr, + 415 => CXCursor_CUDAHostAttr, + 416 => CXCursor_CUDASharedAttr, + 417 => CXCursor_VisibilityAttr, + 418 => CXCursor_DLLExport, + 419 => CXCursor_DLLImport, + 420 => CXCursor_NSReturnsRetained, + 421 => CXCursor_NSReturnsNotRetained, + 422 => CXCursor_NSReturnsAutoreleased, + 423 => CXCursor_NSConsumesSelf, + 424 => CXCursor_NSConsumed, + 425 => CXCursor_ObjCException, + 426 => CXCursor_ObjCNSObject, + 427 => CXCursor_ObjCIndependentClass, + 428 => CXCursor_ObjCPreciseLifetime, + 429 => CXCursor_ObjCReturnsInnerPointer, + 430 => CXCursor_ObjCRequiresSuper, + 431 => CXCursor_ObjCRootClass, + 432 => CXCursor_ObjCSubclassingRestricted, + 433 => CXCursor_ObjCExplicitProtocolImpl, + 434 => CXCursor_ObjCDesignatedInitializer, + 435 => CXCursor_ObjCRuntimeVisible, + 436 => CXCursor_ObjCBoxable, + 437 => CXCursor_FlagEnum, + 438 => CXCursor_ConvergentAttr, + 439 => CXCursor_WarnUnusedAttr, + 440 => CXCursor_WarnUnusedResultAttr, + 441 => CXCursor_AlignedAttr, + 500 => CXCursor_PreprocessingDirective, + 501 => CXCursor_MacroDefinition, + 502 => CXCursor_MacroExpansion, + 503 => CXCursor_InclusionDirective, + 600 => CXCursor_ModuleImportDecl, + 601 => CXCursor_TypeAliasTemplateDecl, + 602 => CXCursor_StaticAssert, + 603 => CXCursor_FriendDecl, + 700 => CXCursor_OverloadCandidate, + _ => throw ArgumentError("Unknown value for CXCursorKind: $value"), + }; + @override String toString() { if (this == CXCursor_UnexposedDecl) @@ -9248,6 +9549,15 @@ enum CXLinkageKind { final int value; const CXLinkageKind(this.value); + + static CXLinkageKind fromValue(int value) => switch (value) { + 0 => CXLinkage_Invalid, + 1 => CXLinkage_NoLinkage, + 2 => CXLinkage_Internal, + 3 => CXLinkage_UniqueExternal, + 4 => CXLinkage_External, + _ => throw ArgumentError("Unknown value for CXLinkageKind: $value"), + }; } typedef NativeClang_getCursorLinkage = ffi.UnsignedInt Function( @@ -9270,6 +9580,14 @@ enum CXVisibilityKind { final int value; const CXVisibilityKind(this.value); + + static CXVisibilityKind fromValue(int value) => switch (value) { + 0 => CXVisibility_Invalid, + 1 => CXVisibility_Hidden, + 2 => CXVisibility_Protected, + 3 => CXVisibility_Default, + _ => throw ArgumentError("Unknown value for CXVisibilityKind: $value"), + }; } typedef NativeClang_getCursorVisibility = ffi.UnsignedInt Function( @@ -9296,6 +9614,15 @@ enum CXAvailabilityKind { final int value; const CXAvailabilityKind(this.value); + + static CXAvailabilityKind fromValue(int value) => switch (value) { + 0 => CXAvailability_Available, + 1 => CXAvailability_Deprecated, + 2 => CXAvailability_NotAvailable, + 3 => CXAvailability_NotAccessible, + _ => + throw ArgumentError("Unknown value for CXAvailabilityKind: $value"), + }; } typedef NativeClang_getCursorAvailability = ffi.UnsignedInt Function( @@ -9361,6 +9688,14 @@ enum CXLanguageKind { final int value; const CXLanguageKind(this.value); + + static CXLanguageKind fromValue(int value) => switch (value) { + 0 => CXLanguage_Invalid, + 1 => CXLanguage_C, + 2 => CXLanguage_ObjC, + 3 => CXLanguage_CPlusPlus, + _ => throw ArgumentError("Unknown value for CXLanguageKind: $value"), + }; } typedef NativeClang_getCursorLanguage = ffi.UnsignedInt Function( @@ -9376,6 +9711,13 @@ enum CXTLSKind { final int value; const CXTLSKind(this.value); + + static CXTLSKind fromValue(int value) => switch (value) { + 0 => CXTLS_None, + 1 => CXTLS_Dynamic, + 2 => CXTLS_Static, + _ => throw ArgumentError("Unknown value for CXTLSKind: $value"), + }; } typedef NativeClang_getCursorTLSKind = ffi.UnsignedInt Function( @@ -9562,6 +9904,126 @@ enum CXTypeKind { final int value; const CXTypeKind(this.value); + static CXTypeKind fromValue(int value) => switch (value) { + 0 => CXType_Invalid, + 1 => CXType_Unexposed, + 2 => CXType_Void, + 3 => CXType_Bool, + 4 => CXType_Char_U, + 5 => CXType_UChar, + 6 => CXType_Char16, + 7 => CXType_Char32, + 8 => CXType_UShort, + 9 => CXType_UInt, + 10 => CXType_ULong, + 11 => CXType_ULongLong, + 12 => CXType_UInt128, + 13 => CXType_Char_S, + 14 => CXType_SChar, + 15 => CXType_WChar, + 16 => CXType_Short, + 17 => CXType_Int, + 18 => CXType_Long, + 19 => CXType_LongLong, + 20 => CXType_Int128, + 21 => CXType_Float, + 22 => CXType_Double, + 23 => CXType_LongDouble, + 24 => CXType_NullPtr, + 25 => CXType_Overload, + 26 => CXType_Dependent, + 27 => CXType_ObjCId, + 28 => CXType_ObjCClass, + 29 => CXType_ObjCSel, + 30 => CXType_Float128, + 31 => CXType_Half, + 32 => CXType_Float16, + 33 => CXType_ShortAccum, + 34 => CXType_Accum, + 35 => CXType_LongAccum, + 36 => CXType_UShortAccum, + 37 => CXType_UAccum, + 38 => CXType_ULongAccum, + 100 => CXType_Complex, + 101 => CXType_Pointer, + 102 => CXType_BlockPointer, + 103 => CXType_LValueReference, + 104 => CXType_RValueReference, + 105 => CXType_Record, + 106 => CXType_Enum, + 107 => CXType_Typedef, + 108 => CXType_ObjCInterface, + 109 => CXType_ObjCObjectPointer, + 110 => CXType_FunctionNoProto, + 111 => CXType_FunctionProto, + 112 => CXType_ConstantArray, + 113 => CXType_Vector, + 114 => CXType_IncompleteArray, + 115 => CXType_VariableArray, + 116 => CXType_DependentSizedArray, + 117 => CXType_MemberPointer, + 118 => CXType_Auto, + 119 => CXType_Elaborated, + 120 => CXType_Pipe, + 121 => CXType_OCLImage1dRO, + 122 => CXType_OCLImage1dArrayRO, + 123 => CXType_OCLImage1dBufferRO, + 124 => CXType_OCLImage2dRO, + 125 => CXType_OCLImage2dArrayRO, + 126 => CXType_OCLImage2dDepthRO, + 127 => CXType_OCLImage2dArrayDepthRO, + 128 => CXType_OCLImage2dMSAARO, + 129 => CXType_OCLImage2dArrayMSAARO, + 130 => CXType_OCLImage2dMSAADepthRO, + 131 => CXType_OCLImage2dArrayMSAADepthRO, + 132 => CXType_OCLImage3dRO, + 133 => CXType_OCLImage1dWO, + 134 => CXType_OCLImage1dArrayWO, + 135 => CXType_OCLImage1dBufferWO, + 136 => CXType_OCLImage2dWO, + 137 => CXType_OCLImage2dArrayWO, + 138 => CXType_OCLImage2dDepthWO, + 139 => CXType_OCLImage2dArrayDepthWO, + 140 => CXType_OCLImage2dMSAAWO, + 141 => CXType_OCLImage2dArrayMSAAWO, + 142 => CXType_OCLImage2dMSAADepthWO, + 143 => CXType_OCLImage2dArrayMSAADepthWO, + 144 => CXType_OCLImage3dWO, + 145 => CXType_OCLImage1dRW, + 146 => CXType_OCLImage1dArrayRW, + 147 => CXType_OCLImage1dBufferRW, + 148 => CXType_OCLImage2dRW, + 149 => CXType_OCLImage2dArrayRW, + 150 => CXType_OCLImage2dDepthRW, + 151 => CXType_OCLImage2dArrayDepthRW, + 152 => CXType_OCLImage2dMSAARW, + 153 => CXType_OCLImage2dArrayMSAARW, + 154 => CXType_OCLImage2dMSAADepthRW, + 155 => CXType_OCLImage2dArrayMSAADepthRW, + 156 => CXType_OCLImage3dRW, + 157 => CXType_OCLSampler, + 158 => CXType_OCLEvent, + 159 => CXType_OCLQueue, + 160 => CXType_OCLReserveID, + 161 => CXType_ObjCObject, + 162 => CXType_ObjCTypeParam, + 163 => CXType_Attributed, + 164 => CXType_OCLIntelSubgroupAVCMcePayload, + 165 => CXType_OCLIntelSubgroupAVCImePayload, + 166 => CXType_OCLIntelSubgroupAVCRefPayload, + 167 => CXType_OCLIntelSubgroupAVCSicPayload, + 168 => CXType_OCLIntelSubgroupAVCMceResult, + 169 => CXType_OCLIntelSubgroupAVCImeResult, + 170 => CXType_OCLIntelSubgroupAVCRefResult, + 171 => CXType_OCLIntelSubgroupAVCSicResult, + 172 => CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout, + 173 => CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout, + 174 => CXType_OCLIntelSubgroupAVCImeSingleRefStreamin, + 175 => CXType_OCLIntelSubgroupAVCImeDualRefStreamin, + 176 => CXType_ExtVector, + _ => throw ArgumentError("Unknown value for CXTypeKind: $value"), + }; + @override String toString() { if (this == CXType_Void) @@ -9624,6 +10086,21 @@ enum CXTemplateArgumentKind { final int value; const CXTemplateArgumentKind(this.value); + + static CXTemplateArgumentKind fromValue(int value) => switch (value) { + 0 => CXTemplateArgumentKind_Null, + 1 => CXTemplateArgumentKind_Type, + 2 => CXTemplateArgumentKind_Declaration, + 3 => CXTemplateArgumentKind_NullPtr, + 4 => CXTemplateArgumentKind_Integral, + 5 => CXTemplateArgumentKind_Template, + 6 => CXTemplateArgumentKind_TemplateExpansion, + 7 => CXTemplateArgumentKind_Expression, + 8 => CXTemplateArgumentKind_Pack, + 9 => CXTemplateArgumentKind_Invalid, + _ => throw ArgumentError( + "Unknown value for CXTemplateArgumentKind: $value"), + }; } typedef NativeClang_Cursor_getTemplateArgumentKind = ffi.UnsignedInt Function( @@ -9705,6 +10182,29 @@ enum CXCallingConv { final int value; const CXCallingConv(this.value); + static CXCallingConv fromValue(int value) => switch (value) { + 0 => CXCallingConv_Default, + 1 => CXCallingConv_C, + 2 => CXCallingConv_X86StdCall, + 3 => CXCallingConv_X86FastCall, + 4 => CXCallingConv_X86ThisCall, + 5 => CXCallingConv_X86Pascal, + 6 => CXCallingConv_AAPCS, + 7 => CXCallingConv_AAPCS_VFP, + 8 => CXCallingConv_X86RegCall, + 9 => CXCallingConv_IntelOclBicc, + 10 => CXCallingConv_Win64, + 11 => CXCallingConv_X86_64SysV, + 12 => CXCallingConv_X86VectorCall, + 13 => CXCallingConv_Swift, + 14 => CXCallingConv_PreserveMost, + 15 => CXCallingConv_PreserveAll, + 16 => CXCallingConv_AArch64VectorCall, + 100 => CXCallingConv_Invalid, + 200 => CXCallingConv_Unexposed, + _ => throw ArgumentError("Unknown value for CXCallingConv: $value"), + }; + @override String toString() { if (this == CXCallingConv_Win64) @@ -9780,6 +10280,15 @@ enum CXTypeNullabilityKind { final int value; const CXTypeNullabilityKind(this.value); + + static CXTypeNullabilityKind fromValue(int value) => switch (value) { + 0 => CXTypeNullability_NonNull, + 1 => CXTypeNullability_Nullable, + 2 => CXTypeNullability_Unspecified, + 3 => CXTypeNullability_Invalid, + _ => throw ArgumentError( + "Unknown value for CXTypeNullabilityKind: $value"), + }; } typedef NativeClang_Type_getNullability = ffi.UnsignedInt Function(CXType T); @@ -9825,6 +10334,14 @@ enum CXRefQualifierKind { final int value; const CXRefQualifierKind(this.value); + + static CXRefQualifierKind fromValue(int value) => switch (value) { + 0 => CXRefQualifier_None, + 1 => CXRefQualifier_LValue, + 2 => CXRefQualifier_RValue, + _ => + throw ArgumentError("Unknown value for CXRefQualifierKind: $value"), + }; } typedef NativeClang_Type_getCXXRefQualifier = ffi.UnsignedInt Function( @@ -9845,6 +10362,15 @@ enum CX_CXXAccessSpecifier { final int value; const CX_CXXAccessSpecifier(this.value); + + static CX_CXXAccessSpecifier fromValue(int value) => switch (value) { + 0 => CX_CXXInvalidAccessSpecifier, + 1 => CX_CXXPublic, + 2 => CX_CXXProtected, + 3 => CX_CXXPrivate, + _ => throw ArgumentError( + "Unknown value for CX_CXXAccessSpecifier: $value"), + }; } typedef NativeClang_getCXXAccessSpecifier = ffi.UnsignedInt Function( @@ -9865,6 +10391,18 @@ enum CX_StorageClass { final int value; const CX_StorageClass(this.value); + + static CX_StorageClass fromValue(int value) => switch (value) { + 0 => CX_SC_Invalid, + 1 => CX_SC_None, + 2 => CX_SC_Extern, + 3 => CX_SC_Static, + 4 => CX_SC_PrivateExtern, + 5 => CX_SC_OpenCLWorkGroupLocal, + 6 => CX_SC_Auto, + 7 => CX_SC_Register, + _ => throw ArgumentError("Unknown value for CX_StorageClass: $value"), + }; } typedef NativeClang_Cursor_getStorageClass = ffi.UnsignedInt Function( @@ -9894,7 +10432,7 @@ typedef CXCursorVisitor = ffi.Pointer>; typedef CXCursorVisitorFunction = ffi.UnsignedInt Function( CXCursor cursor, CXCursor parent, CXClientData client_data); -typedef DartCXCursorVisitorFunction = int Function( +typedef DartCXCursorVisitorFunction = CXChildVisitResult Function( CXCursor cursor, CXCursor parent, CXClientData client_data); /// Describes how the traversal of the children of a particular @@ -9916,6 +10454,14 @@ enum CXChildVisitResult { final int value; const CXChildVisitResult(this.value); + + static CXChildVisitResult fromValue(int value) => switch (value) { + 0 => CXChildVisit_Break, + 1 => CXChildVisit_Continue, + 2 => CXChildVisit_Recurse, + _ => + throw ArgumentError("Unknown value for CXChildVisitResult: $value"), + }; } /// Opaque pointer representing client data that will be passed through @@ -10001,6 +10547,37 @@ enum CXPrintingPolicyProperty { final int value; const CXPrintingPolicyProperty(this.value); + static CXPrintingPolicyProperty fromValue(int value) => switch (value) { + 0 => CXPrintingPolicy_Indentation, + 1 => CXPrintingPolicy_SuppressSpecifiers, + 2 => CXPrintingPolicy_SuppressTagKeyword, + 3 => CXPrintingPolicy_IncludeTagDefinition, + 4 => CXPrintingPolicy_SuppressScope, + 5 => CXPrintingPolicy_SuppressUnwrittenScope, + 6 => CXPrintingPolicy_SuppressInitializers, + 7 => CXPrintingPolicy_ConstantArraySizeAsWritten, + 8 => CXPrintingPolicy_AnonymousTagLocations, + 9 => CXPrintingPolicy_SuppressStrongLifetime, + 10 => CXPrintingPolicy_SuppressLifetimeQualifiers, + 11 => CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + 12 => CXPrintingPolicy_Bool, + 13 => CXPrintingPolicy_Restrict, + 14 => CXPrintingPolicy_Alignof, + 15 => CXPrintingPolicy_UnderscoreAlignof, + 16 => CXPrintingPolicy_UseVoidForZeroParams, + 17 => CXPrintingPolicy_TerseOutput, + 18 => CXPrintingPolicy_PolishForDeclaration, + 19 => CXPrintingPolicy_Half, + 20 => CXPrintingPolicy_MSWChar, + 21 => CXPrintingPolicy_IncludeNewlines, + 22 => CXPrintingPolicy_MSVCFormatting, + 23 => CXPrintingPolicy_ConstantsAsWritten, + 24 => CXPrintingPolicy_SuppressImplicitBase, + 25 => CXPrintingPolicy_FullyQualifiedName, + _ => throw ArgumentError( + "Unknown value for CXPrintingPolicyProperty: $value"), + }; + @override String toString() { if (this == CXPrintingPolicy_FullyQualifiedName) @@ -10199,6 +10776,15 @@ enum CXTokenKind { final int value; const CXTokenKind(this.value); + + static CXTokenKind fromValue(int value) => switch (value) { + 0 => CXToken_Punctuation, + 1 => CXToken_Keyword, + 2 => CXToken_Identifier, + 3 => CXToken_Literal, + 4 => CXToken_Comment, + _ => throw ArgumentError("Unknown value for CXTokenKind: $value"), + }; } typedef NativeClang_getTokenKind = ffi.UnsignedInt Function(CXToken arg0); @@ -10447,6 +11033,32 @@ enum CXCompletionChunkKind { final int value; const CXCompletionChunkKind(this.value); + + static CXCompletionChunkKind fromValue(int value) => switch (value) { + 0 => CXCompletionChunk_Optional, + 1 => CXCompletionChunk_TypedText, + 2 => CXCompletionChunk_Text, + 3 => CXCompletionChunk_Placeholder, + 4 => CXCompletionChunk_Informative, + 5 => CXCompletionChunk_CurrentParameter, + 6 => CXCompletionChunk_LeftParen, + 7 => CXCompletionChunk_RightParen, + 8 => CXCompletionChunk_LeftBracket, + 9 => CXCompletionChunk_RightBracket, + 10 => CXCompletionChunk_LeftBrace, + 11 => CXCompletionChunk_RightBrace, + 12 => CXCompletionChunk_LeftAngle, + 13 => CXCompletionChunk_RightAngle, + 14 => CXCompletionChunk_Comma, + 15 => CXCompletionChunk_ResultType, + 16 => CXCompletionChunk_Colon, + 17 => CXCompletionChunk_SemiColon, + 18 => CXCompletionChunk_Equal, + 19 => CXCompletionChunk_HorizontalSpace, + 20 => CXCompletionChunk_VerticalSpace, + _ => throw ArgumentError( + "Unknown value for CXCompletionChunkKind: $value"), + }; } typedef NativeClang_getCompletionChunkKind = ffi.UnsignedInt Function( @@ -10626,6 +11238,17 @@ enum CXEvalResultKind { final int value; const CXEvalResultKind(this.value); + + static CXEvalResultKind fromValue(int value) => switch (value) { + 1 => CXEval_Int, + 2 => CXEval_Float, + 3 => CXEval_ObjCStrLiteral, + 4 => CXEval_StrLiteral, + 5 => CXEval_CFStr, + 6 => CXEval_Other, + 0 => CXEval_UnExposed, + _ => throw ArgumentError("Unknown value for CXEvalResultKind: $value"), + }; } typedef NativeClang_EvalResult_getKind = ffi.UnsignedInt Function( @@ -10696,6 +11319,12 @@ enum CXVisitorResult { final int value; const CXVisitorResult(this.value); + + static CXVisitorResult fromValue(int value) => switch (value) { + 0 => CXVisit_Break, + 1 => CXVisit_Continue, + _ => throw ArgumentError("Unknown value for CXVisitorResult: $value"), + }; } enum CXResult { @@ -10711,6 +11340,13 @@ enum CXResult { final int value; const CXResult(this.value); + + static CXResult fromValue(int value) => switch (value) { + 0 => CXResult_Success, + 1 => CXResult_Invalid, + 2 => CXResult_VisitBreak, + _ => throw ArgumentError("Unknown value for CXResult: $value"), + }; } typedef NativeClang_findReferencesInFile = ffi.UnsignedInt Function( @@ -10788,6 +11424,14 @@ enum CXIdxAttrKind { final int value; const CXIdxAttrKind(this.value); + + static CXIdxAttrKind fromValue(int value) => switch (value) { + 0 => CXIdxAttr_Unexposed, + 1 => CXIdxAttr_IBAction, + 2 => CXIdxAttr_IBOutlet, + 3 => CXIdxAttr_IBOutletCollection, + _ => throw ArgumentError("Unknown value for CXIdxAttrKind: $value"), + }; } final class CXIdxEntityInfo extends ffi.Struct { @@ -10843,6 +11487,37 @@ enum CXIdxEntityKind { final int value; const CXIdxEntityKind(this.value); + + static CXIdxEntityKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_Unexposed, + 1 => CXIdxEntity_Typedef, + 2 => CXIdxEntity_Function, + 3 => CXIdxEntity_Variable, + 4 => CXIdxEntity_Field, + 5 => CXIdxEntity_EnumConstant, + 6 => CXIdxEntity_ObjCClass, + 7 => CXIdxEntity_ObjCProtocol, + 8 => CXIdxEntity_ObjCCategory, + 9 => CXIdxEntity_ObjCInstanceMethod, + 10 => CXIdxEntity_ObjCClassMethod, + 11 => CXIdxEntity_ObjCProperty, + 12 => CXIdxEntity_ObjCIvar, + 13 => CXIdxEntity_Enum, + 14 => CXIdxEntity_Struct, + 15 => CXIdxEntity_Union, + 16 => CXIdxEntity_CXXClass, + 17 => CXIdxEntity_CXXNamespace, + 18 => CXIdxEntity_CXXNamespaceAlias, + 19 => CXIdxEntity_CXXStaticVariable, + 20 => CXIdxEntity_CXXStaticMethod, + 21 => CXIdxEntity_CXXInstanceMethod, + 22 => CXIdxEntity_CXXConstructor, + 23 => CXIdxEntity_CXXDestructor, + 24 => CXIdxEntity_CXXConversionFunction, + 25 => CXIdxEntity_CXXTypeAlias, + 26 => CXIdxEntity_CXXInterface, + _ => throw ArgumentError("Unknown value for CXIdxEntityKind: $value"), + }; } /// Extra C++ template information for an entity. This can apply to: @@ -10861,6 +11536,15 @@ enum CXIdxEntityCXXTemplateKind { final int value; const CXIdxEntityCXXTemplateKind(this.value); + + static CXIdxEntityCXXTemplateKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_NonTemplate, + 1 => CXIdxEntity_Template, + 2 => CXIdxEntity_TemplatePartialSpecialization, + 3 => CXIdxEntity_TemplateSpecialization, + _ => throw ArgumentError( + "Unknown value for CXIdxEntityCXXTemplateKind: $value"), + }; } enum CXIdxEntityLanguage { @@ -10872,6 +11556,16 @@ enum CXIdxEntityLanguage { final int value; const CXIdxEntityLanguage(this.value); + + static CXIdxEntityLanguage fromValue(int value) => switch (value) { + 0 => CXIdxEntityLang_None, + 1 => CXIdxEntityLang_C, + 2 => CXIdxEntityLang_ObjC, + 3 => CXIdxEntityLang_CXX, + 4 => CXIdxEntityLang_Swift, + _ => + throw ArgumentError("Unknown value for CXIdxEntityLanguage: $value"), + }; } final class CXIdxContainerInfo extends ffi.Struct { @@ -10940,6 +11634,14 @@ enum CXIdxObjCContainerKind { final int value; const CXIdxObjCContainerKind(this.value); + + static CXIdxObjCContainerKind fromValue(int value) => switch (value) { + 0 => CXIdxObjCContainer_ForwardRef, + 1 => CXIdxObjCContainer_Interface, + 2 => CXIdxObjCContainer_Implementation, + _ => throw ArgumentError( + "Unknown value for CXIdxObjCContainerKind: $value"), + }; } final class CXIdxBaseClassInfo extends ffi.Struct { @@ -11048,6 +11750,13 @@ enum CXIdxEntityRefKind { final int value; const CXIdxEntityRefKind(this.value); + + static CXIdxEntityRefKind fromValue(int value) => switch (value) { + 1 => CXIdxEntityRef_Direct, + 2 => CXIdxEntityRef_Implicit, + _ => + throw ArgumentError("Unknown value for CXIdxEntityRefKind: $value"), + }; } /// Roles that are attributed to symbol occurrences. @@ -11068,6 +11777,20 @@ enum CXSymbolRole { final int value; const CXSymbolRole(this.value); + + static CXSymbolRole fromValue(int value) => switch (value) { + 0 => CXSymbolRole_None, + 1 => CXSymbolRole_Declaration, + 2 => CXSymbolRole_Definition, + 4 => CXSymbolRole_Reference, + 8 => CXSymbolRole_Read, + 16 => CXSymbolRole_Write, + 32 => CXSymbolRole_Call, + 64 => CXSymbolRole_Dynamic, + 128 => CXSymbolRole_AddressOf, + 256 => CXSymbolRole_Implicit, + _ => throw ArgumentError("Unknown value for CXSymbolRole: $value"), + }; } typedef NativeClang_index_isEntityObjCContainerKind = ffi.Int Function( @@ -11311,7 +12034,7 @@ typedef CXFieldVisitor = ffi.Pointer>; typedef CXFieldVisitorFunction = ffi.UnsignedInt Function( CXCursor C, CXClientData client_data); -typedef DartCXFieldVisitorFunction = int Function( +typedef DartCXFieldVisitorFunction = CXVisitorResult Function( CXCursor C, CXClientData client_data); typedef NativeClang_Type_visitFields = ffi.UnsignedInt Function( CXType T, CXFieldVisitor visitor, CXClientData client_data); diff --git a/pkgs/ffigen/example/shared_bindings/lib/generated/a_gen.dart b/pkgs/ffigen/example/shared_bindings/lib/generated/a_gen.dart index 32dd7ac82..8f92d2216 100644 --- a/pkgs/ffigen/example/shared_bindings/lib/generated/a_gen.dart +++ b/pkgs/ffigen/example/shared_bindings/lib/generated/a_gen.dart @@ -112,6 +112,12 @@ enum A_Enum { final int value; const A_Enum(this.value); + + static A_Enum fromValue(int value) => switch (value) { + 0 => A_ENUM_1, + 1 => A_ENUM_2, + _ => throw ArgumentError("Unknown value for A_Enum: $value"), + }; } const int BASE_MACRO_1 = 1; diff --git a/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart b/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart index df3963569..c220cab4f 100644 --- a/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart +++ b/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart @@ -67,6 +67,12 @@ enum A_Enum { final int value; const A_Enum(this.value); + + static A_Enum fromValue(int value) => switch (value) { + 0 => A_ENUM_1, + 1 => A_ENUM_2, + _ => throw ArgumentError("Unknown value for A_Enum: $value"), + }; } const int BASE_MACRO_1 = 1; diff --git a/pkgs/ffigen/lib/src/code_generator/enum_class.dart b/pkgs/ffigen/lib/src/code_generator/enum_class.dart index 66e39fb6e..ed544c404 100644 --- a/pkgs/ffigen/lib/src/code_generator/enum_class.dart +++ b/pkgs/ffigen/lib/src/code_generator/enum_class.dart @@ -195,6 +195,20 @@ class EnumClass extends BindingType { s.write("sealed class $name { }\n"); } + /// Writes a static function that maps integers to enum values. + void writeFromValue(StringBuffer s) { + s.write("${depth}static $name fromValue(int value) => switch (value) {\n"); + for (final member in uniqueMembers) { + final memberName = enumNames[member]!; + s.write("$depth$depth${member.value} => $memberName,\n"); + } + s.write( + '$depth${depth}_ => ' + 'throw ArgumentError("Unknown value for $name: \$value"),\n', + ); + s.write("$depth};\n"); + } + @override BindingString toBindingString(Writer w) { final s = StringBuffer(); @@ -211,6 +225,8 @@ class EnumClass extends BindingType { s.write("\n"); writeConstructor(s); s.write("\n"); + writeFromValue(s); + s.write("\n"); writeToStringOverride(s); s.write('}\n\n'); } @@ -236,14 +252,34 @@ class EnumClass extends BindingType { @override String getFfiDartType(Writer w) => nativeType.getFfiDartType(w); + @override + String getDartType(Writer w) => name; + @override bool get sameFfiDartAndCType => nativeType.sameFfiDartAndCType; @override - bool get sameDartAndCType => nativeType.sameDartAndCType; + bool get sameDartAndFfiDartType => false; @override String? getDefaultValue(Writer w) => '0'; + + @override + String convertDartTypeToFfiDartType( + Writer w, + String value, { + required bool objCRetain, + }) => + "$value.value"; + + @override + String convertFfiDartTypeToDartType( + Writer w, + String value, { + required bool objCRetain, + String? objCEnclosingClass, + }) => + "$name.fromValue($value)"; } /// Represents a single value in an enum. diff --git a/pkgs/ffigen/lib/src/code_generator/objc_interface.dart b/pkgs/ffigen/lib/src/code_generator/objc_interface.dart index 6293493ce..cabf9ccaf 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_interface.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_interface.dart @@ -191,7 +191,7 @@ class $name extends ${superType?.getDartType(w) ?? wrapObjType} { // Implementation. final convertReturn = m.kind != ObjCMethodKind.propertySetter && - _needsConverting(returnType); + !returnType.sameDartAndFfiDartType; if (returnType != voidType) { s.write(' ${convertReturn ? 'final _ret = ' : 'return '}'); @@ -394,17 +394,6 @@ class $name extends ${superType?.getDartType(w) ?? wrapObjType} { return '$className.castFromPointer($value, $ownershipFlags)'; } - // Utils for converting between the internal types passed to native code, and - // the external types visible to the user. For example, ObjCInterfaces are - // passed to native as Pointer, but the user sees the Dart wrapper - // class. These methods need to be kept in sync. - bool _needsConverting(Type type) => - type is ObjCInstanceType || - type.typealiasType is ObjCInterface || - type.typealiasType is ObjCBlock || - type.typealiasType is ObjCObjectPointer || - type.typealiasType is ObjCNullable; - String _getConvertedType(Type type, Writer w, String enclosingClass) { if (type is ObjCInstanceType) return enclosingClass; final baseType = type.typealiasType; diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_bindings.dart index f1ef6aa7c..d294f6046 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_bindings.dart @@ -18,4 +18,10 @@ enum Constants { final int value; const Constants(this.value); + + static Constants fromValue(int value) => switch (value) { + 10 => a, + -1 => b, + _ => throw ArgumentError("Unknown value for Constants: $value"), + }; } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_duplicates_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_duplicates_bindings.dart index 3eedd8f62..8bb137664 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_duplicates_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_duplicates_bindings.dart @@ -23,6 +23,12 @@ enum Duplicates { final int value; const Duplicates(this.value); + static Duplicates fromValue(int value) => switch (value) { + 0 => a, + 1 => b, + _ => throw ArgumentError("Unknown value for Duplicates: $value"), + }; + @override String toString() { if (this == b) return "Duplicates.b, Duplicates.c"; diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart index 42a21fd68..2f5c7b9bf 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart @@ -9,6 +9,11 @@ enum Simple { final int value; const Simple(this.value); + + static Simple fromValue(int value) => switch (value) { + 0 => A0, + _ => throw ArgumentError("Unknown value for Simple: $value"), + }; } enum SimpleWithNegative { @@ -17,6 +22,13 @@ enum SimpleWithNegative { final int value; const SimpleWithNegative(this.value); + + static SimpleWithNegative fromValue(int value) => switch (value) { + 0 => B0, + -1000 => B1, + _ => + throw ArgumentError("Unknown value for SimpleWithNegative: $value"), + }; } enum PositiveIntOverflow { @@ -24,6 +36,12 @@ enum PositiveIntOverflow { final int value; const PositiveIntOverflow(this.value); + + static PositiveIntOverflow fromValue(int value) => switch (value) { + -2147483607 => C0, + _ => + throw ArgumentError("Unknown value for PositiveIntOverflow: $value"), + }; } enum ExplicitType { @@ -32,6 +50,12 @@ enum ExplicitType { final int value; const ExplicitType(this.value); + + static ExplicitType fromValue(int value) => switch (value) { + 0 => E0, + 1 => E1, + _ => throw ArgumentError("Unknown value for ExplicitType: $value"), + }; } enum ExplicitTypeWithOverflow { @@ -40,6 +64,13 @@ enum ExplicitTypeWithOverflow { final int value; const ExplicitTypeWithOverflow(this.value); + + static ExplicitTypeWithOverflow fromValue(int value) => switch (value) { + 0 => F0, + -32727 => F1, + _ => throw ArgumentError( + "Unknown value for ExplicitTypeWithOverflow: $value"), + }; } final class Test extends ffi.Struct { diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart index 0f09150b0..63551d7fb 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart @@ -22,11 +22,11 @@ class NativeLibrary { void func( ffi.Pointer a, - int b, + B b, ) { return _func( a, - b, + b.value, ); } @@ -50,4 +50,10 @@ enum B { final int value; const B(this.value); + + static B fromValue(int value) => switch (value) { + 0 => a, + 1 => b, + _ => throw ArgumentError("Unknown value for B: $value"), + }; } diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart index 2b1083e16..d5da7f3eb 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart @@ -110,6 +110,12 @@ enum AnonymousEnumInTypedef { final int value; const AnonymousEnumInTypedef(this.value); + + static AnonymousEnumInTypedef fromValue(int value) => switch (value) { + 0 => a, + _ => throw ArgumentError( + "Unknown value for AnonymousEnumInTypedef: $value"), + }; } enum _NamedEnumInTypedef { @@ -117,6 +123,12 @@ enum _NamedEnumInTypedef { final int value; const _NamedEnumInTypedef(this.value); + + static _NamedEnumInTypedef fromValue(int value) => switch (value) { + 0 => b, + _ => + throw ArgumentError("Unknown value for _NamedEnumInTypedef: $value"), + }; } typedef NestingASpecifiedType = ffi.IntPtr; diff --git a/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart b/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart index 1303a8614..9a7d6cf68 100644 --- a/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart +++ b/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart @@ -97,16 +97,16 @@ class LibClang { /// Map an absolute virtual file path to an absolute real one. The virtual /// path must be canonicalized (not contain "."/".."). - int clang_VirtualFileOverlay_addFileMapping( + CXErrorCode clang_VirtualFileOverlay_addFileMapping( CXVirtualFileOverlay arg0, ffi.Pointer virtualPath, ffi.Pointer realPath, ) { - return _clang_VirtualFileOverlay_addFileMapping( + return CXErrorCode.fromValue(_clang_VirtualFileOverlay_addFileMapping( arg0, virtualPath, realPath, - ); + )); } late final _clang_VirtualFileOverlay_addFileMappingPtr = _lookup< @@ -122,14 +122,14 @@ class LibClang { /// Set the case sensitivity for the CXVirtualFileOverlay object. The /// CXVirtualFileOverlay object is case-sensitive by default, this option can /// be used to override the default. - int clang_VirtualFileOverlay_setCaseSensitivity( + CXErrorCode clang_VirtualFileOverlay_setCaseSensitivity( CXVirtualFileOverlay arg0, int caseSensitive, ) { - return _clang_VirtualFileOverlay_setCaseSensitivity( + return CXErrorCode.fromValue(_clang_VirtualFileOverlay_setCaseSensitivity( arg0, caseSensitive, - ); + )); } late final _clang_VirtualFileOverlay_setCaseSensitivityPtr = _lookup< @@ -141,18 +141,18 @@ class LibClang { .asFunction(); /// Write out the CXVirtualFileOverlay object to a char buffer. - int clang_VirtualFileOverlay_writeToBuffer( + CXErrorCode clang_VirtualFileOverlay_writeToBuffer( CXVirtualFileOverlay arg0, int options, ffi.Pointer> out_buffer_ptr, ffi.Pointer out_buffer_size, ) { - return _clang_VirtualFileOverlay_writeToBuffer( + return CXErrorCode.fromValue(_clang_VirtualFileOverlay_writeToBuffer( arg0, options, out_buffer_ptr, out_buffer_size, - ); + )); } late final _clang_VirtualFileOverlay_writeToBufferPtr = _lookup< @@ -221,14 +221,15 @@ class LibClang { .asFunction(); /// Sets the framework module name that the module.map describes. - int clang_ModuleMapDescriptor_setFrameworkModuleName( + CXErrorCode clang_ModuleMapDescriptor_setFrameworkModuleName( CXModuleMapDescriptor arg0, ffi.Pointer name, ) { - return _clang_ModuleMapDescriptor_setFrameworkModuleName( + return CXErrorCode.fromValue( + _clang_ModuleMapDescriptor_setFrameworkModuleName( arg0, name, - ); + )); } late final _clang_ModuleMapDescriptor_setFrameworkModuleNamePtr = _lookup< @@ -241,14 +242,14 @@ class LibClang { int Function(CXModuleMapDescriptor, ffi.Pointer)>(); /// Sets the umbrealla header name that the module.map describes. - int clang_ModuleMapDescriptor_setUmbrellaHeader( + CXErrorCode clang_ModuleMapDescriptor_setUmbrellaHeader( CXModuleMapDescriptor arg0, ffi.Pointer name, ) { - return _clang_ModuleMapDescriptor_setUmbrellaHeader( + return CXErrorCode.fromValue(_clang_ModuleMapDescriptor_setUmbrellaHeader( arg0, name, - ); + )); } late final _clang_ModuleMapDescriptor_setUmbrellaHeaderPtr = _lookup< @@ -261,18 +262,18 @@ class LibClang { int Function(CXModuleMapDescriptor, ffi.Pointer)>(); /// Write out the CXModuleMapDescriptor object to a char buffer. - int clang_ModuleMapDescriptor_writeToBuffer( + CXErrorCode clang_ModuleMapDescriptor_writeToBuffer( CXModuleMapDescriptor arg0, int options, ffi.Pointer> out_buffer_ptr, ffi.Pointer out_buffer_size, ) { - return _clang_ModuleMapDescriptor_writeToBuffer( + return CXErrorCode.fromValue(_clang_ModuleMapDescriptor_writeToBuffer( arg0, options, out_buffer_ptr, out_buffer_size, - ); + )); } late final _clang_ModuleMapDescriptor_writeToBufferPtr = _lookup< @@ -1130,12 +1131,12 @@ class LibClang { _clang_defaultDiagnosticDisplayOptionsPtr.asFunction(); /// Determine the severity of the given diagnostic. - int clang_getDiagnosticSeverity( + CXDiagnosticSeverity clang_getDiagnosticSeverity( CXDiagnostic arg0, ) { - return _clang_getDiagnosticSeverity( + return CXDiagnosticSeverity.fromValue(_clang_getDiagnosticSeverity( arg0, - ); + )); } late final _clang_getDiagnosticSeverityPtr = @@ -1386,16 +1387,16 @@ class LibClang { .asFunction)>(); /// Create a translation unit from an AST file ( -emit-ast). - int clang_createTranslationUnit2( + CXErrorCode clang_createTranslationUnit2( CXIndex CIdx, ffi.Pointer ast_filename, ffi.Pointer out_TU, ) { - return _clang_createTranslationUnit2( + return CXErrorCode.fromValue(_clang_createTranslationUnit2( CIdx, ast_filename, out_TU, - ); + )); } late final _clang_createTranslationUnit2Ptr = _lookup< @@ -1466,7 +1467,7 @@ class LibClang { /// Parse the given source file and the translation unit corresponding to that /// file. - int clang_parseTranslationUnit2( + CXErrorCode clang_parseTranslationUnit2( CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, @@ -1476,7 +1477,7 @@ class LibClang { int options, ffi.Pointer out_TU, ) { - return _clang_parseTranslationUnit2( + return CXErrorCode.fromValue(_clang_parseTranslationUnit2( CIdx, source_filename, command_line_args, @@ -1485,7 +1486,7 @@ class LibClang { num_unsaved_files, options, out_TU, - ); + )); } late final _clang_parseTranslationUnit2Ptr = _lookup< @@ -1514,7 +1515,7 @@ class LibClang { /// Same as clang_parseTranslationUnit2 but requires a full command line for /// command_line_args including argv[0]. This is useful if the standard /// library paths are relative to the binary. - int clang_parseTranslationUnit2FullArgv( + CXErrorCode clang_parseTranslationUnit2FullArgv( CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, @@ -1524,7 +1525,7 @@ class LibClang { int options, ffi.Pointer out_TU, ) { - return _clang_parseTranslationUnit2FullArgv( + return CXErrorCode.fromValue(_clang_parseTranslationUnit2FullArgv( CIdx, source_filename, command_line_args, @@ -1533,7 +1534,7 @@ class LibClang { num_unsaved_files, options, out_TU, - ); + )); } late final _clang_parseTranslationUnit2FullArgvPtr = _lookup< @@ -1673,10 +1674,10 @@ class LibClang { /// Returns the human-readable null-terminated C string that represents the /// name of the memory category. This string should never be freed. ffi.Pointer clang_getTUResourceUsageName( - int kind, + CXTUResourceUsageKind kind, ) { return _clang_getTUResourceUsageName( - kind, + kind.value, ); } @@ -1853,12 +1854,12 @@ class LibClang { _clang_hashCursorPtr.asFunction(); /// Retrieve the kind of the given cursor. - int clang_getCursorKind( + CXCursorKind clang_getCursorKind( CXCursor arg0, ) { - return _clang_getCursorKind( + return CXCursorKind.fromValue(_clang_getCursorKind( arg0, - ); + )); } late final _clang_getCursorKindPtr = @@ -1869,10 +1870,10 @@ class LibClang { /// Determine whether the given cursor kind represents a declaration. int clang_isDeclaration( - int arg0, + CXCursorKind arg0, ) { return _clang_isDeclaration( - arg0, + arg0.value, ); } @@ -1899,10 +1900,10 @@ class LibClang { /// Determine whether the given cursor kind represents a simple reference. int clang_isReference( - int arg0, + CXCursorKind arg0, ) { return _clang_isReference( - arg0, + arg0.value, ); } @@ -1914,10 +1915,10 @@ class LibClang { /// Determine whether the given cursor kind represents an expression. int clang_isExpression( - int arg0, + CXCursorKind arg0, ) { return _clang_isExpression( - arg0, + arg0.value, ); } @@ -1929,10 +1930,10 @@ class LibClang { /// Determine whether the given cursor kind represents a statement. int clang_isStatement( - int arg0, + CXCursorKind arg0, ) { return _clang_isStatement( - arg0, + arg0.value, ); } @@ -1944,10 +1945,10 @@ class LibClang { /// Determine whether the given cursor kind represents an attribute. int clang_isAttribute( - int arg0, + CXCursorKind arg0, ) { return _clang_isAttribute( - arg0, + arg0.value, ); } @@ -1974,10 +1975,10 @@ class LibClang { /// Determine whether the given cursor kind represents an invalid cursor. int clang_isInvalid( - int arg0, + CXCursorKind arg0, ) { return _clang_isInvalid( - arg0, + arg0.value, ); } @@ -1989,10 +1990,10 @@ class LibClang { /// Determine whether the given cursor kind represents a translation unit. int clang_isTranslationUnit( - int arg0, + CXCursorKind arg0, ) { return _clang_isTranslationUnit( - arg0, + arg0.value, ); } @@ -2005,10 +2006,10 @@ class LibClang { /// * Determine whether the given cursor represents a preprocessing element, /// such as a preprocessor directive or macro instantiation. int clang_isPreprocessing( - int arg0, + CXCursorKind arg0, ) { return _clang_isPreprocessing( - arg0, + arg0.value, ); } @@ -2021,10 +2022,10 @@ class LibClang { /// * Determine whether the given cursor represents a currently unexposed /// piece of the AST (e.g., CXCursor_UnexposedStmt). int clang_isUnexposed( - int arg0, + CXCursorKind arg0, ) { return _clang_isUnexposed( - arg0, + arg0.value, ); } @@ -2035,12 +2036,12 @@ class LibClang { _clang_isUnexposedPtr.asFunction(); /// Determine the linkage of the entity referred to by a given cursor. - int clang_getCursorLinkage( + CXLinkageKind clang_getCursorLinkage( CXCursor cursor, ) { - return _clang_getCursorLinkage( + return CXLinkageKind.fromValue(_clang_getCursorLinkage( cursor, - ); + )); } late final _clang_getCursorLinkagePtr = @@ -2050,12 +2051,12 @@ class LibClang { _clang_getCursorLinkagePtr.asFunction(); /// Describe the visibility of the entity referred to by a cursor. - int clang_getCursorVisibility( + CXVisibilityKind clang_getCursorVisibility( CXCursor cursor, ) { - return _clang_getCursorVisibility( + return CXVisibilityKind.fromValue(_clang_getCursorVisibility( cursor, - ); + )); } late final _clang_getCursorVisibilityPtr = @@ -2066,12 +2067,12 @@ class LibClang { /// Determine the availability of the entity that this cursor refers to, /// taking the current target platform into account. - int clang_getCursorAvailability( + CXAvailabilityKind clang_getCursorAvailability( CXCursor cursor, ) { - return _clang_getCursorAvailability( + return CXAvailabilityKind.fromValue(_clang_getCursorAvailability( cursor, - ); + )); } late final _clang_getCursorAvailabilityPtr = @@ -2141,12 +2142,12 @@ class LibClang { .asFunction)>(); /// Determine the "language" of the entity referred to by a given cursor. - int clang_getCursorLanguage( + CXLanguageKind clang_getCursorLanguage( CXCursor cursor, ) { - return _clang_getCursorLanguage( + return CXLanguageKind.fromValue(_clang_getCursorLanguage( cursor, - ); + )); } late final _clang_getCursorLanguagePtr = @@ -2157,12 +2158,12 @@ class LibClang { /// Determine the "thread-local storage (TLS) kind" of the declaration /// referred to by a cursor. - int clang_getCursorTLSKind( + CXTLSKind clang_getCursorTLSKind( CXCursor cursor, ) { - return _clang_getCursorTLSKind( + return CXTLSKind.fromValue(_clang_getCursorTLSKind( cursor, - ); + )); } late final _clang_getCursorTLSKindPtr = @@ -2544,14 +2545,15 @@ class LibClang { .asFunction(); /// Retrieve the kind of the I'th template argument of the CXCursor C. - int clang_Cursor_getTemplateArgumentKind( + CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( CXCursor C, int I, ) { - return _clang_Cursor_getTemplateArgumentKind( + return CXTemplateArgumentKind.fromValue( + _clang_Cursor_getTemplateArgumentKind( C, I, - ); + )); } late final _clang_Cursor_getTemplateArgumentKindPtr = _lookup< @@ -2840,10 +2842,10 @@ class LibClang { /// Retrieve the spelling of a given CXTypeKind. CXString clang_getTypeKindSpelling( - int K, + CXTypeKind K, ) { return _clang_getTypeKindSpelling( - K, + K.value, ); } @@ -2854,12 +2856,12 @@ class LibClang { _clang_getTypeKindSpellingPtr.asFunction(); /// Retrieve the calling convention associated with a function type. - int clang_getFunctionTypeCallingConv( + CXCallingConv clang_getFunctionTypeCallingConv( CXType T, ) { - return _clang_getFunctionTypeCallingConv( + return CXCallingConv.fromValue(_clang_getFunctionTypeCallingConv( T, - ); + )); } late final _clang_getFunctionTypeCallingConvPtr = @@ -3168,12 +3170,12 @@ class LibClang { _clang_Type_isTransparentTagTypedefPtr.asFunction(); /// Retrieve the nullability kind of a pointer type. - int clang_Type_getNullability( + CXTypeNullabilityKind clang_Type_getNullability( CXType T, ) { - return _clang_Type_getNullability( + return CXTypeNullabilityKind.fromValue(_clang_Type_getNullability( T, - ); + )); } late final _clang_Type_getNullabilityPtr = @@ -3361,12 +3363,12 @@ class LibClang { .asFunction(); /// Retrieve the ref-qualifier kind of a function or method. - int clang_Type_getCXXRefQualifier( + CXRefQualifierKind clang_Type_getCXXRefQualifier( CXType T, ) { - return _clang_Type_getCXXRefQualifier( + return CXRefQualifierKind.fromValue(_clang_Type_getCXXRefQualifier( T, - ); + )); } late final _clang_Type_getCXXRefQualifierPtr = @@ -3408,12 +3410,12 @@ class LibClang { _clang_isVirtualBasePtr.asFunction(); /// Returns the access control level for the referenced object. - int clang_getCXXAccessSpecifier( + CX_CXXAccessSpecifier clang_getCXXAccessSpecifier( CXCursor arg0, ) { - return _clang_getCXXAccessSpecifier( + return CX_CXXAccessSpecifier.fromValue(_clang_getCXXAccessSpecifier( arg0, - ); + )); } late final _clang_getCXXAccessSpecifierPtr = @@ -3423,12 +3425,12 @@ class LibClang { _clang_getCXXAccessSpecifierPtr.asFunction(); /// Returns the storage class for a function or variable declaration. - int clang_Cursor_getStorageClass( + CX_StorageClass clang_Cursor_getStorageClass( CXCursor arg0, ) { - return _clang_Cursor_getStorageClass( + return CX_StorageClass.fromValue(_clang_Cursor_getStorageClass( arg0, - ); + )); } late final _clang_Cursor_getStorageClassPtr = @@ -3676,11 +3678,11 @@ class LibClang { /// Get a property value for the given printing policy. int clang_PrintingPolicy_getProperty( CXPrintingPolicy Policy, - int Property, + CXPrintingPolicyProperty Property, ) { return _clang_PrintingPolicy_getProperty( Policy, - Property, + Property.value, ); } @@ -3695,12 +3697,12 @@ class LibClang { /// Set a property value for the given printing policy. void clang_PrintingPolicy_setProperty( CXPrintingPolicy Policy, - int Property, + CXPrintingPolicyProperty Property, int Value, ) { return _clang_PrintingPolicy_setProperty( Policy, - Property, + Property.value, Value, ); } @@ -4462,12 +4464,12 @@ class LibClang { /// Given a cursor that represents a template, determine the cursor kind of /// the specializations would be generated by instantiating the template. - int clang_getTemplateCursorKind( + CXCursorKind clang_getTemplateCursorKind( CXCursor C, ) { - return _clang_getTemplateCursorKind( + return CXCursorKind.fromValue(_clang_getTemplateCursorKind( C, - ); + )); } late final _clang_getTemplateCursorKindPtr = @@ -4535,12 +4537,12 @@ class LibClang { ffi.Pointer Function(CXTranslationUnit, CXSourceLocation)>(); /// Determine the kind of the given token. - int clang_getTokenKind( + CXTokenKind clang_getTokenKind( CXToken arg0, ) { - return _clang_getTokenKind( + return CXTokenKind.fromValue(_clang_getTokenKind( arg0, - ); + )); } late final _clang_getTokenKindPtr = @@ -4676,10 +4678,10 @@ class LibClang { /// These routines are used for testing and debugging, only, and should not be /// relied upon. CXString clang_getCursorKindSpelling( - int Kind, + CXCursorKind Kind, ) { return _clang_getCursorKindSpelling( - Kind, + Kind.value, ); } @@ -4769,14 +4771,14 @@ class LibClang { int)>(); /// Determine the kind of a particular chunk within a completion string. - int clang_getCompletionChunkKind( + CXCompletionChunkKind clang_getCompletionChunkKind( CXCompletionString completion_string, int chunk_number, ) { - return _clang_getCompletionChunkKind( + return CXCompletionChunkKind.fromValue(_clang_getCompletionChunkKind( completion_string, chunk_number, - ); + )); } late final _clang_getCompletionChunkKindPtr = _lookup< @@ -4857,12 +4859,12 @@ class LibClang { /// Determine the availability of the entity that this code-completion string /// refers to. - int clang_getCompletionAvailability( + CXAvailabilityKind clang_getCompletionAvailability( CXCompletionString completion_string, ) { - return _clang_getCompletionAvailability( + return CXAvailabilityKind.fromValue(_clang_getCompletionAvailability( completion_string, - ); + )); } late final _clang_getCompletionAvailabilityPtr = @@ -5155,14 +5157,14 @@ class LibClang { /// context. The container is only guaranteed to be set for contexts where a /// container exists (i.e. member accesses or Objective-C message sends); if /// there is not a container, this function will return CXCursor_InvalidCode. - int clang_codeCompleteGetContainerKind( + CXCursorKind clang_codeCompleteGetContainerKind( ffi.Pointer Results, ffi.Pointer IsIncomplete, ) { - return _clang_codeCompleteGetContainerKind( + return CXCursorKind.fromValue(_clang_codeCompleteGetContainerKind( Results, IsIncomplete, - ); + )); } late final _clang_codeCompleteGetContainerKindPtr = _lookup< @@ -5281,12 +5283,12 @@ class LibClang { _clang_Cursor_EvaluatePtr.asFunction(); /// Returns the kind of the evaluated result. - int clang_EvalResult_getKind( + CXEvalResultKind clang_EvalResult_getKind( CXEvalResult E, ) { - return _clang_EvalResult_getKind( + return CXEvalResultKind.fromValue(_clang_EvalResult_getKind( E, - ); + )); } late final _clang_EvalResult_getKindPtr = @@ -5499,16 +5501,16 @@ class LibClang { _clang_remap_disposePtr.asFunction(); /// Find references of a declaration in a specific file. - int clang_findReferencesInFile( + CXResult clang_findReferencesInFile( CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor, ) { - return _clang_findReferencesInFile( + return CXResult.fromValue(_clang_findReferencesInFile( cursor, file, visitor, - ); + )); } late final _clang_findReferencesInFilePtr = _lookup< @@ -5519,16 +5521,16 @@ class LibClang { .asFunction(); /// Find #import/#include directives in a specific file. - int clang_findIncludesInFile( + CXResult clang_findIncludesInFile( CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor, ) { - return _clang_findIncludesInFile( + return CXResult.fromValue(_clang_findIncludesInFile( TU, file, visitor, - ); + )); } late final _clang_findIncludesInFilePtr = _lookup< @@ -5540,10 +5542,10 @@ class LibClang { int Function(CXTranslationUnit, CXFile, CXCursorAndRangeVisitor)>(); int clang_index_isEntityObjCContainerKind( - int arg0, + CXIdxEntityKind arg0, ) { return _clang_index_isEntityObjCContainerKind( - arg0, + arg0.value, ); } @@ -6038,6 +6040,15 @@ enum CXErrorCode { final int value; const CXErrorCode(this.value); + + static CXErrorCode fromValue(int value) => switch (value) { + 0 => CXError_Success, + 1 => CXError_Failure, + 2 => CXError_Crashed, + 3 => CXError_InvalidArguments, + 4 => CXError_ASTReadError, + _ => throw ArgumentError("Unknown value for CXErrorCode: $value"), + }; } /// A character string. @@ -6103,6 +6114,15 @@ enum CXAvailabilityKind { final int value; const CXAvailabilityKind(this.value); + + static CXAvailabilityKind fromValue(int value) => switch (value) { + 0 => CXAvailability_Available, + 1 => CXAvailability_Deprecated, + 2 => CXAvailability_NotAvailable, + 3 => CXAvailability_NotAccessible, + _ => + throw ArgumentError("Unknown value for CXAvailabilityKind: $value"), + }; } /// Describes a version number of the form major.minor.subminor. @@ -6158,6 +6178,22 @@ enum CXCursor_ExceptionSpecificationKind { final int value; const CXCursor_ExceptionSpecificationKind(this.value); + + static CXCursor_ExceptionSpecificationKind fromValue(int value) => + switch (value) { + 0 => CXCursor_ExceptionSpecificationKind_None, + 1 => CXCursor_ExceptionSpecificationKind_DynamicNone, + 2 => CXCursor_ExceptionSpecificationKind_Dynamic, + 3 => CXCursor_ExceptionSpecificationKind_MSAny, + 4 => CXCursor_ExceptionSpecificationKind_BasicNoexcept, + 5 => CXCursor_ExceptionSpecificationKind_ComputedNoexcept, + 6 => CXCursor_ExceptionSpecificationKind_Unevaluated, + 7 => CXCursor_ExceptionSpecificationKind_Uninstantiated, + 8 => CXCursor_ExceptionSpecificationKind_Unparsed, + 9 => CXCursor_ExceptionSpecificationKind_NoThrow, + _ => throw ArgumentError( + "Unknown value for CXCursor_ExceptionSpecificationKind: $value"), + }; } /// An "index" that consists of a set of translation units that would typically @@ -6182,6 +6218,14 @@ enum CXGlobalOptFlags { final int value; const CXGlobalOptFlags(this.value); + + static CXGlobalOptFlags fromValue(int value) => switch (value) { + 0 => CXGlobalOpt_None, + 1 => CXGlobalOpt_ThreadBackgroundPriorityForIndexing, + 2 => CXGlobalOpt_ThreadBackgroundPriorityForEditing, + 3 => CXGlobalOpt_ThreadBackgroundPriorityForAll, + _ => throw ArgumentError("Unknown value for CXGlobalOptFlags: $value"), + }; } /// A particular source file that is part of a translation unit. @@ -6249,6 +6293,16 @@ enum CXDiagnosticSeverity { final int value; const CXDiagnosticSeverity(this.value); + + static CXDiagnosticSeverity fromValue(int value) => switch (value) { + 0 => CXDiagnostic_Ignored, + 1 => CXDiagnostic_Note, + 2 => CXDiagnostic_Warning, + 3 => CXDiagnostic_Error, + 4 => CXDiagnostic_Fatal, + _ => + throw ArgumentError("Unknown value for CXDiagnosticSeverity: $value"), + }; } /// A group of CXDiagnostics. @@ -6277,6 +6331,14 @@ enum CXLoadDiag_Error { final int value; const CXLoadDiag_Error(this.value); + + static CXLoadDiag_Error fromValue(int value) => switch (value) { + 0 => CXLoadDiag_None, + 1 => CXLoadDiag_Unknown, + 2 => CXLoadDiag_CannotLoad, + 3 => CXLoadDiag_InvalidFile, + _ => throw ArgumentError("Unknown value for CXLoadDiag_Error: $value"), + }; } /// Options to control the display of diagnostics. @@ -6303,6 +6365,17 @@ enum CXDiagnosticDisplayOptions { final int value; const CXDiagnosticDisplayOptions(this.value); + + static CXDiagnosticDisplayOptions fromValue(int value) => switch (value) { + 1 => CXDiagnostic_DisplaySourceLocation, + 2 => CXDiagnostic_DisplayColumn, + 4 => CXDiagnostic_DisplaySourceRanges, + 8 => CXDiagnostic_DisplayOption, + 16 => CXDiagnostic_DisplayCategoryId, + 32 => CXDiagnostic_DisplayCategoryName, + _ => throw ArgumentError( + "Unknown value for CXDiagnosticDisplayOptions: $value"), + }; } /// Flags that control the creation of translation units. @@ -6370,6 +6443,28 @@ enum CXTranslationUnit_Flags { final int value; const CXTranslationUnit_Flags(this.value); + + static CXTranslationUnit_Flags fromValue(int value) => switch (value) { + 0 => CXTranslationUnit_None, + 1 => CXTranslationUnit_DetailedPreprocessingRecord, + 2 => CXTranslationUnit_Incomplete, + 4 => CXTranslationUnit_PrecompiledPreamble, + 8 => CXTranslationUnit_CacheCompletionResults, + 16 => CXTranslationUnit_ForSerialization, + 32 => CXTranslationUnit_CXXChainedPCH, + 64 => CXTranslationUnit_SkipFunctionBodies, + 128 => CXTranslationUnit_IncludeBriefCommentsInCodeCompletion, + 256 => CXTranslationUnit_CreatePreambleOnFirstParse, + 512 => CXTranslationUnit_KeepGoing, + 1024 => CXTranslationUnit_SingleFileParse, + 2048 => CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, + 4096 => CXTranslationUnit_IncludeAttributedTypes, + 8192 => CXTranslationUnit_VisitImplicitAttributes, + 16384 => CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles, + 32768 => CXTranslationUnit_RetainExcludedConditionalBlocks, + _ => throw ArgumentError( + "Unknown value for CXTranslationUnit_Flags: $value"), + }; } /// Flags that control how translation units are saved. @@ -6379,6 +6474,12 @@ enum CXSaveTranslationUnit_Flags { final int value; const CXSaveTranslationUnit_Flags(this.value); + + static CXSaveTranslationUnit_Flags fromValue(int value) => switch (value) { + 0 => CXSaveTranslationUnit_None, + _ => throw ArgumentError( + "Unknown value for CXSaveTranslationUnit_Flags: $value"), + }; } /// Describes the kind of error that occurred (if any) in a call to @@ -6401,6 +6502,14 @@ enum CXSaveError { final int value; const CXSaveError(this.value); + + static CXSaveError fromValue(int value) => switch (value) { + 0 => CXSaveError_None, + 1 => CXSaveError_Unknown, + 2 => CXSaveError_TranslationErrors, + 3 => CXSaveError_InvalidTU, + _ => throw ArgumentError("Unknown value for CXSaveError: $value"), + }; } /// Flags that control the reparsing of translation units. @@ -6410,6 +6519,11 @@ enum CXReparse_Flags { final int value; const CXReparse_Flags(this.value); + + static CXReparse_Flags fromValue(int value) => switch (value) { + 0 => CXReparse_None, + _ => throw ArgumentError("Unknown value for CXReparse_Flags: $value"), + }; } /// Categorizes how memory is being used by a translation unit. @@ -6439,6 +6553,25 @@ enum CXTUResourceUsageKind { final int value; const CXTUResourceUsageKind(this.value); + static CXTUResourceUsageKind fromValue(int value) => switch (value) { + 1 => CXTUResourceUsage_AST, + 2 => CXTUResourceUsage_Identifiers, + 3 => CXTUResourceUsage_Selectors, + 4 => CXTUResourceUsage_GlobalCompletionResults, + 5 => CXTUResourceUsage_SourceManagerContentCache, + 6 => CXTUResourceUsage_AST_SideTables, + 7 => CXTUResourceUsage_SourceManager_Membuffer_Malloc, + 8 => CXTUResourceUsage_SourceManager_Membuffer_MMap, + 9 => CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc, + 10 => CXTUResourceUsage_ExternalASTSource_Membuffer_MMap, + 11 => CXTUResourceUsage_Preprocessor, + 12 => CXTUResourceUsage_PreprocessingRecord, + 13 => CXTUResourceUsage_SourceManager_DataStructures, + 14 => CXTUResourceUsage_Preprocessor_HeaderSearch, + _ => throw ArgumentError( + "Unknown value for CXTUResourceUsageKind: $value"), + }; + @override String toString() { if (this == CXTUResourceUsage_AST) @@ -7124,6 +7257,252 @@ enum CXCursorKind { final int value; const CXCursorKind(this.value); + static CXCursorKind fromValue(int value) => switch (value) { + 1 => CXCursor_UnexposedDecl, + 2 => CXCursor_StructDecl, + 3 => CXCursor_UnionDecl, + 4 => CXCursor_ClassDecl, + 5 => CXCursor_EnumDecl, + 6 => CXCursor_FieldDecl, + 7 => CXCursor_EnumConstantDecl, + 8 => CXCursor_FunctionDecl, + 9 => CXCursor_VarDecl, + 10 => CXCursor_ParmDecl, + 11 => CXCursor_ObjCInterfaceDecl, + 12 => CXCursor_ObjCCategoryDecl, + 13 => CXCursor_ObjCProtocolDecl, + 14 => CXCursor_ObjCPropertyDecl, + 15 => CXCursor_ObjCIvarDecl, + 16 => CXCursor_ObjCInstanceMethodDecl, + 17 => CXCursor_ObjCClassMethodDecl, + 18 => CXCursor_ObjCImplementationDecl, + 19 => CXCursor_ObjCCategoryImplDecl, + 20 => CXCursor_TypedefDecl, + 21 => CXCursor_CXXMethod, + 22 => CXCursor_Namespace, + 23 => CXCursor_LinkageSpec, + 24 => CXCursor_Constructor, + 25 => CXCursor_Destructor, + 26 => CXCursor_ConversionFunction, + 27 => CXCursor_TemplateTypeParameter, + 28 => CXCursor_NonTypeTemplateParameter, + 29 => CXCursor_TemplateTemplateParameter, + 30 => CXCursor_FunctionTemplate, + 31 => CXCursor_ClassTemplate, + 32 => CXCursor_ClassTemplatePartialSpecialization, + 33 => CXCursor_NamespaceAlias, + 34 => CXCursor_UsingDirective, + 35 => CXCursor_UsingDeclaration, + 36 => CXCursor_TypeAliasDecl, + 37 => CXCursor_ObjCSynthesizeDecl, + 38 => CXCursor_ObjCDynamicDecl, + 39 => CXCursor_CXXAccessSpecifier, + 40 => CXCursor_FirstRef, + 41 => CXCursor_ObjCProtocolRef, + 42 => CXCursor_ObjCClassRef, + 43 => CXCursor_TypeRef, + 44 => CXCursor_CXXBaseSpecifier, + 45 => CXCursor_TemplateRef, + 46 => CXCursor_NamespaceRef, + 47 => CXCursor_MemberRef, + 48 => CXCursor_LabelRef, + 49 => CXCursor_OverloadedDeclRef, + 50 => CXCursor_VariableRef, + 70 => CXCursor_FirstInvalid, + 71 => CXCursor_NoDeclFound, + 72 => CXCursor_NotImplemented, + 73 => CXCursor_InvalidCode, + 100 => CXCursor_FirstExpr, + 101 => CXCursor_DeclRefExpr, + 102 => CXCursor_MemberRefExpr, + 103 => CXCursor_CallExpr, + 104 => CXCursor_ObjCMessageExpr, + 105 => CXCursor_BlockExpr, + 106 => CXCursor_IntegerLiteral, + 107 => CXCursor_FloatingLiteral, + 108 => CXCursor_ImaginaryLiteral, + 109 => CXCursor_StringLiteral, + 110 => CXCursor_CharacterLiteral, + 111 => CXCursor_ParenExpr, + 112 => CXCursor_UnaryOperator, + 113 => CXCursor_ArraySubscriptExpr, + 114 => CXCursor_BinaryOperator, + 115 => CXCursor_CompoundAssignOperator, + 116 => CXCursor_ConditionalOperator, + 117 => CXCursor_CStyleCastExpr, + 118 => CXCursor_CompoundLiteralExpr, + 119 => CXCursor_InitListExpr, + 120 => CXCursor_AddrLabelExpr, + 121 => CXCursor_StmtExpr, + 122 => CXCursor_GenericSelectionExpr, + 123 => CXCursor_GNUNullExpr, + 124 => CXCursor_CXXStaticCastExpr, + 125 => CXCursor_CXXDynamicCastExpr, + 126 => CXCursor_CXXReinterpretCastExpr, + 127 => CXCursor_CXXConstCastExpr, + 128 => CXCursor_CXXFunctionalCastExpr, + 129 => CXCursor_CXXTypeidExpr, + 130 => CXCursor_CXXBoolLiteralExpr, + 131 => CXCursor_CXXNullPtrLiteralExpr, + 132 => CXCursor_CXXThisExpr, + 133 => CXCursor_CXXThrowExpr, + 134 => CXCursor_CXXNewExpr, + 135 => CXCursor_CXXDeleteExpr, + 136 => CXCursor_UnaryExpr, + 137 => CXCursor_ObjCStringLiteral, + 138 => CXCursor_ObjCEncodeExpr, + 139 => CXCursor_ObjCSelectorExpr, + 140 => CXCursor_ObjCProtocolExpr, + 141 => CXCursor_ObjCBridgedCastExpr, + 142 => CXCursor_PackExpansionExpr, + 143 => CXCursor_SizeOfPackExpr, + 144 => CXCursor_LambdaExpr, + 145 => CXCursor_ObjCBoolLiteralExpr, + 146 => CXCursor_ObjCSelfExpr, + 147 => CXCursor_OMPArraySectionExpr, + 148 => CXCursor_ObjCAvailabilityCheckExpr, + 149 => CXCursor_FixedPointLiteral, + 200 => CXCursor_FirstStmt, + 201 => CXCursor_LabelStmt, + 202 => CXCursor_CompoundStmt, + 203 => CXCursor_CaseStmt, + 204 => CXCursor_DefaultStmt, + 205 => CXCursor_IfStmt, + 206 => CXCursor_SwitchStmt, + 207 => CXCursor_WhileStmt, + 208 => CXCursor_DoStmt, + 209 => CXCursor_ForStmt, + 210 => CXCursor_GotoStmt, + 211 => CXCursor_IndirectGotoStmt, + 212 => CXCursor_ContinueStmt, + 213 => CXCursor_BreakStmt, + 214 => CXCursor_ReturnStmt, + 215 => CXCursor_GCCAsmStmt, + 216 => CXCursor_ObjCAtTryStmt, + 217 => CXCursor_ObjCAtCatchStmt, + 218 => CXCursor_ObjCAtFinallyStmt, + 219 => CXCursor_ObjCAtThrowStmt, + 220 => CXCursor_ObjCAtSynchronizedStmt, + 221 => CXCursor_ObjCAutoreleasePoolStmt, + 222 => CXCursor_ObjCForCollectionStmt, + 223 => CXCursor_CXXCatchStmt, + 224 => CXCursor_CXXTryStmt, + 225 => CXCursor_CXXForRangeStmt, + 226 => CXCursor_SEHTryStmt, + 227 => CXCursor_SEHExceptStmt, + 228 => CXCursor_SEHFinallyStmt, + 229 => CXCursor_MSAsmStmt, + 230 => CXCursor_NullStmt, + 231 => CXCursor_DeclStmt, + 232 => CXCursor_OMPParallelDirective, + 233 => CXCursor_OMPSimdDirective, + 234 => CXCursor_OMPForDirective, + 235 => CXCursor_OMPSectionsDirective, + 236 => CXCursor_OMPSectionDirective, + 237 => CXCursor_OMPSingleDirective, + 238 => CXCursor_OMPParallelForDirective, + 239 => CXCursor_OMPParallelSectionsDirective, + 240 => CXCursor_OMPTaskDirective, + 241 => CXCursor_OMPMasterDirective, + 242 => CXCursor_OMPCriticalDirective, + 243 => CXCursor_OMPTaskyieldDirective, + 244 => CXCursor_OMPBarrierDirective, + 245 => CXCursor_OMPTaskwaitDirective, + 246 => CXCursor_OMPFlushDirective, + 247 => CXCursor_SEHLeaveStmt, + 248 => CXCursor_OMPOrderedDirective, + 249 => CXCursor_OMPAtomicDirective, + 250 => CXCursor_OMPForSimdDirective, + 251 => CXCursor_OMPParallelForSimdDirective, + 252 => CXCursor_OMPTargetDirective, + 253 => CXCursor_OMPTeamsDirective, + 254 => CXCursor_OMPTaskgroupDirective, + 255 => CXCursor_OMPCancellationPointDirective, + 256 => CXCursor_OMPCancelDirective, + 257 => CXCursor_OMPTargetDataDirective, + 258 => CXCursor_OMPTaskLoopDirective, + 259 => CXCursor_OMPTaskLoopSimdDirective, + 260 => CXCursor_OMPDistributeDirective, + 261 => CXCursor_OMPTargetEnterDataDirective, + 262 => CXCursor_OMPTargetExitDataDirective, + 263 => CXCursor_OMPTargetParallelDirective, + 264 => CXCursor_OMPTargetParallelForDirective, + 265 => CXCursor_OMPTargetUpdateDirective, + 266 => CXCursor_OMPDistributeParallelForDirective, + 267 => CXCursor_OMPDistributeParallelForSimdDirective, + 268 => CXCursor_OMPDistributeSimdDirective, + 269 => CXCursor_OMPTargetParallelForSimdDirective, + 270 => CXCursor_OMPTargetSimdDirective, + 271 => CXCursor_OMPTeamsDistributeDirective, + 272 => CXCursor_OMPTeamsDistributeSimdDirective, + 273 => CXCursor_OMPTeamsDistributeParallelForSimdDirective, + 274 => CXCursor_OMPTeamsDistributeParallelForDirective, + 275 => CXCursor_OMPTargetTeamsDirective, + 276 => CXCursor_OMPTargetTeamsDistributeDirective, + 277 => CXCursor_OMPTargetTeamsDistributeParallelForDirective, + 278 => CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective, + 279 => CXCursor_OMPTargetTeamsDistributeSimdDirective, + 280 => CXCursor_BuiltinBitCastExpr, + 281 => CXCursor_OMPMasterTaskLoopDirective, + 282 => CXCursor_OMPParallelMasterTaskLoopDirective, + 283 => CXCursor_OMPMasterTaskLoopSimdDirective, + 284 => CXCursor_OMPParallelMasterTaskLoopSimdDirective, + 285 => CXCursor_OMPParallelMasterDirective, + 300 => CXCursor_TranslationUnit, + 400 => CXCursor_FirstAttr, + 401 => CXCursor_IBActionAttr, + 402 => CXCursor_IBOutletAttr, + 403 => CXCursor_IBOutletCollectionAttr, + 404 => CXCursor_CXXFinalAttr, + 405 => CXCursor_CXXOverrideAttr, + 406 => CXCursor_AnnotateAttr, + 407 => CXCursor_AsmLabelAttr, + 408 => CXCursor_PackedAttr, + 409 => CXCursor_PureAttr, + 410 => CXCursor_ConstAttr, + 411 => CXCursor_NoDuplicateAttr, + 412 => CXCursor_CUDAConstantAttr, + 413 => CXCursor_CUDADeviceAttr, + 414 => CXCursor_CUDAGlobalAttr, + 415 => CXCursor_CUDAHostAttr, + 416 => CXCursor_CUDASharedAttr, + 417 => CXCursor_VisibilityAttr, + 418 => CXCursor_DLLExport, + 419 => CXCursor_DLLImport, + 420 => CXCursor_NSReturnsRetained, + 421 => CXCursor_NSReturnsNotRetained, + 422 => CXCursor_NSReturnsAutoreleased, + 423 => CXCursor_NSConsumesSelf, + 424 => CXCursor_NSConsumed, + 425 => CXCursor_ObjCException, + 426 => CXCursor_ObjCNSObject, + 427 => CXCursor_ObjCIndependentClass, + 428 => CXCursor_ObjCPreciseLifetime, + 429 => CXCursor_ObjCReturnsInnerPointer, + 430 => CXCursor_ObjCRequiresSuper, + 431 => CXCursor_ObjCRootClass, + 432 => CXCursor_ObjCSubclassingRestricted, + 433 => CXCursor_ObjCExplicitProtocolImpl, + 434 => CXCursor_ObjCDesignatedInitializer, + 435 => CXCursor_ObjCRuntimeVisible, + 436 => CXCursor_ObjCBoxable, + 437 => CXCursor_FlagEnum, + 438 => CXCursor_ConvergentAttr, + 439 => CXCursor_WarnUnusedAttr, + 440 => CXCursor_WarnUnusedResultAttr, + 441 => CXCursor_AlignedAttr, + 500 => CXCursor_PreprocessingDirective, + 501 => CXCursor_MacroDefinition, + 502 => CXCursor_MacroExpansion, + 503 => CXCursor_InclusionDirective, + 600 => CXCursor_ModuleImportDecl, + 601 => CXCursor_TypeAliasTemplateDecl, + 602 => CXCursor_StaticAssert, + 603 => CXCursor_FriendDecl, + 700 => CXCursor_OverloadCandidate, + _ => throw ArgumentError("Unknown value for CXCursorKind: $value"), + }; + @override String toString() { if (this == CXCursor_UnexposedDecl) @@ -7201,6 +7580,15 @@ enum CXLinkageKind { final int value; const CXLinkageKind(this.value); + + static CXLinkageKind fromValue(int value) => switch (value) { + 0 => CXLinkage_Invalid, + 1 => CXLinkage_NoLinkage, + 2 => CXLinkage_Internal, + 3 => CXLinkage_UniqueExternal, + 4 => CXLinkage_External, + _ => throw ArgumentError("Unknown value for CXLinkageKind: $value"), + }; } enum CXVisibilityKind { @@ -7219,6 +7607,14 @@ enum CXVisibilityKind { final int value; const CXVisibilityKind(this.value); + + static CXVisibilityKind fromValue(int value) => switch (value) { + 0 => CXVisibility_Invalid, + 1 => CXVisibility_Hidden, + 2 => CXVisibility_Protected, + 3 => CXVisibility_Default, + _ => throw ArgumentError("Unknown value for CXVisibilityKind: $value"), + }; } /// Describes the availability of a given entity on a particular platform, e.g., @@ -7257,6 +7653,14 @@ enum CXLanguageKind { final int value; const CXLanguageKind(this.value); + + static CXLanguageKind fromValue(int value) => switch (value) { + 0 => CXLanguage_Invalid, + 1 => CXLanguage_C, + 2 => CXLanguage_ObjC, + 3 => CXLanguage_CPlusPlus, + _ => throw ArgumentError("Unknown value for CXLanguageKind: $value"), + }; } /// Describe the "thread-local storage (TLS) kind" of the declaration referred @@ -7268,6 +7672,13 @@ enum CXTLSKind { final int value; const CXTLSKind(this.value); + + static CXTLSKind fromValue(int value) => switch (value) { + 0 => CXTLS_None, + 1 => CXTLS_Dynamic, + 2 => CXTLS_Static, + _ => throw ArgumentError("Unknown value for CXTLSKind: $value"), + }; } final class CXCursorSetImpl extends ffi.Opaque {} @@ -7405,6 +7816,126 @@ enum CXTypeKind { final int value; const CXTypeKind(this.value); + static CXTypeKind fromValue(int value) => switch (value) { + 0 => CXType_Invalid, + 1 => CXType_Unexposed, + 2 => CXType_Void, + 3 => CXType_Bool, + 4 => CXType_Char_U, + 5 => CXType_UChar, + 6 => CXType_Char16, + 7 => CXType_Char32, + 8 => CXType_UShort, + 9 => CXType_UInt, + 10 => CXType_ULong, + 11 => CXType_ULongLong, + 12 => CXType_UInt128, + 13 => CXType_Char_S, + 14 => CXType_SChar, + 15 => CXType_WChar, + 16 => CXType_Short, + 17 => CXType_Int, + 18 => CXType_Long, + 19 => CXType_LongLong, + 20 => CXType_Int128, + 21 => CXType_Float, + 22 => CXType_Double, + 23 => CXType_LongDouble, + 24 => CXType_NullPtr, + 25 => CXType_Overload, + 26 => CXType_Dependent, + 27 => CXType_ObjCId, + 28 => CXType_ObjCClass, + 29 => CXType_ObjCSel, + 30 => CXType_Float128, + 31 => CXType_Half, + 32 => CXType_Float16, + 33 => CXType_ShortAccum, + 34 => CXType_Accum, + 35 => CXType_LongAccum, + 36 => CXType_UShortAccum, + 37 => CXType_UAccum, + 38 => CXType_ULongAccum, + 100 => CXType_Complex, + 101 => CXType_Pointer, + 102 => CXType_BlockPointer, + 103 => CXType_LValueReference, + 104 => CXType_RValueReference, + 105 => CXType_Record, + 106 => CXType_Enum, + 107 => CXType_Typedef, + 108 => CXType_ObjCInterface, + 109 => CXType_ObjCObjectPointer, + 110 => CXType_FunctionNoProto, + 111 => CXType_FunctionProto, + 112 => CXType_ConstantArray, + 113 => CXType_Vector, + 114 => CXType_IncompleteArray, + 115 => CXType_VariableArray, + 116 => CXType_DependentSizedArray, + 117 => CXType_MemberPointer, + 118 => CXType_Auto, + 119 => CXType_Elaborated, + 120 => CXType_Pipe, + 121 => CXType_OCLImage1dRO, + 122 => CXType_OCLImage1dArrayRO, + 123 => CXType_OCLImage1dBufferRO, + 124 => CXType_OCLImage2dRO, + 125 => CXType_OCLImage2dArrayRO, + 126 => CXType_OCLImage2dDepthRO, + 127 => CXType_OCLImage2dArrayDepthRO, + 128 => CXType_OCLImage2dMSAARO, + 129 => CXType_OCLImage2dArrayMSAARO, + 130 => CXType_OCLImage2dMSAADepthRO, + 131 => CXType_OCLImage2dArrayMSAADepthRO, + 132 => CXType_OCLImage3dRO, + 133 => CXType_OCLImage1dWO, + 134 => CXType_OCLImage1dArrayWO, + 135 => CXType_OCLImage1dBufferWO, + 136 => CXType_OCLImage2dWO, + 137 => CXType_OCLImage2dArrayWO, + 138 => CXType_OCLImage2dDepthWO, + 139 => CXType_OCLImage2dArrayDepthWO, + 140 => CXType_OCLImage2dMSAAWO, + 141 => CXType_OCLImage2dArrayMSAAWO, + 142 => CXType_OCLImage2dMSAADepthWO, + 143 => CXType_OCLImage2dArrayMSAADepthWO, + 144 => CXType_OCLImage3dWO, + 145 => CXType_OCLImage1dRW, + 146 => CXType_OCLImage1dArrayRW, + 147 => CXType_OCLImage1dBufferRW, + 148 => CXType_OCLImage2dRW, + 149 => CXType_OCLImage2dArrayRW, + 150 => CXType_OCLImage2dDepthRW, + 151 => CXType_OCLImage2dArrayDepthRW, + 152 => CXType_OCLImage2dMSAARW, + 153 => CXType_OCLImage2dArrayMSAARW, + 154 => CXType_OCLImage2dMSAADepthRW, + 155 => CXType_OCLImage2dArrayMSAADepthRW, + 156 => CXType_OCLImage3dRW, + 157 => CXType_OCLSampler, + 158 => CXType_OCLEvent, + 159 => CXType_OCLQueue, + 160 => CXType_OCLReserveID, + 161 => CXType_ObjCObject, + 162 => CXType_ObjCTypeParam, + 163 => CXType_Attributed, + 164 => CXType_OCLIntelSubgroupAVCMcePayload, + 165 => CXType_OCLIntelSubgroupAVCImePayload, + 166 => CXType_OCLIntelSubgroupAVCRefPayload, + 167 => CXType_OCLIntelSubgroupAVCSicPayload, + 168 => CXType_OCLIntelSubgroupAVCMceResult, + 169 => CXType_OCLIntelSubgroupAVCImeResult, + 170 => CXType_OCLIntelSubgroupAVCRefResult, + 171 => CXType_OCLIntelSubgroupAVCSicResult, + 172 => CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout, + 173 => CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout, + 174 => CXType_OCLIntelSubgroupAVCImeSingleRefStreamin, + 175 => CXType_OCLIntelSubgroupAVCImeDualRefStreamin, + 176 => CXType_ExtVector, + _ => throw ArgumentError("Unknown value for CXTypeKind: $value"), + }; + @override String toString() { if (this == CXType_Void) @@ -7442,6 +7973,29 @@ enum CXCallingConv { final int value; const CXCallingConv(this.value); + static CXCallingConv fromValue(int value) => switch (value) { + 0 => CXCallingConv_Default, + 1 => CXCallingConv_C, + 2 => CXCallingConv_X86StdCall, + 3 => CXCallingConv_X86FastCall, + 4 => CXCallingConv_X86ThisCall, + 5 => CXCallingConv_X86Pascal, + 6 => CXCallingConv_AAPCS, + 7 => CXCallingConv_AAPCS_VFP, + 8 => CXCallingConv_X86RegCall, + 9 => CXCallingConv_IntelOclBicc, + 10 => CXCallingConv_Win64, + 11 => CXCallingConv_X86_64SysV, + 12 => CXCallingConv_X86VectorCall, + 13 => CXCallingConv_Swift, + 14 => CXCallingConv_PreserveMost, + 15 => CXCallingConv_PreserveAll, + 16 => CXCallingConv_AArch64VectorCall, + 100 => CXCallingConv_Invalid, + 200 => CXCallingConv_Unexposed, + _ => throw ArgumentError("Unknown value for CXCallingConv: $value"), + }; + @override String toString() { if (this == CXCallingConv_Win64) @@ -7474,6 +8028,21 @@ enum CXTemplateArgumentKind { final int value; const CXTemplateArgumentKind(this.value); + + static CXTemplateArgumentKind fromValue(int value) => switch (value) { + 0 => CXTemplateArgumentKind_Null, + 1 => CXTemplateArgumentKind_Type, + 2 => CXTemplateArgumentKind_Declaration, + 3 => CXTemplateArgumentKind_NullPtr, + 4 => CXTemplateArgumentKind_Integral, + 5 => CXTemplateArgumentKind_Template, + 6 => CXTemplateArgumentKind_TemplateExpansion, + 7 => CXTemplateArgumentKind_Expression, + 8 => CXTemplateArgumentKind_Pack, + 9 => CXTemplateArgumentKind_Invalid, + _ => throw ArgumentError( + "Unknown value for CXTemplateArgumentKind: $value"), + }; } enum CXTypeNullabilityKind { @@ -7493,6 +8062,15 @@ enum CXTypeNullabilityKind { final int value; const CXTypeNullabilityKind(this.value); + + static CXTypeNullabilityKind fromValue(int value) => switch (value) { + 0 => CXTypeNullability_NonNull, + 1 => CXTypeNullability_Nullable, + 2 => CXTypeNullability_Unspecified, + 3 => CXTypeNullability_Invalid, + _ => throw ArgumentError( + "Unknown value for CXTypeNullabilityKind: $value"), + }; } /// List the possible error codes for clang_Type_getSizeOf, @@ -7518,6 +8096,16 @@ enum CXTypeLayoutError { final int value; const CXTypeLayoutError(this.value); + + static CXTypeLayoutError fromValue(int value) => switch (value) { + -1 => CXTypeLayoutError_Invalid, + -2 => CXTypeLayoutError_Incomplete, + -3 => CXTypeLayoutError_Dependent, + -4 => CXTypeLayoutError_NotConstantSize, + -5 => CXTypeLayoutError_InvalidFieldName, + -6 => CXTypeLayoutError_Undeduced, + _ => throw ArgumentError("Unknown value for CXTypeLayoutError: $value"), + }; } enum CXRefQualifierKind { @@ -7532,6 +8120,14 @@ enum CXRefQualifierKind { final int value; const CXRefQualifierKind(this.value); + + static CXRefQualifierKind fromValue(int value) => switch (value) { + 0 => CXRefQualifier_None, + 1 => CXRefQualifier_LValue, + 2 => CXRefQualifier_RValue, + _ => + throw ArgumentError("Unknown value for CXRefQualifierKind: $value"), + }; } /// Represents the C++ access control level to a base class for a cursor with @@ -7544,6 +8140,15 @@ enum CX_CXXAccessSpecifier { final int value; const CX_CXXAccessSpecifier(this.value); + + static CX_CXXAccessSpecifier fromValue(int value) => switch (value) { + 0 => CX_CXXInvalidAccessSpecifier, + 1 => CX_CXXPublic, + 2 => CX_CXXProtected, + 3 => CX_CXXPrivate, + _ => throw ArgumentError( + "Unknown value for CX_CXXAccessSpecifier: $value"), + }; } /// Represents the storage classes as declared in the source. CX_SC_Invalid was @@ -7560,6 +8165,18 @@ enum CX_StorageClass { final int value; const CX_StorageClass(this.value); + + static CX_StorageClass fromValue(int value) => switch (value) { + 0 => CX_SC_Invalid, + 1 => CX_SC_None, + 2 => CX_SC_Extern, + 3 => CX_SC_Static, + 4 => CX_SC_PrivateExtern, + 5 => CX_SC_OpenCLWorkGroupLocal, + 6 => CX_SC_Auto, + 7 => CX_SC_Register, + _ => throw ArgumentError("Unknown value for CX_StorageClass: $value"), + }; } /// Describes how the traversal of the children of a particular cursor should @@ -7578,6 +8195,14 @@ enum CXChildVisitResult { final int value; const CXChildVisitResult(this.value); + + static CXChildVisitResult fromValue(int value) => switch (value) { + 0 => CXChildVisit_Break, + 1 => CXChildVisit_Continue, + 2 => CXChildVisit_Recurse, + _ => + throw ArgumentError("Unknown value for CXChildVisitResult: $value"), + }; } /// Visitor invoked for each cursor found by a traversal. @@ -7585,7 +8210,7 @@ typedef CXCursorVisitor = ffi.Pointer>; typedef CXCursorVisitorFunction = ffi.UnsignedInt Function( CXCursor cursor, CXCursor parent, CXClientData client_data); -typedef DartCXCursorVisitorFunction = int Function( +typedef DartCXCursorVisitorFunction = CXChildVisitResult Function( CXCursor cursor, CXCursor parent, CXClientData client_data); /// Opaque pointer representing client data that will be passed through to @@ -7627,6 +8252,37 @@ enum CXPrintingPolicyProperty { final int value; const CXPrintingPolicyProperty(this.value); + static CXPrintingPolicyProperty fromValue(int value) => switch (value) { + 0 => CXPrintingPolicy_Indentation, + 1 => CXPrintingPolicy_SuppressSpecifiers, + 2 => CXPrintingPolicy_SuppressTagKeyword, + 3 => CXPrintingPolicy_IncludeTagDefinition, + 4 => CXPrintingPolicy_SuppressScope, + 5 => CXPrintingPolicy_SuppressUnwrittenScope, + 6 => CXPrintingPolicy_SuppressInitializers, + 7 => CXPrintingPolicy_ConstantArraySizeAsWritten, + 8 => CXPrintingPolicy_AnonymousTagLocations, + 9 => CXPrintingPolicy_SuppressStrongLifetime, + 10 => CXPrintingPolicy_SuppressLifetimeQualifiers, + 11 => CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + 12 => CXPrintingPolicy_Bool, + 13 => CXPrintingPolicy_Restrict, + 14 => CXPrintingPolicy_Alignof, + 15 => CXPrintingPolicy_UnderscoreAlignof, + 16 => CXPrintingPolicy_UseVoidForZeroParams, + 17 => CXPrintingPolicy_TerseOutput, + 18 => CXPrintingPolicy_PolishForDeclaration, + 19 => CXPrintingPolicy_Half, + 20 => CXPrintingPolicy_MSWChar, + 21 => CXPrintingPolicy_IncludeNewlines, + 22 => CXPrintingPolicy_MSVCFormatting, + 23 => CXPrintingPolicy_ConstantsAsWritten, + 24 => CXPrintingPolicy_SuppressImplicitBase, + 25 => CXPrintingPolicy_FullyQualifiedName, + _ => throw ArgumentError( + "Unknown value for CXPrintingPolicyProperty: $value"), + }; + @override String toString() { if (this == CXPrintingPolicy_FullyQualifiedName) @@ -7658,6 +8314,25 @@ enum CXObjCPropertyAttrKind { final int value; const CXObjCPropertyAttrKind(this.value); + + static CXObjCPropertyAttrKind fromValue(int value) => switch (value) { + 0 => CXObjCPropertyAttr_noattr, + 1 => CXObjCPropertyAttr_readonly, + 2 => CXObjCPropertyAttr_getter, + 4 => CXObjCPropertyAttr_assign, + 8 => CXObjCPropertyAttr_readwrite, + 16 => CXObjCPropertyAttr_retain, + 32 => CXObjCPropertyAttr_copy, + 64 => CXObjCPropertyAttr_nonatomic, + 128 => CXObjCPropertyAttr_setter, + 256 => CXObjCPropertyAttr_atomic, + 512 => CXObjCPropertyAttr_weak, + 1024 => CXObjCPropertyAttr_strong, + 2048 => CXObjCPropertyAttr_unsafe_unretained, + 4096 => CXObjCPropertyAttr_class, + _ => throw ArgumentError( + "Unknown value for CXObjCPropertyAttrKind: $value"), + }; } /// 'Qualifiers' written next to the return and parameter types in Objective-C @@ -7673,6 +8348,18 @@ enum CXObjCDeclQualifierKind { final int value; const CXObjCDeclQualifierKind(this.value); + + static CXObjCDeclQualifierKind fromValue(int value) => switch (value) { + 0 => CXObjCDeclQualifier_None, + 1 => CXObjCDeclQualifier_In, + 2 => CXObjCDeclQualifier_Inout, + 4 => CXObjCDeclQualifier_Out, + 8 => CXObjCDeclQualifier_Bycopy, + 16 => CXObjCDeclQualifier_Byref, + 32 => CXObjCDeclQualifier_Oneway, + _ => throw ArgumentError( + "Unknown value for CXObjCDeclQualifierKind: $value"), + }; } /// The functions in this group provide access to information about modules. @@ -7691,6 +8378,13 @@ enum CXNameRefFlags { final int value; const CXNameRefFlags(this.value); + + static CXNameRefFlags fromValue(int value) => switch (value) { + 1 => CXNameRange_WantQualifier, + 2 => CXNameRange_WantTemplateArgs, + 4 => CXNameRange_WantSinglePiece, + _ => throw ArgumentError("Unknown value for CXNameRefFlags: $value"), + }; } /// Describes a kind of token. @@ -7712,6 +8406,15 @@ enum CXTokenKind { final int value; const CXTokenKind(this.value); + + static CXTokenKind fromValue(int value) => switch (value) { + 0 => CXToken_Punctuation, + 1 => CXToken_Keyword, + 2 => CXToken_Identifier, + 3 => CXToken_Literal, + 4 => CXToken_Comment, + _ => throw ArgumentError("Unknown value for CXTokenKind: $value"), + }; } /// Describes a single preprocessing token. @@ -7810,6 +8513,32 @@ enum CXCompletionChunkKind { final int value; const CXCompletionChunkKind(this.value); + + static CXCompletionChunkKind fromValue(int value) => switch (value) { + 0 => CXCompletionChunk_Optional, + 1 => CXCompletionChunk_TypedText, + 2 => CXCompletionChunk_Text, + 3 => CXCompletionChunk_Placeholder, + 4 => CXCompletionChunk_Informative, + 5 => CXCompletionChunk_CurrentParameter, + 6 => CXCompletionChunk_LeftParen, + 7 => CXCompletionChunk_RightParen, + 8 => CXCompletionChunk_LeftBracket, + 9 => CXCompletionChunk_RightBracket, + 10 => CXCompletionChunk_LeftBrace, + 11 => CXCompletionChunk_RightBrace, + 12 => CXCompletionChunk_LeftAngle, + 13 => CXCompletionChunk_RightAngle, + 14 => CXCompletionChunk_Comma, + 15 => CXCompletionChunk_ResultType, + 16 => CXCompletionChunk_Colon, + 17 => CXCompletionChunk_SemiColon, + 18 => CXCompletionChunk_Equal, + 19 => CXCompletionChunk_HorizontalSpace, + 20 => CXCompletionChunk_VerticalSpace, + _ => throw ArgumentError( + "Unknown value for CXCompletionChunkKind: $value"), + }; } /// Contains the results of code-completion. @@ -7847,6 +8576,16 @@ enum CXCodeComplete_Flags { final int value; const CXCodeComplete_Flags(this.value); + + static CXCodeComplete_Flags fromValue(int value) => switch (value) { + 1 => CXCodeComplete_IncludeMacros, + 2 => CXCodeComplete_IncludeCodePatterns, + 4 => CXCodeComplete_IncludeBriefComments, + 8 => CXCodeComplete_SkipPreamble, + 16 => CXCodeComplete_IncludeCompletionsWithFixIts, + _ => + throw ArgumentError("Unknown value for CXCodeComplete_Flags: $value"), + }; } /// Bits that represent the context under which completion is occurring. @@ -7943,6 +8682,36 @@ enum CXCompletionContext { final int value; const CXCompletionContext(this.value); + + static CXCompletionContext fromValue(int value) => switch (value) { + 0 => CXCompletionContext_Unexposed, + 1 => CXCompletionContext_AnyType, + 2 => CXCompletionContext_AnyValue, + 4 => CXCompletionContext_ObjCObjectValue, + 8 => CXCompletionContext_ObjCSelectorValue, + 16 => CXCompletionContext_CXXClassTypeValue, + 32 => CXCompletionContext_DotMemberAccess, + 64 => CXCompletionContext_ArrowMemberAccess, + 128 => CXCompletionContext_ObjCPropertyAccess, + 256 => CXCompletionContext_EnumTag, + 512 => CXCompletionContext_UnionTag, + 1024 => CXCompletionContext_StructTag, + 2048 => CXCompletionContext_ClassTag, + 4096 => CXCompletionContext_Namespace, + 8192 => CXCompletionContext_NestedNameSpecifier, + 16384 => CXCompletionContext_ObjCInterface, + 32768 => CXCompletionContext_ObjCProtocol, + 65536 => CXCompletionContext_ObjCCategory, + 131072 => CXCompletionContext_ObjCInstanceMessage, + 262144 => CXCompletionContext_ObjCClassMessage, + 524288 => CXCompletionContext_ObjCSelectorName, + 1048576 => CXCompletionContext_MacroName, + 2097152 => CXCompletionContext_NaturalLanguage, + 4194304 => CXCompletionContext_IncludedFile, + 8388607 => CXCompletionContext_Unknown, + _ => + throw ArgumentError("Unknown value for CXCompletionContext: $value"), + }; } /// Visitor invoked for each file in a translation unit (used with @@ -7971,6 +8740,17 @@ enum CXEvalResultKind { final int value; const CXEvalResultKind(this.value); + + static CXEvalResultKind fromValue(int value) => switch (value) { + 1 => CXEval_Int, + 2 => CXEval_Float, + 3 => CXEval_ObjCStrLiteral, + 4 => CXEval_StrLiteral, + 5 => CXEval_CFStr, + 6 => CXEval_Other, + 0 => CXEval_UnExposed, + _ => throw ArgumentError("Unknown value for CXEvalResultKind: $value"), + }; } /// Evaluation result of a cursor @@ -7986,6 +8766,12 @@ enum CXVisitorResult { final int value; const CXVisitorResult(this.value); + + static CXVisitorResult fromValue(int value) => switch (value) { + 0 => CXVisit_Break, + 1 => CXVisit_Continue, + _ => throw ArgumentError("Unknown value for CXVisitorResult: $value"), + }; } final class CXCursorAndRangeVisitor extends ffi.Struct { @@ -8009,6 +8795,13 @@ enum CXResult { final int value; const CXResult(this.value); + + static CXResult fromValue(int value) => switch (value) { + 0 => CXResult_Success, + 1 => CXResult_Invalid, + 2 => CXResult_VisitBreak, + _ => throw ArgumentError("Unknown value for CXResult: $value"), + }; } /// Source location passed to index callbacks. @@ -8090,6 +8883,37 @@ enum CXIdxEntityKind { final int value; const CXIdxEntityKind(this.value); + + static CXIdxEntityKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_Unexposed, + 1 => CXIdxEntity_Typedef, + 2 => CXIdxEntity_Function, + 3 => CXIdxEntity_Variable, + 4 => CXIdxEntity_Field, + 5 => CXIdxEntity_EnumConstant, + 6 => CXIdxEntity_ObjCClass, + 7 => CXIdxEntity_ObjCProtocol, + 8 => CXIdxEntity_ObjCCategory, + 9 => CXIdxEntity_ObjCInstanceMethod, + 10 => CXIdxEntity_ObjCClassMethod, + 11 => CXIdxEntity_ObjCProperty, + 12 => CXIdxEntity_ObjCIvar, + 13 => CXIdxEntity_Enum, + 14 => CXIdxEntity_Struct, + 15 => CXIdxEntity_Union, + 16 => CXIdxEntity_CXXClass, + 17 => CXIdxEntity_CXXNamespace, + 18 => CXIdxEntity_CXXNamespaceAlias, + 19 => CXIdxEntity_CXXStaticVariable, + 20 => CXIdxEntity_CXXStaticMethod, + 21 => CXIdxEntity_CXXInstanceMethod, + 22 => CXIdxEntity_CXXConstructor, + 23 => CXIdxEntity_CXXDestructor, + 24 => CXIdxEntity_CXXConversionFunction, + 25 => CXIdxEntity_CXXTypeAlias, + 26 => CXIdxEntity_CXXInterface, + _ => throw ArgumentError("Unknown value for CXIdxEntityKind: $value"), + }; } enum CXIdxEntityLanguage { @@ -8101,6 +8925,16 @@ enum CXIdxEntityLanguage { final int value; const CXIdxEntityLanguage(this.value); + + static CXIdxEntityLanguage fromValue(int value) => switch (value) { + 0 => CXIdxEntityLang_None, + 1 => CXIdxEntityLang_C, + 2 => CXIdxEntityLang_ObjC, + 3 => CXIdxEntityLang_CXX, + 4 => CXIdxEntityLang_Swift, + _ => + throw ArgumentError("Unknown value for CXIdxEntityLanguage: $value"), + }; } /// Extra C++ template information for an entity. This can apply to: @@ -8115,6 +8949,15 @@ enum CXIdxEntityCXXTemplateKind { final int value; const CXIdxEntityCXXTemplateKind(this.value); + + static CXIdxEntityCXXTemplateKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_NonTemplate, + 1 => CXIdxEntity_Template, + 2 => CXIdxEntity_TemplatePartialSpecialization, + 3 => CXIdxEntity_TemplateSpecialization, + _ => throw ArgumentError( + "Unknown value for CXIdxEntityCXXTemplateKind: $value"), + }; } enum CXIdxAttrKind { @@ -8125,6 +8968,14 @@ enum CXIdxAttrKind { final int value; const CXIdxAttrKind(this.value); + + static CXIdxAttrKind fromValue(int value) => switch (value) { + 0 => CXIdxAttr_Unexposed, + 1 => CXIdxAttr_IBAction, + 2 => CXIdxAttr_IBOutlet, + 3 => CXIdxAttr_IBOutletCollection, + _ => throw ArgumentError("Unknown value for CXIdxAttrKind: $value"), + }; } final class CXIdxAttrInfo extends ffi.Struct { @@ -8177,6 +9028,12 @@ enum CXIdxDeclInfoFlags { final int value; const CXIdxDeclInfoFlags(this.value); + + static CXIdxDeclInfoFlags fromValue(int value) => switch (value) { + 1 => CXIdxDeclFlag_Skipped, + _ => + throw ArgumentError("Unknown value for CXIdxDeclInfoFlags: $value"), + }; } final class CXIdxDeclInfo extends ffi.Struct { @@ -8224,6 +9081,14 @@ enum CXIdxObjCContainerKind { final int value; const CXIdxObjCContainerKind(this.value); + + static CXIdxObjCContainerKind fromValue(int value) => switch (value) { + 0 => CXIdxObjCContainer_ForwardRef, + 1 => CXIdxObjCContainer_Interface, + 2 => CXIdxObjCContainer_Implementation, + _ => throw ArgumentError( + "Unknown value for CXIdxObjCContainerKind: $value"), + }; } final class CXIdxObjCContainerDeclInfo extends ffi.Struct { @@ -8304,6 +9169,13 @@ enum CXIdxEntityRefKind { final int value; const CXIdxEntityRefKind(this.value); + + static CXIdxEntityRefKind fromValue(int value) => switch (value) { + 1 => CXIdxEntityRef_Direct, + 2 => CXIdxEntityRef_Implicit, + _ => + throw ArgumentError("Unknown value for CXIdxEntityRefKind: $value"), + }; } /// Roles that are attributed to symbol occurrences. @@ -8321,6 +9193,20 @@ enum CXSymbolRole { final int value; const CXSymbolRole(this.value); + + static CXSymbolRole fromValue(int value) => switch (value) { + 0 => CXSymbolRole_None, + 1 => CXSymbolRole_Declaration, + 2 => CXSymbolRole_Definition, + 4 => CXSymbolRole_Reference, + 8 => CXSymbolRole_Read, + 16 => CXSymbolRole_Write, + 32 => CXSymbolRole_Call, + 64 => CXSymbolRole_Dynamic, + 128 => CXSymbolRole_AddressOf, + 256 => CXSymbolRole_Implicit, + _ => throw ArgumentError("Unknown value for CXSymbolRole: $value"), + }; } /// Data for IndexerCallbacks#indexEntityReference. @@ -8448,6 +9334,16 @@ enum CXIndexOptFlags { final int value; const CXIndexOptFlags(this.value); + + static CXIndexOptFlags fromValue(int value) => switch (value) { + 0 => CXIndexOpt_None, + 1 => CXIndexOpt_SuppressRedundantRefs, + 2 => CXIndexOpt_IndexFunctionLocalSymbols, + 4 => CXIndexOpt_IndexImplicitTemplateInstantiations, + 8 => CXIndexOpt_SuppressWarnings, + 16 => CXIndexOpt_SkipParsedBodiesInSession, + _ => throw ArgumentError("Unknown value for CXIndexOptFlags: $value"), + }; } /// Visitor invoked for each field found by a traversal. @@ -8455,7 +9351,7 @@ typedef CXFieldVisitor = ffi.Pointer>; typedef CXFieldVisitorFunction = ffi.UnsignedInt Function( CXCursor C, CXClientData client_data); -typedef DartCXFieldVisitorFunction = int Function( +typedef DartCXFieldVisitorFunction = CXVisitorResult Function( CXCursor C, CXClientData client_data); const int CINDEX_VERSION_MAJOR = 0;