ffi-clang 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/rakefile.rb +2 -2
  4. data/lib/ffi/clang/clang_version.rb +7 -3
  5. data/lib/ffi/clang/code_completion.rb +121 -44
  6. data/lib/ffi/clang/comment.rb +164 -57
  7. data/lib/ffi/clang/compilation_database.rb +79 -25
  8. data/lib/ffi/clang/cursor.rb +395 -149
  9. data/lib/ffi/clang/diagnostic.rb +57 -23
  10. data/lib/ffi/clang/error.rb +12 -0
  11. data/lib/ffi/clang/file.rb +30 -11
  12. data/lib/ffi/clang/index.rb +37 -13
  13. data/lib/ffi/clang/lib/clang_version.rb +2 -2
  14. data/lib/ffi/clang/lib/code_completion.rb +15 -11
  15. data/lib/ffi/clang/lib/comment.rb +16 -14
  16. data/lib/ffi/clang/lib/compilation_database.rb +5 -5
  17. data/lib/ffi/clang/lib/cursor.rb +74 -56
  18. data/lib/ffi/clang/lib/diagnostic.rb +14 -14
  19. data/lib/ffi/clang/lib/file.rb +10 -6
  20. data/lib/ffi/clang/lib/inclusions.rb +3 -3
  21. data/lib/ffi/clang/lib/index.rb +7 -5
  22. data/lib/ffi/clang/lib/printing_policy.rb +36 -36
  23. data/lib/ffi/clang/lib/source_location.rb +9 -7
  24. data/lib/ffi/clang/lib/source_range.rb +5 -3
  25. data/lib/ffi/clang/lib/string.rb +9 -4
  26. data/lib/ffi/clang/lib/token.rb +17 -4
  27. data/lib/ffi/clang/lib/translation_unit.rb +17 -13
  28. data/lib/ffi/clang/lib/type.rb +19 -17
  29. data/lib/ffi/clang/lib.rb +35 -19
  30. data/lib/ffi/clang/platform.rb +25 -0
  31. data/lib/ffi/clang/printing_policy.rb +31 -18
  32. data/lib/ffi/clang/source_location.rb +119 -36
  33. data/lib/ffi/clang/source_range.rb +30 -12
  34. data/lib/ffi/clang/token.rb +48 -23
  35. data/lib/ffi/clang/translation_unit.rb +97 -33
  36. data/lib/ffi/clang/types/array.rb +15 -1
  37. data/lib/ffi/clang/types/elaborated.rb +19 -4
  38. data/lib/ffi/clang/types/function.rb +35 -10
  39. data/lib/ffi/clang/types/pointer.rb +23 -7
  40. data/lib/ffi/clang/types/record.rb +23 -8
  41. data/lib/ffi/clang/types/type.rb +80 -36
  42. data/lib/ffi/clang/types/type_def.rb +14 -2
  43. data/lib/ffi/clang/types/vector.rb +13 -1
  44. data/lib/ffi/clang/unsaved_file.rb +18 -8
  45. data/lib/ffi/clang/version.rb +4 -2
  46. data/lib/ffi/clang.rb +23 -45
  47. data/license.md +3 -2
  48. data/readme.md +12 -13
  49. data/releases.md +5 -0
  50. data.tar.gz.sig +0 -0
  51. metadata +10 -5
  52. metadata.gz.sig +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2013, by Garry Marshall.
5
- # Copyright, 2013-2024, by Samuel Williams.
5
+ # Copyright, 2013-2025, by Samuel Williams.
6
6
  # Copyright, 2013, by Carlos Martín Nieto.
7
7
  # Copyright, 2013, by Dave Wilkinson.
8
8
  # Copyright, 2013, by Takeshi Watanabe.
@@ -13,17 +13,17 @@
13
13
  # Copyright, 2020, by Zete Lui.
14
14
  # Copyright, 2023-2024, by Charlie Savage.
15
15
 
16
- require_relative 'translation_unit'
17
- require_relative 'diagnostic'
18
- require_relative 'comment'
19
- require_relative 'type'
16
+ require_relative "translation_unit"
17
+ require_relative "diagnostic"
18
+ require_relative "comment"
19
+ require_relative "type"
20
20
 
21
21
  module FFI
22
22
  module Clang
23
23
  module Lib
24
24
  # In Clang 15 the enum value changed from 300 to 350!
25
- CUSOR_TRANSLATION_UNIT = Clang.clang_version < Gem::Version.new('15.0.0') ? 300 : 350
26
-
25
+ CUSOR_TRANSLATION_UNIT = Clang.clang_version < Gem::Version.new("15.0.0") ? 300 : 350
26
+
27
27
  enum :cursor_kind, [
28
28
  :cursor_unexposed_decl, 1,
29
29
  :cursor_struct, 2,
@@ -296,21 +296,21 @@ module FFI
296
296
  # :cursor_last_extra_decl, :cursor_friend_decl,
297
297
  :cursor_overload_candidate, 700
298
298
  ]
