ffi-clang 0.7.0 → 0.9.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 (80) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +3 -0
  3. data/ext/rakefile.rb +4 -0
  4. data/ext/teapot.rb +4 -3
  5. data/lib/ffi/clang/clang_version.rb +10 -19
  6. data/lib/ffi/clang/code_completion.rb +8 -20
  7. data/lib/ffi/clang/comment.rb +7 -19
  8. data/lib/ffi/clang/compilation_database.rb +4 -18
  9. data/lib/ffi/clang/cursor.rb +117 -35
  10. data/lib/ffi/clang/diagnostic.rb +11 -23
  11. data/lib/ffi/clang/file.rb +4 -18
  12. data/lib/ffi/clang/index.rb +19 -23
  13. data/lib/ffi/clang/lib/clang_version.rb +5 -19
  14. data/lib/ffi/clang/lib/code_completion.rb +13 -26
  15. data/lib/ffi/clang/lib/comment.rb +7 -20
  16. data/lib/ffi/clang/lib/compilation_database.rb +4 -18
  17. data/lib/ffi/clang/lib/cursor.rb +102 -28
  18. data/lib/ffi/clang/lib/diagnostic.rb +7 -20
  19. data/lib/ffi/clang/lib/file.rb +7 -20
  20. data/lib/ffi/clang/lib/inclusions.rb +5 -19
  21. data/lib/ffi/clang/lib/index.rb +25 -20
  22. data/lib/ffi/clang/lib/printing_policy.rb +47 -0
  23. data/lib/ffi/clang/lib/source_location.rb +5 -20
  24. data/lib/ffi/clang/lib/source_range.rb +5 -22
  25. data/lib/ffi/clang/lib/string.rb +4 -20
  26. data/lib/ffi/clang/lib/token.rb +4 -18
  27. data/lib/ffi/clang/lib/translation_unit.rb +19 -21
  28. data/lib/ffi/clang/lib/type.rb +87 -22
  29. data/lib/ffi/clang/lib.rb +24 -28
  30. data/lib/ffi/clang/printing_policy.rb +36 -0
  31. data/lib/ffi/clang/source_location.rb +42 -38
  32. data/lib/ffi/clang/source_range.rb +7 -22
  33. data/lib/ffi/clang/token.rb +4 -18
  34. data/lib/ffi/clang/translation_unit.rb +10 -20
  35. data/lib/ffi/clang/type.rb +52 -25
  36. data/lib/ffi/clang/unsaved_file.rb +6 -20
  37. data/lib/ffi/clang/version.rb +7 -21
  38. data/lib/ffi/clang.rb +9 -20
  39. data/license.md +39 -0
  40. data/readme.md +56 -0
  41. data.tar.gz.sig +0 -0
  42. metadata +62 -116
  43. metadata.gz.sig +0 -0
  44. data/.editorconfig +0 -23
  45. data/.gitignore +0 -19
  46. data/.rspec +0 -5
  47. data/.travis.yml +0 -30
  48. data/Gemfile +0 -12
  49. data/README.md +0 -74
  50. data/Rakefile +0 -12
  51. data/examples/docs.cpp +0 -25
  52. data/examples/docs.rb +0 -31
  53. data/ffi-clang.gemspec +0 -25
  54. data/spec/ffi/clang/code_completion_spec.rb +0 -181
  55. data/spec/ffi/clang/comment_spec.rb +0 -453
  56. data/spec/ffi/clang/compilation_database_spec.rb +0 -180
  57. data/spec/ffi/clang/cursor_spec.rb +0 -741
  58. data/spec/ffi/clang/diagnostic_spec.rb +0 -89
  59. data/spec/ffi/clang/file_spec.rb +0 -82
  60. data/spec/ffi/clang/fixtures/a.c +0 -7
  61. data/spec/ffi/clang/fixtures/canonical.c +0 -5
  62. data/spec/ffi/clang/fixtures/class.cpp +0 -8
  63. data/spec/ffi/clang/fixtures/compile_commands.json +0 -17
  64. data/spec/ffi/clang/fixtures/completion.cxx +0 -8
  65. data/spec/ffi/clang/fixtures/docs.c +0 -1
  66. data/spec/ffi/clang/fixtures/docs.cc +0 -1
  67. data/spec/ffi/clang/fixtures/docs.h +0 -54
  68. data/spec/ffi/clang/fixtures/list.c +0 -11
  69. data/spec/ffi/clang/fixtures/location1.c +0 -7
  70. data/spec/ffi/clang/fixtures/simple.ast +0 -0
  71. data/spec/ffi/clang/fixtures/simple.c +0 -3
  72. data/spec/ffi/clang/fixtures/test.cxx +0 -62
  73. data/spec/ffi/clang/index_spec.rb +0 -90
  74. data/spec/ffi/clang/source_location_spec.rb +0 -138
  75. data/spec/ffi/clang/source_range_spec.rb +0 -74
  76. data/spec/ffi/clang/token_spec.rb +0 -82
  77. data/spec/ffi/clang/translation_unit_spec.rb +0 -220
  78. data/spec/ffi/clang/type_spec.rb +0 -273
  79. data/spec/ffi/clang/version_spec.rb +0 -28
  80. data/spec/spec_helper.rb +0 -51
