ffi-clang 0.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49fb826573fff8e593fdd5671533332527ac2284b50740700134ddd7425d22dd
4
- data.tar.gz: 00ad98e0fe43999cb523be92b759cb5c4973d9ba24726420e97d98470c734eb1
3
+ metadata.gz: a7bac4481c13b37b86189208dd7e0589bd96a42059319828c22ae623025ccc75
4
+ data.tar.gz: 3d6cc4ebca61f93b710b5a8fcc80d6fa51eeb8aac466246775c5ba80d8274c32
5
5
  SHA512:
6
- metadata.gz: 3ebff7af9edbd58036a10ca360c801ddf1b9a8e251f6a869f48371a971e3497186d5abc52aa2bf9d883e7207f769973b0e998fae98d7d5ef2c0f6df989de6a17
7
- data.tar.gz: bbb56cd257720aa7fa87e12f068f9899b8f254b9cdc5d5036419744c4362f14eb21d48049418a4fa7f11ea6769806b6b758baab09c0c63a7b5ce4f2bf269b455
6
+ metadata.gz: 816df5fbe722de3c3bc513598455a076bc64a32ee0d4d1697bc51dca767d06b9645be1c6dba444bc50d9d3f073fc02b2d13c6afbce355617df03368dc416930c
7
+ data.tar.gz: ec3be8892d6710742e173e54cb6c4f498b28a5178ca7c15ad9c08aae66f67824a039820f7ddff0a21c8aa50221c286dbeef9a2132e140bebb8c5f65fc69928c9
checksums.yaml.gz.sig CHANGED
@@ -1,4 +1,3 @@
1
- �5٣���ǵ&�
2
- �~of[��ɾ�r�$MWL��Е�芅�lV!`At1�D�&o8�����~�����2ׇ�t2�M؝1ڙ�{>�����_ǡIr���d�=T>�w�����/�ol�WN#5HT�%ˆ,�W6
3
- Y'z����tae�_��$Me�-�"Uh'E�dž�k�����,2�-�E\��~���<�iO���l�#l�� =�OI!E\S��wXC�H�� +y��!; r�.I��� +������E��.1Ѵ���\q�����/໴�qq �J�v')ة�1;�����(}'�gj.�(���̀|�C_$ P���D_*�!�T���~������65H�,`�X-.����
4
- �Z�4?IcE
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��uYU7��?��{(���bUX7<�`u>�,���(J#xk_*��lt�^NC>�+9𡵅R`������0"���}�4
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2016-2022, by Samuel Williams.
4
+ # Copyright, 2016-2024, by Samuel Williams.
5
+ # Copyright, 2023, by Charlie Savage.
5
6
 
6
7
  require_relative 'lib/clang_version'
7
8
 
@@ -2,7 +2,8 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2014, by Masahiro Sano.
5
- # Copyright, 2014-2022, by Samuel Williams.
5
+ # Copyright, 2014-2024, by Samuel Williams.
6
+ # Copyright, 2023-2024, by Charlie Savage.
6
7
 
7
8
  require_relative 'lib/code_completion'
8
9
 
@@ -10,7 +11,7 @@ module FFI
10
11
  module Clang
11
12
  class CodeCompletion
12
13
  def self.default_code_completion_options
13
- Lib.opts_from Lib::CodeCompleteFlags, Lib.default_code_completion_options
14
+ Lib.opts_from(Lib::CodeCompleteFlags, Lib.default_code_completion_options)
14
15
  end
15
16
 
16
17
  class Results < FFI::AutoPointer
@@ -27,7 +28,8 @@ module FFI
27
28
  end
28
29
 
29
30
  def self.release(pointer)
30
- Lib.dispose_code_complete_results(pointer)
31
+ results = Lib::CXCodeCompleteResults.new(pointer)
32
+ Lib.dispose_code_complete_results(results)
31
33
  end
32
34
 
33
35
  def each(&block)
@@ -2,7 +2,7 @@
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-2024, 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.
@@ -11,10 +11,12 @@
11
11
  # Copyright, 2014, by Niklas Therning.
12
12
  # Copyright, 2019, by Michael Metivier.
13
13
  # Copyright, 2022, by Motonori Iwamuro.
14
+ # Copyright, 2023-2024, by Charlie Savage.
14
15
 
15
16
  require_relative 'lib/cursor'
16
17
  require_relative 'lib/code_completion'
17
18
 
19
+ require_relative 'printing_policy'
18
20
  require_relative 'source_location'
19
21
  require_relative 'source_range'
20
22
  require_relative 'comment'
@@ -108,9 +110,22 @@ module FFI
108
110
  Lib.is_unexposed(kind) != 0
109
111
  end
110
112
 
111
- def location
113
+ def expansion_location
112
114
  ExpansionLocation.new(Lib.get_cursor_location(@cursor))
113
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
114
129
 
115
130
  def extent
116
131
  SourceRange.new(Lib.get_cursor_extent(@cursor))
@@ -120,10 +135,21 @@ module FFI
120
135
  Lib.extract_string Lib.get_cursor_display_name(@cursor)
121
136
  end
122
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
+
123
145
  def spelling
124
146
  Lib.extract_string Lib.get_cursor_spelling(@cursor)
125
147
  end
126
148
 
149
+ def printing_policy
150
+ PrintingPolicy.new(cursor)
151
+ end
152
+
127
153
  def usr
128
154
  Lib.extract_string Lib.get_cursor_usr(@cursor)
129
155
  end
@@ -148,14 +174,6 @@ module FFI
148
174
  Type.new Lib.get_typedef_decl_underlying_type(@cursor), @translation_unit
149
175
  end
150
176
 
151
- def enum_decl_integer_type
152
- Type.new Lib.get_enum_decl_integer_type(@cursor), @translation_unit
153
- end
154
-
155
- def typedef_type
156
- Type.new Lib.get_typedef_decl_unerlying_type(@cursor), @translation_unit
157
- end
158
-
159
177
  def virtual_base?
160
178
  Lib.is_virtual_base(@cursor) != 0
161
179
  end
@@ -193,7 +211,7 @@ module FFI
193
211
  end
194
212
 
195
213
  def enum_type
196
- Type.new Lib.get_enum_type(@cursor), @translation_unit
214
+ Type.new Lib.get_enum_decl_integer_type(@cursor), @translation_unit
197
215
  end
198
216
 
199
217
  def specialized_template
@@ -208,6 +226,21 @@ module FFI
208
226
  Cursor.new Lib.get_cursor_definition(@cursor), @translation_unit
209
227
  end
210
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
+
211
244
  def referenced
212
245
  Cursor.new Lib.get_cursor_referenced(@cursor), @translation_unit
213
246
  end
@@ -383,6 +416,10 @@ module FFI
383
416
  end
384
417
  end
385
418
 
419
+ def to_s
420
+ "Cursor <#{self.kind.to_s.gsub(/^cursor_/, '')}: #{self.spelling}>"
421
+ end
422
+
386
423
  def to_a
387
424
  filter.collect{|child, parent| child}
388
425
  end
@@ -3,9 +3,10 @@
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-2024, by Samuel Williams.
7
7
  # Copyright, 2013, by Garry Marshall.
8
8
  # Copyright, 2014, by Masahiro Sano.
9
+ # Copyright, 2023, by Charlie Savage.
9
10
 
10
11
  require_relative 'lib/diagnostic'
11
12
  require_relative 'source_range'
@@ -14,7 +15,7 @@ module FFI
14
15
  module Clang
15
16
  class Diagnostic < AutoPointer
16
17
  def self.default_display_opts
17
- Lib.opts_from Lib::DiagnosticDisplayOptions, Lib.default_diagnostic_display_options
18
+ Lib.opts_from(Lib::DiagnosticDisplayOptions, Lib.default_diagnostic_display_options)
18
19
  end
19
20
 
20
21
  def initialize(translation_unit, pointer)
@@ -96,7 +97,7 @@ module FFI
96
97
  if opts.empty?
97
98
  Lib.default_diagnostic_display_options
98
99
  else
99
- Lib.bitmask_from Lib::DiagnosticDisplayOptions, opts
100
+ Lib.bitmask_from(Lib::DiagnosticDisplayOptions, opts)
100
101
  end
101
102
  end
102
103
  end
@@ -3,11 +3,12 @@
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-2024, by Samuel Williams.
7
7
  # Copyright, 2013, by Carlos Martín Nieto.
8
8
  # Copyright, 2013, by Dave Wilkinson.
9
9
  # Copyright, 2013, by Takeshi Watanabe.
10
10
  # Copyright, 2014, by Masahiro Sano.
11
+ # Copyright, 2023, by Charlie Savage.
11
12
 
12
13
  require_relative 'lib/index'
13
14
 
@@ -26,10 +27,16 @@ module FFI
26
27
  command_line_args = Array(command_line_args)
27
28
  unsaved_files = UnsavedFile.unsaved_pointer_from(unsaved)
28
29
 
29
- 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)
30
31
 
31
- 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
32
38
 
39
+ translation_unit_pointer = translation_unit_pointer_out.read_pointer
33
40
  TranslationUnit.new translation_unit_pointer, self
34
41
  end
35
42
 
@@ -53,7 +60,7 @@ module FFI
53
60
  end
54
61
 
55
62
  def options_bitmask_from(opts)
56
- Lib.bitmask_from Lib::TranslationUnitFlags, opts
63
+ Lib.bitmask_from(Lib::TranslationUnitFlags, opts)
57
64
  end
58
65
  end
59
66
  end
@@ -3,6 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2014, by Masahiro Sano.
5
5
  # Copyright, 2014-2022, by Samuel Williams.
6
+ # Copyright, 2024, by Charlie Savage.
6
7
 
7
8
  require_relative 'cursor'
8
9
  require_relative 'diagnostic'
@@ -96,16 +97,16 @@ module FFI
96
97
  attach_function :get_completion_brief_comment, :clang_getCompletionBriefComment, [:CXCompletionString], CXString.by_value
97
98
 
98
99
  # CXCodeCompleteResults functions
99
- attach_function :get_code_complete_get_num_diagnostics, :clang_codeCompleteGetNumDiagnostics, [CXCodeCompleteResults.ptr], :uint
100
- attach_function :get_code_complete_get_diagnostic, :clang_codeCompleteGetDiagnostic, [CXCodeCompleteResults.ptr, :uint], :CXDiagnostic
101
- attach_function :get_code_complete_get_contexts, :clang_codeCompleteGetContexts, [CXCodeCompleteResults.ptr], :ulong_long
102
- attach_function :get_code_complete_get_container_kind, :clang_codeCompleteGetContainerKind, [CXCodeCompleteResults.ptr, :pointer], :cursor_kind
103
- attach_function :get_code_complete_get_container_usr, :clang_codeCompleteGetContainerUSR, [CXCodeCompleteResults.ptr], CXString.by_value
104
- 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
105
106
 
106
107
  # Other functions
107
- attach_function :code_complete_at, :clang_codeCompleteAt, [:CXTranslationUnit, :string, :uint, :uint, :pointer, :uint, :uint], CXCodeCompleteResults.ptr
108
- 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
109
110
  attach_function :get_cursor_completion_string, :clang_getCursorCompletionString, [CXCursor.by_value], :CXCompletionString
110
111
  attach_function :default_code_completion_options, :clang_defaultCodeCompleteOptions, [], :uint
111
112
  attach_function :sort_code_completion_results, :clang_sortCodeCompletionResults, [:pointer, :uint], :void
@@ -2,7 +2,7 @@
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-2024, 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.
@@ -10,7 +10,8 @@
10
10
  # Copyright, 2014, by George Pimm.
11
11
  # Copyright, 2014, by Niklas Therning.
12
12
  # Copyright, 2019, by Michael Metivier.
13
- # Copyright, 2020, by Luikore.
13
+ # Copyright, 2020, by Zete Lui.
14
+ # Copyright, 2023-2024, by Charlie Savage.
14
15
 
15
16
  require_relative 'translation_unit'
16
17
  require_relative 'diagnostic'
@@ -26,9 +27,9 @@ module FFI
26
27
  enum :cursor_kind, [
27
28
  :cursor_unexposed_decl, 1,
28
29
  :cursor_struct, 2,
29
- # :cusor_struct_decl, :cursor_struct
30
+ # :cursor_struct_decl, :cursor_struct
30
31
  :cursor_union, 3,
31
- # :cusor_union_decl, :cursor_union
32
+ # :cursor_union_decl, :cursor_union
32
33
  :cursor_class_decl, 4,
33
34
  :cursor_enum_decl, 5,
34
35
  :cursor_field_decl, 6,
@@ -471,28 +472,90 @@ module FFI
471
472
  attach_function :get_overridden_cursors, :clang_getOverriddenCursors, [CXCursor.by_value, :pointer, :pointer], :void
472
473
  attach_function :dispose_overridden_cursors, :clang_disposeOverriddenCursors, [:pointer], :void
473
474
 
474
- attach_function :get_typedef_decl_unerlying_type, :clang_getTypedefDeclUnderlyingType, [CXCursor.by_value], CXType.by_value
475
-
476
- attach_function :get_enum_type, :clang_getEnumDeclIntegerType, [CXCursor.by_value], CXType.by_value
477
-
478
475
  attach_function :get_num_args, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
479
476
 
480
- attach_function :is_converting_constructor, :clang_CXXConstructor_isConvertingConstructor, [CXCursor.by_value], :uint
481
- attach_function :is_copy_constructor, :clang_CXXConstructor_isCopyConstructor, [CXCursor.by_value], :uint
482
- attach_function :is_default_constructor, :clang_CXXConstructor_isDefaultConstructor, [CXCursor.by_value], :uint
483
- attach_function :is_move_constructor, :clang_CXXConstructor_isMoveConstructor, [CXCursor.by_value], :uint
484
- attach_function :is_mutable, :clang_CXXField_isMutable, [CXCursor.by_value], :uint
485
- attach_function :is_defaulted, :clang_CXXMethod_isDefaulted, [CXCursor.by_value], :uint
486
- attach_function :is_abstract, :clang_CXXRecord_isAbstract, [CXCursor.by_value], :uint
487
- attach_function :is_enum_scoped, :clang_EnumDecl_isScoped, [CXCursor.by_value], :uint
488
- attach_function :is_const, :clang_CXXMethod_isConst, [CXCursor.by_value], :uint
489
-
490
- if Clang.clang_version >= Gem::Version.new('16.0.0')
491
- attach_function :is_deleted, :clang_CXXMethod_isDeleted, [CXCursor.by_value], :uint
492
- attach_function :is_copy_assignment_operator, :clang_CXXMethod_isCopyAssignmentOperator, [CXCursor.by_value], :uint
493
- attach_function :is_move_assignment_operator, :clang_CXXMethod_isMoveAssignmentOperator, [CXCursor.by_value], :uint
494
- attach_function :is_explicit, :clang_CXXMethod_isExplicit, [CXCursor.by_value], :uint
495
- end
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
494
+
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
496
559
  end
497
560
  end
498
561
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2013-2022, by Samuel Williams.
4
+ # Copyright, 2013-2024, by Samuel Williams.
5
5
  # Copyright, 2013, by Garry Marshall.
6
6
  # Copyright, 2014, by Masahiro Sano.
7
- # Copyright, 2020, by Luikore.
7
+ # Copyright, 2020, by Zete Lui.
8
8
 
9
9
  require_relative 'translation_unit'
10
10
  require_relative 'source_location'
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2013-2022, by Samuel Williams.
4
+ # Copyright, 2010, by Jari Bakken.
5
+ # Copyright, 2012, by Hal Brodigan.
6
+ # Copyright, 2013-2024, by Samuel Williams.
5
7
  # Copyright, 2013, by Carlos Martín Nieto.
6
8
  # Copyright, 2014, by Masahiro Sano.
7
9
 
@@ -4,6 +4,7 @@
4
4
  # Copyright, 2010, by Jari Bakken.
5
5
  # Copyright, 2012, by Hal Brodigan.
6
6
  # Copyright, 2013-2022, by Samuel Williams.
7
+ # Copyright, 2024, by Charlie Savage.
7
8
 
8
9
  module FFI
9
10
  module Clang
@@ -13,6 +14,24 @@ module FFI
13
14
  # Source code index:
14
15
  attach_function :create_index, :clang_createIndex, [:int, :int], :CXIndex
15
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
16
35
  end
17
36
  end
18
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,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
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.
4
+ # Copyright, 2013-2024, by Samuel Williams.
7
5
 
8
6
  module FFI
9
7
  module Clang
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2013-2022, by Samuel Williams.
4
+ # Copyright, 2013-2024, by Samuel Williams.
5
5
  # Copyright, 2014, by Masahiro Sano.
6
6
  # Copyright, 2019, by Hayden Purdy.
7
7
  # Copyright, 2022, by Motonori Iwamuro.
8
+ # Copyright, 2023, by Charlie Savage.
8
9
 
9
10
  require_relative 'index'
10
11
 
@@ -28,7 +29,9 @@ module FFI
28
29
  :single_file_parse, 0x400,
29
30
  :limit_skip_function_bodies_to_preamble, 0x800,
30
31
  :include_attributed_type, 0x1000,
31
- :visit_implicit_attributes, 0x2000
32
+ :visit_implicit_attributes, 0x2000,
33
+ :ignore_non_errors_from_included_files, 0x4000,
34
+ :retain_excluded_conditional_blocks, 0x8000,
32
35
  ]
33
36
 
34
37
  SaveTranslationUnitFlags = enum [
@@ -63,6 +66,14 @@ module FFI
63
66
  :preprocessor_header_search, 14,
64
67
  ]
65
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
+
66
77
  class CXTUResourceUsage < FFI::Struct
67
78
  layout(
68
79
  :data, :pointer,
@@ -80,6 +91,7 @@ module FFI
80
91
 
81
92
  # Source code translation units:
82
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
83
95
  attach_function :create_translation_unit, :clang_createTranslationUnit, [:CXIndex, :string], :CXTranslationUnit
84
96
  attach_function :dispose_translation_unit, :clang_disposeTranslationUnit, [:CXTranslationUnit], :void
85
97
  attach_function :get_translation_unit_spelling, :clang_getTranslationUnitSpelling, [:CXTranslationUnit], CXString.by_value
@@ -2,10 +2,11 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2013, by Carlos Martín Nieto.
5
- # Copyright, 2013-2022, by Samuel Williams.
5
+ # Copyright, 2013-2024, by Samuel Williams.
6
6
  # Copyright, 2013, by Takeshi Watanabe.
7
7
  # Copyright, 2013-2014, by Masahiro Sano.
8
8
  # Copyright, 2014, by Niklas Therning.
9
+ # Copyright, 2024, by Charlie Savage.
9
10
 
10
11
  module FFI
11
12
  module Clang
@@ -59,6 +60,71 @@ module FFI
59
60
  :type_variable_array, 115,
60
61
  :type_dependent_sized_array, 116,
61
62
  :type_member_pointer, 117,
63
+ :type_auto, 118,
64
+ :type_elaborated, 119,
65
+ :type_pipe, 120,
66
+ :type_ocl_image_1d_ro, 121,
67
+ :type_ocl_image_1d_array_ro, 122,
68
+ :type_ocl_image_1d_buffer_ro, 123,
69
+ :type_ocl_image_2d_ro, 124,
70
+ :type_ocl_image_2d_array_ro, 125,
71
+ :type_ocl_image_2d_depth_ro, 126,
72
+ :type_ocl_image_2d_array_depth_ro, 127,
73
+ :type_ocl_image_2d_msaa_ro, 128,
74
+ :type_ocl_image_2d_array_msaa_ro, 129,
75
+ :type_ocl_image_2d_msaa_depth_ro, 130,
76
+ :type_ocl_image_2d_array_msaa_depth_ro, 131,
77
+ :type_ocl_image_3d_ro, 132,
78
+ :type_ocl_image_1d_wo, 133,
79
+ :type_ocl_image_1d_array_wo, 134,
80
+ :type_ocl_image_1d_buffer_wo, 135,
81
+ :type_ocl_image_2d_wo, 136,
82
+ :type_ocl_image_2d_array_wo, 137,
83
+ :type_ocl_image_2d_depth_wo, 138,
84
+ :type_ocl_image_2d_arraydepth_wo, 139,
85
+ :type_ocl_image_2d_msaa_wo, 140,
86
+ :type_ocl_image_2d_array_msaa_wo, 141,
87
+ :type_ocl_image_2d_msaa_depth_wo, 142,
88
+ :type_ocl_image_2d_array_msaa_depth_wo, 143,
89
+ :type_ocl_image_3d_wo, 144,
90
+ :type_ocl_image_1d_rw, 145,
91
+ :type_ocl_image_1d_array_rw, 146,
92
+ :type_ocl_image_1d_buffer_rw, 147,
93
+ :type_ocl_image_2d_rw, 148,
94
+ :type_ocl_image_2d_array_rw, 149,
95
+ :type_ocl_image_2d_depth_rw, 150,
96
+ :type_ocl_image_2d_arraydepth_rw, 151,
97
+ :type_ocl_image_2d_msaa_rw, 152,
98
+ :type_ocl_image_2d_array_msaa_rw, 153,
99
+ :type_ocl_image_2d_msaa_depth_rw, 154,
100
+ :type_ocl_image_2d_array_msaa_depth_rw, 155,
101
+ :type_ocl_image_3d_rw, 156,
102
+ :type_ocl_sampler, 157,
103
+ :type_ocl_event, 158,
104
+ :type_ocl_queue, 159,
105
+ :type_ocl_reserve_id, 160,
106
+ :type_objc_object, 161,
107
+ :type_objc_type_param, 162,
108
+ :type_attributed, 163,
109
+ :type_ocl_intel_subgroup_avc_mce_payload, 164,
110
+ :type_ocl_intel_subgroup_avc_ime_payload, 165,
111
+ :type_ocl_intel_subgroup_avc_ref_payload, 166,
112
+ :type_ocl_intel_subgroup_avc_sic_payload, 167,
113
+ :type_ocl_intel_subgroup_avc_mce_result, 168,
114
+ :type_ocl_intel_subgroup_avc_ime_result, 169,
115
+ :type_ocl_intel_subgroup_avc_ref_result, 170,
116
+ :type_ocl_intel_subgroup_avc_sic_result, 171,
117
+ :type_ocl_intel_subgroup_avc_ime_result_single_reference_streamout, 172,
118
+ :type_ocl_intel_subgroup_avc_ime_result_dual_reference_streamout, 173,
119
+ :type_ocl_intel_subgroup_avc_ime_single_reference_streamin, 174,
120
+ :type_ocl_intel_subgroup_avc_ime_dual_reference_streamin, 175,
121
+ :type_ocl_intel_subgroup_avc_ime_result_single_ref_streamout, 172,
122
+ :type_ocl_intel_subgroup_avc_ime_result_dual_ref_streamout, 173,
123
+ :type_ocl_intel_subgroup_avc_ime_single_ref_streamin, 174,
124
+ :type_ocl_intel_subgroup_avc_ime_dual_ref_streamin, 175,
125
+ :type_ext_vector, 176,
126
+ :type_atomic, 177,
127
+ :type_btf_tag_attributed, 178
62
128
  ]
63
129
 
64
130
  enum :calling_conv, [
@@ -74,6 +140,16 @@ module FFI
74
140
  :calling_conv_intel_ocl_bicc, 9,
75
141
  :calling_conv_x86_64_win64, 10,
76
142
  :calling_conv_x86_64_sysv, 11,
143
+ :calling_conv_x86_vector_call, 12,
144
+ :calling_conv_swift, 13,
145
+ :calling_conv_preserve_most, 14,
146
+ :calling_conv_preserve_all, 15,
147
+ :calling_conv_aarch64_vector_call, 16,
148
+ :calling_conv_swift_async, 17,
149
+ :calling_conv_aarch64_sve_pcs, 18,
150
+ :calling_conv_m68k_rtd, 19,
151
+ :calling_conv_preserve_none, 20,
152
+ :calling_conv_riscv_vector_call, 21,
77
153
  :calling_conv_invalid, 100,
78
154
  :calling_conv_unexposed, 200
79
155
  ]
@@ -90,6 +166,7 @@ module FFI
90
166
  :layout_error_dependent, -3,
91
167
  :layout_error_not_constant_size, -4,
92
168
  :layout_error_invalid_field_name, -5,
169
+ :layout_error_undeduced, -6
93
170
  ]
94
171
 
95
172
  class CXType < FFI::Struct
@@ -108,7 +185,7 @@ module FFI
108
185
  attach_function :get_pointee_type, :clang_getPointeeType, [CXType.by_value], CXType.by_value
109
186
  attach_function :get_result_type, :clang_getResultType, [CXType.by_value], CXType.by_value
110
187
  attach_function :get_canonical_type, :clang_getCanonicalType, [CXType.by_value], CXType.by_value
111
-
188
+
112
189
  attach_function :type_get_class_type, :clang_Type_getClassType, [CXType.by_value], CXType.by_value
113
190
 
114
191
  attach_function :is_const_qualified_type, :clang_isConstQualifiedType, [CXType.by_value], :uint
@@ -127,7 +204,7 @@ module FFI
127
204
  attach_function :type_get_offset_of, :clang_Type_getOffsetOf, [CXType.by_value, :string], :long_long
128
205
 
129
206
  attach_function :type_get_cxx_ref_qualifier, :clang_Type_getCXXRefQualifier, [CXType.by_value], :ref_qualifier_kind
130
-
207
+
131
208
  attach_function :get_fuction_type_calling_conv, :clang_getFunctionTypeCallingConv, [CXType.by_value], :calling_conv
132
209
 
133
210
  attach_function :equal_types, :clang_equalTypes, [CXType.by_value, CXType.by_value], :uint
data/lib/ffi/clang/lib.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2010-2012, by Jari Bakken.
5
5
  # Copyright, 2012, by Hal Brodigan.
6
- # Copyright, 2013-2022, by Samuel Williams.
6
+ # Copyright, 2013-2024, by Samuel Williams.
7
7
  # Copyright, 2013-2014, by Carlos Martín Nieto.
8
8
  # Copyright, 2013, by Takeshi Watanabe.
9
9
  # Copyright, 2014, by Masahiro Sano.
@@ -12,7 +12,8 @@
12
12
  # Copyright, 2016, by Mike Dalessio.
13
13
  # Copyright, 2019, by Hayden Purdy.
14
14
  # Copyright, 2019, by Dominic Sisnero.
15
- # Copyright, 2020, by Luikore.
15
+ # Copyright, 2020, by Zete Lui.
16
+ # Copyright, 2023, by Charlie Savage.
16
17
 
17
18
  require 'mkmf'
18
19
 
@@ -69,11 +70,11 @@ module FFI
69
70
  def self.bitmask_from(enum, opts)
70
71
  bitmask = 0
71
72
 
72
- opts.each do |key, value|
73
- if int = enum[key]
73
+ opts.each do |symbol|
74
+ if int = enum[symbol]
74
75
  bitmask |= int
75
76
  else
76
- raise Error, "unknown option: #{key.inspect}, expected one of #{enum.symbols}"
77
+ raise Error, "unknown option: #{symbol}, expected one of #{enum.symbols}"
77
78
  end
78
79
  end
79
80
 
@@ -82,19 +83,19 @@ module FFI
82
83
 
83
84
  def self.opts_from(enum, bitmask)
84
85
  bit = 1
85
- opts = {}
86
+ result = []
86
87
  while bitmask != 0
87
88
  if bitmask & 1
88
- if sym = enum[bit]
89
- opts[sym] = true
89
+ if symbol = enum[bit]
90
+ result << symbol
90
91
  else
91
- raise Error, "unknown values: #{bit}, expected one of #{enum.symbols}"
92
+ raise(Error, "unknown values: #{bit}, expected one of #{enum.symbols}")
92
93
  end
93
94
  end
94
95
  bitmask >>= 1
95
96
  bit <<= 1
96
97
  end
97
- opts
98
+ result
98
99
  end
99
100
  end
100
101
  end
@@ -0,0 +1,36 @@
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
+ require_relative 'lib/printing_policy'
8
+
9
+ module FFI
10
+ module Clang
11
+ class PrintingPolicy < AutoPointer
12
+ def initialize(cursor)
13
+ policy = Lib.get_printing_policy(cursor)
14
+ super(policy)
15
+ @cursor = cursor
16
+ end
17
+
18
+ def self.release(pointer)
19
+ Lib.dispose_printing_policy(pointer)
20
+ end
21
+
22
+ def get_property(property)
23
+ result = Lib.printing_policy_get_property(self, property)
24
+ result == 0 ? false : true
25
+ end
26
+
27
+ def set_property(property, value)
28
+ Lib.printing_policy_set_property(self, property, value ? 1 : 0)
29
+ end
30
+
31
+ def pretty_print
32
+ Lib.extract_string Lib.pretty_print(@cursor, self)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -6,6 +6,7 @@
6
6
  # Copyright, 2013-2022, by Samuel Williams.
7
7
  # Copyright, 2013, by Garry Marshall.
8
8
  # Copyright, 2014, by Masahiro Sano.
9
+ # Copyright, 2024, by Charlie Savage.
9
10
 
10
11
  require_relative 'lib/source_location'
11
12
  require_relative 'lib/file'
@@ -30,22 +31,6 @@ module FFI
30
31
  Lib.location_is_from_main_file(@location) != 0
31
32
  end
32
33
 
33
- def expansion_location
34
- ExpansionLocation.new(@location)
35
- end
36
-
37
- def presumed_location
38
- PresumedLocation.new(@location)
39
- end
40
-
41
- def spelling_location
42
- SpellingLocation.new(@location)
43
- end
44
-
45
- def file_location
46
- FileLocation.new(@location)
47
- end
48
-
49
34
  def null?
50
35
  Lib.equal_locations(@location, Lib.get_null_location) != 0
51
36
  end
@@ -73,6 +58,14 @@ module FFI
73
58
  @column = column.get_uint(0)
74
59
  @offset = offset.get_uint(0)
75
60
  end
61
+
62
+ def as_string
63
+ "#{@file}:#{@line}:#{@column}:#{@offset}"
64
+ end
65
+
66
+ def to_s
67
+ "ExpansionLocation <#{self.as_string}>"
68
+ end
76
69
  end
77
70
 
78
71
  class PresumedLocation < SourceLocation
@@ -82,8 +75,8 @@ module FFI
82
75
  super(location)
83
76
 
84
77
  cxstring = MemoryPointer.new Lib::CXString
85
- line = MemoryPointer.new :uint
86
- column = MemoryPointer.new :uint
78
+ line = MemoryPointer.new :uint
79
+ column = MemoryPointer.new :uint
87
80
 
88
81
  Lib::get_presumed_location(@location, cxstring, line, column)
89
82
 
@@ -91,6 +84,14 @@ module FFI
91
84
  @line = line.get_uint(0)
92
85
  @column = column.get_uint(0)
93
86
  end
87
+
88
+ def as_string
89
+ "#{@filename}:#{@line}:#{@column}"
90
+ end
91
+
92
+ def to_s
93
+ "PresumedLocation <#{self.as_string}>"
94
+ end
94
95
  end
95
96
 
96
97
  class SpellingLocation < SourceLocation
@@ -111,6 +112,14 @@ module FFI
111
112
  @column = column.get_uint(0)
112
113
  @offset = offset.get_uint(0)
113
114
  end
115
+
116
+ def as_string
117
+ "#{@file}:#{@line}:#{@column}:#{@offset}"
118
+ end
119
+
120
+ def to_s
121
+ "SpellingLocation <#{self.as_string}>"
122
+ end
114
123
  end
115
124
 
116
125
  class FileLocation < SourceLocation
@@ -131,6 +140,14 @@ module FFI
131
140
  @column = column.get_uint(0)
132
141
  @offset = offset.get_uint(0)
133
142
  end
143
+
144
+ def as_string
145
+ "#{@file}:#{@line}:#{@column}:#{@offset}"
146
+ end
147
+
148
+ def to_s
149
+ "FileLocation <#{self.as_string}>"
150
+ end
134
151
  end
135
152
  end
136
153
  end
@@ -2,10 +2,11 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2013, by Carlos Martín Nieto.
5
- # Copyright, 2013-2022, by Samuel Williams.
5
+ # Copyright, 2013-2024, by Samuel Williams.
6
6
  # Copyright, 2013, by Takeshi Watanabe.
7
7
  # Copyright, 2014, by Masahiro Sano.
8
8
  # Copyright, 2014, by Niklas Therning.
9
+ # Copyright, 2024, by Charlie Savage.
9
10
 
10
11
  module FFI
11
12
  module Clang
@@ -41,8 +42,17 @@ module FFI
41
42
  Lib.get_num_arg_types(@type)
42
43
  end
43
44
 
45
+ def pointer?
46
+ [:type_pointer, :type_block_pointer, :type_obj_c_object_pointer, :type_member_pointer].
47
+ include?(self.kind)
48
+ end
49
+
44
50
  def pointee
45
- Type.new Lib.get_pointee_type(@type), @translation_unit
51
+ if self.pointer?
52
+ Type.new Lib.get_pointee_type(@type), @translation_unit
53
+ else
54
+ nil
55
+ end
46
56
  end
47
57
 
48
58
  def canonical
@@ -50,7 +60,11 @@ module FFI
50
60
  end
51
61
 
52
62
  def class_type
53
- Type.new Lib.type_get_class_type(@type), @translation_unit
63
+ if self.kind == :type_member_pointer
64
+ Type.new Lib.type_get_class_type(@type), @translation_unit
65
+ else
66
+ nil
67
+ end
54
68
  end
55
69
 
56
70
  def const_qualified?
@@ -65,24 +79,49 @@ module FFI
65
79
  Lib.is_restrict_qualified_type(@type) != 0
66
80
  end
67
81
 
82
+ def function?
83
+ [:type_function_no_proto, :type_function_proto].include?(self.kind)
84
+ end
85
+
68
86
  def arg_type(i)
69
- Type.new Lib.get_arg_type(@type, i), @translation_unit
87
+ if self.function?
88
+ Type.new Lib.get_arg_type(@type, i), @translation_unit
89
+ else
90
+ nil
91
+ end
70
92
  end
71
93
 
72
94
  def result_type
73
- Type.new Lib.get_result_type(@type), @translation_unit
95
+ if self.function?
96
+ Type.new Lib.get_result_type(@type), @translation_unit
97
+ else
98
+ nil
99
+ end
74
100
  end
75
101
 
76
102
  def element_type
77
- Type.new Lib.get_element_type(@type), @translation_unit
103
+ if self.array? || [:type_vector, :type_complex].include?(self.kind)
104
+ Type.new Lib.get_element_type(@type), @translation_unit
105
+ else
106
+ nil
107
+ end
78
108
  end
79
109
 
80
110
  def num_elements
81
111
  Lib.get_num_elements(@type)
82
112
  end
83
113
 
114
+ def array?
115
+ [:type_constant_array, :type_incomplete_array, :type_variable_array, :type_dependent_sized_array].
116
+ include?(self.kind)
117
+ end
118
+
84
119
  def array_element_type
85
- Type.new Lib.get_array_element_type(@type), @translation_unit
120
+ if self.array?
121
+ Type.new Lib.get_array_element_type(@type), @translation_unit
122
+ else
123
+ nil
124
+ end
86
125
  end
87
126
 
88
127
  def array_size
@@ -3,10 +3,10 @@
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-2024, by Samuel Williams.
7
7
 
8
8
  module FFI
9
9
  module Clang
10
- VERSION = "0.8.0"
10
+ VERSION = "0.9.0"
11
11
  end
12
12
  end
data/license.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Copyright, 2010-2012, by Jari Bakken.
4
4
  Copyright, 2012, by Hal Brodigan.
5
- Copyright, 2013-2022, by Samuel Williams.
5
+ Copyright, 2013-2024, by Samuel Williams.
6
6
  Copyright, 2013, by Garry Marshall.
7
7
  Copyright, 2013-2014, by Carlos Martín Nieto.
8
8
  Copyright, 2013, by Dave Wilkinson.
@@ -16,8 +16,9 @@ Copyright, 2017, by Cameron Dutro.
16
16
  Copyright, 2019, by Hayden Purdy.
17
17
  Copyright, 2019, by Michael Metivier.
18
18
  Copyright, 2019, by Dominic Sisnero.
19
- Copyright, 2020, by Luikore.
19
+ Copyright, 2020, by Zete Lui.
20
20
  Copyright, 2022, by Motonori Iwamuro.
21
+ Copyright, 2023-2024, by Charlie Savage.
21
22
 
22
23
  Permission is hereby granted, free of charge, to any person obtaining a copy
23
24
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -39,8 +39,18 @@ Due to issues figuring out which library to use, we require you to manually spec
39
39
 
40
40
  ## Contributing
41
41
 
42
- 1. Fork it
43
- 2. Create your feature branch (`git checkout -b my-new-feature`)
44
- 3. Commit your changes (`git commit -am 'Add some feature'`)
45
- 4. Push to the branch (`git push origin my-new-feature`)
46
- 5. Create new Pull Request
42
+ We welcome contributions to this project.
43
+
44
+ 1. Fork it.
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
47
+ 4. Push to the branch (`git push origin my-new-feature`).
48
+ 5. Create new Pull Request.
49
+
50
+ ### Developer Certificate of Origin
51
+
52
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
53
+
54
+ ### Contributor Covenant
55
+
56
+ This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-clang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Masahiro Sano
9
9
  - Carlos Martín Nieto
10
+ - Charlie Savage
10
11
  - Jari Bakken
11
12
  - Takeshi Watanabe
12
13
  - Garry Marshall
13
14
  - George Pimm
15
+ - Zete Lui
14
16
  - Greg Hazel
15
- - Luikore
16
17
  - Michael Metivier
17
18
  - Dave Wilkinson
18
19
  - Hayden Purdy
@@ -54,7 +55,7 @@ cert_chain:
54
55
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
55
56
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
56
57
  -----END CERTIFICATE-----
57
- date: 2023-05-01 00:00:00.000000000 Z
58
+ date: 2024-04-07 00:00:00.000000000 Z
58
59
  dependencies:
59
60
  - !ruby/object:Gem::Dependency
60
61
  name: ffi
@@ -70,62 +71,6 @@ dependencies:
70
71
  - - ">="
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
- - !ruby/object:Gem::Dependency
74
- name: bake-test
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- type: :development
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: '0'
87
- - !ruby/object:Gem::Dependency
88
- name: bundler
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: '1.3'
94
- type: :development
95
- prerelease: false
96
- version_requirements: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: '1.3'
101
- - !ruby/object:Gem::Dependency
102
- name: rspec
103
- requirement: !ruby/object:Gem::Requirement
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- version: 3.4.0
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: 3.4.0
115
- - !ruby/object:Gem::Dependency
116
- name: rake
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
- type: :development
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
74
  description:
130
75
  email:
131
76
  executables: []
@@ -153,12 +98,14 @@ files:
153
98
  - lib/ffi/clang/lib/file.rb
154
99
  - lib/ffi/clang/lib/inclusions.rb
155
100
  - lib/ffi/clang/lib/index.rb
101
+ - lib/ffi/clang/lib/printing_policy.rb
156
102
  - lib/ffi/clang/lib/source_location.rb
157
103
  - lib/ffi/clang/lib/source_range.rb
158
104
  - lib/ffi/clang/lib/string.rb
159
105
  - lib/ffi/clang/lib/token.rb
160
106
  - lib/ffi/clang/lib/translation_unit.rb
161
107
  - lib/ffi/clang/lib/type.rb
108
+ - lib/ffi/clang/printing_policy.rb
162
109
  - lib/ffi/clang/source_location.rb
163
110
  - lib/ffi/clang/source_range.rb
164
111
  - lib/ffi/clang/token.rb
@@ -173,6 +120,7 @@ licenses:
173
120
  - MIT
174
121
  metadata:
175
122
  funding_uri: https://github.com/sponsors/ioquatix/
123
+ source_code_uri: https://github.com/ioquatix/ffi-clang.git
176
124
  post_install_message:
177
125
  rdoc_options: []
178
126
  require_paths:
@@ -181,14 +129,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
129
  requirements:
182
130
  - - ">="
183
131
  - !ruby/object:Gem::Version
184
- version: '0'
132
+ version: '3.1'
185
133
  required_rubygems_version: !ruby/object:Gem::Requirement
186
134
  requirements:
187
135
  - - ">="
188
136
  - !ruby/object:Gem::Version
189
137
  version: '0'
190
138
  requirements: []
191
- rubygems_version: 3.4.10
139
+ rubygems_version: 3.5.3
192
140
  signing_key:
193
141
  specification_version: 4
194
142
  summary: Ruby FFI bindings for libclang C interface.
metadata.gz.sig CHANGED
Binary file