299
-
299
+
300
300
  enum :access_specifier, [
301
301
  :invalid, 0,
302
302
  :public, 1,
303
303
  :protected, 2,
304
304
  :private, 3
305
305
  ]
306
-
306
+
307
307
  enum :availability, [
308
308
  :available, 0,
309
309
  :deprecated, 1,
310
310
  :not_available, 2,
311
311
  :not_accesible, 3
312
312
  ]
313
-
313
+
314
314
  enum :linkage_kind, [
315
315
  :invalid, 0,
316
316
  :no_linkage, 1,
@@ -318,7 +318,7 @@ module FFI
318
318
  :unique_external, 3,
319
319
  :external, 4,
320
320
  ]
321
-
321
+
322
322
  enum :exception_specification_type, [
323
323
  :none,
324
324
  :dynamic_none,
@@ -331,7 +331,9 @@ module FFI
331
331
  :unparsed,
332
332
  :no_throw
333
333
  ]
334
-
334
+
335
+ # FFI struct representing a cursor in the libclang AST.
336
+ # @private
335
337
  class CXCursor < FFI::Struct
336
338
  layout(
337
339
  :kind, :cursor_kind,
@@ -339,35 +341,49 @@ module FFI
339
341
  :data, [:pointer, 3]
340
342
  )
341
343
  end
342
-
344
+
345
+ # FFI struct representing a version number with major, minor, and subminor components.
346
+ # @private
343
347
  class CXVersion < FFI::Struct
344
348
  layout(
345
349
  :major, :int,
346
350
  :minor, :int,
347
351
  :subminor, :int,
348
352
  )
349
-
353
+
354
+ # Get the major version number.
355
+ # @returns [Integer] The major version.
350
356
  def major
351
357
  self[:major]
352
358
  end
353
-
359
+
360
+ # Get the minor version number.
361
+ # @returns [Integer] The minor version.
354
362
  def minor
355
363
  self[:minor]
356
364
  end
357
-
365
+
366
+ # Get the subminor version number.
367
+ # @returns [Integer] The subminor version.
358
368
  def subminor
359
369
  self[:subminor]
360
370
  end
361
-
371
+
372
+ # Get the version as a string.
373
+ # @returns [String] The version string (e.g., "1.2.3").
362
374
  def version_string
363
375
  [major, minor, subminor].reject{|v| v < 0}.map(&:to_s).join(".")
364
376
  end
365
-
377
+
378
+ # Convert to a string representation.
379
+ # @returns [String] The version string.
366
380
  def to_s
367
381
  version_string
368
382
  end
369
383
  end
370
-
384
+
385
+ # FFI struct representing platform-specific availability information.
386
+ # @private
371
387
  class CXPlatformAvailability < FFI::Struct
372
388
  layout(
373
389
  :platform, CXString,
@@ -378,53 +394,55 @@ module FFI
378
394
  :message, CXString,
379
395
  )
380
396
  end
381
-
397
+
382
398
  enum :visitor_result, [:break, :continue]
383
-
399
+
400
+ # FFI struct for visiting cursors and ranges.
401
+ # @private
384
402
  class CXCursorAndRangeVisitor < FFI::Struct
385
403
  layout(
386
404
  :context, :pointer,
387
405
  :visit, callback([:pointer, CXCursor.by_value, CXSourceRange.by_value], :visitor_result),
388
406
  )
389
407
  end
390
-
408
+
391
409
  enum :cxx_access_specifier, [:invalid, :public, :protected, :private]
392
410
  attach_function :get_cxx_access_specifier, :clang_getCXXAccessSpecifier, [CXCursor.by_value], :cxx_access_specifier
393
-
411
+
394
412
  attach_function :get_enum_value, :clang_getEnumConstantDeclValue, [CXCursor.by_value], :long_long
395
413
  attach_function :get_enum_unsigned_value, :clang_getEnumConstantDeclUnsignedValue, [CXCursor.by_value], :ulong_long
396
-
414
+
397
415
  attach_function :is_virtual_base, :clang_isVirtualBase, [CXCursor.by_value], :uint
398
416
  attach_function :is_dynamic_call, :clang_Cursor_isDynamicCall, [CXCursor.by_value], :uint
399
417
  attach_function :is_variadic, :clang_Cursor_isVariadic, [CXCursor.by_value], :uint
400
-
418
+
401
419
  attach_function :is_definition, :clang_isCursorDefinition, [CXCursor.by_value], :uint