@@ -1,23 +1,10 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013, by Carlos Martín Nieto.
5
+ # Copyright, 2013-2022, by Samuel Williams.
6
+ # Copyright, 2014, by George Pimm.
7
+ # Copyright, 2014, by Masahiro Sano.
21
8
 
22
9
  module FFI
23
10
  module Clang
@@ -1,22 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
1
4
  # Copyright, 2014, by Masahiro Sano.
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
5
+ # Copyright, 2014-2022, by Samuel Williams.
20
6
 
21
7
  module FFI
22
8
  module Clang
@@ -1,25 +1,17 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
- # Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
4
- # Copyright, 2014, by Masahiro Sano.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013, by Garry Marshall.
5
+ # Copyright, 2013-2024, by Samuel Williams.
6
+ # Copyright, 2013, by Carlos Martín Nieto.
7
+ # Copyright, 2013, by Dave Wilkinson.
8
+ # Copyright, 2013, by Takeshi Watanabe.
9
+ # Copyright, 2013-2014, by Masahiro Sano.
10
+ # Copyright, 2014, by George Pimm.
11
+ # Copyright, 2014, by Niklas Therning.
12
+ # Copyright, 2019, by Michael Metivier.
13
+ # Copyright, 2020, by Zete Lui.
14
+ # Copyright, 2023-2024, by Charlie Savage.
23
15
 
24
16
  require_relative 'translation_unit'
25
17
  require_relative 'diagnostic'
@@ -29,12 +21,15 @@ require_relative 'type'
29
21
  module FFI
30
22
  module Clang
