ffi-clang 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 371454aeb7550fde909b4e944d5371e8c56a3b07551fb4321b9761db71c65290
4
- data.tar.gz: 95d22ce375a63f2ab4a2881c39b048393297246684af30751ba70e1886957473
3
+ metadata.gz: a7bac4481c13b37b86189208dd7e0589bd96a42059319828c22ae623025ccc75
4
+ data.tar.gz: 3d6cc4ebca61f93b710b5a8fcc80d6fa51eeb8aac466246775c5ba80d8274c32
5
5
  SHA512:
6
- metadata.gz: a89207faa58c1c78a44147d7405f88bce71734c33850f1b171b8f93ddaaaf3610521ad18ccd82ccbc327789bd674ef5aaa912d8bfb855729753eb0a640dc63b7
7
- data.tar.gz: 3b8cf9d510d9abc186c4d695db6c6d4d2268f9b0fcfa8b7fd6261d19bf2fed8d052edbde8c5565ea13bd0e05bf61781f1f46a256add91e6e4feb34c8a9298699
6
+ metadata.gz: 816df5fbe722de3c3bc513598455a076bc64a32ee0d4d1697bc51dca767d06b9645be1c6dba444bc50d9d3f073fc02b2d13c6afbce355617df03368dc416930c
7
+ data.tar.gz: ec3be8892d6710742e173e54cb6c4f498b28a5178ca7c15ad9c08aae66f67824a039820f7ddff0a21c8aa50221c286dbeef9a2132e140bebb8c5f65fc69928c9
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ ���%%�Cƕ��j�.� 7��8�#Hx���m�ԭT7�Z@���@Ŏ��,��56�t��x �S[��|�ux9,� !�(�z�V����}��V?c+���{�K�J���a� p����"��P�$�V �)�HN�խ��c� m+���S+"U9���0��ErK���
2
+ �jļ���(Ȑ0�B�^uط�r�h q��T���
3
+ �prab}���ّ7w�����Ji��u�YU�7��?��{(���bU�X�7<�`u>�,���(J#xk_*��l�t�^NC>�+9𡵅R`������0"���}�4�
data/ext/rakefile.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2022, by Samuel Williams.
1
5
 
2
6
  require 'teapot'
3
7
 
data/ext/teapot.rb CHANGED
@@ -1,6 +1,7 @@
1
- #
2
- # This file is part of the "Teapot" project, and is released under the MIT license.
3
- #
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2013-2022, by Samuel Williams.
4
5
 
5
6
  teapot_version "0.8.0"
6
7
 
@@ -1,22 +1,8 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
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, 2016-2024, by Samuel Williams.
5
+ # Copyright, 2023, by Charlie Savage.
20
6
 
21
7
  require_relative 'lib/clang_version'
22
8
 
@@ -25,5 +11,10 @@ module FFI
25
11
  def self.clang_version_string
26
12
  Lib.extract_string Lib.get_clang_version
27
13
  end
14
+
15
+ def self.clang_version
16
+ clang_version = self.clang_version_string.match(/\d+\.\d+\.\d+/)
17
+ Gem::Version.new(clang_version)
18
+ end
28
19
  end
29
20
  end
@@ -1,22 +1,9 @@
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-2024, by Samuel Williams.
6
+ # Copyright, 2023-2024, by Charlie Savage.
20
7
 
21
8
  require_relative 'lib/code_completion'
22
9
 
@@ -24,7 +11,7 @@ module FFI
24
11
  module Clang
25
12
  class CodeCompletion
26
13
  def self.default_code_completion_options
27
- Lib.opts_from Lib::CodeCompleteFlags, Lib.default_code_completion_options
14
+ Lib.opts_from(Lib::CodeCompleteFlags, Lib.default_code_completion_options)
28
15
  end
29
16
 
30
17
  class Results < FFI::AutoPointer
@@ -41,7 +28,8 @@ module FFI
41
28
  end
42
29
 
43
30
  def self.release(pointer)
44
- Lib.dispose_code_complete_results(pointer)
31
+ results = Lib::CXCodeCompleteResults.new(pointer)
32
+ Lib.dispose_code_complete_results(results)
45
33
  end
46
34
 
47
35
  def each(&block)
@@ -1,22 +1,10 @@
1
- # Copyright, 2013, by Carlos Martín Nieto <cmn@dwim.me>
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, 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.
20
8
 
21
9
  require_relative 'lib/cursor'
22
10
  require_relative 'lib/comment'
@@ -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
  require_relative 'lib/compilation_database'
22
8
 
@@ -1,28 +1,22 @@
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-2024, by Samuel Williams.
6
+ # Copyright, 2013, by Carlos Martín Nieto.
7
+ # Copyright, 2013, by Dave Wilkinson.
8
+ # Copyright, 2013, by Takeshi Watanabe.
3
9
  # 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.
10
+ # Copyright, 2014, by George Pimm.
11
+ # Copyright, 2014, by Niklas Therning.
12
+ # Copyright, 2019, by Michael Metivier.
13
+ # Copyright, 2022, by Motonori Iwamuro.
14
+ # Copyright, 2023-2024, by Charlie Savage.
22
15
 
23
16
  require_relative 'lib/cursor'
24
17
  require_relative 'lib/code_completion'
25
18
 
19
+ require_relative 'printing_policy'
26
20
  require_relative 'source_location'
27
21
  require_relative 'source_range'
28
22
  require_relative 'comment'
@@ -116,9 +110,22 @@ module FFI
116
110
  Lib.is_unexposed(kind) != 0
117
111
  end
118
112
 
119
- def location
113
+ def expansion_location
120
114
  ExpansionLocation.new(Lib.get_cursor_location(@cursor))
121
115
  end
116
+ alias :location :expansion_location
117
+
118
+ def presumed_location
119
+ PresumedLocation.new(Lib.get_cursor_location(@cursor))
120
+ end
121
+
122
+ def spelling_location
123
+ SpellingLocation.new(Lib.get_cursor_location(@cursor))
124
+ end
125
+
126
+ def file_location
127
+ FileLocation.new(Lib.get_cursor_location(@cursor))
128
+ end
122
129
 
123
130
  def extent
124
131
  SourceRange.new(Lib.get_cursor_extent(@cursor))
@@ -128,10 +135,21 @@ module FFI
128
135
  Lib.extract_string Lib.get_cursor_display_name(@cursor)
129
136
  end
130
137
 
138
+ def qualified_name
139
+ if self.kind != :cursor_translation_unit
140
+ result = self.semantic_parent.qualified_name
141
+ result ? "#{result}::#{self.spelling}" : self.spelling
142
+ end
143
+ end
144
+
131
145
  def spelling
132
146
  Lib.extract_string Lib.get_cursor_spelling(@cursor)
133
147
  end
134
148
 
149
+ def printing_policy
150
+ PrintingPolicy.new(cursor)
151
+ end
152
+
135
153
  def usr
136
154
  Lib.extract_string Lib.get_cursor_usr(@cursor)
137
155
  end
@@ -156,14 +174,6 @@ module FFI
156
174
  Type.new Lib.get_typedef_decl_underlying_type(@cursor), @translation_unit
157
175
  end
158
176
 
159
- def enum_decl_integer_type
160
- Type.new Lib.get_enum_decl_integer_type(@cursor), @translation_unit
161
- end
162
-
163
- def typedef_type
164
- Type.new Lib.get_typedef_decl_unerlying_type(@cursor), @translation_unit
165
- end
166
-
167
177
  def virtual_base?
168
178
  Lib.is_virtual_base(@cursor) != 0
169
179
  end
@@ -201,7 +211,7 @@ module FFI
201
211
  end
202
212
 
203
213
  def enum_type
204
- Type.new Lib.get_enum_type(@cursor), @translation_unit
214
+ Type.new Lib.get_enum_decl_integer_type(@cursor), @translation_unit
205
215
  end
206
216
 
207
217
  def specialized_template
@@ -216,6 +226,21 @@ module FFI
216
226
  Cursor.new Lib.get_cursor_definition(@cursor), @translation_unit
217
227
  end
218
228
 
229
+ def opaque_declaration?
230
+ # Is this a declaration that does not have a definition in the translation unit
231
+ self.declaration? && !self.definition? && self.definition.invalid?
232
+ end
233
+
234
+ def forward_declaration?
235
+ # Is this a forward declaration for a definition contained in the same translation_unit?
236
+ # https://joshpeterson.github.io/identifying-a-forward-declaration-with-libclang
237
+ #
238
+ # Possible alternate implementations?
239
+ # self.declaration? && !self.definition? && self.definition
240
+ # !self.definition? && self.definition
241
+ self.declaration? && !self.eql?(self.definition) && !self.definition.invalid?
242
+ end
243
+
219
244
  def referenced
220
245
  Cursor.new Lib.get_cursor_referenced(@cursor), @translation_unit
221
246
  end
@@ -322,10 +347,6 @@ module FFI
322
347
  overriddens
323
348
  end
324
349
 
325
- def hash
326
- Lib.get_cursor_hash(@cursor)
327
- end
328
-
329
350
  def bitfield?
330
351
  Lib.is_bit_field(@cursor) != 0
331
352
  end
@@ -354,9 +375,14 @@ module FFI
354
375
  Lib.cursor_get_num_arguments(@cursor)
355
376
  end
356
377
 
357
- def ==(other)
378
+ def eql?(other)
358
379
  Lib.are_equal(@cursor, other.cursor) != 0
359
380
  end
381
+ alias == eql?
382
+
383
+ def hash
384
+ Lib.get_cursor_hash(@cursor)
385
+ end
360
386
 
361
387
  def find_all(*kinds)
362
388
  filter do |child, parent|
@@ -390,6 +416,10 @@ module FFI
390
416
  end
391
417
  end
392
418
 
419
+ def to_s
420
+ "Cursor <#{self.kind.to_s.gsub(/^cursor_/, '')}: #{self.spelling}>"
421
+ end
422
+
393
423
  def to_a
394
424
  filter.collect{|child, parent| child}
395
425
  end
@@ -403,6 +433,58 @@ module FFI
403
433
  refs
404
434
  end
405
435
 
436
+ def converting_constructor?
437
+ Lib.is_converting_constructor(@cursor) != 0
438
+ end
439
+
440
+ def copy_constructor?
441
+ Lib.is_copy_constructor(@cursor) != 0
442
+ end
443
+
444
+ def default_constructor?
445
+ Lib.is_default_constructor(@cursor) != 0
446
+ end
447
+
448
+ def move_constructor?
449
+ Lib.is_move_constructor(@cursor) != 0
450
+ end
451
+
452
+ def mutable?
453
+ Lib.is_mutable(@cursor) != 0
454
+ end
455
+
456
+ def defaulted?
457
+ Lib.is_defaulted(@cursor) != 0
458
+ end
459
+
460
+ def deleted?
461
+ Lib.is_deleted(@cursor) != 0
462
+ end
463
+
464
+ def copy_assignment_operator?
465
+ Lib.is_copy_assignment_operator(@cursor) != 0
466
+ end
467
+
468
+ def move_assignment_operator?
469
+ Lib.is_move_assignment_operator(@cursor) != 0
470
+ end
471
+
472
+ def explicit?
473
+ Lib.is_explicit(@cursor) != 0
474
+ end
475
+
476
+ def abstract?
477
+ Lib.is_abstract(@cursor) != 0
478
+ end
479
+
480
+ def enum_scoped?
481
+ Lib.is_enum_scoped(@cursor) != 0
482
+ end
483
+
484
+ def const?
485
+ Lib.is_const(@cursor) != 0
486
+ end
487
+
406
488
  class PlatformAvailability < AutoPointer
407
489
  def initialize(memory_pointer)
408
490
  pointer = FFI::Pointer.new(memory_pointer)
@@ -1,24 +1,12 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright, 2010-2012 by Jari Bakken.
3
- # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
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.
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 Garry Marshall.
8
+ # Copyright, 2014, by Masahiro Sano.
9
+ # Copyright, 2023, by Charlie Savage.
22
10
 
23
11
  require_relative 'lib/diagnostic'
24
12
  require_relative 'source_range'
@@ -27,7 +15,7 @@ module FFI
27
15
  module Clang
28
16
  class Diagnostic < AutoPointer
29
17
  def self.default_display_opts
30
- Lib.opts_from Lib::DiagnosticDisplayOptions, Lib.default_diagnostic_display_options
18
+ Lib.opts_from(Lib::DiagnosticDisplayOptions, Lib.default_diagnostic_display_options)
31
19
  end
32
20
 
33
21
  def initialize(translation_unit, pointer)
@@ -109,7 +97,7 @@ module FFI
109
97
  if opts.empty?
110
98
  Lib.default_diagnostic_display_options
111
99
  else
112
- Lib.bitmask_from Lib::DiagnosticDisplayOptions, opts
100
+ Lib.bitmask_from(Lib::DiagnosticDisplayOptions, opts)
113
101
  end
114
102
  end
115
103
  end
@@ -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
  require_relative 'lib/file'
22
8
 
@@ -1,24 +1,14 @@
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.
8
+ # Copyright, 2013, by Dave Wilkinson.
9
+ # Copyright, 2013, by Takeshi Watanabe.
3
10
  # 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.
11
+ # Copyright, 2023, by Charlie Savage.
22
12
 
23
13
  require_relative 'lib/index'
24
14
 
@@ -37,10 +27,16 @@ module FFI
37
27
  command_line_args = Array(command_line_args)
38
28
  unsaved_files = UnsavedFile.unsaved_pointer_from(unsaved)
39
29
 
40
- translation_unit_pointer = Lib.parse_translation_unit(self, source_file, args_pointer_from(command_line_args), command_line_args.size, unsaved_files, unsaved.length, options_bitmask_from(opts))
30
+ translation_unit_pointer_out = FFI::MemoryPointer.new(:pointer)
41
31
 
42
- raise Error, "error parsing #{source_file.inspect}" if translation_unit_pointer.null?
32
+ error_code = Lib.parse_translation_unit2(self, source_file, args_pointer_from(command_line_args), command_line_args.size, unsaved_files, unsaved.length, options_bitmask_from(opts), translation_unit_pointer_out)
33
+ if error_code != :cx_error_success
34
+ error_name = Lib::ErrorCodes.from_native(error_code, nil)
35
+ message = "Error parsing file. Code: #{error_name}. File: #{source_file.inspect}"
36
+ raise(Error, message)
37
+ end
43
38
 
39
+ translation_unit_pointer = translation_unit_pointer_out.read_pointer
44
40
  TranslationUnit.new translation_unit_pointer, self
45
41
  end
46
42
 
@@ -64,7 +60,7 @@ module FFI
64
60
  end
65
61
 
66
62
  def options_bitmask_from(opts)
67
- Lib.bitmask_from Lib::TranslationUnitFlags, opts
63
+ Lib.bitmask_from(Lib::TranslationUnitFlags, opts)
68
64
  end
69
65
  end
70
66
  end
@@ -1,22 +1,8 @@
1
- # 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.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2014, by Masahiro Sano.
5
+ # Copyright, 2014-2022, by Samuel Williams.
20
6
 
21
7
  require_relative 'string'
22
8
 
@@ -1,22 +1,9 @@
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.
6
+ # Copyright, 2024, by Charlie Savage.
20
7
 
21
8
  require_relative 'cursor'
22
9
  require_relative 'diagnostic'
@@ -110,16 +97,16 @@ module FFI
110
97
  attach_function :get_completion_brief_comment, :clang_getCompletionBriefComment, [:CXCompletionString], CXString.by_value
111
98
 
112
99
  # CXCodeCompleteResults functions
113
- attach_function :get_code_complete_get_num_diagnostics, :clang_codeCompleteGetNumDiagnostics, [CXCodeCompleteResults.ptr], :uint
114
- attach_function :get_code_complete_get_diagnostic, :clang_codeCompleteGetDiagnostic, [CXCodeCompleteResults.ptr, :uint], :CXDiagnostic
115
- attach_function :get_code_complete_get_contexts, :clang_codeCompleteGetContexts, [CXCodeCompleteResults.ptr], :ulong_long
116
- attach_function :get_code_complete_get_container_kind, :clang_codeCompleteGetContainerKind, [CXCodeCompleteResults.ptr, :pointer], :cursor_kind
117
- attach_function :get_code_complete_get_container_usr, :clang_codeCompleteGetContainerUSR, [CXCodeCompleteResults.ptr], CXString.by_value
118
- attach_function :get_code_complete_get_objc_selector, :clang_codeCompleteGetObjCSelector, [CXCodeCompleteResults.ptr], CXString.by_value
100
+ attach_function :get_code_complete_get_num_diagnostics, :clang_codeCompleteGetNumDiagnostics, [CXCodeCompleteResults.by_ref], :uint
101
+ attach_function :get_code_complete_get_diagnostic, :clang_codeCompleteGetDiagnostic, [CXCodeCompleteResults.by_ref, :uint], :CXDiagnostic
102
+ attach_function :get_code_complete_get_contexts, :clang_codeCompleteGetContexts, [CXCodeCompleteResults.by_ref], :ulong_long
103
+ attach_function :get_code_complete_get_container_kind, :clang_codeCompleteGetContainerKind, [CXCodeCompleteResults.by_ref, :pointer], :cursor_kind
104
+ attach_function :get_code_complete_get_container_usr, :clang_codeCompleteGetContainerUSR, [CXCodeCompleteResults.by_ref], CXString.by_value
105
+ attach_function :get_code_complete_get_objc_selector, :clang_codeCompleteGetObjCSelector, [CXCodeCompleteResults.by_ref], CXString.by_value
119
106
 
120
107
  # Other functions
121
- attach_function :code_complete_at, :clang_codeCompleteAt, [:CXTranslationUnit, :string, :uint, :uint, :pointer, :uint, :uint], CXCodeCompleteResults.ptr
122
- attach_function :dispose_code_complete_results, :clang_disposeCodeCompleteResults, [CXCodeCompleteResults.ptr], :void
108
+ attach_function :code_complete_at, :clang_codeCompleteAt, [:CXTranslationUnit, :string, :uint, :uint, :pointer, :uint, :uint], CXCodeCompleteResults.by_ref
109
+ attach_function :dispose_code_complete_results, :clang_disposeCodeCompleteResults, [CXCodeCompleteResults.by_ref], :void
123
110
  attach_function :get_cursor_completion_string, :clang_getCursorCompletionString, [CXCursor.by_value], :CXCompletionString
124
111
  attach_function :default_code_completion_options, :clang_defaultCodeCompleteOptions, [], :uint
125
112
  attach_function :sort_code_completion_results, :clang_sortCodeCompletionResults, [:pointer, :uint], :void