402
420
  attach_function :cxx_method_is_static, :clang_CXXMethod_isStatic, [CXCursor.by_value], :uint
403
421
  attach_function :cxx_method_is_virtual, :clang_CXXMethod_isVirtual, [CXCursor.by_value], :uint
404
-
422
+
405
423
  attach_function :cxx_method_is_pure_virtual, :clang_CXXMethod_isPureVirtual, [CXCursor.by_value], :uint
406
424
 
407
425
  attach_function :cxx_get_access_specifier, :clang_getCXXAccessSpecifier, [CXCursor.by_value], :access_specifier
408
426
 
409
427
  enum :language_kind, [:invalid, :c, :obj_c, :c_plus_plus]
410
428
  attach_function :get_language, :clang_getCursorLanguage, [CXCursor.by_value], :language_kind
411
-
429
+
412
430
  attach_function :get_canonical_cursor, :clang_getCanonicalCursor, [CXCursor.by_value], CXCursor.by_value
413
431
  attach_function :get_cursor_definition, :clang_getCursorDefinition, [CXCursor.by_value], CXCursor.by_value
414
432
  attach_function :get_specialized_cursor_template, :clang_getSpecializedCursorTemplate, [CXCursor.by_value], CXCursor.by_value
415
433
  attach_function :get_template_cursor_kind, :clang_getTemplateCursorKind, [CXCursor.by_value], :cursor_kind
416
-
434
+
417
435
  attach_function :get_translation_unit_cursor, :clang_getTranslationUnitCursor, [:CXTranslationUnit], CXCursor.by_value
418
436
  attach_function :cursor_get_translation_unit, :clang_Cursor_getTranslationUnit, [CXCursor.by_value], :CXTranslationUnit
419
-
437
+
420
438
  attach_function :get_null_cursor, :clang_getNullCursor, [], CXCursor.by_value
421
-
439
+
422
440
  attach_function :cursor_is_null, :clang_Cursor_isNull, [CXCursor.by_value], :int
423
-
441
+
424
442
  attach_function :cursor_get_comment_range, :clang_Cursor_getCommentRange, [CXCursor.by_value], CXSourceRange.by_value
425
443
  attach_function :cursor_get_raw_comment_text, :clang_Cursor_getRawCommentText, [CXCursor.by_value], CXString.by_value
426
444
  attach_function :cursor_get_parsed_comment, :clang_Cursor_getParsedComment, [CXCursor.by_value], CXComment.by_value
427
-
445
+
428
446
  attach_function :get_cursor, :clang_getCursor, [:CXTranslationUnit, CXSourceLocation.by_value], CXCursor.by_value
429
447
  attach_function :get_cursor_location, :clang_getCursorLocation, [CXCursor.by_value], CXSourceLocation.by_value
430
448
  attach_function :get_cursor_extent, :clang_getCursorExtent, [CXCursor.by_value], CXSourceRange.by_value
@@ -432,9 +450,9 @@ module FFI
432
450
  attach_function :get_cursor_spelling, :clang_getCursorSpelling, [CXCursor.by_value], CXString.by_value
433
451
  attach_function :get_cursor_usr, :clang_getCursorUSR, [CXCursor.by_value], CXString.by_value
434
452
  attach_function :get_cursor_kind_spelling, :clang_getCursorKindSpelling, [:cursor_kind], CXString.by_value
435
-
453
+
436
454
  attach_function :are_equal, :clang_equalCursors, [CXCursor.by_value, CXCursor.by_value], :uint
437
-
455
+
438
456
  attach_function :is_declaration, :clang_isDeclaration, [:cursor_kind], :uint
439
457
  attach_function :is_reference, :clang_isReference, [:cursor_kind], :uint
440
458
  attach_function :is_expression, :clang_isExpression, [:cursor_kind], :uint
@@ -444,15 +462,15 @@ module FFI
444
462
  attach_function :is_translation_unit, :clang_isTranslationUnit, [:cursor_kind], :uint
445
463
  attach_function :is_preprocessing, :clang_isPreprocessing, [:cursor_kind], :uint
446
464
  attach_function :is_unexposed, :clang_isUnexposed, [:cursor_kind], :uint
447
-
465
+
448
466
  enum :child_visit_result, [:break, :continue, :recurse]
449
-
467
+
450
468
  callback :visit_children_function, [CXCursor.by_value, CXCursor.by_value, :pointer], :child_visit_result
451
469
  attach_function :visit_children, :clang_visitChildren, [CXCursor.by_value, :visit_children_function, :pointer], :uint
452
-
470
+
453
471
  enum :result, [:success, :invalid, :visit_break]
454
472
  attach_function :find_references_in_file, :clang_findReferencesInFile, [CXCursor.by_value, :CXFile, CXCursorAndRangeVisitor.by_value], :result