31
23
  module Lib
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
+
32
27
  enum :cursor_kind, [
33
28
  :cursor_unexposed_decl, 1,
34
29
  :cursor_struct, 2,
35
- # :cusor_struct_decl, :cursor_struct
30
+ # :cursor_struct_decl, :cursor_struct
36
31
  :cursor_union, 3,
37
- # :cusor_union_decl, :cursor_union
32
+ # :cursor_union_decl, :cursor_union
38
33
  :cursor_class_decl, 4,
39
34
  :cursor_enum_decl, 5,
40
35
  :cursor_field_decl, 6,
@@ -241,7 +236,7 @@ module FFI
241
236
  :cursor_omp_depobj_directive, 286,
242
237
  :cursor_omp_scan_directive, 287,
243
238
  # :cursor_last_stmt, :cursor_omp_scan_directive,
244
- :cursor_translation_unit, 300,
239
+ :cursor_translation_unit, CUSOR_TRANSLATION_UNIT,
245
240
  :cursor_first_attr, 400,
246
241
  :cursor_unexposed_attr, 400,
247
242
  :cursor_ibaction_attr, 401,
@@ -477,11 +472,90 @@ module FFI
477
472
  attach_function :get_overridden_cursors, :clang_getOverriddenCursors, [CXCursor.by_value, :pointer, :pointer], :void
478
473
  attach_function :dispose_overridden_cursors, :clang_disposeOverriddenCursors, [:pointer], :void
479
474
 
480
- attach_function :get_typedef_decl_unerlying_type, :clang_getTypedefDeclUnderlyingType, [CXCursor.by_value], CXType.by_value
475
+ attach_function :get_num_args, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
481
476
 
482
- attach_function :get_enum_type, :clang_getEnumDeclIntegerType, [CXCursor.by_value], CXType.by_value
477
+ attach_function :is_converting_constructor, :clang_CXXConstructor_isConvertingConstructor, [CXCursor.by_value], :uint
478
+ attach_function :is_copy_constructor, :clang_CXXConstructor_isCopyConstructor, [CXCursor.by_value], :uint
479
+ attach_function :is_default_constructor, :clang_CXXConstructor_isDefaultConstructor, [CXCursor.by_value], :uint
480
+ attach_function :is_move_constructor, :clang_CXXConstructor_isMoveConstructor, [CXCursor.by_value], :uint
481
+ attach_function :is_mutable, :clang_CXXField_isMutable, [CXCursor.by_value], :uint
482
+ attach_function :is_defaulted, :clang_CXXMethod_isDefaulted, [CXCursor.by_value], :uint
483
+ attach_function :is_abstract, :clang_CXXRecord_isAbstract, [CXCursor.by_value], :uint
484
+ attach_function :is_enum_scoped, :clang_EnumDecl_isScoped, [CXCursor.by_value], :uint
485
+ attach_function :is_const, :clang_CXXMethod_isConst, [CXCursor.by_value], :uint
486
+
487
+ if Clang.clang_version >= Gem::Version.new('16.0.0')
488
+ attach_function :get_unqualified_type, :clang_getUnqualifiedType, [CXType.by_value], CXType.by_value
489
+ attach_function :get_non_reference_type, :clang_getNonReferenceType, [CXType.by_value], CXType.by_value
490
+ attach_function :is_deleted, :clang_CXXMethod_isDeleted, [CXCursor.by_value], :uint
491
+ attach_function :is_copy_assignment_operator, :clang_CXXMethod_isCopyAssignmentOperator, [CXCursor.by_value], :uint
492
+ attach_function :is_move_assignment_operator, :clang_CXXMethod_isMoveAssignmentOperator, [CXCursor.by_value], :uint
493
+ end
483
494
 
484
- attach_function :get_num_args, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
495
+ if Clang.clang_version >= Gem::Version.new('17.0.0')
496
+ attach_function :is_explicit, :clang_CXXMethod_isExplicit, [CXCursor.by_value], :uint
497
+
498
+ enum :binary_operator_kind, [
499
+ :binary_operator_invalid,
500
+ :binary_operator_ptr_mem_d,
501
+ :binary_operator_ptr_mem_i,
502
+ :binary_operator_mul,
503
+ :binary_operator_div,
504
+ :binary_operator_rem,
505
+ :binary_operator_add,
506
+ :binary_operator_sub,
507
+ :binary_operator_shl,
508
+ :binary_operator_shr,
509
+ :binary_operator_cmp,
510
+ :binary_operator_lt,
511
+ :binary_operator_gt,
512
+ :binary_operator_le,
513
+ :binary_operator_ge,
514
+ :binary_operator_eq,
515
+ :binary_operator_ne,
516
+ :binary_operator_and,
517
+ :binary_operator_xor,
518
+ :binary_operator_or,
519
+ :binary_operator_l_and,
520
+ :binary_operator_l_or,
521
+ :binary_operator_assign,
522
+ :binary_operator_mul_assign,
523
+ :binary_operator_div_assign,
524
+ :binary_operator_rem_assign,
525
+ :binary_operator_add_assign,
526
+ :binary_operator_sub_assign,
527
+ :binary_operator_shl_assign,
528
+ :binary_operator_shr_assign,
529
+ :binary_operator_and_assign,
530
+ :binary_operator_xor_assign,
531
+ :binary_operator_or_assign,
532
+ :binary_operator_comma
533
+ ]
534
+
535
+ attach_function :get_binary_operator_kind_spelling, :clang_getBinaryOperatorKindSpelling, [:binary_operator_kind], CXString.by_value
536
+ attach_function :get_cursor_binary_operator_kind, :clang_getCursorBinaryOperatorKind, [CXCursor.by_value], :binary_operator_kind
537
+
538
+ enum :unary_operator_kind, [
539
+ :unary_operator_Invalid,
540
+ :unary_operator_PostInc,
541
+ :unary_operator_PostDec,
542
+ :unary_operator_PreInc,
543
+ :unary_operator_PreDec,
544
+ :unary_operator_AddrOf,
545
+ :unary_operator_Deref,
546
+ :unary_operator_Plus,
547
+ :unary_operator_Minus,
548
+ :unary_operator_Not,
549
+ :unary_operator_LNot,
550
+ :unary_operator_Real,
551
+ :unary_operator_Imag,
552
+ :unary_operator_Extension,
553
+ :unary_operator_Coawait
554
+ ]
555
+
556
+ attach_function :get_unary_operator_kind_spelling, :clang_getUnaryOperatorKindSpelling, [:unary_operator_kind], CXString.by_value
557
+ attach_function :get_cursor_unary_operator_kind, :clang_getCursorUnaryOperatorKind, [CXCursor.by_value], :unary_operator_kind
558
+ end
485
559
  end
486
560
  end
487
561
  end
@@ -1,23 +1,10 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2024, by Samuel Williams.
5
+ # Copyright, 2013, by Garry Marshall.
6
+ # Copyright, 2014, by Masahiro Sano.
7
+ # Copyright, 2020, by Zete Lui.
21
8
 
22
9
  require_relative 'translation_unit'
23
10
  require_relative 'source_location'
@@ -1,24 +1,11 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2010, by Jari Bakken.
5
+ # Copyright, 2012, by Hal Brodigan.
6
+ # Copyright, 2013-2024, by Samuel Williams.
7
+ # Copyright, 2013, by Carlos Martín Nieto.
3
8
  # Copyright, 2014, by Masahiro Sano.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
9
 
23
10
  require_relative 'string'
24
11
  require_relative 'translation_unit'
@@ -1,22 +1,8 @@
1
- # Copyright, 2014, by Greg Hazel
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2014, by Greg Hazel.
5
+ # Copyright, 2014-2022, by Samuel Williams.
20
6
 
21
7
  require_relative 'file'
22
8
  require_relative 'source_location'
@@ -1,23 +1,10 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2010, by Jari Bakken.
5
+ # Copyright, 2012, by Hal Brodigan.
6
+ # Copyright, 2013-2022, by Samuel Williams.
7
+ # Copyright, 2024, by Charlie Savage.
21
8
 
22
9
  module FFI
23
10
  module Clang
@@ -27,6 +14,24 @@ module FFI
27
14
  # Source code index:
28
15
  attach_function :create_index, :clang_createIndex, [:int, :int], :CXIndex
29
16
  attach_function :dispose_index, :clang_disposeIndex, [:CXIndex], :void
17
+
18
+ if Clang.clang_version >= Gem::Version.new('17.0.0')
19
+ class CXIndexOptions < FFI::Struct
20
+ layout(
21
+ :size, :uint,
22
+ :thread_background_priority_for_indexing, :uchar,
23
+ :thread_background_priority_for_editing, :uchar,
24
+ :exclude_declarations_from_pch, :uint,
25
+ :display_diagnostics, :uint,
26
+ :store_preambles_in_memory, :uint,
27
+ :reserved, :uint,
28
+ :preamble_storage_path, :string,
29
+ :invocation_emission_path, :string
30
+ )
31
+ end
32
+
33
+ attach_function :create_index_with_options, :clang_createIndexWithOptions, [CXIndexOptions.by_ref], :CXIndex
34
+ end
30
35
  end
31
36
  end
32
37
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Charlie Savage.
5
+ # Copyright, 2024, by Samuel Williams.
6
+
7
+ module FFI
8
+ module Clang
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
45
+ end
46
+ end
47
+ end
@@ -1,24 +1,9 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013, by Garry Marshall.
5
+ # Copyright, 2013-2022, by Samuel Williams.
3
6
  # Copyright, 2014, by Masahiro Sano.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
7
 
23
8
  require_relative 'file'
24
9
 
@@ -1,26 +1,9 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright, 2010-2012 by Jari Bakken.
3
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013, by Garry Marshall.
5
+ # Copyright, 2013-2022, by Samuel Williams.
5
6
  # Copyright, 2014, by Masahiro Sano.
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the "Software"), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in
15
- # all copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- # THE SOFTWARE.
24
7
 
