ffi-clang 0.8.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/ffi/clang/clang_version.rb +2 -1
- data/lib/ffi/clang/code_completion.rb +5 -3
- data/lib/ffi/clang/cursor.rb +102 -53
- data/lib/ffi/clang/diagnostic.rb +4 -3
- data/lib/ffi/clang/index.rb +11 -4
- data/lib/ffi/clang/lib/code_completion.rb +9 -8
- data/lib/ffi/clang/lib/cursor.rb +89 -24
- data/lib/ffi/clang/lib/diagnostic.rb +2 -2
- data/lib/ffi/clang/lib/file.rb +3 -1
- data/lib/ffi/clang/lib/index.rb +19 -0
- data/lib/ffi/clang/lib/printing_policy.rb +47 -0
- data/lib/ffi/clang/lib/string.rb +1 -3
- data/lib/ffi/clang/lib/translation_unit.rb +14 -2
- data/lib/ffi/clang/lib/type.rb +80 -3
- data/lib/ffi/clang/lib.rb +11 -10
- data/lib/ffi/clang/printing_policy.rb +36 -0
- data/lib/ffi/clang/source_location.rb +35 -18
- data/lib/ffi/clang/types/array.rb +15 -0
- data/lib/ffi/clang/types/elaborated.rb +26 -0
- data/lib/ffi/clang/types/function.rb +27 -0
- data/lib/ffi/clang/types/pointer.rb +42 -0
- data/lib/ffi/clang/types/record.rb +26 -0
- data/lib/ffi/clang/types/type.rb +98 -0
- data/lib/ffi/clang/types/type_def.rb +15 -0
- data/lib/ffi/clang/types/vector.rb +15 -0
- data/lib/ffi/clang/version.rb +2 -2
- data/lib/ffi/clang.rb +9 -0
- data/license.md +3 -2
- data/readme.md +15 -5
- data.tar.gz.sig +0 -0
- metadata +17 -62
- metadata.gz.sig +0 -0
- data/lib/ffi/clang/type.rb +0 -121
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eed14776878ea1dd5fe61ec2b8c9bb57be78116944d5943722077dd958e65b90
|
4
|
+
data.tar.gz: 15acda164aae15f941ae12031e1f68a8a220f0b5e48c6ed07737e0d8a733893d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb918188b02394a8d21f863f1b989a2cb96789f11c97d83c417258ac25a590e63297daf7e7fb6851f06e4890051f9130b9c75d850f1662ad29f6652a244bceb4
|
7
|
+
data.tar.gz: 6b48dabf35dc7606859f18f4267800f4e6de1a2eec1496e3e89cbad282727cb8f80c4820b1405e772bad59bfd8559a98076804e2320b453d65e0d22104ba9bd0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2014, by Masahiro Sano.
|
5
|
-
# Copyright, 2014-
|
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
|
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
|
-
|
31
|
+
results = Lib::CXCodeCompleteResults.new(pointer)
|
32
|
+
Lib.dispose_code_complete_results(results)
|
31
33
|
end
|
32
34
|
|
33
35
|
def each(&block)
|
data/lib/ffi/clang/cursor.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2013, by Garry Marshall.
|
5
|
-
# Copyright, 2013-
|
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,18 +11,21 @@
|
|
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'
|
21
|
-
require_relative 'type'
|
22
23
|
|
23
24
|
module FFI
|
24
25
|
module Clang
|
25
26
|
class Cursor
|
27
|
+
include Enumerable
|
28
|
+
|
26
29
|
attr_reader :cursor
|
27
30
|
attr_reader :translation_unit
|
28
31
|
|
@@ -60,6 +63,14 @@ module FFI
|
|
60
63
|
CodeCompletion::String.new Lib.get_cursor_completion_string(@cursor)
|
61
64
|
end
|
62
65
|
|
66
|
+
def anonymous?
|
67
|
+
Lib.cursor_is_anonymous(@cursor) != 0
|
68
|
+
end
|
69
|
+
|
70
|
+
def anonymous_record_declaration?
|
71
|
+
Lib.cursor_is_anonymous_record_decl(@cursor) != 0
|
72
|
+
end
|
73
|
+
|
63
74
|
def declaration?
|
64
75
|
Lib.is_declaration(kind) != 0
|
65
76
|
end
|
@@ -108,9 +119,22 @@ module FFI
|
|
108
119
|
Lib.is_unexposed(kind) != 0
|
109
120
|
end
|
110
121
|
|
111
|
-
def
|
122
|
+
def expansion_location
|
112
123
|
ExpansionLocation.new(Lib.get_cursor_location(@cursor))
|
113
124
|
end
|
125
|
+
alias :location :expansion_location
|
126
|
+
|
127
|
+
def presumed_location
|
128
|
+
PresumedLocation.new(Lib.get_cursor_location(@cursor))
|
129
|
+
end
|
130
|
+
|
131
|
+
def spelling_location
|
132
|
+
SpellingLocation.new(Lib.get_cursor_location(@cursor))
|
133
|
+
end
|
134
|
+
|
135
|
+
def file_location
|
136
|
+
FileLocation.new(Lib.get_cursor_location(@cursor))
|
137
|
+
end
|
114
138
|
|
115
139
|
def extent
|
116
140
|
SourceRange.new(Lib.get_cursor_extent(@cursor))
|
@@ -120,16 +144,27 @@ module FFI
|
|
120
144
|
Lib.extract_string Lib.get_cursor_display_name(@cursor)
|
121
145
|
end
|
122
146
|
|
147
|
+
def qualified_name
|
148
|
+
if self.kind != :cursor_translation_unit
|
149
|
+
result = self.semantic_parent.qualified_name
|
150
|
+
result ? "#{result}::#{self.spelling}" : self.spelling
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
123
154
|
def spelling
|
124
155
|
Lib.extract_string Lib.get_cursor_spelling(@cursor)
|
125
156
|
end
|
126
157
|
|
158
|
+
def printing_policy
|
159
|
+
PrintingPolicy.new(cursor)
|
160
|
+
end
|
161
|
+
|
127
162
|
def usr
|
128
163
|
Lib.extract_string Lib.get_cursor_usr(@cursor)
|
129
164
|
end
|
130
165
|
|
131
166
|
def kind
|
132
|
-
@cursor[:kind]
|
167
|
+
@cursor ? @cursor[:kind] : nil
|
133
168
|
end
|
134
169
|
|
135
170
|
def kind_spelling
|
@@ -137,23 +172,15 @@ module FFI
|
|
137
172
|
end
|
138
173
|
|
139
174
|
def type
|
140
|
-
Type.
|
175
|
+
Types::Type.create Lib.get_cursor_type(@cursor), @translation_unit
|
141
176
|
end
|
142
177
|
|
143
178
|
def result_type
|
144
|
-
Type.
|
179
|
+
Types::Type.create Lib.get_cursor_result_type(@cursor), @translation_unit
|
145
180
|
end
|
146
181
|
|
147
182
|
def underlying_type
|
148
|
-
Type.
|
149
|
-
end
|
150
|
-
|
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
|
183
|
+
Types::Type.create Lib.get_typedef_decl_underlying_type(@cursor), @translation_unit
|
157
184
|
end
|
158
185
|
|
159
186
|
def virtual_base?
|
@@ -193,7 +220,7 @@ module FFI
|
|
193
220
|
end
|
194
221
|
|
195
222
|
def enum_type
|
196
|
-
Type.
|
223
|
+
Types::Type.create Lib.get_enum_decl_integer_type(@cursor), @translation_unit
|
197
224
|
end
|
198
225
|
|
199
226
|
def specialized_template
|
@@ -208,6 +235,21 @@ module FFI
|
|
208
235
|
Cursor.new Lib.get_cursor_definition(@cursor), @translation_unit
|
209
236
|
end
|
210
237
|
|
238
|
+
def opaque_declaration?
|
239
|
+
# Is this a declaration that does not have a definition in the translation unit
|
240
|
+
self.declaration? && !self.definition? && self.definition.invalid?
|
241
|
+
end
|
242
|
+
|
243
|
+
def forward_declaration?
|
244
|
+
# Is this a forward declaration for a definition contained in the same translation_unit?
|
245
|
+
# https://joshpeterson.github.io/identifying-a-forward-declaration-with-libclang
|
246
|
+
#
|
247
|
+
# Possible alternate implementations?
|
248
|
+
# self.declaration? && !self.definition? && self.definition
|
249
|
+
# !self.definition? && self.definition
|
250
|
+
self.declaration? && !self.eql?(self.definition) && !self.definition.invalid?
|
251
|
+
end
|
252
|
+
|
211
253
|
def referenced
|
212
254
|
Cursor.new Lib.get_cursor_referenced(@cursor), @translation_unit
|
213
255
|
end
|
@@ -236,14 +278,53 @@ module FFI
|
|
236
278
|
Lib.get_num_args @cursor
|
237
279
|
end
|
238
280
|
|
239
|
-
def
|
281
|
+
def each(recurse = true, &block)
|
282
|
+
return to_enum(:each, recurse) unless block_given?
|
283
|
+
|
240
284
|
adapter = Proc.new do |cxcursor, parent_cursor, unused|
|
241
|
-
block
|
285
|
+
# Call the block and capture the result. This lets advanced users
|
286
|
+
# modify the recursion on a case by case basis if needed
|
287
|
+
result = block.call Cursor.new(cxcursor, @translation_unit), Cursor.new(parent_cursor, @translation_unit)
|
288
|
+
case result
|
289
|
+
when :continue
|
290
|
+
:continue
|
291
|
+
when :recurse
|
292
|
+
:recurse
|
293
|
+
else
|
294
|
+
recurse ? :recurse : :continue
|
295
|
+
end
|
242
296
|
end
|
243
|
-
|
297
|
+
|
244
298
|
Lib.visit_children(@cursor, adapter, nil)
|
245
299
|
end
|
246
300
|
|
301
|
+
def ancestors_by_kind(*kinds)
|
302
|
+
result = Array.new
|
303
|
+
|
304
|
+
parent = self
|
305
|
+
while parent != self.semantic_parent
|
306
|
+
parent = self.semantic_parent
|
307
|
+
if kinds.include?(parent.kind)
|
308
|
+
result << parent
|
309
|
+
end
|
310
|
+
end
|
311
|
+
result
|
312
|
+
end
|
313
|
+
|
314
|
+
def find_by_kind(recurse, *kinds)
|
315
|
+
unless (recurse == nil || recurse == true || recurse == false)
|
316
|
+
raise("Recurse parameter must be nil or a boolean value. Value was: #{recurse}")
|
317
|
+
end
|
318
|
+
|
319
|
+
result = Array.new
|
320
|
+
self.each(recurse) do |child, parent|
|
321
|
+
if kinds.include?(child.kind)
|
322
|
+
result << child
|
323
|
+
end
|
324
|
+
end
|
325
|
+
result
|
326
|
+
end
|
327
|
+
|
247
328
|
def find_references_in_file(file = nil, &block)
|
248
329
|
file ||= Lib.extract_string Lib.get_translation_unit_spelling(@translation_unit)
|
249
330
|
|
@@ -351,40 +432,8 @@ module FFI
|
|
351
432
|
Lib.get_cursor_hash(@cursor)
|
352
433
|
end
|
353
434
|
|
354
|
-
def
|
355
|
-
|
356
|
-
kinds.include?(child.kind)
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
def find_first(*kinds)
|
361
|
-
find_all(*kinds).first
|
362
|
-
end
|
363
|
-
|
364
|
-
def filter
|
365
|
-
return to_enum(:select) unless block_given?
|
366
|
-
|
367
|
-
matching = []
|
368
|
-
|
369
|
-
self.visit_children do |child, parent|
|
370
|
-
if yield(child, parent)
|
371
|
-
matching << child
|
372
|
-
end
|
373
|
-
|
374
|
-
:recurse
|
375
|
-
end
|
376
|
-
|
377
|
-
return matching
|
378
|
-
end
|
379
|
-
|
380
|
-
def select
|
381
|
-
filter do |child, parent|
|
382
|
-
yield(child)
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
def to_a
|
387
|
-
filter.collect{|child, parent| child}
|
435
|
+
def to_s
|
436
|
+
"Cursor <#{self.kind.to_s.gsub(/^cursor_/, '')}: #{self.spelling}>"
|
388
437
|
end
|
389
438
|
|
390
439
|
def references(file = nil)
|
data/lib/ffi/clang/diagnostic.rb
CHANGED
@@ -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-
|
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
|
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
|
100
|
+
Lib.bitmask_from(Lib::DiagnosticDisplayOptions, opts)
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
data/lib/ffi/clang/index.rb
CHANGED
@@ -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-
|
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
|
-
|
30
|
+
translation_unit_pointer_out = FFI::MemoryPointer.new(:pointer)
|
30
31
|
|
31
|
-
|
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
|
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.
|
100
|
-
attach_function :get_code_complete_get_diagnostic, :clang_codeCompleteGetDiagnostic, [CXCodeCompleteResults.
|
101
|
-
attach_function :get_code_complete_get_contexts, :clang_codeCompleteGetContexts, [CXCodeCompleteResults.
|
102
|
-
attach_function :get_code_complete_get_container_kind, :clang_codeCompleteGetContainerKind, [CXCodeCompleteResults.
|
103
|
-
attach_function :get_code_complete_get_container_usr, :clang_codeCompleteGetContainerUSR, [CXCodeCompleteResults.
|
104
|
-
attach_function :get_code_complete_get_objc_selector, :clang_codeCompleteGetObjCSelector, [CXCodeCompleteResults.
|
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.
|
108
|
-
attach_function :dispose_code_complete_results, :clang_disposeCodeCompleteResults, [CXCodeCompleteResults.
|
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
|
data/lib/ffi/clang/lib/cursor.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2013, by Garry Marshall.
|
5
|
-
# Copyright, 2013-
|
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
|
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
|
-
# :
|
30
|
+
# :cursor_struct_decl, :cursor_struct
|
30
31
|
:cursor_union, 3,
|
31
|
-
# :
|
32
|
+
# :cursor_union_decl, :cursor_union
|
32
33
|
:cursor_class_decl, 4,
|
33
34
|
:cursor_enum_decl, 5,
|
34
35
|
:cursor_field_decl, 6,
|
@@ -440,6 +441,8 @@ module FFI
|
|
440
441
|
attach_function :find_references_in_file, :clang_findReferencesInFile, [CXCursor.by_value, :CXFile, CXCursorAndRangeVisitor.by_value], :result
|
441
442
|
|
442
443
|
attach_function :get_cursor_type, :clang_getCursorType, [CXCursor.by_value], CXType.by_value
|
444
|
+
attach_function :cursor_is_anonymous, :clang_Cursor_isAnonymous, [CXCursor.by_value], :uint
|
445
|
+
attach_function :cursor_is_anonymous_record_decl, :clang_Cursor_isAnonymousRecordDecl, [CXCursor.by_value], :uint
|
443
446
|
attach_function :get_cursor_result_type, :clang_getCursorResultType, [CXCursor.by_value], CXType.by_value
|
444
447
|
attach_function :get_typedef_decl_underlying_type, :clang_getTypedefDeclUnderlyingType, [CXCursor.by_value], CXType.by_value
|
445
448
|
attach_function :get_enum_decl_integer_type, :clang_getEnumDeclIntegerType, [CXCursor.by_value], CXType.by_value
|
@@ -471,28 +474,90 @@ module FFI
|
|
471
474
|
attach_function :get_overridden_cursors, :clang_getOverriddenCursors, [CXCursor.by_value, :pointer, :pointer], :void
|
472
475
|
attach_function :dispose_overridden_cursors, :clang_disposeOverriddenCursors, [:pointer], :void
|
473
476
|
|
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
477
|
attach_function :get_num_args, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
|
479
478
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
479
|
+
attach_function :is_converting_constructor, :clang_CXXConstructor_isConvertingConstructor, [CXCursor.by_value], :uint
|
480
|
+
attach_function :is_copy_constructor, :clang_CXXConstructor_isCopyConstructor, [CXCursor.by_value], :uint
|
481
|
+
attach_function :is_default_constructor, :clang_CXXConstructor_isDefaultConstructor, [CXCursor.by_value], :uint
|
482
|
+
attach_function :is_move_constructor, :clang_CXXConstructor_isMoveConstructor, [CXCursor.by_value], :uint
|
483
|
+
attach_function :is_mutable, :clang_CXXField_isMutable, [CXCursor.by_value], :uint
|
484
|
+
attach_function :is_defaulted, :clang_CXXMethod_isDefaulted, [CXCursor.by_value], :uint
|
485
|
+
attach_function :is_abstract, :clang_CXXRecord_isAbstract, [CXCursor.by_value], :uint
|
486
|
+
attach_function :is_enum_scoped, :clang_EnumDecl_isScoped, [CXCursor.by_value], :uint
|
487
|
+
attach_function :is_const, :clang_CXXMethod_isConst, [CXCursor.by_value], :uint
|
488
|
+
|
489
|
+
if Clang.clang_version >= Gem::Version.new('16.0.0')
|
490
|
+
attach_function :get_unqualified_type, :clang_getUnqualifiedType, [CXType.by_value], CXType.by_value
|
491
|
+
attach_function :get_non_reference_type, :clang_getNonReferenceType, [CXType.by_value], CXType.by_value
|
492
|
+
attach_function :is_deleted, :clang_CXXMethod_isDeleted, [CXCursor.by_value], :uint
|
493
|
+
attach_function :is_copy_assignment_operator, :clang_CXXMethod_isCopyAssignmentOperator, [CXCursor.by_value], :uint
|
494
|
+
attach_function :is_move_assignment_operator, :clang_CXXMethod_isMoveAssignmentOperator, [CXCursor.by_value], :uint
|
495
|
+
end
|
496
|
+
|
497
|
+
if Clang.clang_version >= Gem::Version.new('17.0.0')
|
498
|
+
attach_function :is_explicit, :clang_CXXMethod_isExplicit, [CXCursor.by_value], :uint
|
499
|
+
|
500
|
+
enum :binary_operator_kind, [
|
501
|
+
:binary_operator_invalid,
|
502
|
+
:binary_operator_ptr_mem_d,
|
503
|
+
:binary_operator_ptr_mem_i,
|
504
|
+
:binary_operator_mul,
|
505
|
+
:binary_operator_div,
|
506
|
+
:binary_operator_rem,
|
507
|
+
:binary_operator_add,
|
508
|
+
:binary_operator_sub,
|
509
|
+
:binary_operator_shl,
|
510
|
+
:binary_operator_shr,
|
511
|
+
:binary_operator_cmp,
|
512
|
+
:binary_operator_lt,
|
513
|
+
:binary_operator_gt,
|
514
|
+
:binary_operator_le,
|
515
|
+
:binary_operator_ge,
|
516
|
+
:binary_operator_eq,
|
517
|
+
:binary_operator_ne,
|
518
|
+
:binary_operator_and,
|
519
|
+
:binary_operator_xor,
|
520
|
+
:binary_operator_or,
|
521
|
+
:binary_operator_l_and,
|
522
|
+
:binary_operator_l_or,
|
523
|
+
:binary_operator_assign,
|
524
|
+
:binary_operator_mul_assign,
|
525
|
+
:binary_operator_div_assign,
|
526
|
+
:binary_operator_rem_assign,
|
527
|
+
:binary_operator_add_assign,
|
528
|
+
:binary_operator_sub_assign,
|
529
|
+
:binary_operator_shl_assign,
|
530
|
+
:binary_operator_shr_assign,
|
531
|
+
:binary_operator_and_assign,
|
532
|
+
:binary_operator_xor_assign,
|
533
|
+
:binary_operator_or_assign,
|
534
|
+
:binary_operator_comma
|
535
|
+
]
|
536
|
+
|
537
|
+
attach_function :get_binary_operator_kind_spelling, :clang_getBinaryOperatorKindSpelling, [:binary_operator_kind], CXString.by_value
|
538
|
+
attach_function :get_cursor_binary_operator_kind, :clang_getCursorBinaryOperatorKind, [CXCursor.by_value], :binary_operator_kind
|
539
|
+
|
540
|
+
enum :unary_operator_kind, [
|
541
|
+
:unary_operator_Invalid,
|
542
|
+
:unary_operator_PostInc,
|
543
|
+
:unary_operator_PostDec,
|
544
|
+
:unary_operator_PreInc,
|
545
|
+
:unary_operator_PreDec,
|
546
|
+
:unary_operator_AddrOf,
|
547
|
+
:unary_operator_Deref,
|
548
|
+
:unary_operator_Plus,
|
549
|
+
:unary_operator_Minus,
|
550
|
+
:unary_operator_Not,
|
551
|
+
:unary_operator_LNot,
|
552
|
+
:unary_operator_Real,
|
553
|
+
:unary_operator_Imag,
|
554
|
+
:unary_operator_Extension,
|
555
|
+
:unary_operator_Coawait
|
556
|
+
]
|
557
|
+
|
558
|
+
attach_function :get_unary_operator_kind_spelling, :clang_getUnaryOperatorKindSpelling, [:unary_operator_kind], CXString.by_value
|
559
|
+
attach_function :get_cursor_unary_operator_kind, :clang_getCursorUnaryOperatorKind, [CXCursor.by_value], :unary_operator_kind
|
560
|
+
end
|
496
561
|
end
|
497
562
|
end
|
498
563
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2013-
|
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
|
7
|
+
# Copyright, 2020, by Zete Lui.
|
8
8
|
|
9
9
|
require_relative 'translation_unit'
|
10
10
|
require_relative 'source_location'
|
data/lib/ffi/clang/lib/file.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright,
|
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
|
|
data/lib/ffi/clang/lib/index.rb
CHANGED
@@ -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
|