455
-
473
+
456
474
  attach_function :get_cursor_type, :clang_getCursorType, [CXCursor.by_value], CXType.by_value
457
475
  attach_function :cursor_is_anonymous, :clang_Cursor_isAnonymous, [CXCursor.by_value], :uint
458
476
  attach_function :cursor_is_anonymous_record_decl, :clang_Cursor_isAnonymousRecordDecl, [CXCursor.by_value], :uint
@@ -460,36 +478,36 @@ module FFI
460
478
  attach_function :get_typedef_decl_underlying_type, :clang_getTypedefDeclUnderlyingType, [CXCursor.by_value], CXType.by_value
461
479
  attach_function :get_enum_decl_integer_type, :clang_getEnumDeclIntegerType, [CXCursor.by_value], CXType.by_value
462
480
  attach_function :get_type_declaration, :clang_getTypeDeclaration, [CXType.by_value], FFI::Clang::Lib::CXCursor.by_value
463
-
481
+
464
482
  attach_function :get_cursor_referenced, :clang_getCursorReferenced, [CXCursor.by_value], CXCursor.by_value
465
483
  attach_function :get_cursor_semantic_parent, :clang_getCursorSemanticParent, [CXCursor.by_value], CXCursor.by_value
466
484
  attach_function :get_cursor_lexical_parent, :clang_getCursorLexicalParent, [CXCursor.by_value], CXCursor.by_value
467
-
485
+
468
486
  attach_function :get_cursor_availability, :clang_getCursorAvailability, [CXCursor.by_value], :availability
469
487
  attach_function :get_cursor_linkage, :clang_getCursorLinkage, [CXCursor.by_value], :linkage_kind
470
488
  attach_function :get_cursor_exception_specification_type, :clang_getCursorExceptionSpecificationType, [CXCursor.by_value], :exception_specification_type
471
489
  attach_function :get_included_file, :clang_getIncludedFile, [CXCursor.by_value], :CXFile
472
490
  attach_function :get_cursor_hash, :clang_hashCursor, [CXCursor.by_value], :uint
473
-
491
+
474
492
  attach_function :is_bit_field,:clang_Cursor_isBitField, [CXCursor.by_value], :uint
475
493
  attach_function :get_field_decl_bit_width, :clang_getFieldDeclBitWidth, [CXCursor.by_value], :int
476
-
494
+
477
495
  attach_function :get_overloaded_decl, :clang_getOverloadedDecl, [CXCursor.by_value, :uint], CXCursor.by_value
478
496
  attach_function :get_num_overloaded_decls, :clang_getNumOverloadedDecls, [CXCursor.by_value], :uint
479
-
497
+
480
498
  attach_function :cursor_get_argument, :clang_Cursor_getArgument, [CXCursor.by_value, :uint], CXCursor.by_value
481
499
  attach_function :cursor_get_num_arguments, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
482
-
500
+
483
501
  attach_function :get_decl_objc_type_encoding, :clang_getDeclObjCTypeEncoding, [CXCursor.by_value], CXString.by_value
484
-
502
+
485
503
  attach_function :get_cursor_platform_availability, :clang_getCursorPlatformAvailability, [CXCursor.by_value, :pointer, :pointer, :pointer, :pointer, :pointer, :int], :int
486
504
  attach_function :dispose_platform_availability, :clang_disposeCXPlatformAvailability, [:pointer], :void
487
-
505
+
488
506
  attach_function :get_overridden_cursors, :clang_getOverriddenCursors, [CXCursor.by_value, :pointer, :pointer], :void
489
507
  attach_function :dispose_overridden_cursors, :clang_disposeOverriddenCursors, [:pointer], :void
490
-
508
+
491
509
  attach_function :get_num_args, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
492
-
510
+
493
511
  attach_function :is_converting_constructor, :clang_CXXConstructor_isConvertingConstructor, [CXCursor.by_value], :uint
494
512
  attach_function :is_copy_constructor, :clang_CXXConstructor_isCopyConstructor, [CXCursor.by_value], :uint
495
513
  attach_function :is_default_constructor, :clang_CXXConstructor_isDefaultConstructor, [CXCursor.by_value], :uint
@@ -499,18 +517,18 @@ module FFI
499
517
  attach_function :is_abstract, :clang_CXXRecord_isAbstract, [CXCursor.by_value], :uint
500
518
  attach_function :is_enum_scoped, :clang_EnumDecl_isScoped, [CXCursor.by_value], :uint
501
519
  attach_function :is_const, :clang_CXXMethod_isConst, [CXCursor.by_value], :uint