25
8
  require_relative 'source_location'
26
9
 
@@ -1,23 +1,7 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2024, by Samuel Williams.
21
5
 
22
6
  module FFI
23
7
  module Clang
@@ -1,22 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
1
4
  # Copyright, 2014, by Masahiro Sano.
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
5
+ # Copyright, 2014-2022, by Samuel Williams.
20
6
 
21
7
  module FFI
22
8
  module Clang
@@ -1,24 +1,11 @@
1
- # Copyright, 2010-2012 by Jari Bakken.
2
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2024, by Samuel Williams.
3
5
  # Copyright, 2014, by Masahiro Sano.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
6
+ # Copyright, 2019, by Hayden Purdy.
7
+ # Copyright, 2022, by Motonori Iwamuro.
8
+ # Copyright, 2023, by Charlie Savage.
22
9
 
23
10
  require_relative 'index'
24
11
 
@@ -42,7 +29,9 @@ module FFI
42
29
  :single_file_parse, 0x400,
43
30
  :limit_skip_function_bodies_to_preamble, 0x800,
44
31
  :include_attributed_type, 0x1000,
45
- :visit_implicit_attributes, 0x2000
32
+ :visit_implicit_attributes, 0x2000,
33
+ :ignore_non_errors_from_included_files, 0x4000,
34
+ :retain_excluded_conditional_blocks, 0x8000,
46
35
  ]