502
-
503
- if Clang.clang_version >= Gem::Version.new('16.0.0')
520
+
521
+ if Clang.clang_version >= Gem::Version.new("16.0.0")
504
522
  attach_function :get_unqualified_type, :clang_getUnqualifiedType, [CXType.by_value], CXType.by_value
505
523
  attach_function :get_non_reference_type, :clang_getNonReferenceType, [CXType.by_value], CXType.by_value
506
524
  attach_function :is_deleted, :clang_CXXMethod_isDeleted, [CXCursor.by_value], :uint
507
525
  attach_function :is_copy_assignment_operator, :clang_CXXMethod_isCopyAssignmentOperator, [CXCursor.by_value], :uint
508
526
  attach_function :is_move_assignment_operator, :clang_CXXMethod_isMoveAssignmentOperator, [CXCursor.by_value], :uint
509
527
  end
510
-
511
- if Clang.clang_version >= Gem::Version.new('17.0.0')
528
+
529
+ if Clang.clang_version >= Gem::Version.new("17.0.0")
512
530
  attach_function :is_explicit, :clang_CXXMethod_isExplicit, [CXCursor.by_value], :uint
513
-
531
+
514
532
  enum :binary_operator_kind, [
515
533
  :binary_operator_invalid,
516
534
  :binary_operator_ptr_mem_d,
@@ -547,10 +565,10 @@ module FFI
547
565
  :binary_operator_or_assign,
548
566
  :binary_operator_comma
549
567
  ]
550
-
568
+
551
569
  attach_function :get_binary_operator_kind_spelling, :clang_getBinaryOperatorKindSpelling, [:binary_operator_kind], CXString.by_value
552
570
  attach_function :get_cursor_binary_operator_kind, :clang_getCursorBinaryOperatorKind, [CXCursor.by_value], :binary_operator_kind
553
-
571
+
554
572
  enum :unary_operator_kind, [
555
573
  :unary_operator_Invalid,
556
574
  :unary_operator_PostInc,
@@ -568,7 +586,7 @@ module FFI
568
586
  :unary_operator_Extension,
569
587
  :unary_operator_Coawait
570
588
  ]
571
-
589
+
572
590
  attach_function :get_unary_operator_kind_spelling, :clang_getUnaryOperatorKindSpelling, [:unary_operator_kind], CXString.by_value
573
591
  attach_function :get_cursor_unary_operator_kind, :clang_getCursorUnaryOperatorKind, [CXCursor.by_value], :unary_operator_kind
574
592
  end
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2013-2024, by Samuel Williams.
4
+ # Copyright, 2013-2025, by Samuel Williams.
5
5
  # Copyright, 2013, by Garry Marshall.
6
6
  # Copyright, 2014, by Masahiro Sano.
7
7
  # Copyright, 2020, by Zete Lui.
8
8
 
9
- require_relative 'translation_unit'
10
- require_relative 'source_location'
11
- require_relative 'string'
12
- require_relative 'source_range'
9
+ require_relative "translation_unit"
10
+ require_relative "source_location"
11
+ require_relative "string"
12
+ require_relative "source_range"
13
13
 
14
14
  module FFI
15
15
  module Clang
16
16
  module Lib
17
17
  typedef :pointer, :CXDiagnostic
18
18
  typedef :pointer, :CXDiagnosticSet
19
-
19
+
20
20
  DiagnosticDisplayOptions = enum [
21
21
  :source_location, 0x01,
22
22
  :column, 0x02,
@@ -25,40 +25,40 @@ module FFI
25
25
  :category_id, 0x10,
26
26
  :category_name , 0x20,
27
27
  ]
28
-
28
+
29
29
  enum :diagnostic_severity, [:ignored, :note, :warning, :error, :fatal]
30
-
30
+
31
31
  # Source code diagnostics:
32
32
  attach_function :get_num_diagnostics, :clang_getNumDiagnostics, [:CXTranslationUnit], :uint
33
33
  attach_function :get_diagnostic, :clang_getDiagnostic, [:CXTranslationUnit, :uint], :CXDiagnostic
34
34
  attach_function :dispose_diagnostic, :clang_disposeDiagnostic, [:CXDiagnostic], :void
35
-
35
+
36
36
  # DiagnosticSet (not used yet)
37
37
  # attach_function :get_diagnostic_set_from_translation_unit, :clang_getDiagnosticSetFromTU, [:CXTranslationUnit], :CXDiagnosticSet
38
38
  # attach_function :dispose_diagnostic_set, :clang_disposeDiagnosticSet, [:CXDiagnosticSet], :void
39
39
  # attach_function :load_diagnostics, :clang_loadDiagnostics, [:string, :pointer, :pointer], :CXDiagnosticSet
40
-
40
+
41
41
  # Diagnostic details and string representations:
42
42
  attach_function :get_diagnostic_spelling, :clang_getDiagnosticSpelling, [:CXDiagnostic], CXString.by_value
43
43
  attach_function :default_diagnostic_display_options, :clang_defaultDiagnosticDisplayOptions, [], :uint
44
44
  attach_function :format_diagnostic, :clang_formatDiagnostic, [:CXDiagnostic, :uint], CXString.by_value
45
45
  attach_function :get_diagnostic_severity, :clang_getDiagnosticSeverity, [:CXDiagnostic], :diagnostic_severity
46
46
  attach_function :get_diagnostic_option, :clang_getDiagnosticOption, [:CXDiagnostic, :pointer], CXString.by_value
47
-
47
+
48
48
  # Diagnostic source location and source ranges:
49
49
  attach_function :get_diagnostic_location, :clang_getDiagnosticLocation, [:CXDiagnostic], CXSourceLocation.by_value
50
50
  attach_function :get_diagnostic_num_ranges, :clang_getDiagnosticNumRanges, [:CXDiagnostic], :uint
51
51
  attach_function :get_diagnostic_range, :clang_getDiagnosticRange, [:CXDiagnostic, :uint], CXSourceRange.by_value
52
-
52
+
53
53
  # Child Diagnostics:
54
54
  attach_function :get_child_diagnostics, :clang_getChildDiagnostics, [:CXDiagnostic], :CXDiagnosticSet
55
55
  attach_function :get_num_diagnostics_in_set, :clang_getNumDiagnosticsInSet, [:CXDiagnosticSet], :uint
56
56
  attach_function :get_diagnostic_in_set, :clang_getDiagnosticInSet, [:CXDiagnosticSet, :uint], :CXDiagnostic
57
-
57
+
58
58
  # Category:
59
59
  attach_function :get_diagnostic_category, :clang_getDiagnosticCategory, [:CXDiagnostic], :uint
60
60
  attach_function :get_diagnostic_category_text, :clang_getDiagnosticCategoryText, [:CXDiagnostic], CXString.by_value
61
-
61
+
62
62
  # Fixit:
63
63
  attach_function :get_diagnostic_num_fix_its, :clang_getDiagnosticNumFixIts, [:CXDiagnostic], :uint
64
64
  attach_function :get_diagnostic_fix_it, :clang_getDiagnosticFixIt, [:CXDiagnostic, :uint, :pointer], CXString.by_value
@@ -3,16 +3,18 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2010, by Jari Bakken.
5
5
  # Copyright, 2012, by Hal Brodigan.
6
- # Copyright, 2013-2024, by Samuel Williams.
6
+ # Copyright, 2013-2025, by Samuel Williams.
7
7
  # Copyright, 2013, by Carlos Martín Nieto.
8
8
  # Copyright, 2014, by Masahiro Sano.
9
9
 
10
- require_relative 'string'
11
- require_relative 'translation_unit'
10
+ require_relative "string"
11
+ require_relative "translation_unit"
12
12
 
13
13
  module FFI
14
14
  module Clang
15
15
  module Lib
16
+ # FFI struct representing an unsaved file for parsing.
17
+ # @private
16
18
  class CXUnsavedFile < FFI::Struct
17
19
  layout(
18
20
  :filename, :pointer,
@@ -20,7 +22,9 @@ module FFI
20
22
  :length, :ulong
21
23
  )
22
24
  end
23
-
25
+
26
+ # FFI struct representing a unique file identifier.
27
+ # @private
24
28
  class CXFileUniqueID < FFI::Struct
25
29
  layout(
26
30
  :device, :ulong_long,
@@ -28,9 +32,9 @@ module FFI
28
32
  :modification, :ulong_long
29
33
  )
30
34
  end
31
-
35
+
32
36
  typedef :pointer, :CXFile
33
-
37
+
34
38
  attach_function :get_file, :clang_getFile, [:CXTranslationUnit, :string], :CXFile
35
39
  attach_function :get_file_name, :clang_getFileName, [:CXFile], CXString.by_value
36
40
  attach_function :get_file_time, :clang_getFileTime, [:CXFile], :time_t
@@ -2,10 +2,10 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2014, by Greg Hazel.
5
- # Copyright, 2014-2022, by Samuel Williams.
5
+ # Copyright, 2014-2025, by Samuel Williams.
6
6
 
7
- require_relative 'file'
8
- require_relative 'source_location'
7
+ require_relative "file"
8
+ require_relative "source_location"
9
9
 
10
10
  module FFI
11
11
  module Clang
@@ -3,19 +3,21 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2010, by Jari Bakken.
5
5
  # Copyright, 2012, by Hal Brodigan.
6
- # Copyright, 2013-2022, by Samuel Williams.
6
+ # Copyright, 2013-2025, by Samuel Williams.
7
7
  # Copyright, 2024, by Charlie Savage.