47
36
 
48
37
  SaveTranslationUnitFlags = enum [
@@ -77,6 +66,14 @@ module FFI
77
66
  :preprocessor_header_search, 14,
78
67
  ]
79
68
 
69
+ ErrorCodes = enum [
70
+ :cx_error_success, 0,
71
+ :cx_error_failure, 1,
72
+ :cx_error_crashed, 2,
73
+ :cx_error_invalid_arguments, 3,
74
+ :cx_error_ast_read_error, 4,
75
+ ]
76
+
80
77
  class CXTUResourceUsage < FFI::Struct
81
78
  layout(
82
79
  :data, :pointer,
@@ -94,6 +91,7 @@ module FFI
94
91
 
95
92
  # Source code translation units:
96
93
  attach_function :parse_translation_unit, :clang_parseTranslationUnit, [:CXIndex, :string, :pointer, :int, :pointer, :uint, :uint], :CXTranslationUnit
94
+ attach_function :parse_translation_unit2, :clang_parseTranslationUnit2, [:CXIndex, :string, :pointer, :int, :pointer, :uint, :uint, :pointer], ErrorCodes
97
95
  attach_function :create_translation_unit, :clang_createTranslationUnit, [:CXIndex, :string], :CXTranslationUnit
98
96
  attach_function :dispose_translation_unit, :clang_disposeTranslationUnit, [:CXTranslationUnit], :void
99
97
  attach_function :get_translation_unit_spelling, :clang_getTranslationUnitSpelling, [:CXTranslationUnit], CXString.by_value