8
8
 
9
9
  module FFI
10
10
  module Clang
11
11
  module Lib
12
12
  typedef :pointer, :CXIndex
13
-
13
+
14
14
  # Source code index:
15
15
  attach_function :create_index, :clang_createIndex, [:int, :int], :CXIndex
16
16
  attach_function :dispose_index, :clang_disposeIndex, [:CXIndex], :void
17
-
18
- if Clang.clang_version >= Gem::Version.new('17.0.0')
17
+
18
+ if Clang.clang_version >= Gem::Version.new("17.0.0")
19
+ # FFI struct for index creation options (libclang 17.0.0+).
20
+ # @private
19
21
  class CXIndexOptions < FFI::Struct
20
22
  layout(
21
23
  :size, :uint,
@@ -29,7 +31,7 @@ module FFI
29
31
  :invocation_emission_path, :string
30
32
  )
31
33
  end
32
-
34
+
33
35
  attach_function :create_index_with_options, :clang_createIndexWithOptions, [CXIndexOptions.by_ref], :CXIndex
34
36
  end
35
37
  end
@@ -2,46 +2,46 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2024, by Charlie Savage.
5
- # Copyright, 2024, by Samuel Williams.
5
+ # Copyright, 2024-2025, by Samuel Williams.
6
6
 
7
7
  module FFI
8
8
  module Clang
9
9
  module Lib
10
- typedef :pointer, :CXPrintingPolicy
11
-
12
- PrintingPolicyProperty = enum [:printing_policy_indentation,
13
- :printing_policy_suppress_specifiers,
14
- :printing_policy_suppress_tag_keyword,
15
- :printing_policy_include_tag_definition,
16
- :printing_policy_suppress_scope,
17
- :printing_policy_suppress_unwritten_scope,
18
- :printing_policy_suppress_initializers,
19
- :printing_policy_constant_array_aize_as_written,
20
- :printing_policy_anonymous_tag_locations,
21
- :printing_policy_suppress_strong_lifetime,
22
- :printing_policy_suppress_lifetime_qualifiers,
23
- :printing_policy_suppress_template_args_in_cxx_constructors,
24
- :printing_policy_bool,
25
- :printing_policy_restrict,
26
- :printing_policy_alignof,
27
- :printing_policy_underscore_alignof,
28
- :printing_policy_use_void_for_zero_params,
29
- :printing_policy_terse_output,
30
- :printing_policy_polish_for_declaration,
31
- :printing_policy_half,
32
- :printing_policy_msw_char,
33
- :printing_policy_include_new_lines,
34
- :printing_policy_msvc_formatting,
35
- :printing_policy_constants_as_written,
36
- :printing_policy_suppress_implicit_base,
37
- :printing_policy_fully_qualified_name,
38
- :printing_policy_last_property]
39
-
40
- attach_function :printing_policy_get_property, :clang_PrintingPolicy_getProperty, [:CXPrintingPolicy, PrintingPolicyProperty], :uint
41
- attach_function :printing_policy_set_property, :clang_PrintingPolicy_setProperty, [:CXPrintingPolicy, PrintingPolicyProperty, :uint], :void
42
- attach_function :get_printing_policy, :clang_getCursorPrintingPolicy, [CXCursor.by_value], :CXPrintingPolicy
43
- attach_function :dispose_printing_policy, :clang_PrintingPolicy_dispose, [:CXPrintingPolicy], :void
44
- attach_function :pretty_print, :clang_getCursorPrettyPrinted, [CXCursor.by_value, :CXPrintingPolicy], CXString.by_value
10
+ typedef :pointer, :CXPrintingPolicy
11
+
12
+ PrintingPolicyProperty = enum [:printing_policy_indentation,
13
+ :printing_policy_suppress_specifiers,
14
+ :printing_policy_suppress_tag_keyword,
15
+ :printing_policy_include_tag_definition,
16
+ :printing_policy_suppress_scope,
17
+ :printing_policy_suppress_unwritten_scope,
18
+ :printing_policy_suppress_initializers,
19
+ :printing_policy_constant_array_aize_as_written,
20
+ :printing_policy_anonymous_tag_locations,
21
+ :printing_policy_suppress_strong_lifetime,
22
+ :printing_policy_suppress_lifetime_qualifiers,
23
+ :printing_policy_suppress_template_args_in_cxx_constructors,
24
+ :printing_policy_bool,
25
+ :printing_policy_restrict,
26
+ :printing_policy_alignof,
27
+ :printing_policy_underscore_alignof,
28
+ :printing_policy_use_void_for_zero_params,
29
+ :printing_policy_terse_output,
30
+ :printing_policy_polish_for_declaration,
31
+ :printing_policy_half,
32
+ :printing_policy_msw_char,
33
+ :printing_policy_include_new_lines,
34
+ :printing_policy_msvc_formatting,
35
+ :printing_policy_constants_as_written,
36
+ :printing_policy_suppress_implicit_base,
37
+ :printing_policy_fully_qualified_name,
38
+ :printing_policy_last_property]
39
+
40
+ attach_function :printing_policy_get_property, :clang_PrintingPolicy_getProperty, [:CXPrintingPolicy, PrintingPolicyProperty], :uint
41
+ attach_function :printing_policy_set_property, :clang_PrintingPolicy_setProperty, [:CXPrintingPolicy, PrintingPolicyProperty, :uint], :void
42
+ attach_function :get_printing_policy, :clang_getCursorPrintingPolicy, [CXCursor.by_value], :CXPrintingPolicy
43
+ attach_function :dispose_printing_policy, :clang_PrintingPolicy_dispose, [:CXPrintingPolicy], :void
44
+ attach_function :pretty_print, :clang_getCursorPrettyPrinted, [CXCursor.by_value, :CXPrintingPolicy], CXString.by_value
45
45
  end
46
46
  end
47
47
  end
@@ -2,33 +2,35 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2013, by Garry Marshall.
5
- # Copyright, 2013-2022, by Samuel Williams.
5
+ # Copyright, 2013-2025, by Samuel Williams.
6
6
  # Copyright, 2014, by Masahiro Sano.
7
7
 
8
- require_relative 'file'
8
+ require_relative "file"
9
9
 
10
10
  module FFI
11
11
  module Clang
12
12
  module Lib
13
+ # FFI struct representing a source location in libclang.
14
+ # @private
13
15
  class CXSourceLocation < FFI::Struct
14
16
  layout(
15
17
  :ptr_data, [:pointer, 2],
16
18
  :int_data, :uint
17
19
  )
18
20
  end
19
-
21
+
20
22
  attach_function :get_null_location, :clang_getNullLocation, [], CXSourceLocation.by_value
21
23
  attach_function :equal_locations, :clang_equalLocations, [CXSourceLocation.by_value, CXSourceLocation.by_value], :int
22
-
24
+
23
25
  attach_function :get_location, :clang_getLocation, [:CXTranslationUnit, :CXFile, :uint, :uint], CXSourceLocation.by_value
24
26
  attach_function :get_location_offset, :clang_getLocationForOffset, [:CXTranslationUnit, :CXFile, :uint], CXSourceLocation.by_value
25
27
  attach_function :get_expansion_location, :clang_getExpansionLocation, [CXSourceLocation.by_value, :pointer, :pointer, :pointer, :pointer], :void
26
28
  attach_function :get_presumed_location, :clang_getPresumedLocation, [CXSourceLocation.by_value, :pointer, :pointer, :pointer], :void
27
-
29
+
28
30
  attach_function :get_file_location, :clang_getFileLocation, [CXSourceLocation.by_value, :pointer, :pointer, :pointer, :pointer], :void
29
-
31
+
30
32
  attach_function :get_spelling_location, :clang_getSpellingLocation, [CXSourceLocation.by_value, :pointer, :pointer, :pointer, :pointer], :void
31
-
33
+
32
34
  attach_function :location_in_system_header, :clang_Location_isInSystemHeader, [CXSourceLocation.by_value], :int
33
35
  attach_function :location_is_from_main_file, :clang_Location_isFromMainFile, [CXSourceLocation.by_value], :int
34
36
  end
@@ -2,14 +2,16 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2013, by Garry Marshall.
5
- # Copyright, 2013-2022, by Samuel Williams.
5
+ # Copyright, 2013-2025, by Samuel Williams.
6
6
  # Copyright, 2014, by Masahiro Sano.
7
7
 
8
- require_relative 'source_location'
8
+ require_relative "source_location"
9
9
 
10
10
  module FFI
11
11
  module Clang
12
12
  module Lib
13
+ # FFI struct representing a source range in libclang.
14
+ # @private
13
15
  class CXSourceRange < FFI::Struct
14
16
  layout(
15
17
  :ptr_data, [:pointer, 2],
@@ -17,7 +19,7 @@ module FFI
17
19
  :end_int_data, :uint
18
20
  )
19
21
  end
20
-
22
+
21
23
  attach_function :get_null_range, :clang_getNullRange, [], CXSourceLocation.by_value
22
24
  attach_function :get_range, :clang_getRange, [CXSourceLocation.by_value, CXSourceLocation.by_value], CXSourceRange.by_value
23
25
  attach_function :get_range_start, :clang_getRangeStart, [CXSourceRange.by_value], CXSourceLocation.by_value