rbind 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/lib/rbind.rb +1 -0
  2. data/lib/rbind/clang/clang.rb +3699 -0
  3. data/lib/rbind/clang/clang_types.rb +327 -0
  4. data/lib/rbind/clang_parser.rb +451 -0
  5. data/lib/rbind/core.rb +7 -4
  6. data/lib/rbind/core/rattribute.rb +17 -21
  7. data/lib/rbind/core/rbase.rb +98 -64
  8. data/lib/rbind/core/rcallback.rb +15 -0
  9. data/lib/rbind/core/rclass.rb +79 -16
  10. data/lib/rbind/core/rdata_type.rb +40 -39
  11. data/lib/rbind/core/renum.rb +18 -0
  12. data/lib/rbind/core/rnamespace.rb +189 -52
  13. data/lib/rbind/core/roperation.rb +52 -20
  14. data/lib/rbind/core/rparameter.rb +43 -8
  15. data/lib/rbind/core/rpointer.rb +70 -0
  16. data/lib/rbind/core/rreference.rb +54 -0
  17. data/lib/rbind/core/rtemplate_class.rb +49 -0
  18. data/lib/rbind/core/rtype_qualifier.rb +60 -0
  19. data/lib/rbind/default_parser.rb +48 -36
  20. data/lib/rbind/generator_c.rb +2 -2
  21. data/lib/rbind/generator_extern.rb +1 -3
  22. data/lib/rbind/generator_ruby.rb +201 -47
  23. data/lib/rbind/logger.rb +3 -0
  24. data/lib/rbind/rbind.rb +25 -9
  25. data/lib/rbind/templates/c/CMakeLists.txt +6 -6
  26. data/lib/rbind/templates/ruby/rbind.rb +1 -1
  27. data/lib/rbind/templates/ruby/rmethod.rb +4 -1
  28. data/lib/rbind/templates/ruby/rnamespace.rb +2 -1
  29. data/lib/rbind/templates/ruby/roverloaded_method.rb +3 -1
  30. data/lib/rbind/templates/ruby/roverloaded_method_call.rb +1 -0
  31. data/lib/rbind/templates/ruby/roverloaded_static_method.rb +3 -2
  32. data/lib/rbind/templates/ruby/rstatic_method.rb +4 -1
  33. data/lib/rbind/templates/ruby/rtype.rb +19 -16
  34. data/lib/rbind/templates/ruby/rtype_template.rb +7 -0
  35. data/lib/rbind/{core/rstring.rb → types/std_string.rb} +8 -8
  36. data/lib/rbind/types/std_vector.rb +100 -0
  37. data/rbind.gemspec +2 -2
  38. data/test/headers/cfunctions.h +7 -0
  39. data/test/headers/classes.hpp +29 -0
  40. data/test/headers/constants.hpp +14 -0
  41. data/test/headers/enums.hpp +22 -0
  42. data/test/headers/std_string.hpp +26 -0
  43. data/test/headers/std_vector.hpp +31 -0
  44. data/test/headers/structs.hpp +34 -0
  45. data/test/headers/templates.hpp +20 -0
  46. data/test/test_clang_parser.rb +146 -0
  47. data/test/test_generator_ruby.rb +0 -5
  48. data/test/test_roperation.rb +144 -0
  49. data/test/test_rparameter.rb +88 -0
  50. metadata +24 -7
  51. data/lib/rbind/core/.roperation.rb.swp +0 -0
  52. data/lib/rbind/core/rconst.rb +0 -35
  53. data/lib/rbind/core/rstruct.rb +0 -87
  54. data/lib/rbind/core/rvector.rb +0 -27
@@ -1,6 +1,7 @@
1
1
  require 'rbind/rbind'
2
2
  require 'rbind/core'
3
3
  require 'rbind/default_parser'
4
+ require 'rbind/clang_parser'
4
5
  require 'rbind/generator_c'
5
6
  require 'rbind/generator_ruby'
6
7
  require 'rbind/generator_extern'
@@ -0,0 +1,3699 @@
1
+ require 'ffi'
2
+ require 'rbind/clang/clang_types'
3
+
4
+ module::Clang
5
+ module Rbind
6
+ extend FFI::Library
7
+ ffi_lib 'clang'
8
+
9
+ # Provides the contents of a file that has not yet been saved to disk.
10
+ #
11
+ # Each CXUnsavedFile instance provides the name of a file on the
12
+ # system along with the current contents of that file that have not
13
+ # yet been saved to disk.
14
+ #
15
+ # = Fields:
16
+ # :filename ::
17
+ # (String) The file whose contents have not yet been saved.
18
+ #
19
+ # This file must already exist in the file system.
20
+ # :contents ::
21
+ # (String) A buffer containing the unsaved contents of this file.
22
+ # :length ::
23
+ # (Integer) The length of the unsaved contents of this buffer.
24
+ class UnsavedFile < FFI::Struct
25
+ layout :filename, :string,
26
+ :contents, :string,
27
+ :length, :ulong
28
+ end
29
+
30
+ # Describes the availability of a particular entity, which indicates
31
+ # whether the use of this entity will result in a warning or error due to
32
+ # it being deprecated or unavailable.
33
+ #
34
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:availability_kind).</em>
35
+ #
36
+ # === Options:
37
+ # :available ::
38
+ # The entity is available.
39
+ # :deprecated ::
40
+ # The entity is available, but has been deprecated (and its use is
41
+ # not recommended).
42
+ # :not_available ::
43
+ # The entity is not available; any use of it will be an error.
44
+ # :not_accessible ::
45
+ # The entity is available, but not accessible; any use of it will be
46
+ # an error.
47
+ #
48
+ # @method _enum_availability_kind_
49
+ # @return [Symbol]
50
+ # @scope class
51
+ enum :availability_kind, [
52
+ :available,
53
+ :deprecated,
54
+ :not_available,
55
+ :not_accessible
56
+ ]
57
+
58
+ # A character string.
59
+ #
60
+ # The \c CXString type is used to return strings from the interface when
61
+ # the ownership of that string might different from one call to the next.
62
+ # Use \c clang_getCString() to retrieve the string data and, once finished
63
+ # with the string data, call \c clang_disposeString() to free the string.
64
+ #
65
+ # = Fields:
66
+ # :data ::
67
+ # (FFI::Pointer(*Void))
68
+ # :private_flags ::
69
+ # (Integer)
70
+ class String < FFI::Struct
71
+ layout :data, :pointer,
72
+ :private_flags, :uint
73
+ end
74
+
75
+ # Retrieve the character data associated with the given string.
76
+ #
77
+ # @method get_c_string(string)
78
+ # @param [String] string
79
+ # @return [String]
80
+ # @scope class
81
+ attach_function :get_c_string, :clang_getCString, [String.by_value], :string
82
+
83
+ # Free the given string,
84
+ #
85
+ # @method dispose_string(string)
86
+ # @param [String] string
87
+ # @return [nil]
88
+ # @scope class
89
+ attach_function :dispose_string, :clang_disposeString, [String.by_value], :void
90
+
91
+ # clang_createIndex() provides a shared context for creating
92
+ # translation units. It provides two options:
93
+ #
94
+ # - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
95
+ # declarations (when loading any new translation units). A "local" declaration
96
+ # is one that belongs in the translation unit itself and not in a precompiled
97
+ # header that was used by the translation unit. If zero, all declarations
98
+ # will be enumerated.
99
+ #
100
+ # Here is an example:
101
+ #
102
+ # // excludeDeclsFromPCH = 1, displayDiagnostics=1
103
+ # Idx = clang_createIndex(1, 1);
104
+ #
105
+ # // IndexTest.pch was produced with the following command:
106
+ # // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
107
+ # TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
108
+ #
109
+ # // This will load all the symbols from 'IndexTest.pch'
110
+ # clang_visitChildren(clang_getTranslationUnitCursor(TU),
111
+ # TranslationUnitVisitor, 0);
112
+ # clang_disposeTranslationUnit(TU);
113
+ #
114
+ # // This will load all the symbols from 'IndexTest.c', excluding symbols
115
+ # // from 'IndexTest.pch'.
116
+ # char *args() = { "-Xclang", "-include-pch=IndexTest.pch" };
117
+ # TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
118
+ # 0, 0);
119
+ # clang_visitChildren(clang_getTranslationUnitCursor(TU),
120
+ # TranslationUnitVisitor, 0);
121
+ # clang_disposeTranslationUnit(TU);
122
+ #
123
+ # This process of creating the 'pch', loading it separately, and using it (via
124
+ # -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
125
+ # (which gives the indexer the same performance benefit as the compiler).
126
+ #
127
+ # @method create_index(exclude_declarations_from_pch, display_diagnostics)
128
+ # @param [Integer] exclude_declarations_from_pch
129
+ # @param [Integer] display_diagnostics
130
+ # @return [FFI::Pointer(Index)]
131
+ # @scope class
132
+ attach_function :create_index, :clang_createIndex, [:int, :int], :pointer
133
+
134
+ # Destroy the given index.
135
+ #
136
+ # The index must not be destroyed until all of the translation units created
137
+ # within that index have been destroyed.
138
+ #
139
+ # @method dispose_index(index)
140
+ # @param [FFI::Pointer(Index)] index
141
+ # @return [nil]
142
+ # @scope class
143
+ attach_function :dispose_index, :clang_disposeIndex, [:pointer], :void
144
+
145
+ # Retrieve the complete file and path name of the given file.
146
+ #
147
+ # @method get_file_name(s_file)
148
+ # @param [FFI::Pointer(File)] s_file
149
+ # @return [String]
150
+ # @scope class
151
+ attach_function :get_file_name, :clang_getFileName, [:pointer], String.by_value
152
+
153
+ # Retrieve the last modification time of the given file.
154
+ #
155
+ # @method get_file_time(s_file)
156
+ # @param [FFI::Pointer(File)] s_file
157
+ # @return [Integer]
158
+ # @scope class
159
+ attach_function :get_file_time, :clang_getFileTime, [:pointer], :long
160
+
161
+ # Determine whether the given header is guarded against
162
+ # multiple inclusions, either with the conventional
163
+ # #ifndef/#define/#endif macro guards or with #pragma once.
164
+ #
165
+ # @method is_file_multiple_include_guarded(tu, file)
166
+ # @param [TranslationUnitImpl] tu
167
+ # @param [FFI::Pointer(File)] file
168
+ # @return [Integer]
169
+ # @scope class
170
+ attach_function :is_file_multiple_include_guarded, :clang_isFileMultipleIncludeGuarded, [TranslationUnitImpl, :pointer], :uint
171
+
172
+ # Retrieve a file handle within the given translation unit.
173
+ #
174
+ # @method get_file(tu, file_name)
175
+ # @param [TranslationUnitImpl] tu the translation unit
176
+ # @param [String] file_name the name of the file.
177
+ # @return [FFI::Pointer(File)] the file handle for the named file in the translation unit \p tu,
178
+ # or a NULL file handle if the file was not a part of this translation unit.
179
+ # @scope class
180
+ attach_function :get_file, :clang_getFile, [TranslationUnitImpl, :string], :pointer
181
+
182
+ # Identifies a specific source location within a translation
183
+ # unit.
184
+ #
185
+ # Use clang_getExpansionLocation() or clang_getSpellingLocation()
186
+ # to map a source location to a particular file, line, and column.
187
+ #
188
+ # = Fields:
189
+ # :ptr_data ::
190
+ # (Array<FFI::Pointer(*Void)>)
191
+ # :int_data ::
192
+ # (Integer)
193
+ class SourceLocation < FFI::Struct
194
+ layout :ptr_data, [:pointer, 2],
195
+ :int_data, :uint
196
+ end
197
+
198
+ # Identifies a half-open character range in the source code.
199
+ #
200
+ # Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
201
+ # starting and end locations from a source range, respectively.
202
+ #
203
+ # = Fields:
204
+ # :ptr_data ::
205
+ # (Array<FFI::Pointer(*Void)>)
206
+ # :begin_int_data ::
207
+ # (Integer)
208
+ # :end_int_data ::
209
+ # (Integer)
210
+ class SourceRange < FFI::Struct
211
+ layout :ptr_data, [:pointer, 2],
212
+ :begin_int_data, :uint,
213
+ :end_int_data, :uint
214
+ end
215
+
216
+ # Retrieve a NULL (invalid) source location.
217
+ #
218
+ # @method get_null_location()
219
+ # @return [SourceLocation]
220
+ # @scope class
221
+ attach_function :get_null_location, :clang_getNullLocation, [], SourceLocation.by_value
222
+
223
+ # Determine whether two source locations, which must refer into
224
+ # the same translation unit, refer to exactly the same point in the source
225
+ # code.
226
+ #
227
+ # @method equal_locations(loc1, loc2)
228
+ # @param [SourceLocation] loc1
229
+ # @param [SourceLocation] loc2
230
+ # @return [Integer] non-zero if the source locations refer to the same location, zero
231
+ # if they refer to different locations.
232
+ # @scope class
233
+ attach_function :equal_locations, :clang_equalLocations, [SourceLocation.by_value, SourceLocation.by_value], :uint
234
+
235
+ # Retrieves the source location associated with a given file/line/column
236
+ # in a particular translation unit.
237
+ #
238
+ # @method get_location(tu, file, line, column)
239
+ # @param [TranslationUnitImpl] tu
240
+ # @param [FFI::Pointer(File)] file
241
+ # @param [Integer] line
242
+ # @param [Integer] column
243
+ # @return [SourceLocation]
244
+ # @scope class
245
+ attach_function :get_location, :clang_getLocation, [TranslationUnitImpl, :pointer, :uint, :uint], SourceLocation.by_value
246
+
247
+ # Retrieves the source location associated with a given character offset
248
+ # in a particular translation unit.
249
+ #
250
+ # @method get_location_for_offset(tu, file, offset)
251
+ # @param [TranslationUnitImpl] tu
252
+ # @param [FFI::Pointer(File)] file
253
+ # @param [Integer] offset
254
+ # @return [SourceLocation]
255
+ # @scope class
256
+ attach_function :get_location_for_offset, :clang_getLocationForOffset, [TranslationUnitImpl, :pointer, :uint], SourceLocation.by_value
257
+
258
+ # Retrieve a NULL (invalid) source range.
259
+ #
260
+ # @method get_null_range()
261
+ # @return [SourceRange]
262
+ # @scope class
263
+ attach_function :get_null_range, :clang_getNullRange, [], SourceRange.by_value
264
+
265
+ # Retrieve a source range given the beginning and ending source
266
+ # locations.
267
+ #
268
+ # @method get_range(begin, end)
269
+ # @param [SourceLocation] begin
270
+ # @param [SourceLocation] end
271
+ # @return [SourceRange]
272
+ # @scope class
273
+ attach_function :get_range, :clang_getRange, [SourceLocation.by_value, SourceLocation.by_value], SourceRange.by_value
274
+
275
+ # Determine whether two ranges are equivalent.
276
+ #
277
+ # @method equal_ranges(range1, range2)
278
+ # @param [SourceRange] range1
279
+ # @param [SourceRange] range2
280
+ # @return [Integer] non-zero if the ranges are the same, zero if they differ.
281
+ # @scope class
282
+ attach_function :equal_ranges, :clang_equalRanges, [SourceRange.by_value, SourceRange.by_value], :uint
283
+
284
+ # Returns non-zero if \arg range is null.
285
+ #
286
+ # @method range_is_null(range)
287
+ # @param [SourceRange] range
288
+ # @return [Integer]
289
+ # @scope class
290
+ attach_function :range_is_null, :clang_Range_isNull, [SourceRange.by_value], :int
291
+
292
+ # Retrieve the file, line, column, and offset represented by
293
+ # the given source location, as specified in a # line directive.
294
+ #
295
+ # Example: given the following source code in a file somefile.c
296
+ #
297
+ # #123 "dummy.c" 1
298
+ #
299
+ # static int func(void)
300
+ # {
301
+ # return 0;
302
+ # }
303
+ #
304
+ # the location information returned by this function would be
305
+ #
306
+ # File: dummy.c Line: 124 Column: 12
307
+ #
308
+ # whereas clang_getExpansionLocation would have returned
309
+ #
310
+ # File: somefile.c Line: 3 Column: 12
311
+ #
312
+ # @method get_presumed_location(location, filename, line, column)
313
+ # @param [SourceLocation] location the location within a source file that will be decomposed
314
+ # into its parts.
315
+ # @param [String] filename (out) if non-NULL, will be set to the filename of the
316
+ # source location. Note that filenames returned will be for "virtual" files,
317
+ # which don't necessarily exist on the machine running clang - e.g. when
318
+ # parsing preprocessed output obtained from a different environment. If
319
+ # a non-NULL value is passed in, remember to dispose of the returned value
320
+ # using \c clang_disposeString() once you've finished with it. For an invalid
321
+ # source location, an empty string is returned.
322
+ # @param [FFI::Pointer(*UInt)] line (out) if non-NULL, will be set to the line number of the
323
+ # source location. For an invalid source location, zero is returned.
324
+ # @param [FFI::Pointer(*UInt)] column (out) if non-NULL, will be set to the column number of the
325
+ # source location. For an invalid source location, zero is returned.
326
+ # @return [nil]
327
+ # @scope class
328
+ attach_function :get_presumed_location, :clang_getPresumedLocation, [SourceLocation.by_value, String, :pointer, :pointer], :void
329
+
330
+ # Legacy API to retrieve the file, line, column, and offset represented
331
+ # by the given source location.
332
+ #
333
+ # This interface has been replaced by the newer interface
334
+ # \see clang_getExpansionLocation(). See that interface's documentation for
335
+ # details.
336
+ #
337
+ # @method get_instantiation_location(location, file, line, column, offset)
338
+ # @param [SourceLocation] location
339
+ # @param [FFI::Pointer(*File)] file
340
+ # @param [FFI::Pointer(*UInt)] line
341
+ # @param [FFI::Pointer(*UInt)] column
342
+ # @param [FFI::Pointer(*UInt)] offset
343
+ # @return [nil]
344
+ # @scope class
345
+ attach_function :get_instantiation_location, :clang_getInstantiationLocation, [SourceLocation.by_value, :pointer, :pointer, :pointer, :pointer], :void
346
+
347
+ # Retrieve the file, line, column, and offset represented by
348
+ # the given source location.
349
+ #
350
+ # If the location refers into a macro instantiation, return where the
351
+ # location was originally spelled in the source file.
352
+ #
353
+ # @method get_spelling_location(location, file, line, column, offset)
354
+ # @param [SourceLocation] location the location within a source file that will be decomposed
355
+ # into its parts.
356
+ # @param [FFI::Pointer(*File)] file (out) if non-NULL, will be set to the file to which the given
357
+ # source location points.
358
+ # @param [FFI::Pointer(*UInt)] line (out) if non-NULL, will be set to the line to which the given
359
+ # source location points.
360
+ # @param [FFI::Pointer(*UInt)] column (out) if non-NULL, will be set to the column to which the given
361
+ # source location points.
362
+ # @param [FFI::Pointer(*UInt)] offset (out) if non-NULL, will be set to the offset into the
363
+ # buffer to which the given source location points.
364
+ # @return [nil]
365
+ # @scope class
366
+ attach_function :get_spelling_location, :clang_getSpellingLocation, [SourceLocation.by_value, :pointer, :pointer, :pointer, :pointer], :void
367
+
368
+ # Retrieve a source location representing the first character within a
369
+ # source range.
370
+ #
371
+ # @method get_range_start(range)
372
+ # @param [SourceRange] range
373
+ # @return [SourceLocation]
374
+ # @scope class
375
+ attach_function :get_range_start, :clang_getRangeStart, [SourceRange.by_value], SourceLocation.by_value
376
+
377
+ # Retrieve a source location representing the last character within a
378
+ # source range.
379
+ #
380
+ # @method get_range_end(range)
381
+ # @param [SourceRange] range
382
+ # @return [SourceLocation]
383
+ # @scope class
384
+ attach_function :get_range_end, :clang_getRangeEnd, [SourceRange.by_value], SourceLocation.by_value
385
+
386
+ # Describes the severity of a particular diagnostic.
387
+ #
388
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:diagnostic_severity).</em>
389
+ #
390
+ # === Options:
391
+ # :ignored ::
392
+ # A diagnostic that has been suppressed, e.g., by a command-line
393
+ # option.
394
+ # :note ::
395
+ # This diagnostic is a note that should be attached to the
396
+ # previous (non-note) diagnostic.
397
+ # :warning ::
398
+ # This diagnostic indicates suspicious code that may not be
399
+ # wrong.
400
+ # :error ::
401
+ # This diagnostic indicates that the code is ill-formed.
402
+ # :fatal ::
403
+ # This diagnostic indicates that the code is ill-formed such
404
+ # that future parser recovery is unlikely to produce useful
405
+ # results.
406
+ #
407
+ # @method _enum_diagnostic_severity_
408
+ # @return [Symbol]
409
+ # @scope class
410
+ enum :diagnostic_severity, [
411
+ :ignored, 0,
412
+ :note, 1,
413
+ :warning, 2,
414
+ :error, 3,
415
+ :fatal, 4
416
+ ]
417
+
418
+ # Determine the number of diagnostics produced for the given
419
+ # translation unit.
420
+ #
421
+ # @method get_num_diagnostics(unit)
422
+ # @param [TranslationUnitImpl] unit
423
+ # @return [Integer]
424
+ # @scope class
425
+ attach_function :get_num_diagnostics, :clang_getNumDiagnostics, [TranslationUnitImpl], :uint
426
+
427
+ # Retrieve a diagnostic associated with the given translation unit.
428
+ #
429
+ # @method get_diagnostic(unit, index)
430
+ # @param [TranslationUnitImpl] unit the translation unit to query.
431
+ # @param [Integer] index the zero-based diagnostic number to retrieve.
432
+ # @return [FFI::Pointer(Diagnostic)] the requested diagnostic. This diagnostic must be freed
433
+ # via a call to \c clang_disposeDiagnostic().
434
+ # @scope class
435
+ attach_function :get_diagnostic, :clang_getDiagnostic, [TranslationUnitImpl, :uint], :pointer
436
+
437
+ # Destroy a diagnostic.
438
+ #
439
+ # @method dispose_diagnostic(diagnostic)
440
+ # @param [FFI::Pointer(Diagnostic)] diagnostic
441
+ # @return [nil]
442
+ # @scope class
443
+ attach_function :dispose_diagnostic, :clang_disposeDiagnostic, [:pointer], :void
444
+
445
+ # Options to control the display of diagnostics.
446
+ #
447
+ # The values in this enum are meant to be combined to customize the
448
+ # behavior of \c clang_displayDiagnostic().
449
+ #
450
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:diagnostic_display_options).</em>
451
+ #
452
+ # === Options:
453
+ # :display_source_location ::
454
+ # Display the source-location information where the
455
+ # diagnostic was located.
456
+ #
457
+ # When set, diagnostics will be prefixed by the file, line, and
458
+ # (optionally) column to which the diagnostic refers. For example,
459
+ #
460
+ # \code
461
+ # test.c:28: warning: extra tokens at end of #endif directive
462
+ # \endcode
463
+ #
464
+ # This option corresponds to the clang flag \c -fshow-source-location.
465
+ # :display_column ::
466
+ # If displaying the source-location information of the
467
+ # diagnostic, also include the column number.
468
+ #
469
+ # This option corresponds to the clang flag \c -fshow-column.
470
+ # :display_source_ranges ::
471
+ # If displaying the source-location information of the
472
+ # diagnostic, also include information about source ranges in a
473
+ # machine-parsable format.
474
+ #
475
+ # This option corresponds to the clang flag
476
+ # \c -fdiagnostics-print-source-range-info.
477
+ # :display_option ::
478
+ # Display the option name associated with this diagnostic, if any.
479
+ #
480
+ # The option name displayed (e.g., -Wconversion) will be placed in brackets
481
+ # after the diagnostic text. This option corresponds to the clang flag
482
+ # \c -fdiagnostics-show-option.
483
+ # :display_category_id ::
484
+ # Display the category number associated with this diagnostic, if any.
485
+ #
486
+ # The category number is displayed within brackets after the diagnostic text.
487
+ # This option corresponds to the clang flag
488
+ # \c -fdiagnostics-show-category=id.
489
+ # :display_category_name ::
490
+ # Display the category name associated with this diagnostic, if any.
491
+ #
492
+ # The category name is displayed within brackets after the diagnostic text.
493
+ # This option corresponds to the clang flag
494
+ # \c -fdiagnostics-show-category=name.
495
+ #
496
+ # @method _enum_diagnostic_display_options_
497
+ # @return [Symbol]
498
+ # @scope class
499
+ enum :diagnostic_display_options, [
500
+ :display_source_location, 0x01,
501
+ :display_column, 0x02,
502
+ :display_source_ranges, 0x04,
503
+ :display_option, 0x08,
504
+ :display_category_id, 0x10,
505
+ :display_category_name, 0x20
506
+ ]
507
+
508
+ # Format the given diagnostic in a manner that is suitable for display.
509
+ #
510
+ # This routine will format the given diagnostic to a string, rendering
511
+ # the diagnostic according to the various options given. The
512
+ # \c clang_defaultDiagnosticDisplayOptions() function returns the set of
513
+ # options that most closely mimics the behavior of the clang compiler.
514
+ #
515
+ # @method format_diagnostic(diagnostic, options)
516
+ # @param [FFI::Pointer(Diagnostic)] diagnostic The diagnostic to print.
517
+ # @param [Integer] options A set of options that control the diagnostic display,
518
+ # created by combining \c CXDiagnosticDisplayOptions values.
519
+ # @return [String] A new string containing for formatted diagnostic.
520
+ # @scope class
521
+ attach_function :format_diagnostic, :clang_formatDiagnostic, [:pointer, :uint], String.by_value
522
+
523
+ # Retrieve the set of display options most similar to the
524
+ # default behavior of the clang compiler.
525
+ #
526
+ # @method default_diagnostic_display_options()
527
+ # @return [Integer] A set of display options suitable for use with \c
528
+ # clang_displayDiagnostic().
529
+ # @scope class
530
+ attach_function :default_diagnostic_display_options, :clang_defaultDiagnosticDisplayOptions, [], :uint
531
+
532
+ # Determine the severity of the given diagnostic.
533
+ #
534
+ # @method get_diagnostic_severity(diagnostic)
535
+ # @param [FFI::Pointer(Diagnostic)] diagnostic
536
+ # @return [Symbol from _enum_diagnostic_severity_]
537
+ # @scope class
538
+ attach_function :get_diagnostic_severity, :clang_getDiagnosticSeverity, [:pointer], :diagnostic_severity
539
+
540
+ # Retrieve the source location of the given diagnostic.
541
+ #
542
+ # This location is where Clang would print the caret ('^') when
543
+ # displaying the diagnostic on the command line.
544
+ #
545
+ # @method get_diagnostic_location(diagnostic)
546
+ # @param [FFI::Pointer(Diagnostic)] diagnostic
547
+ # @return [SourceLocation]
548
+ # @scope class
549
+ attach_function :get_diagnostic_location, :clang_getDiagnosticLocation, [:pointer], SourceLocation.by_value
550
+
551
+ # Retrieve the text of the given diagnostic.
552
+ #
553
+ # @method get_diagnostic_spelling(diagnostic)
554
+ # @param [FFI::Pointer(Diagnostic)] diagnostic
555
+ # @return [String]
556
+ # @scope class
557
+ attach_function :get_diagnostic_spelling, :clang_getDiagnosticSpelling, [:pointer], String.by_value
558
+
559
+ # Retrieve the name of the command-line option that enabled this
560
+ # diagnostic.
561
+ #
562
+ # @method get_diagnostic_option(diag, disable)
563
+ # @param [FFI::Pointer(Diagnostic)] diag The diagnostic to be queried.
564
+ # @param [String] disable If non-NULL, will be set to the option that disables this
565
+ # diagnostic (if any).
566
+ # @return [String] A string that contains the command-line option used to enable this
567
+ # warning, such as "-Wconversion" or "-pedantic".
568
+ # @scope class
569
+ attach_function :get_diagnostic_option, :clang_getDiagnosticOption, [:pointer, String], String.by_value
570
+
571
+ # Retrieve the category number for this diagnostic.
572
+ #
573
+ # Diagnostics can be categorized into groups along with other, related
574
+ # diagnostics (e.g., diagnostics under the same warning flag). This routine
575
+ # retrieves the category number for the given diagnostic.
576
+ #
577
+ # @method get_diagnostic_category(diagnostic)
578
+ # @param [FFI::Pointer(Diagnostic)] diagnostic
579
+ # @return [Integer] The number of the category that contains this diagnostic, or zero
580
+ # if this diagnostic is uncategorized.
581
+ # @scope class
582
+ attach_function :get_diagnostic_category, :clang_getDiagnosticCategory, [:pointer], :uint
583
+
584
+ # Retrieve the name of a particular diagnostic category.
585
+ #
586
+ # @method get_diagnostic_category_name(category)
587
+ # @param [Integer] category A diagnostic category number, as returned by
588
+ # \c clang_getDiagnosticCategory().
589
+ # @return [String] The name of the given diagnostic category.
590
+ # @scope class
591
+ attach_function :get_diagnostic_category_name, :clang_getDiagnosticCategoryName, [:uint], String.by_value
592
+
593
+ # Determine the number of source ranges associated with the given
594
+ # diagnostic.
595
+ #
596
+ # @method get_diagnostic_num_ranges(diagnostic)
597
+ # @param [FFI::Pointer(Diagnostic)] diagnostic
598
+ # @return [Integer]
599
+ # @scope class
600
+ attach_function :get_diagnostic_num_ranges, :clang_getDiagnosticNumRanges, [:pointer], :uint
601
+
602
+ # Retrieve a source range associated with the diagnostic.
603
+ #
604
+ # A diagnostic's source ranges highlight important elements in the source
605
+ # code. On the command line, Clang displays source ranges by
606
+ # underlining them with '~' characters.
607
+ #
608
+ # @method get_diagnostic_range(diagnostic, range)
609
+ # @param [FFI::Pointer(Diagnostic)] diagnostic the diagnostic whose range is being extracted.
610
+ # @param [Integer] range the zero-based index specifying which range to
611
+ # @return [SourceRange] the requested source range.
612
+ # @scope class
613
+ attach_function :get_diagnostic_range, :clang_getDiagnosticRange, [:pointer, :uint], SourceRange.by_value
614
+
615
+ # Determine the number of fix-it hints associated with the
616
+ # given diagnostic.
617
+ #
618
+ # @method get_diagnostic_num_fix_its(diagnostic)
619
+ # @param [FFI::Pointer(Diagnostic)] diagnostic
620
+ # @return [Integer]
621
+ # @scope class
622
+ attach_function :get_diagnostic_num_fix_its, :clang_getDiagnosticNumFixIts, [:pointer], :uint
623
+
624
+ # Retrieve the replacement information for a given fix-it.
625
+ #
626
+ # Fix-its are described in terms of a source range whose contents
627
+ # should be replaced by a string. This approach generalizes over
628
+ # three kinds of operations: removal of source code (the range covers
629
+ # the code to be removed and the replacement string is empty),
630
+ # replacement of source code (the range covers the code to be
631
+ # replaced and the replacement string provides the new code), and
632
+ # insertion (both the start and end of the range point at the
633
+ # insertion location, and the replacement string provides the text to
634
+ # insert).
635
+ #
636
+ # @method get_diagnostic_fix_it(diagnostic, fix_it, replacement_range)
637
+ # @param [FFI::Pointer(Diagnostic)] diagnostic The diagnostic whose fix-its are being queried.
638
+ # @param [Integer] fix_it The zero-based index of the fix-it.
639
+ # @param [SourceRange] replacement_range The source range whose contents will be
640
+ # replaced with the returned replacement string. Note that source
641
+ # ranges are half-open ranges (a, b), so the source code should be
642
+ # replaced from a and up to (but not including) b.
643
+ # @return [String] A string containing text that should be replace the source
644
+ # code indicated by the \c ReplacementRange.
645
+ # @scope class
646
+ attach_function :get_diagnostic_fix_it, :clang_getDiagnosticFixIt, [:pointer, :uint, SourceRange], String.by_value
647
+
648
+ # Get the original translation unit source file name.
649
+ #
650
+ # @method get_translation_unit_spelling(ct_unit)
651
+ # @param [TranslationUnitImpl] ct_unit
652
+ # @return [String]
653
+ # @scope class
654
+ attach_function :get_translation_unit_spelling, :clang_getTranslationUnitSpelling, [TranslationUnitImpl], String.by_value
655
+
656
+ # Return the CXTranslationUnit for a given source file and the provided
657
+ # command line arguments one would pass to the compiler.
658
+ #
659
+ # Note: The 'source_filename' argument is optional. If the caller provides a
660
+ # NULL pointer, the name of the source file is expected to reside in the
661
+ # specified command line arguments.
662
+ #
663
+ # Note: When encountered in 'clang_command_line_args', the following options
664
+ # are ignored:
665
+ #
666
+ # '-c'
667
+ # '-emit-ast'
668
+ # '-fsyntax-only'
669
+ # '-o <output file>' (both '-o' and '<output file>' are ignored)
670
+ #
671
+ # @method create_translation_unit_from_source_file(c_idx, source_filename, num_clang_command_line_args, command_line_args, num_unsaved_files, unsaved_files)
672
+ # @param [FFI::Pointer(Index)] c_idx The index object with which the translation unit will be
673
+ # associated.
674
+ # @param [String] source_filename - The name of the source file to load, or NULL if the
675
+ # source file is included in \p clang_command_line_args.
676
+ # @param [Integer] num_clang_command_line_args The number of command-line arguments in
677
+ # \p clang_command_line_args.
678
+ # @param [FFI::Pointer(**Char_S)] command_line_args The command-line arguments that would be
679
+ # passed to the \c clang executable if it were being invoked out-of-process.
680
+ # These command-line options will be parsed and will affect how the translation
681
+ # unit is parsed. Note that the following options are ignored: '-c',
682
+ # '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
683
+ # @param [Integer] num_unsaved_files the number of unsaved file entries in \p
684
+ # unsaved_files.
685
+ # @param [UnsavedFile] unsaved_files the files that have not yet been saved to disk
686
+ # but may be required for code completion, including the contents of
687
+ # those files. The contents and name of these files (as specified by
688
+ # CXUnsavedFile) are copied when necessary, so the client only needs to
689
+ # guarantee their validity until the call to this function returns.
690
+ # @return [TranslationUnitImpl]
691
+ # @scope class
692
+ attach_function :create_translation_unit_from_source_file, :clang_createTranslationUnitFromSourceFile, [:pointer, :string, :int, :pointer, :uint, UnsavedFile], TranslationUnitImpl
693
+
694
+ # Create a translation unit from an AST file (-emit-ast).
695
+ #
696
+ # @method create_translation_unit(index, ast_filename)
697
+ # @param [FFI::Pointer(Index)] index
698
+ # @param [String] ast_filename
699
+ # @return [TranslationUnitImpl]
700
+ # @scope class
701
+ attach_function :create_translation_unit, :clang_createTranslationUnit, [:pointer, :string], TranslationUnitImpl
702
+
703
+ # Flags that control the creation of translation units.
704
+ #
705
+ # The enumerators in this enumeration type are meant to be bitwise
706
+ # ORed together to specify which options should be used when
707
+ # constructing the translation unit.
708
+ #
709
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:translation_unit_flags).</em>
710
+ #
711
+ # === Options:
712
+ # :none ::
713
+ # Used to indicate that no special translation-unit options are
714
+ # needed.
715
+ # :detailed_preprocessing_record ::
716
+ # Used to indicate that the parser should construct a "detailed"
717
+ # preprocessing record, including all macro definitions and instantiations.
718
+ #
719
+ # Constructing a detailed preprocessing record requires more memory
720
+ # and time to parse, since the information contained in the record
721
+ # is usually not retained. However, it can be useful for
722
+ # applications that require more detailed information about the
723
+ # behavior of the preprocessor.
724
+ # :incomplete ::
725
+ # Used to indicate that the translation unit is incomplete.
726
+ #
727
+ # When a translation unit is considered "incomplete", semantic
728
+ # analysis that is typically performed at the end of the
729
+ # translation unit will be suppressed. For example, this suppresses
730
+ # the completion of tentative declarations in C and of
731
+ # instantiation of implicitly-instantiation function templates in
732
+ # C++. This option is typically used when parsing a header with the
733
+ # intent of producing a precompiled header.
734
+ # :precompiled_preamble ::
735
+ # Used to indicate that the translation unit should be built with an
736
+ # implicit precompiled header for the preamble.
737
+ #
738
+ # An implicit precompiled header is used as an optimization when a
739
+ # particular translation unit is likely to be reparsed many times
740
+ # when the sources aren't changing that often. In this case, an
741
+ # implicit precompiled header will be built containing all of the
742
+ # initial includes at the top of the main file (what we refer to as
743
+ # the "preamble" of the file). In subsequent parses, if the
744
+ # preamble or the files in it have not changed, \c
745
+ # clang_reparseTranslationUnit() will re-use the implicit
746
+ # precompiled header to improve parsing performance.
747
+ # :cache_completion_results ::
748
+ # Used to indicate that the translation unit should cache some
749
+ # code-completion results with each reparse of the source file.
750
+ #
751
+ # Caching of code-completion results is a performance optimization that
752
+ # introduces some overhead to reparsing but improves the performance of
753
+ # code-completion operations.
754
+ # :x_precompiled_preamble ::
755
+ # DEPRECATED: Enable precompiled preambles in C++.
756
+ #
757
+ # Note: this is a *temporary* option that is available only while
758
+ # we are testing C++ precompiled preamble support. It is deprecated.
759
+ # :x_chained_pch ::
760
+ # DEPRECATED: Enabled chained precompiled preambles in C++.
761
+ #
762
+ # Note: this is a *temporary* option that is available only while
763
+ # we are testing C++ precompiled preamble support. It is deprecated.
764
+ # :nested_macro_expansions ::
765
+ # Used to indicate that the "detailed" preprocessing record,
766
+ # if requested, should also contain nested macro expansions.
767
+ #
768
+ # Nested macro expansions (i.e., macro expansions that occur
769
+ # inside another macro expansion) can, in some code bases, require
770
+ # a large amount of storage to due preprocessor metaprogramming. Moreover,
771
+ # its fairly rare that this information is useful for libclang clients.
772
+ #
773
+ # @method _enum_translation_unit_flags_
774
+ # @return [Symbol]
775
+ # @scope class
776
+ enum :translation_unit_flags, [
777
+ :none, 0x0,
778
+ :detailed_preprocessing_record, 0x01,
779
+ :incomplete, 0x02,
780
+ :precompiled_preamble, 0x04,
781
+ :cache_completion_results, 0x08,
782
+ :x_precompiled_preamble, 0x10,
783
+ :x_chained_pch, 0x20,
784
+ :nested_macro_expansions, 0x40
785
+ ]
786
+
787
+ # Returns the set of flags that is suitable for parsing a translation
788
+ # unit that is being edited.
789
+ #
790
+ # The set of flags returned provide options for \c clang_parseTranslationUnit()
791
+ # to indicate that the translation unit is likely to be reparsed many times,
792
+ # either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
793
+ # (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
794
+ # set contains an unspecified set of optimizations (e.g., the precompiled
795
+ # preamble) geared toward improving the performance of these routines. The
796
+ # set of optimizations enabled may change from one version to the next.
797
+ #
798
+ # @method default_editing_translation_unit_options()
799
+ # @return [Integer]
800
+ # @scope class
801
+ attach_function :default_editing_translation_unit_options, :clang_defaultEditingTranslationUnitOptions, [], :uint
802
+
803
+ # Parse the given source file and the translation unit corresponding
804
+ # to that file.
805
+ #
806
+ # This routine is the main entry point for the Clang C API, providing the
807
+ # ability to parse a source file into a translation unit that can then be
808
+ # queried by other functions in the API. This routine accepts a set of
809
+ # command-line arguments so that the compilation can be configured in the same
810
+ # way that the compiler is configured on the command line.
811
+ #
812
+ # @method parse_translation_unit(c_idx, source_filename, command_line_args, num_command_line_args, unsaved_files, num_unsaved_files, options)
813
+ # @param [FFI::Pointer(Index)] c_idx The index object with which the translation unit will be
814
+ # associated.
815
+ # @param [String] source_filename The name of the source file to load, or NULL if the
816
+ # source file is included in \p command_line_args.
817
+ # @param [FFI::Pointer(**Char_S)] command_line_args The command-line arguments that would be
818
+ # passed to the \c clang executable if it were being invoked out-of-process.
819
+ # These command-line options will be parsed and will affect how the translation
820
+ # unit is parsed. Note that the following options are ignored: '-c',
821
+ # '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
822
+ # @param [Integer] num_command_line_args The number of command-line arguments in
823
+ # \p command_line_args.
824
+ # @param [UnsavedFile] unsaved_files the files that have not yet been saved to disk
825
+ # but may be required for parsing, including the contents of
826
+ # those files. The contents and name of these files (as specified by
827
+ # CXUnsavedFile) are copied when necessary, so the client only needs to
828
+ # guarantee their validity until the call to this function returns.
829
+ # @param [Integer] num_unsaved_files the number of unsaved file entries in \p
830
+ # unsaved_files.
831
+ # @param [Integer] options A bitmask of options that affects how the translation unit
832
+ # is managed but not its compilation. This should be a bitwise OR of the
833
+ # CXTranslationUnit_XXX flags.
834
+ # @return [TranslationUnitImpl] A new translation unit describing the parsed code and containing
835
+ # any diagnostics produced by the compiler. If there is a failure from which
836
+ # the compiler cannot recover, returns NULL.
837
+ # @scope class
838
+ attach_function :parse_translation_unit, :clang_parseTranslationUnit, [:pointer, :string, :pointer, :int, UnsavedFile, :uint, :uint], TranslationUnitImpl
839
+
840
+ # Flags that control how translation units are saved.
841
+ #
842
+ # The enumerators in this enumeration type are meant to be bitwise
843
+ # ORed together to specify which options should be used when
844
+ # saving the translation unit.
845
+ #
846
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:save_translation_unit_flags).</em>
847
+ #
848
+ # === Options:
849
+ # :save_translation_unit_none ::
850
+ # Used to indicate that no special saving options are needed.
851
+ #
852
+ # @method _enum_save_translation_unit_flags_
853
+ # @return [Symbol]
854
+ # @scope class
855
+ enum :save_translation_unit_flags, [
856
+ :save_translation_unit_none, 0x0
857
+ ]
858
+
859
+ # Returns the set of flags that is suitable for saving a translation
860
+ # unit.
861
+ #
862
+ # The set of flags returned provide options for
863
+ # \c clang_saveTranslationUnit() by default. The returned flag
864
+ # set contains an unspecified set of options that save translation units with
865
+ # the most commonly-requested data.
866
+ #
867
+ # @method default_save_options(tu)
868
+ # @param [TranslationUnitImpl] tu
869
+ # @return [Integer]
870
+ # @scope class
871
+ attach_function :default_save_options, :clang_defaultSaveOptions, [TranslationUnitImpl], :uint
872
+
873
+ # Describes the kind of error that occurred (if any) in a call to
874
+ # \c clang_saveTranslationUnit().
875
+ #
876
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:save_error).</em>
877
+ #
878
+ # === Options:
879
+ # :none ::
880
+ # Indicates that no error occurred while saving a translation unit.
881
+ # :unknown ::
882
+ # Indicates that an unknown error occurred while attempting to save
883
+ # the file.
884
+ #
885
+ # This error typically indicates that file I/O failed when attempting to
886
+ # write the file.
887
+ # :translation_errors ::
888
+ # Indicates that errors during translation prevented this attempt
889
+ # to save the translation unit.
890
+ #
891
+ # Errors that prevent the translation unit from being saved can be
892
+ # extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
893
+ # :invalid_tu ::
894
+ # Indicates that the translation unit to be saved was somehow
895
+ # invalid (e.g., NULL).
896
+ #
897
+ # @method _enum_save_error_
898
+ # @return [Symbol]
899
+ # @scope class
900
+ enum :save_error, [
901
+ :none, 0,
902
+ :unknown, 1,
903
+ :translation_errors, 2,
904
+ :invalid_tu, 3
905
+ ]
906
+
907
+ # Saves a translation unit into a serialized representation of
908
+ # that translation unit on disk.
909
+ #
910
+ # Any translation unit that was parsed without error can be saved
911
+ # into a file. The translation unit can then be deserialized into a
912
+ # new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
913
+ # if it is an incomplete translation unit that corresponds to a
914
+ # header, used as a precompiled header when parsing other translation
915
+ # units.
916
+ #
917
+ # @method save_translation_unit(tu, file_name, options)
918
+ # @param [TranslationUnitImpl] tu The translation unit to save.
919
+ # @param [String] file_name The file to which the translation unit will be saved.
920
+ # @param [Integer] options A bitmask of options that affects how the translation unit
921
+ # is saved. This should be a bitwise OR of the
922
+ # CXSaveTranslationUnit_XXX flags.
923
+ # @return [Integer] A value that will match one of the enumerators of the CXSaveError
924
+ # enumeration. Zero (CXSaveError_None) indicates that the translation unit was
925
+ # saved successfully, while a non-zero value indicates that a problem occurred.
926
+ # @scope class
927
+ attach_function :save_translation_unit, :clang_saveTranslationUnit, [TranslationUnitImpl, :string, :uint], :int
928
+
929
+ # Destroy the specified CXTranslationUnit object.
930
+ #
931
+ # @method dispose_translation_unit(translation_unit_impl)
932
+ # @param [TranslationUnitImpl] translation_unit_impl
933
+ # @return [nil]
934
+ # @scope class
935
+ attach_function :dispose_translation_unit, :clang_disposeTranslationUnit, [TranslationUnitImplStruct], :void
936
+
937
+ # Flags that control the reparsing of translation units.
938
+ #
939
+ # The enumerators in this enumeration type are meant to be bitwise
940
+ # ORed together to specify which options should be used when
941
+ # reparsing the translation unit.
942
+ #
943
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:reparse_flags).</em>
944
+ #
945
+ # === Options:
946
+ # :reparse_none ::
947
+ # Used to indicate that no special reparsing options are needed.
948
+ #
949
+ # @method _enum_reparse_flags_
950
+ # @return [Symbol]
951
+ # @scope class
952
+ enum :reparse_flags, [
953
+ :reparse_none, 0x0
954
+ ]
955
+
956
+ # Returns the set of flags that is suitable for reparsing a translation
957
+ # unit.
958
+ #
959
+ # The set of flags returned provide options for
960
+ # \c clang_reparseTranslationUnit() by default. The returned flag
961
+ # set contains an unspecified set of optimizations geared toward common uses
962
+ # of reparsing. The set of optimizations enabled may change from one version
963
+ # to the next.
964
+ #
965
+ # @method default_reparse_options(tu)
966
+ # @param [TranslationUnitImpl] tu
967
+ # @return [Integer]
968
+ # @scope class
969
+ attach_function :default_reparse_options, :clang_defaultReparseOptions, [TranslationUnitImpl], :uint
970
+
971
+ # Reparse the source files that produced this translation unit.
972
+ #
973
+ # This routine can be used to re-parse the source files that originally
974
+ # created the given translation unit, for example because those source files
975
+ # have changed (either on disk or as passed via \p unsaved_files). The
976
+ # source code will be reparsed with the same command-line options as it
977
+ # was originally parsed.
978
+ #
979
+ # Reparsing a translation unit invalidates all cursors and source locations
980
+ # that refer into that translation unit. This makes reparsing a translation
981
+ # unit semantically equivalent to destroying the translation unit and then
982
+ # creating a new translation unit with the same command-line arguments.
983
+ # However, it may be more efficient to reparse a translation
984
+ # unit using this routine.
985
+ #
986
+ # @method reparse_translation_unit(tu, num_unsaved_files, unsaved_files, options)
987
+ # @param [TranslationUnitImpl] tu The translation unit whose contents will be re-parsed. The
988
+ # translation unit must originally have been built with
989
+ # \c clang_createTranslationUnitFromSourceFile().
990
+ # @param [Integer] num_unsaved_files The number of unsaved file entries in \p
991
+ # unsaved_files.
992
+ # @param [UnsavedFile] unsaved_files The files that have not yet been saved to disk
993
+ # but may be required for parsing, including the contents of
994
+ # those files. The contents and name of these files (as specified by
995
+ # CXUnsavedFile) are copied when necessary, so the client only needs to
996
+ # guarantee their validity until the call to this function returns.
997
+ # @param [Integer] options A bitset of options composed of the flags in CXReparse_Flags.
998
+ # The function \c clang_defaultReparseOptions() produces a default set of
999
+ # options recommended for most uses, based on the translation unit.
1000
+ # @return [Integer] 0 if the sources could be reparsed. A non-zero value will be
1001
+ # returned if reparsing was impossible, such that the translation unit is
1002
+ # invalid. In such cases, the only valid call for \p TU is
1003
+ # \c clang_disposeTranslationUnit(TU).
1004
+ # @scope class
1005
+ attach_function :reparse_translation_unit, :clang_reparseTranslationUnit, [TranslationUnitImpl, :uint, UnsavedFile, :uint], :int
1006
+
1007
+ # Categorizes how memory is being used by a translation unit.
1008
+ #
1009
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:tu_resource_usage_kind).</em>
1010
+ #
1011
+ # === Options:
1012
+ # :ast ::
1013
+ #
1014
+ # :identifiers ::
1015
+ #
1016
+ # :selectors ::
1017
+ #
1018
+ # :global_completion_results ::
1019
+ #
1020
+ # :source_manager_content_cache ::
1021
+ #
1022
+ # :ast_side_tables ::
1023
+ #
1024
+ # :source_manager_membuffer_malloc ::
1025
+ #
1026
+ # :source_manager_membuffer_m_map ::
1027
+ #
1028
+ # :external_ast_source_membuffer_malloc ::
1029
+ #
1030
+ # :external_ast_source_membuffer_m_map ::
1031
+ #
1032
+ # :preprocessor ::
1033
+ #
1034
+ # :preprocessing_record ::
1035
+ #
1036
+ # :source_manager_data_structures ::
1037
+ #
1038
+ # :preprocessor_header_search ::
1039
+ #
1040
+ #
1041
+ # @method _enum_tu_resource_usage_kind_
1042
+ # @return [Symbol]
1043
+ # @scope class
1044
+ enum :tu_resource_usage_kind, [
1045
+ :ast, 1,
1046
+ :identifiers, 2,
1047
+ :selectors, 3,
1048
+ :global_completion_results, 4,
1049
+ :source_manager_content_cache, 5,
1050
+ :ast_side_tables, 6,
1051
+ :source_manager_membuffer_malloc, 7,
1052
+ :source_manager_membuffer_m_map, 8,
1053
+ :external_ast_source_membuffer_malloc, 9,
1054
+ :external_ast_source_membuffer_m_map, 10,
1055
+ :preprocessor, 11,
1056
+ :preprocessing_record, 12,
1057
+ :source_manager_data_structures, 13,
1058
+ :preprocessor_header_search, 14
1059
+ ]
1060
+
1061
+ # Returns the human-readable null-terminated C string that represents
1062
+ # the name of the memory category. This string should never be freed.
1063
+ #
1064
+ # @method get_tu_resource_usage_name(kind)
1065
+ # @param [Symbol from _enum_tu_resource_usage_kind_] kind
1066
+ # @return [String]
1067
+ # @scope class
1068
+ attach_function :get_tu_resource_usage_name, :clang_getTUResourceUsageName, [:tu_resource_usage_kind], :string
1069
+
1070
+ # (Not documented)
1071
+ #
1072
+ # = Fields:
1073
+ # :kind ::
1074
+ # (Symbol from _enum_tu_resource_usage_kind_) The memory usage category.
1075
+ # :amount ::
1076
+ # (Integer) Amount of resources used.
1077
+ # The units will depend on the resource kind.
1078
+ class TUResourceUsageEntry < FFI::Struct
1079
+ layout :kind, :tu_resource_usage_kind,
1080
+ :amount, :ulong
1081
+ end
1082
+
1083
+ # The memory usage of a CXTranslationUnit, broken into categories.
1084
+ #
1085
+ # = Fields:
1086
+ # :data ::
1087
+ # (FFI::Pointer(*Void)) Private data member, used for queries.
1088
+ # :num_entries ::
1089
+ # (Integer) The number of entries in the 'entries' array.
1090
+ # :entries ::
1091
+ # (TUResourceUsageEntry) An array of key-value pairs, representing the breakdown of memory
1092
+ # usage.
1093
+ class TUResourceUsage < FFI::Struct
1094
+ layout :data, :pointer,
1095
+ :num_entries, :uint,
1096
+ :entries, TUResourceUsageEntry
1097
+ end
1098
+
1099
+ # Return the memory usage of a translation unit. This object
1100
+ # should be released with clang_disposeCXTUResourceUsage().
1101
+ #
1102
+ # @method get_cxtu_resource_usage(tu)
1103
+ # @param [TranslationUnitImpl] tu
1104
+ # @return [TUResourceUsage]
1105
+ # @scope class
1106
+ attach_function :get_cxtu_resource_usage, :clang_getCXTUResourceUsage, [TranslationUnitImpl], TUResourceUsage.by_value
1107
+
1108
+ # (Not documented)
1109
+ #
1110
+ # @method dispose_cxtu_resource_usage(usage)
1111
+ # @param [TUResourceUsage] usage
1112
+ # @return [nil]
1113
+ # @scope class
1114
+ attach_function :dispose_cxtu_resource_usage, :clang_disposeCXTUResourceUsage, [TUResourceUsage.by_value], :void
1115
+
1116
+ # Describes the kind of entity that a cursor refers to.
1117
+ #
1118
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:cursor_kind).</em>
1119
+ #
1120
+ # === Options:
1121
+ # :unexposed_decl ::
1122
+ # A declaration whose specific kind is not exposed via this
1123
+ # interface.
1124
+ #
1125
+ # Unexposed declarations have the same operations as any other kind
1126
+ # of declaration; one can extract their location information,
1127
+ # spelling, find their definitions, etc. However, the specific kind
1128
+ # of the declaration is not reported.
1129
+ # :struct_decl ::
1130
+ # A C or C++ struct.
1131
+ # :union_decl ::
1132
+ # A C or C++ union.
1133
+ # :class_decl ::
1134
+ # A C++ class.
1135
+ # :enum_decl ::
1136
+ # An enumeration.
1137
+ # :field_decl ::
1138
+ # A field (in C) or non-static data member (in C++) in a
1139
+ # struct, union, or C++ class.
1140
+ # :enum_constant_decl ::
1141
+ # An enumerator constant.
1142
+ # :function_decl ::
1143
+ # A function.
1144
+ # :var_decl ::
1145
+ # A variable.
1146
+ # :parm_decl ::
1147
+ # A function or method parameter.
1148
+ # :obj_c_interface_decl ::
1149
+ # An Objective-C @interface.
1150
+ # :obj_c_category_decl ::
1151
+ # An Objective-C @interface for a category.
1152
+ # :obj_c_protocol_decl ::
1153
+ # An Objective-C @protocol declaration.
1154
+ # :obj_c_property_decl ::
1155
+ # An Objective-C @property declaration.
1156
+ # :obj_c_ivar_decl ::
1157
+ # An Objective-C instance variable.
1158
+ # :obj_c_instance_method_decl ::
1159
+ # An Objective-C instance method.
1160
+ # :obj_c_class_method_decl ::
1161
+ # An Objective-C class method.
1162
+ # :obj_c_implementation_decl ::
1163
+ # An Objective-C @implementation.
1164
+ # :obj_c_category_impl_decl ::
1165
+ # An Objective-C @implementation for a category.
1166
+ # :typedef_decl ::
1167
+ # A typedef
1168
+ # :x_method ::
1169
+ # A C++ class method.
1170
+ # :namespace ::
1171
+ # A C++ namespace.
1172
+ # :linkage_spec ::
1173
+ # A linkage specification, e.g. 'extern "C"'.
1174
+ # :constructor ::
1175
+ # A C++ constructor.
1176
+ # :destructor ::
1177
+ # A C++ destructor.
1178
+ # :conversion_function ::
1179
+ # A C++ conversion function.
1180
+ # :template_type_parameter ::
1181
+ # A C++ template type parameter.
1182
+ # :non_type_template_parameter ::
1183
+ # A C++ non-type template parameter.
1184
+ # :template_template_parameter ::
1185
+ # A C++ template template parameter.
1186
+ # :function_template ::
1187
+ # A C++ function template.
1188
+ # :class_template ::
1189
+ # A C++ class template.
1190
+ # :class_template_partial_specialization ::
1191
+ # A C++ class template partial specialization.
1192
+ # :namespace_alias ::
1193
+ # A C++ namespace alias declaration.
1194
+ # :using_directive ::
1195
+ # A C++ using directive.
1196
+ # :using_declaration ::
1197
+ # A C++ using declaration.
1198
+ # :type_alias_decl ::
1199
+ # A C++ alias declaration
1200
+ # :obj_c_synthesize_decl ::
1201
+ # An Objective-C @synthesize definition.
1202
+ # :obj_c_dynamic_decl ::
1203
+ # An Objective-C @dynamic definition.
1204
+ # :x_access_specifier ::
1205
+ # An access specifier.
1206
+ # :first_ref ::
1207
+ # References
1208
+ # :obj_c_super_class_ref ::
1209
+ # Decl references
1210
+ # :obj_c_protocol_ref ::
1211
+ #
1212
+ # :obj_c_class_ref ::
1213
+ #
1214
+ # :type_ref ::
1215
+ # A reference to a type declaration.
1216
+ #
1217
+ # A type reference occurs anywhere where a type is named but not
1218
+ # declared. For example, given:
1219
+ #
1220
+ # \code
1221
+ # typedef unsigned size_type;
1222
+ # size_type size;
1223
+ # \endcode
1224
+ #
1225
+ # The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1226
+ # while the type of the variable "size" is referenced. The cursor
1227
+ # referenced by the type of size is the typedef for size_type.
1228
+ # :x_base_specifier ::
1229
+ #
1230
+ # :template_ref ::
1231
+ # A reference to a class template, function template, template
1232
+ # template parameter, or class template partial specialization.
1233
+ # :namespace_ref ::
1234
+ # A reference to a namespace or namespace alias.
1235
+ # :member_ref ::
1236
+ # A reference to a member of a struct, union, or class that occurs in
1237
+ # some non-expression context, e.g., a designated initializer.
1238
+ # :label_ref ::
1239
+ # A reference to a labeled statement.
1240
+ #
1241
+ # This cursor kind is used to describe the jump to "start_over" in the
1242
+ # goto statement in the following example:
1243
+ #
1244
+ # \code
1245
+ # start_over:
1246
+ # ++counter;
1247
+ #
1248
+ # goto start_over;
1249
+ # \endcode
1250
+ #
1251
+ # A label reference cursor refers to a label statement.
1252
+ # :overloaded_decl_ref ::
1253
+ # A reference to a set of overloaded functions or function templates
1254
+ # that has not yet been resolved to a specific function or function template.
1255
+ #
1256
+ # An overloaded declaration reference cursor occurs in C++ templates where
1257
+ # a dependent name refers to a function. For example:
1258
+ #
1259
+ # \code
1260
+ # template<typename T> void swap(T&, T&);
1261
+ #
1262
+ # struct X { ... };
1263
+ # void swap(X&, X&);
1264
+ #
1265
+ # template<typename T>
1266
+ # void reverse(T* first, T* last) {
1267
+ # while (first < last - 1) {
1268
+ # swap(*first, *--last);
1269
+ # ++first;
1270
+ # }
1271
+ # }
1272
+ #
1273
+ # struct Y { };
1274
+ # void swap(Y&, Y&);
1275
+ # \endcode
1276
+ #
1277
+ # Here, the identifier "swap" is associated with an overloaded declaration
1278
+ # reference. In the template definition, "swap" refers to either of the two
1279
+ # "swap" functions declared above, so both results will be available. At
1280
+ # instantiation time, "swap" may also refer to other functions found via
1281
+ # argument-dependent lookup (e.g., the "swap" function at the end of the
1282
+ # example).
1283
+ #
1284
+ # The functions \c clang_getNumOverloadedDecls() and
1285
+ # \c clang_getOverloadedDecl() can be used to retrieve the definitions
1286
+ # referenced by this cursor.
1287
+ # :first_invalid ::
1288
+ # Error conditions
1289
+ # :invalid_file ::
1290
+ #
1291
+ # :no_decl_found ::
1292
+ #
1293
+ # :not_implemented ::
1294
+ #
1295
+ # :invalid_code ::
1296
+ #
1297
+ # :first_expr ::
1298
+ # Expressions
1299
+ # :unexposed_expr ::
1300
+ # An expression whose specific kind is not exposed via this
1301
+ # interface.
1302
+ #
1303
+ # Unexposed expressions have the same operations as any other kind
1304
+ # of expression; one can extract their location information,
1305
+ # spelling, children, etc. However, the specific kind of the
1306
+ # expression is not reported.
1307
+ # :decl_ref_expr ::
1308
+ # An expression that refers to some value declaration, such
1309
+ # as a function, varible, or enumerator.
1310
+ # :member_ref_expr ::
1311
+ # An expression that refers to a member of a struct, union,
1312
+ # class, Objective-C class, etc.
1313
+ # :call_expr ::
1314
+ # An expression that calls a function.
1315
+ # :obj_c_message_expr ::
1316
+ # An expression that sends a message to an Objective-C
1317
+ # object or class.
1318
+ # :block_expr ::
1319
+ # An expression that represents a block literal.
1320
+ # :integer_literal ::
1321
+ # An integer literal.
1322
+ # :floating_literal ::
1323
+ # A floating point number literal.
1324
+ # :imaginary_literal ::
1325
+ # An imaginary number literal.
1326
+ # :string_literal ::
1327
+ # A string literal.
1328
+ # :character_literal ::
1329
+ # A character literal.
1330
+ # :paren_expr ::
1331
+ # A parenthesized expression, e.g. "(1)".
1332
+ #
1333
+ # This AST node is only formed if full location information is requested.
1334
+ # :unary_operator ::
1335
+ # This represents the unary-expression's (except sizeof and
1336
+ # alignof).
1337
+ # :array_subscript_expr ::
1338
+ # (C99 6.5.2.1) Array Subscripting.
1339
+ # :binary_operator ::
1340
+ # A builtin binary operation expression such as "x + y" or
1341
+ # "x <= y".
1342
+ # :compound_assign_operator ::
1343
+ # Compound assignment such as "+=".
1344
+ # :conditional_operator ::
1345
+ # The ?: ternary operator.
1346
+ # :c_style_cast_expr ::
1347
+ # An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1348
+ # (C++ (expr.cast)), which uses the syntax (Type)expr.
1349
+ #
1350
+ # For example: (int)f.
1351
+ # :compound_literal_expr ::
1352
+ # (C99 6.5.2.5)
1353
+ # :init_list_expr ::
1354
+ # Describes an C or C++ initializer list.
1355
+ # :addr_label_expr ::
1356
+ # The GNU address of label extension, representing &&label.
1357
+ # :stmt_expr ::
1358
+ # This is the GNU Statement Expression extension: ({int X=4; X;})
1359
+ # :generic_selection_expr ::
1360
+ # Represents a C1X generic selection.
1361
+ # :gnu_null_expr ::
1362
+ # Implements the GNU __null extension, which is a name for a null
1363
+ # pointer constant that has integral type (e.g., int or long) and is the same
1364
+ # size and alignment as a pointer.
1365
+ #
1366
+ # The __null extension is typically only used by system headers, which define
1367
+ # NULL as __null in C++ rather than using 0 (which is an integer that may not
1368
+ # match the size of a pointer).
1369
+ # :x_static_cast_expr ::
1370
+ # C++'s static_cast<> expression.
1371
+ # :x_dynamic_cast_expr ::
1372
+ # C++'s dynamic_cast<> expression.
1373
+ # :x_reinterpret_cast_expr ::
1374
+ # C++'s reinterpret_cast<> expression.
1375
+ # :x_const_cast_expr ::
1376
+ # C++'s const_cast<> expression.
1377
+ # :x_functional_cast_expr ::
1378
+ # Represents an explicit C++ type conversion that uses "functional"
1379
+ # notion (C++ (expr.type.conv)).
1380
+ #
1381
+ # Example:
1382
+ # \code
1383
+ # x = int(0.5);
1384
+ # \endcode
1385
+ # :x_typeid_expr ::
1386
+ # A C++ typeid expression (C++ (expr.typeid)).
1387
+ # :x_bool_literal_expr ::
1388
+ # (C++ 2.13.5) C++ Boolean Literal.
1389
+ # :x_null_ptr_literal_expr ::
1390
+ # (C++0x 2.14.7) C++ Pointer Literal.
1391
+ # :x_this_expr ::
1392
+ # Represents the "this" expression in C++
1393
+ # :x_throw_expr ::
1394
+ # (C++ 15) C++ Throw Expression.
1395
+ #
1396
+ # This handles 'throw' and 'throw' assignment-expression. When
1397
+ # assignment-expression isn't present, Op will be null.
1398
+ # :x_new_expr ::
1399
+ # A new expression for memory allocation and constructor calls, e.g:
1400
+ # "new CXXNewExpr(foo)".
1401
+ # :x_delete_expr ::
1402
+ # A delete expression for memory deallocation and destructor calls,
1403
+ # e.g. "delete() pArray".
1404
+ # :unary_expr ::
1405
+ # A unary expression.
1406
+ # :obj_c_string_literal ::
1407
+ # ObjCStringLiteral, used for Objective-C string literals i.e. "foo".
1408
+ # :obj_c_encode_expr ::
1409
+ # ObjCEncodeExpr, used for in Objective-C.
1410
+ # :obj_c_selector_expr ::
1411
+ # ObjCSelectorExpr used for in Objective-C.
1412
+ # :obj_c_protocol_expr ::
1413
+ # Objective-C's protocol expression.
1414
+ # :obj_c_bridged_cast_expr ::
1415
+ # An Objective-C "bridged" cast expression, which casts between
1416
+ # Objective-C pointers and C pointers, transferring ownership in the process.
1417
+ #
1418
+ # \code
1419
+ # NSString *str = (__bridge_transfer NSString *)CFCreateString();
1420
+ # \endcode
1421
+ # :pack_expansion_expr ::
1422
+ # Represents a C++0x pack expansion that produces a sequence of
1423
+ # expressions.
1424
+ #
1425
+ # A pack expansion expression contains a pattern (which itself is an
1426
+ # expression) followed by an ellipsis. For example:
1427
+ #
1428
+ # \code
1429
+ # template<typename F, typename ...Types>
1430
+ # void forward(F f, Types &&...args) {
1431
+ # f(static_cast<Types&&>(args)...);
1432
+ # }
1433
+ # \endcode
1434
+ # :size_of_pack_expr ::
1435
+ # Represents an expression that computes the length of a parameter
1436
+ # pack.
1437
+ #
1438
+ # \code
1439
+ # template<typename ...Types>
1440
+ # struct count {
1441
+ # static const unsigned value = sizeof...(Types);
1442
+ # };
1443
+ # \endcode
1444
+ # :first_stmt ::
1445
+ # Statements
1446
+ # :unexposed_stmt ::
1447
+ # A statement whose specific kind is not exposed via this
1448
+ # interface.
1449
+ #
1450
+ # Unexposed statements have the same operations as any other kind of
1451
+ # statement; one can extract their location information, spelling,
1452
+ # children, etc. However, the specific kind of the statement is not
1453
+ # reported.
1454
+ # :label_stmt ::
1455
+ # A labelled statement in a function.
1456
+ #
1457
+ # This cursor kind is used to describe the "start_over:" label statement in
1458
+ # the following example:
1459
+ #
1460
+ # \code
1461
+ # start_over:
1462
+ # ++counter;
1463
+ # \endcode
1464
+ # :compound_stmt ::
1465
+ # A group of statements like { stmt stmt }.
1466
+ #
1467
+ # This cursor kind is used to describe compound statements, e.g. function
1468
+ # bodies.
1469
+ # :case_stmt ::
1470
+ # A case statment.
1471
+ # :default_stmt ::
1472
+ # A default statement.
1473
+ # :if_stmt ::
1474
+ # An if statement
1475
+ # :switch_stmt ::
1476
+ # A switch statement.
1477
+ # :while_stmt ::
1478
+ # A while statement.
1479
+ # :do_stmt ::
1480
+ # A do statement.
1481
+ # :for_stmt ::
1482
+ # A for statement.
1483
+ # :goto_stmt ::
1484
+ # A goto statement.
1485
+ # :indirect_goto_stmt ::
1486
+ # An indirect goto statement.
1487
+ # :continue_stmt ::
1488
+ # A continue statement.
1489
+ # :break_stmt ::
1490
+ # A break statement.
1491
+ # :return_stmt ::
1492
+ # A return statement.
1493
+ # :asm_stmt ::
1494
+ # A GNU inline assembly statement extension.
1495
+ # :obj_c_at_try_stmt ::
1496
+ # Objective-C's overall @try-@catc-@finall statement.
1497
+ # :obj_c_at_catch_stmt ::
1498
+ # Objective-C's @catch statement.
1499
+ # :obj_c_at_finally_stmt ::
1500
+ # Objective-C's @finally statement.
1501
+ # :obj_c_at_throw_stmt ::
1502
+ # Objective-C's @throw statement.
1503
+ # :obj_c_at_synchronized_stmt ::
1504
+ # Objective-C's @synchronized statement.
1505
+ # :obj_c_autorelease_pool_stmt ::
1506
+ # Objective-C's autorelease pool statement.
1507
+ # :obj_c_for_collection_stmt ::
1508
+ # Objective-C's collection statement.
1509
+ # :x_catch_stmt ::
1510
+ # C++'s catch statement.
1511
+ # :x_try_stmt ::
1512
+ # C++'s try statement.
1513
+ # :x_for_range_stmt ::
1514
+ # C++'s for (* : *) statement.
1515
+ # :seh_try_stmt ::
1516
+ # Windows Structured Exception Handling's try statement.
1517
+ # :seh_except_stmt ::
1518
+ # Windows Structured Exception Handling's except statement.
1519
+ # :seh_finally_stmt ::
1520
+ # Windows Structured Exception Handling's finally statement.
1521
+ # :null_stmt ::
1522
+ # The null satement ";": C99 6.8.3p3.
1523
+ #
1524
+ # This cursor kind is used to describe the null statement.
1525
+ # :decl_stmt ::
1526
+ # Adaptor class for mixing declarations with statements and
1527
+ # expressions.
1528
+ # :translation_unit ::
1529
+ # Cursor that represents the translation unit itself.
1530
+ #
1531
+ # The translation unit cursor exists primarily to act as the root
1532
+ # cursor for traversing the contents of a translation unit.
1533
+ # :first_attr ::
1534
+ # Attributes
1535
+ # :unexposed_attr ::
1536
+ # An attribute whose specific kind is not exposed via this
1537
+ # interface.
1538
+ # :ib_action_attr ::
1539
+ #
1540
+ # :ib_outlet_attr ::
1541
+ #
1542
+ # :ib_outlet_collection_attr ::
1543
+ #
1544
+ # :x_final_attr ::
1545
+ #
1546
+ # :x_override_attr ::
1547
+ #
1548
+ # :annotate_attr ::
1549
+ #
1550
+ # :preprocessing_directive ::
1551
+ # Preprocessing
1552
+ # :macro_definition ::
1553
+ #
1554
+ # :macro_expansion ::
1555
+ #
1556
+ # :inclusion_directive ::
1557
+ #
1558
+ #
1559
+ # @method _enum_cursor_kind_
1560
+ # @return [Symbol]
1561
+ # @scope class
1562
+ enum :cursor_kind, [
1563
+ :unexposed_decl, 1,
1564
+ :struct_decl, 2,
1565
+ :union_decl, 3,
1566
+ :class_decl, 4,
1567
+ :enum_decl, 5,
1568
+ :field_decl, 6,
1569
+ :enum_constant_decl, 7,
1570
+ :function_decl, 8,
1571
+ :var_decl, 9,
1572
+ :parm_decl, 10,
1573
+ :obj_c_interface_decl, 11,
1574
+ :obj_c_category_decl, 12,
1575
+ :obj_c_protocol_decl, 13,
1576
+ :obj_c_property_decl, 14,
1577
+ :obj_c_ivar_decl, 15,
1578
+ :obj_c_instance_method_decl, 16,
1579
+ :obj_c_class_method_decl, 17,
1580
+ :obj_c_implementation_decl, 18,
1581
+ :obj_c_category_impl_decl, 19,
1582
+ :typedef_decl, 20,
1583
+ :x_method, 21,
1584
+ :namespace, 22,
1585
+ :linkage_spec, 23,
1586
+ :constructor, 24,
1587
+ :destructor, 25,
1588
+ :conversion_function, 26,
1589
+ :template_type_parameter, 27,
1590
+ :non_type_template_parameter, 28,
1591
+ :template_template_parameter, 29,
1592
+ :function_template, 30,
1593
+ :class_template, 31,
1594
+ :class_template_partial_specialization, 32,
1595
+ :namespace_alias, 33,
1596
+ :using_directive, 34,
1597
+ :using_declaration, 35,
1598
+ :type_alias_decl, 36,
1599
+ :obj_c_synthesize_decl, 37,
1600
+ :obj_c_dynamic_decl, 38,
1601
+ :x_access_specifier, 39,
1602
+ :first_ref, 40,
1603
+ :obj_c_super_class_ref, 40,
1604
+ :obj_c_protocol_ref, 41,
1605
+ :obj_c_class_ref, 42,
1606
+ :type_ref, 43,
1607
+ :x_base_specifier, 44,
1608
+ :template_ref, 45,
1609
+ :namespace_ref, 46,
1610
+ :member_ref, 47,
1611
+ :label_ref, 48,
1612
+ :overloaded_decl_ref, 49,
1613
+ :first_invalid, 70,
1614
+ :invalid_file, 70,
1615
+ :no_decl_found, 71,
1616
+ :not_implemented, 72,
1617
+ :invalid_code, 73,
1618
+ :first_expr, 100,
1619
+ :unexposed_expr, 100,
1620
+ :decl_ref_expr, 101,
1621
+ :member_ref_expr, 102,
1622
+ :call_expr, 103,
1623
+ :obj_c_message_expr, 104,
1624
+ :block_expr, 105,
1625
+ :integer_literal, 106,
1626
+ :floating_literal, 107,
1627
+ :imaginary_literal, 108,
1628
+ :string_literal, 109,
1629
+ :character_literal, 110,
1630
+ :paren_expr, 111,
1631
+ :unary_operator, 112,
1632
+ :array_subscript_expr, 113,
1633
+ :binary_operator, 114,
1634
+ :compound_assign_operator, 115,
1635
+ :conditional_operator, 116,
1636
+ :c_style_cast_expr, 117,
1637
+ :compound_literal_expr, 118,
1638
+ :init_list_expr, 119,
1639
+ :addr_label_expr, 120,
1640
+ :stmt_expr, 121,
1641
+ :generic_selection_expr, 122,
1642
+ :gnu_null_expr, 123,
1643
+ :x_static_cast_expr, 124,
1644
+ :x_dynamic_cast_expr, 125,
1645
+ :x_reinterpret_cast_expr, 126,
1646
+ :x_const_cast_expr, 127,
1647
+ :x_functional_cast_expr, 128,
1648
+ :x_typeid_expr, 129,
1649
+ :x_bool_literal_expr, 130,
1650
+ :x_null_ptr_literal_expr, 131,
1651
+ :x_this_expr, 132,
1652
+ :x_throw_expr, 133,
1653
+ :x_new_expr, 134,
1654
+ :x_delete_expr, 135,
1655
+ :unary_expr, 136,
1656
+ :obj_c_string_literal, 137,
1657
+ :obj_c_encode_expr, 138,
1658
+ :obj_c_selector_expr, 139,
1659
+ :obj_c_protocol_expr, 140,
1660
+ :obj_c_bridged_cast_expr, 141,
1661
+ :pack_expansion_expr, 142,
1662
+ :size_of_pack_expr, 143,
1663
+ :first_stmt, 200,
1664
+ :unexposed_stmt, 200,
1665
+ :label_stmt, 201,
1666
+ :compound_stmt, 202,
1667
+ :case_stmt, 203,
1668
+ :default_stmt, 204,
1669
+ :if_stmt, 205,
1670
+ :switch_stmt, 206,
1671
+ :while_stmt, 207,
1672
+ :do_stmt, 208,
1673
+ :for_stmt, 209,
1674
+ :goto_stmt, 210,
1675
+ :indirect_goto_stmt, 211,
1676
+ :continue_stmt, 212,
1677
+ :break_stmt, 213,
1678
+ :return_stmt, 214,
1679
+ :asm_stmt, 215,
1680
+ :obj_c_at_try_stmt, 216,
1681
+ :obj_c_at_catch_stmt, 217,
1682
+ :obj_c_at_finally_stmt, 218,
1683
+ :obj_c_at_throw_stmt, 219,
1684
+ :obj_c_at_synchronized_stmt, 220,
1685
+ :obj_c_autorelease_pool_stmt, 221,
1686
+ :obj_c_for_collection_stmt, 222,
1687
+ :x_catch_stmt, 223,
1688
+ :x_try_stmt, 224,
1689
+ :x_for_range_stmt, 225,
1690
+ :seh_try_stmt, 226,
1691
+ :seh_except_stmt, 227,
1692
+ :seh_finally_stmt, 228,
1693
+ :null_stmt, 230,
1694
+ :decl_stmt, 231,
1695
+ :translation_unit, 300,
1696
+ :first_attr, 400,
1697
+ :unexposed_attr, 400,
1698
+ :ib_action_attr, 401,
1699
+ :ib_outlet_attr, 402,
1700
+ :ib_outlet_collection_attr, 403,
1701
+ :x_final_attr, 404,
1702
+ :x_override_attr, 405,
1703
+ :annotate_attr, 406,
1704
+ :preprocessing_directive, 500,
1705
+ :macro_definition, 501,
1706
+ :macro_expansion, 502,
1707
+ :inclusion_directive, 503
1708
+ ]
1709
+
1710
+ # A cursor representing some element in the abstract syntax tree for
1711
+ # a translation unit.
1712
+ #
1713
+ # The cursor abstraction unifies the different kinds of entities in a
1714
+ # program--declaration, statements, expressions, references to declarations,
1715
+ # etc.--under a single "cursor" abstraction with a common set of operations.
1716
+ # Common operation for a cursor include: getting the physical location in
1717
+ # a source file where the cursor points, getting the name associated with a
1718
+ # cursor, and retrieving cursors for any child nodes of a particular cursor.
1719
+ #
1720
+ # Cursors can be produced in two specific ways.
1721
+ # clang_getTranslationUnitCursor() produces a cursor for a translation unit,
1722
+ # from which one can use clang_visitChildren() to explore the rest of the
1723
+ # translation unit. clang_getCursor() maps from a physical source location
1724
+ # to the entity that resides at that location, allowing one to map from the
1725
+ # source code into the AST.
1726
+ #
1727
+ # = Fields:
1728
+ # :kind ::
1729
+ # (Symbol from _enum_cursor_kind_)
1730
+ # :xdata ::
1731
+ # (Integer)
1732
+ # :data ::
1733
+ # (Array<FFI::Pointer(*Void)>)
1734
+ class Cursor < FFI::Struct
1735
+ layout :kind, :cursor_kind,
1736
+ :xdata, :int,
1737
+ :data, [:pointer, 3]
1738
+ end
1739
+
1740
+ # Retrieve the NULL cursor, which represents no entity.
1741
+ #
1742
+ # @method get_null_cursor()
1743
+ # @return [Cursor]
1744
+ # @scope class
1745
+ attach_function :get_null_cursor, :clang_getNullCursor, [], Cursor.by_value
1746
+
1747
+ # Retrieve the cursor that represents the given translation unit.
1748
+ #
1749
+ # The translation unit cursor can be used to start traversing the
1750
+ # various declarations within the given translation unit.
1751
+ #
1752
+ # @method get_translation_unit_cursor(translation_unit_impl)
1753
+ # @param [TranslationUnitImpl] translation_unit_impl
1754
+ # @return [Cursor]
1755
+ # @scope class
1756
+ attach_function :get_translation_unit_cursor, :clang_getTranslationUnitCursor, [TranslationUnitImpl], Cursor.by_value
1757
+
1758
+ # Determine whether two cursors are equivalent.
1759
+ #
1760
+ # @method equal_cursors(cursor, cursor)
1761
+ # @param [Cursor] cursor
1762
+ # @param [Cursor] cursor
1763
+ # @return [Integer]
1764
+ # @scope class
1765
+ attach_function :equal_cursors, :clang_equalCursors, [Cursor.by_value, Cursor.by_value], :uint
1766
+
1767
+ # Returns non-zero if \arg cursor is null.
1768
+ #
1769
+ # @method cursor_is_null(cursor)
1770
+ # @param [Cursor] cursor
1771
+ # @return [Integer]
1772
+ # @scope class
1773
+ attach_function :cursor_is_null, :clang_Cursor_isNull, [Cursor.by_value], :int
1774
+
1775
+ # Compute a hash value for the given cursor.
1776
+ #
1777
+ # @method hash_cursor(cursor)
1778
+ # @param [Cursor] cursor
1779
+ # @return [Integer]
1780
+ # @scope class
1781
+ attach_function :hash_cursor, :clang_hashCursor, [Cursor.by_value], :uint
1782
+
1783
+ # Retrieve the kind of the given cursor.
1784
+ #
1785
+ # @method get_cursor_kind(cursor)
1786
+ # @param [Cursor] cursor
1787
+ # @return [Symbol from _enum_cursor_kind_]
1788
+ # @scope class
1789
+ attach_function :get_cursor_kind, :clang_getCursorKind, [Cursor.by_value], :cursor_kind
1790
+
1791
+ # Determine whether the given cursor kind represents a declaration.
1792
+ #
1793
+ # @method is_declaration(cursor_kind)
1794
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1795
+ # @return [Integer]
1796
+ # @scope class
1797
+ attach_function :is_declaration, :clang_isDeclaration, [:cursor_kind], :uint
1798
+
1799
+ # Determine whether the given cursor kind represents a simple
1800
+ # reference.
1801
+ #
1802
+ # Note that other kinds of cursors (such as expressions) can also refer to
1803
+ # other cursors. Use clang_getCursorReferenced() to determine whether a
1804
+ # particular cursor refers to another entity.
1805
+ #
1806
+ # @method is_reference(cursor_kind)
1807
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1808
+ # @return [Integer]
1809
+ # @scope class
1810
+ attach_function :is_reference, :clang_isReference, [:cursor_kind], :uint
1811
+
1812
+ # Determine whether the given cursor kind represents an expression.
1813
+ #
1814
+ # @method is_expression(cursor_kind)
1815
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1816
+ # @return [Integer]
1817
+ # @scope class
1818
+ attach_function :is_expression, :clang_isExpression, [:cursor_kind], :uint
1819
+
1820
+ # Determine whether the given cursor kind represents a statement.
1821
+ #
1822
+ # @method is_statement(cursor_kind)
1823
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1824
+ # @return [Integer]
1825
+ # @scope class
1826
+ attach_function :is_statement, :clang_isStatement, [:cursor_kind], :uint
1827
+
1828
+ # Determine whether the given cursor kind represents an attribute.
1829
+ #
1830
+ # @method is_attribute(cursor_kind)
1831
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1832
+ # @return [Integer]
1833
+ # @scope class
1834
+ attach_function :is_attribute, :clang_isAttribute, [:cursor_kind], :uint
1835
+
1836
+ # Determine whether the given cursor kind represents an invalid
1837
+ # cursor.
1838
+ #
1839
+ # @method is_invalid(cursor_kind)
1840
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1841
+ # @return [Integer]
1842
+ # @scope class
1843
+ attach_function :is_invalid, :clang_isInvalid, [:cursor_kind], :uint
1844
+
1845
+ # Determine whether the given cursor kind represents a translation
1846
+ # unit.
1847
+ #
1848
+ # @method is_translation_unit(cursor_kind)
1849
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1850
+ # @return [Integer]
1851
+ # @scope class
1852
+ attach_function :is_translation_unit, :clang_isTranslationUnit, [:cursor_kind], :uint
1853
+
1854
+ # Determine whether the given cursor represents a preprocessing
1855
+ # element, such as a preprocessor directive or macro instantiation.
1856
+ #
1857
+ # @method is_preprocessing(cursor_kind)
1858
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1859
+ # @return [Integer]
1860
+ # @scope class
1861
+ attach_function :is_preprocessing, :clang_isPreprocessing, [:cursor_kind], :uint
1862
+
1863
+ # Determine whether the given cursor represents a currently
1864
+ # unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
1865
+ #
1866
+ # @method is_unexposed(cursor_kind)
1867
+ # @param [Symbol from _enum_cursor_kind_] cursor_kind
1868
+ # @return [Integer]
1869
+ # @scope class
1870
+ attach_function :is_unexposed, :clang_isUnexposed, [:cursor_kind], :uint
1871
+
1872
+ # Describe the linkage of the entity referred to by a cursor.
1873
+ #
1874
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:linkage_kind).</em>
1875
+ #
1876
+ # === Options:
1877
+ # :invalid ::
1878
+ # This value indicates that no linkage information is available
1879
+ # for a provided CXCursor.
1880
+ # :no_linkage ::
1881
+ # This is the linkage for variables, parameters, and so on that
1882
+ # have automatic storage. This covers normal (non-extern) local variables.
1883
+ # :internal ::
1884
+ # This is the linkage for static variables and static functions.
1885
+ # :unique_external ::
1886
+ # This is the linkage for entities with external linkage that live
1887
+ # in C++ anonymous namespaces.
1888
+ # :external ::
1889
+ # This is the linkage for entities with true, external linkage.
1890
+ #
1891
+ # @method _enum_linkage_kind_
1892
+ # @return [Symbol]
1893
+ # @scope class
1894
+ enum :linkage_kind, [
1895
+ :invalid,
1896
+ :no_linkage,
1897
+ :internal,
1898
+ :unique_external,
1899
+ :external
1900
+ ]
1901
+
1902
+ # Determine the linkage of the entity referred to by a given cursor.
1903
+ #
1904
+ # @method get_cursor_linkage(cursor)
1905
+ # @param [Cursor] cursor
1906
+ # @return [Symbol from _enum_linkage_kind_]
1907
+ # @scope class
1908
+ attach_function :get_cursor_linkage, :clang_getCursorLinkage, [Cursor.by_value], :linkage_kind
1909
+
1910
+ # Determine the availability of the entity that this cursor refers to.
1911
+ #
1912
+ # @method get_cursor_availability(cursor)
1913
+ # @param [Cursor] cursor The cursor to query.
1914
+ # @return [Symbol from _enum_availability_kind_] The availability of the cursor.
1915
+ # @scope class
1916
+ attach_function :get_cursor_availability, :clang_getCursorAvailability, [Cursor.by_value], :availability_kind
1917
+
1918
+ # Describe the "language" of the entity referred to by a cursor.
1919
+ #
1920
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:language_kind).</em>
1921
+ #
1922
+ # === Options:
1923
+ # :invalid ::
1924
+ #
1925
+ # :c ::
1926
+ #
1927
+ # :obj_c ::
1928
+ #
1929
+ # :c_plus_plus ::
1930
+ #
1931
+ #
1932
+ # @method _enum_language_kind_
1933
+ # @return [Symbol]
1934
+ # @scope class
1935
+ enum :language_kind, [
1936
+ :invalid, 0,
1937
+ :c,
1938
+ :obj_c,
1939
+ :c_plus_plus
1940
+ ]
1941
+
1942
+ # Determine the "language" of the entity referred to by a given cursor.
1943
+ #
1944
+ # @method get_cursor_language(cursor)
1945
+ # @param [Cursor] cursor
1946
+ # @return [Symbol from _enum_language_kind_]
1947
+ # @scope class
1948
+ attach_function :get_cursor_language, :clang_getCursorLanguage, [Cursor.by_value], :language_kind
1949
+
1950
+ # Returns the translation unit that a cursor originated from.
1951
+ #
1952
+ # @method cursor_get_translation_unit(cursor)
1953
+ # @param [Cursor] cursor
1954
+ # @return [TranslationUnitImpl]
1955
+ # @scope class
1956
+ attach_function :cursor_get_translation_unit, :clang_Cursor_getTranslationUnit, [Cursor.by_value], TranslationUnitImpl
1957
+
1958
+ # A fast container representing a set of CXCursors.
1959
+ class CursorSetImpl < FFI::Struct
1960
+ layout :dummy, :char
1961
+ end
1962
+
1963
+ # Creates an empty CXCursorSet.
1964
+ #
1965
+ # @method create_cx_cursor_set()
1966
+ # @return [CursorSetImpl]
1967
+ # @scope class
1968
+ attach_function :create_cx_cursor_set, :clang_createCXCursorSet, [], CursorSetImpl
1969
+
1970
+ # Disposes a CXCursorSet and releases its associated memory.
1971
+ #
1972
+ # @method dispose_cx_cursor_set(cset)
1973
+ # @param [CursorSetImpl] cset
1974
+ # @return [nil]
1975
+ # @scope class
1976
+ attach_function :dispose_cx_cursor_set, :clang_disposeCXCursorSet, [CursorSetImpl], :void
1977
+
1978
+ # Queries a CXCursorSet to see if it contains a specific CXCursor.
1979
+ #
1980
+ # @method cx_cursor_set_contains(cset, cursor)
1981
+ # @param [CursorSetImpl] cset
1982
+ # @param [Cursor] cursor
1983
+ # @return [Integer] non-zero if the set contains the specified cursor.
1984
+ # @scope class
1985
+ attach_function :cx_cursor_set_contains, :clang_CXCursorSet_contains, [CursorSetImpl, Cursor.by_value], :uint
1986
+
1987
+ # Inserts a CXCursor into a CXCursorSet.
1988
+ #
1989
+ # @method cx_cursor_set_insert(cset, cursor)
1990
+ # @param [CursorSetImpl] cset
1991
+ # @param [Cursor] cursor
1992
+ # @return [Integer] zero if the CXCursor was already in the set, and non-zero otherwise.
1993
+ # @scope class
1994
+ attach_function :cx_cursor_set_insert, :clang_CXCursorSet_insert, [CursorSetImpl, Cursor.by_value], :uint
1995
+
1996
+ # Determine the semantic parent of the given cursor.
1997
+ #
1998
+ # The semantic parent of a cursor is the cursor that semantically contains
1999
+ # the given \p cursor. For many declarations, the lexical and semantic parents
2000
+ # are equivalent (the lexical parent is returned by
2001
+ # \c clang_getCursorLexicalParent()). They diverge when declarations or
2002
+ # definitions are provided out-of-line. For example:
2003
+ #
2004
+ # \code
2005
+ # class C {
2006
+ # void f();
2007
+ # };
2008
+ #
2009
+ # void C::f() { }
2010
+ # \endcode
2011
+ #
2012
+ # In the out-of-line definition of \c C::f, the semantic parent is the
2013
+ # the class \c C, of which this function is a member. The lexical parent is
2014
+ # the place where the declaration actually occurs in the source code; in this
2015
+ # case, the definition occurs in the translation unit. In general, the
2016
+ # lexical parent for a given entity can change without affecting the semantics
2017
+ # of the program, and the lexical parent of different declarations of the
2018
+ # same entity may be different. Changing the semantic parent of a declaration,
2019
+ # on the other hand, can have a major impact on semantics, and redeclarations
2020
+ # of a particular entity should all have the same semantic context.
2021
+ #
2022
+ # In the example above, both declarations of \c C::f have \c C as their
2023
+ # semantic context, while the lexical context of the first \c C::f is \c C
2024
+ # and the lexical context of the second \c C::f is the translation unit.
2025
+ #
2026
+ # For global declarations, the semantic parent is the translation unit.
2027
+ #
2028
+ # @method get_cursor_semantic_parent(cursor)
2029
+ # @param [Cursor] cursor
2030
+ # @return [Cursor]
2031
+ # @scope class
2032
+ attach_function :get_cursor_semantic_parent, :clang_getCursorSemanticParent, [Cursor.by_value], Cursor.by_value
2033
+
2034
+ # Determine the lexical parent of the given cursor.
2035
+ #
2036
+ # The lexical parent of a cursor is the cursor in which the given \p cursor
2037
+ # was actually written. For many declarations, the lexical and semantic parents
2038
+ # are equivalent (the semantic parent is returned by
2039
+ # \c clang_getCursorSemanticParent()). They diverge when declarations or
2040
+ # definitions are provided out-of-line. For example:
2041
+ #
2042
+ # \code
2043
+ # class C {
2044
+ # void f();
2045
+ # };
2046
+ #
2047
+ # void C::f() { }
2048
+ # \endcode
2049
+ #
2050
+ # In the out-of-line definition of \c C::f, the semantic parent is the
2051
+ # the class \c C, of which this function is a member. The lexical parent is
2052
+ # the place where the declaration actually occurs in the source code; in this
2053
+ # case, the definition occurs in the translation unit. In general, the
2054
+ # lexical parent for a given entity can change without affecting the semantics
2055
+ # of the program, and the lexical parent of different declarations of the
2056
+ # same entity may be different. Changing the semantic parent of a declaration,
2057
+ # on the other hand, can have a major impact on semantics, and redeclarations
2058
+ # of a particular entity should all have the same semantic context.
2059
+ #
2060
+ # In the example above, both declarations of \c C::f have \c C as their
2061
+ # semantic context, while the lexical context of the first \c C::f is \c C
2062
+ # and the lexical context of the second \c C::f is the translation unit.
2063
+ #
2064
+ # For declarations written in the global scope, the lexical parent is
2065
+ # the translation unit.
2066
+ #
2067
+ # @method get_cursor_lexical_parent(cursor)
2068
+ # @param [Cursor] cursor
2069
+ # @return [Cursor]
2070
+ # @scope class
2071
+ attach_function :get_cursor_lexical_parent, :clang_getCursorLexicalParent, [Cursor.by_value], Cursor.by_value
2072
+
2073
+ # Determine the set of methods that are overridden by the given
2074
+ # method.
2075
+ #
2076
+ # In both Objective-C and C++, a method (aka virtual member function,
2077
+ # in C++) can override a virtual method in a base class. For
2078
+ # Objective-C, a method is said to override any method in the class's
2079
+ # interface (if we're coming from an implementation), its protocols,
2080
+ # or its categories, that has the same selector and is of the same
2081
+ # kind (class or instance). If no such method exists, the search
2082
+ # continues to the class's superclass, its protocols, and its
2083
+ # categories, and so on.
2084
+ #
2085
+ # For C++, a virtual member function overrides any virtual member
2086
+ # function with the same signature that occurs in its base
2087
+ # classes. With multiple inheritance, a virtual member function can
2088
+ # override several virtual member functions coming from different
2089
+ # base classes.
2090
+ #
2091
+ # In all cases, this function determines the immediate overridden
2092
+ # method, rather than all of the overridden methods. For example, if
2093
+ # a method is originally declared in a class A, then overridden in B
2094
+ # (which in inherits from A) and also in C (which inherited from B),
2095
+ # then the only overridden method returned from this function when
2096
+ # invoked on C's method will be B's method. The client may then
2097
+ # invoke this function again, given the previously-found overridden
2098
+ # methods, to map out the complete method-override set.
2099
+ #
2100
+ # @method get_overridden_cursors(cursor, overridden, num_overridden)
2101
+ # @param [Cursor] cursor A cursor representing an Objective-C or C++
2102
+ # method. This routine will compute the set of methods that this
2103
+ # method overrides.
2104
+ # @param [FFI::Pointer(**Cursor)] overridden A pointer whose pointee will be replaced with a
2105
+ # pointer to an array of cursors, representing the set of overridden
2106
+ # methods. If there are no overridden methods, the pointee will be
2107
+ # set to NULL. The pointee must be freed via a call to
2108
+ # \c clang_disposeOverriddenCursors().
2109
+ # @param [FFI::Pointer(*UInt)] num_overridden A pointer to the number of overridden
2110
+ # functions, will be set to the number of overridden functions in the
2111
+ # array pointed to by \p overridden.
2112
+ # @return [nil]
2113
+ # @scope class
2114
+ attach_function :get_overridden_cursors, :clang_getOverriddenCursors, [Cursor.by_value, :pointer, :pointer], :void
2115
+
2116
+ # Free the set of overridden cursors returned by \c
2117
+ # clang_getOverriddenCursors().
2118
+ #
2119
+ # @method dispose_overridden_cursors(overridden)
2120
+ # @param [Cursor] overridden
2121
+ # @return [nil]
2122
+ # @scope class
2123
+ attach_function :dispose_overridden_cursors, :clang_disposeOverriddenCursors, [Cursor], :void
2124
+
2125
+ # Retrieve the file that is included by the given inclusion directive
2126
+ # cursor.
2127
+ #
2128
+ # @method get_included_file(cursor)
2129
+ # @param [Cursor] cursor
2130
+ # @return [FFI::Pointer(File)]
2131
+ # @scope class
2132
+ attach_function :get_included_file, :clang_getIncludedFile, [Cursor.by_value], :pointer
2133
+
2134
+ # Map a source location to the cursor that describes the entity at that
2135
+ # location in the source code.
2136
+ #
2137
+ # clang_getCursor() maps an arbitrary source location within a translation
2138
+ # unit down to the most specific cursor that describes the entity at that
2139
+ # location. For example, given an expression \c x + y, invoking
2140
+ # clang_getCursor() with a source location pointing to "x" will return the
2141
+ # cursor for "x"; similarly for "y". If the cursor points anywhere between
2142
+ # "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2143
+ # will return a cursor referring to the "+" expression.
2144
+ #
2145
+ # @method get_cursor(translation_unit_impl, source_location)
2146
+ # @param [TranslationUnitImpl] translation_unit_impl
2147
+ # @param [SourceLocation] source_location
2148
+ # @return [Cursor] a cursor representing the entity at the given source location, or
2149
+ # a NULL cursor if no such entity can be found.
2150
+ # @scope class
2151
+ attach_function :get_cursor, :clang_getCursor, [TranslationUnitImpl, SourceLocation.by_value], Cursor.by_value
2152
+
2153
+ # Retrieve the physical location of the source constructor referenced
2154
+ # by the given cursor.
2155
+ #
2156
+ # The location of a declaration is typically the location of the name of that
2157
+ # declaration, where the name of that declaration would occur if it is
2158
+ # unnamed, or some keyword that introduces that particular declaration.
2159
+ # The location of a reference is where that reference occurs within the
2160
+ # source code.
2161
+ #
2162
+ # @method get_cursor_location(cursor)
2163
+ # @param [Cursor] cursor
2164
+ # @return [SourceLocation]
2165
+ # @scope class
2166
+ attach_function :get_cursor_location, :clang_getCursorLocation, [Cursor.by_value], SourceLocation.by_value
2167
+
2168
+ # Retrieve the physical extent of the source construct referenced by
2169
+ # the given cursor.
2170
+ #
2171
+ # The extent of a cursor starts with the file/line/column pointing at the
2172
+ # first character within the source construct that the cursor refers to and
2173
+ # ends with the last character withinin that source construct. For a
2174
+ # declaration, the extent covers the declaration itself. For a reference,
2175
+ # the extent covers the location of the reference (e.g., where the referenced
2176
+ # entity was actually used).
2177
+ #
2178
+ # @method get_cursor_extent(cursor)
2179
+ # @param [Cursor] cursor
2180
+ # @return [SourceRange]
2181
+ # @scope class
2182
+ attach_function :get_cursor_extent, :clang_getCursorExtent, [Cursor.by_value], SourceRange.by_value
2183
+
2184
+ # Describes the kind of type
2185
+ #
2186
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:type_kind).</em>
2187
+ #
2188
+ # === Options:
2189
+ # :invalid ::
2190
+ # Reprents an invalid type (e.g., where no type is available).
2191
+ # :unexposed ::
2192
+ # A type whose specific kind is not exposed via this
2193
+ # interface.
2194
+ # :void ::
2195
+ # Builtin types
2196
+ # :bool ::
2197
+ #
2198
+ # :char_u ::
2199
+ #
2200
+ # :u_char ::
2201
+ #
2202
+ # :char16 ::
2203
+ #
2204
+ # :char32 ::
2205
+ #
2206
+ # :u_short ::
2207
+ #
2208
+ # :u_int ::
2209
+ #
2210
+ # :u_long ::
2211
+ #
2212
+ # :u_long_long ::
2213
+ #
2214
+ # :u_int128 ::
2215
+ #
2216
+ # :char_s ::
2217
+ #
2218
+ # :s_char ::
2219
+ #
2220
+ # :w_char ::
2221
+ #
2222
+ # :short ::
2223
+ #
2224
+ # :int ::
2225
+ #
2226
+ # :long ::
2227
+ #
2228
+ # :long_long ::
2229
+ #
2230
+ # :int128 ::
2231
+ #
2232
+ # :float ::
2233
+ #
2234
+ # :double ::
2235
+ #
2236
+ # :long_double ::
2237
+ #
2238
+ # :null_ptr ::
2239
+ #
2240
+ # :overload ::
2241
+ #
2242
+ # :dependent ::
2243
+ #
2244
+ # :obj_c_id ::
2245
+ #
2246
+ # :obj_c_class ::
2247
+ #
2248
+ # :obj_c_sel ::
2249
+ #
2250
+ # :complex ::
2251
+ #
2252
+ # :pointer ::
2253
+ #
2254
+ # :block_pointer ::
2255
+ #
2256
+ # :l_value_reference ::
2257
+ #
2258
+ # :r_value_reference ::
2259
+ #
2260
+ # :record ::
2261
+ #
2262
+ # :enum ::
2263
+ #
2264
+ # :typedef ::
2265
+ #
2266
+ # :obj_c_interface ::
2267
+ #
2268
+ # :obj_c_object_pointer ::
2269
+ #
2270
+ # :function_no_proto ::
2271
+ #
2272
+ # :function_proto ::
2273
+ #
2274
+ # :constant_array ::
2275
+ #
2276
+ #
2277
+ # @method _enum_type_kind_
2278
+ # @return [Symbol]
2279
+ # @scope class
2280
+ enum :type_kind, [
2281
+ :invalid, 0,
2282
+ :unexposed, 1,
2283
+ :void, 2,
2284
+ :bool, 3,
2285
+ :char_u, 4,
2286
+ :u_char, 5,
2287
+ :char16, 6,
2288
+ :char32, 7,
2289
+ :u_short, 8,
2290
+ :u_int, 9,
2291
+ :u_long, 10,
2292
+ :u_long_long, 11,
2293
+ :u_int128, 12,
2294
+ :char_s, 13,
2295
+ :s_char, 14,
2296
+ :w_char, 15,
2297
+ :short, 16,
2298
+ :int, 17,
2299
+ :long, 18,
2300
+ :long_long, 19,
2301
+ :int128, 20,
2302
+ :float, 21,
2303
+ :double, 22,
2304
+ :long_double, 23,
2305
+ :null_ptr, 24,
2306
+ :overload, 25,
2307
+ :dependent, 26,
2308
+ :obj_c_id, 27,
2309
+ :obj_c_class, 28,
2310
+ :obj_c_sel, 29,
2311
+ :complex, 100,
2312
+ :pointer, 101,
2313
+ :block_pointer, 102,
2314
+ :l_value_reference, 103,
2315
+ :r_value_reference, 104,
2316
+ :record, 105,
2317
+ :enum, 106,
2318
+ :typedef, 107,
2319
+ :obj_c_interface, 108,
2320
+ :obj_c_object_pointer, 109,
2321
+ :function_no_proto, 110,
2322
+ :function_proto, 111,
2323
+ :constant_array, 112
2324
+ ]
2325
+
2326
+ # The type of an element in the abstract syntax tree.
2327
+ #
2328
+ # = Fields:
2329
+ # :kind ::
2330
+ # (Symbol from _enum_type_kind_)
2331
+ # :data ::
2332
+ # (Array<FFI::Pointer(*Void)>)
2333
+ class Type < FFI::Struct
2334
+ layout :kind, :type_kind,
2335
+ :data, [:pointer, 2]
2336
+ end
2337
+
2338
+ # Retrieve the type of a CXCursor (if any).
2339
+ #
2340
+ # @method get_cursor_type(c)
2341
+ # @param [Cursor] c
2342
+ # @return [Type]
2343
+ # @scope class
2344
+ attach_function :get_cursor_type, :clang_getCursorType, [Cursor.by_value], Type.by_value
2345
+
2346
+ # Determine whether two CXTypes represent the same type.
2347
+ #
2348
+ # @method equal_types(a, b)
2349
+ # @param [Type] a
2350
+ # @param [Type] b
2351
+ # @return [Integer] non-zero if the CXTypes represent the same type and
2352
+ # zero otherwise.
2353
+ # @scope class
2354
+ attach_function :equal_types, :clang_equalTypes, [Type.by_value, Type.by_value], :uint
2355
+
2356
+ # Return the canonical type for a CXType.
2357
+ #
2358
+ # Clang's type system explicitly models typedefs and all the ways
2359
+ # a specific type can be represented. The canonical type is the underlying
2360
+ # type with all the "sugar" removed. For example, if 'T' is a typedef
2361
+ # for 'int', the canonical type for 'T' would be 'int'.
2362
+ #
2363
+ # @method get_canonical_type(t)
2364
+ # @param [Type] t
2365
+ # @return [Type]
2366
+ # @scope class
2367
+ attach_function :get_canonical_type, :clang_getCanonicalType, [Type.by_value], Type.by_value
2368
+
2369
+ # Determine whether a CXType has the "const" qualifier set,
2370
+ # without looking through typedefs that may have added "const" at a different level.
2371
+ #
2372
+ # @method is_const_qualified_type(t)
2373
+ # @param [Type] t
2374
+ # @return [Integer]
2375
+ # @scope class
2376
+ attach_function :is_const_qualified_type, :clang_isConstQualifiedType, [Type.by_value], :uint
2377
+
2378
+ # Determine whether a CXType has the "volatile" qualifier set,
2379
+ # without looking through typedefs that may have added "volatile" at a different level.
2380
+ #
2381
+ # @method is_volatile_qualified_type(t)
2382
+ # @param [Type] t
2383
+ # @return [Integer]
2384
+ # @scope class
2385
+ attach_function :is_volatile_qualified_type, :clang_isVolatileQualifiedType, [Type.by_value], :uint
2386
+
2387
+ # Determine whether a CXType has the "restrict" qualifier set,
2388
+ # without looking through typedefs that may have added "restrict" at a different level.
2389
+ #
2390
+ # @method is_restrict_qualified_type(t)
2391
+ # @param [Type] t
2392
+ # @return [Integer]
2393
+ # @scope class
2394
+ attach_function :is_restrict_qualified_type, :clang_isRestrictQualifiedType, [Type.by_value], :uint
2395
+
2396
+ # For pointer types, returns the type of the pointee.
2397
+ #
2398
+ # @method get_pointee_type(t)
2399
+ # @param [Type] t
2400
+ # @return [Type]
2401
+ # @scope class
2402
+ attach_function :get_pointee_type, :clang_getPointeeType, [Type.by_value], Type.by_value
2403
+
2404
+ # Return the cursor for the declaration of the given type.
2405
+ #
2406
+ # @method get_type_declaration(t)
2407
+ # @param [Type] t
2408
+ # @return [Cursor]
2409
+ # @scope class
2410
+ attach_function :get_type_declaration, :clang_getTypeDeclaration, [Type.by_value], Cursor.by_value
2411
+
2412
+ # Returns the Objective-C type encoding for the specified declaration.
2413
+ #
2414
+ # @method get_decl_obj_c_type_encoding(c)
2415
+ # @param [Cursor] c
2416
+ # @return [String]
2417
+ # @scope class
2418
+ attach_function :get_decl_obj_c_type_encoding, :clang_getDeclObjCTypeEncoding, [Cursor.by_value], String.by_value
2419
+
2420
+ # Retrieve the spelling of a given CXTypeKind.
2421
+ #
2422
+ # @method get_type_kind_spelling(k)
2423
+ # @param [Symbol from _enum_type_kind_] k
2424
+ # @return [String]
2425
+ # @scope class
2426
+ attach_function :get_type_kind_spelling, :clang_getTypeKindSpelling, [:type_kind], String.by_value
2427
+
2428
+ # Retrieve the result type associated with a function type.
2429
+ #
2430
+ # @method get_result_type(t)
2431
+ # @param [Type] t
2432
+ # @return [Type]
2433
+ # @scope class
2434
+ attach_function :get_result_type, :clang_getResultType, [Type.by_value], Type.by_value
2435
+
2436
+ # Retrieve the result type associated with a given cursor. This only
2437
+ # returns a valid type of the cursor refers to a function or method.
2438
+ #
2439
+ # @method get_cursor_result_type(c)
2440
+ # @param [Cursor] c
2441
+ # @return [Type]
2442
+ # @scope class
2443
+ attach_function :get_cursor_result_type, :clang_getCursorResultType, [Cursor.by_value], Type.by_value
2444
+
2445
+ # Return 1 if the CXType is a POD (plain old data) type, and 0
2446
+ # otherwise.
2447
+ #
2448
+ # @method is_pod_type(t)
2449
+ # @param [Type] t
2450
+ # @return [Integer]
2451
+ # @scope class
2452
+ attach_function :is_pod_type, :clang_isPODType, [Type.by_value], :uint
2453
+
2454
+ # Return the element type of an array type.
2455
+ #
2456
+ # If a non-array type is passed in, an invalid type is returned.
2457
+ #
2458
+ # @method get_array_element_type(t)
2459
+ # @param [Type] t
2460
+ # @return [Type]
2461
+ # @scope class
2462
+ attach_function :get_array_element_type, :clang_getArrayElementType, [Type.by_value], Type.by_value
2463
+
2464
+ # Return the the array size of a constant array.
2465
+ #
2466
+ # If a non-array type is passed in, -1 is returned.
2467
+ #
2468
+ # @method get_array_size(t)
2469
+ # @param [Type] t
2470
+ # @return [Integer]
2471
+ # @scope class
2472
+ attach_function :get_array_size, :clang_getArraySize, [Type.by_value], :long_long
2473
+
2474
+ # Returns 1 if the base class specified by the cursor with kind
2475
+ # CX_CXXBaseSpecifier is virtual.
2476
+ #
2477
+ # @method is_virtual_base(cursor)
2478
+ # @param [Cursor] cursor
2479
+ # @return [Integer]
2480
+ # @scope class
2481
+ attach_function :is_virtual_base, :clang_isVirtualBase, [Cursor.by_value], :uint
2482
+
2483
+ # Represents the C++ access control level to a base class for a
2484
+ # cursor with kind CX_CXXBaseSpecifier.
2485
+ #
2486
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:cxx_access_specifier).</em>
2487
+ #
2488
+ # === Options:
2489
+ # :x_invalid_access_specifier ::
2490
+ #
2491
+ # :x_public ::
2492
+ #
2493
+ # :x_protected ::
2494
+ #
2495
+ # :x_private ::
2496
+ #
2497
+ #
2498
+ # @method _enum_cxx_access_specifier_
2499
+ # @return [Symbol]
2500
+ # @scope class
2501
+ enum :cxx_access_specifier, [
2502
+ :x_invalid_access_specifier,
2503
+ :x_public,
2504
+ :x_protected,
2505
+ :x_private
2506
+ ]
2507
+
2508
+ # Returns the access control level for the C++ base specifier
2509
+ # represented by a cursor with kind CXCursor_CXXBaseSpecifier or
2510
+ # CXCursor_AccessSpecifier.
2511
+ #
2512
+ # @method get_cxx_access_specifier(cursor)
2513
+ # @param [Cursor] cursor
2514
+ # @return [Symbol from _enum_cxx_access_specifier_]
2515
+ # @scope class
2516
+ attach_function :get_cxx_access_specifier, :clang_getCXXAccessSpecifier, [Cursor.by_value], :cxx_access_specifier
2517
+
2518
+ # Determine the number of overloaded declarations referenced by a
2519
+ # \c CXCursor_OverloadedDeclRef cursor.
2520
+ #
2521
+ # @method get_num_overloaded_decls(cursor)
2522
+ # @param [Cursor] cursor The cursor whose overloaded declarations are being queried.
2523
+ # @return [Integer] The number of overloaded declarations referenced by \c cursor. If it
2524
+ # is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
2525
+ # @scope class
2526
+ attach_function :get_num_overloaded_decls, :clang_getNumOverloadedDecls, [Cursor.by_value], :uint
2527
+
2528
+ # Retrieve a cursor for one of the overloaded declarations referenced
2529
+ # by a \c CXCursor_OverloadedDeclRef cursor.
2530
+ #
2531
+ # @method get_overloaded_decl(cursor, index)
2532
+ # @param [Cursor] cursor The cursor whose overloaded declarations are being queried.
2533
+ # @param [Integer] index The zero-based index into the set of overloaded declarations in
2534
+ # the cursor.
2535
+ # @return [Cursor] A cursor representing the declaration referenced by the given
2536
+ # \c cursor at the specified \c index. If the cursor does not have an
2537
+ # associated set of overloaded declarations, or if the index is out of bounds,
2538
+ # returns \c clang_getNullCursor();
2539
+ # @scope class
2540
+ attach_function :get_overloaded_decl, :clang_getOverloadedDecl, [Cursor.by_value, :uint], Cursor.by_value
2541
+
2542
+ # For cursors representing an iboutletcollection attribute,
2543
+ # this function returns the collection element type.
2544
+ #
2545
+ # @method get_ib_outlet_collection_type(cursor)
2546
+ # @param [Cursor] cursor
2547
+ # @return [Type]
2548
+ # @scope class
2549
+ attach_function :get_ib_outlet_collection_type, :clang_getIBOutletCollectionType, [Cursor.by_value], Type.by_value
2550
+
2551
+ # Describes how the traversal of the children of a particular
2552
+ # cursor should proceed after visiting a particular child cursor.
2553
+ #
2554
+ # A value of this enumeration type should be returned by each
2555
+ # \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
2556
+ #
2557
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:child_visit_result).</em>
2558
+ #
2559
+ # === Options:
2560
+ # :break ::
2561
+ # Terminates the cursor traversal.
2562
+ # :continue ::
2563
+ # Continues the cursor traversal with the next sibling of
2564
+ # the cursor just visited, without visiting its children.
2565
+ # :recurse ::
2566
+ # Recursively traverse the children of this cursor, using
2567
+ # the same visitor and client data.
2568
+ #
2569
+ # @method _enum_child_visit_result_
2570
+ # @return [Symbol]
2571
+ # @scope class
2572
+ enum :child_visit_result, [
2573
+ :break,
2574
+ :continue,
2575
+ :recurse
2576
+ ]
2577
+
2578
+ # Visitor invoked for each cursor found by a traversal.
2579
+ #
2580
+ # This visitor function will be invoked for each cursor found by
2581
+ # clang_visitCursorChildren(). Its first argument is the cursor being
2582
+ # visited, its second argument is the parent visitor for that cursor,
2583
+ # and its third argument is the client data provided to
2584
+ # clang_visitCursorChildren().
2585
+ #
2586
+ # The visitor should return one of the \c CXChildVisitResult values
2587
+ # to direct clang_visitCursorChildren().
2588
+ #
2589
+ # <em>This entry is only for documentation and no real method.</em>
2590
+ #
2591
+ # @method _callback_cursor_visitor_(cursor, parent, client_data)
2592
+ # @param [Cursor] cursor
2593
+ # @param [Cursor] parent
2594
+ # @param [FFI::Pointer(ClientData)] client_data
2595
+ # @return [Symbol from _enum_child_visit_result_]
2596
+ # @scope class
2597
+ callback :cursor_visitor, [Cursor.by_value, Cursor.by_value, :pointer], :child_visit_result
2598
+
2599
+ # Visit the children of a particular cursor.
2600
+ #
2601
+ # This function visits all the direct children of the given cursor,
2602
+ # invoking the given \p visitor function with the cursors of each
2603
+ # visited child. The traversal may be recursive, if the visitor returns
2604
+ # \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
2605
+ # the visitor returns \c CXChildVisit_Break.
2606
+ #
2607
+ # @method visit_children(parent, visitor, client_data)
2608
+ # @param [Cursor] parent the cursor whose child may be visited. All kinds of
2609
+ # cursors can be visited, including invalid cursors (which, by
2610
+ # definition, have no children).
2611
+ # @param [Proc(_callback_cursor_visitor_)] visitor the visitor function that will be invoked for each
2612
+ # child of \p parent.
2613
+ # @param [FFI::Pointer(ClientData)] client_data pointer data supplied by the client, which will
2614
+ # be passed to the visitor each time it is invoked.
2615
+ # @return [Integer] a non-zero value if the traversal was terminated
2616
+ # prematurely by the visitor returning \c CXChildVisit_Break.
2617
+ # @scope class
2618
+ attach_function :visit_children, :clang_visitChildren, [Cursor.by_value, :cursor_visitor, :pointer], :uint
2619
+
2620
+ # Retrieve a Unified Symbol Resolution (USR) for the entity referenced
2621
+ # by the given cursor.
2622
+ #
2623
+ # A Unified Symbol Resolution (USR) is a string that identifies a particular
2624
+ # entity (function, class, variable, etc.) within a program. USRs can be
2625
+ # compared across translation units to determine, e.g., when references in
2626
+ # one translation refer to an entity defined in another translation unit.
2627
+ #
2628
+ # @method get_cursor_usr(cursor)
2629
+ # @param [Cursor] cursor
2630
+ # @return [String]
2631
+ # @scope class
2632
+ attach_function :get_cursor_usr, :clang_getCursorUSR, [Cursor.by_value], String.by_value
2633
+
2634
+ # Construct a USR for a specified Objective-C class.
2635
+ #
2636
+ # @method construct_usr_obj_c_class(class_name)
2637
+ # @param [String] class_name
2638
+ # @return [String]
2639
+ # @scope class
2640
+ attach_function :construct_usr_obj_c_class, :clang_constructUSR_ObjCClass, [:string], String.by_value
2641
+
2642
+ # Construct a USR for a specified Objective-C category.
2643
+ #
2644
+ # @method construct_usr_obj_c_category(class_name, category_name)
2645
+ # @param [String] class_name
2646
+ # @param [String] category_name
2647
+ # @return [String]
2648
+ # @scope class
2649
+ attach_function :construct_usr_obj_c_category, :clang_constructUSR_ObjCCategory, [:string, :string], String.by_value
2650
+
2651
+ # Construct a USR for a specified Objective-C protocol.
2652
+ #
2653
+ # @method construct_usr_obj_c_protocol(protocol_name)
2654
+ # @param [String] protocol_name
2655
+ # @return [String]
2656
+ # @scope class
2657
+ attach_function :construct_usr_obj_c_protocol, :clang_constructUSR_ObjCProtocol, [:string], String.by_value
2658
+
2659
+ # Construct a USR for a specified Objective-C instance variable and
2660
+ # the USR for its containing class.
2661
+ #
2662
+ # @method construct_usr_obj_c_ivar(name, class_usr)
2663
+ # @param [String] name
2664
+ # @param [String] class_usr
2665
+ # @return [String]
2666
+ # @scope class
2667
+ attach_function :construct_usr_obj_c_ivar, :clang_constructUSR_ObjCIvar, [:string, String.by_value], String.by_value
2668
+
2669
+ # Construct a USR for a specified Objective-C method and
2670
+ # the USR for its containing class.
2671
+ #
2672
+ # @method construct_usr_obj_c_method(name, is_instance_method, class_usr)
2673
+ # @param [String] name
2674
+ # @param [Integer] is_instance_method
2675
+ # @param [String] class_usr
2676
+ # @return [String]
2677
+ # @scope class
2678
+ attach_function :construct_usr_obj_c_method, :clang_constructUSR_ObjCMethod, [:string, :uint, String.by_value], String.by_value
2679
+
2680
+ # Construct a USR for a specified Objective-C property and the USR
2681
+ # for its containing class.
2682
+ #
2683
+ # @method construct_usr_obj_c_property(property, class_usr)
2684
+ # @param [String] property
2685
+ # @param [String] class_usr
2686
+ # @return [String]
2687
+ # @scope class
2688
+ attach_function :construct_usr_obj_c_property, :clang_constructUSR_ObjCProperty, [:string, String.by_value], String.by_value
2689
+
2690
+ # Retrieve a name for the entity referenced by this cursor.
2691
+ #
2692
+ # @method get_cursor_spelling(cursor)
2693
+ # @param [Cursor] cursor
2694
+ # @return [String]
2695
+ # @scope class
2696
+ attach_function :get_cursor_spelling, :clang_getCursorSpelling, [Cursor.by_value], String.by_value
2697
+
2698
+ # Retrieve the display name for the entity referenced by this cursor.
2699
+ #
2700
+ # The display name contains extra information that helps identify the cursor,
2701
+ # such as the parameters of a function or template or the arguments of a
2702
+ # class template specialization.
2703
+ #
2704
+ # @method get_cursor_display_name(cursor)
2705
+ # @param [Cursor] cursor
2706
+ # @return [String]
2707
+ # @scope class
2708
+ attach_function :get_cursor_display_name, :clang_getCursorDisplayName, [Cursor.by_value], String.by_value
2709
+
2710
+ # For a cursor that is a reference, retrieve a cursor representing the
2711
+ # entity that it references.
2712
+ #
2713
+ # Reference cursors refer to other entities in the AST. For example, an
2714
+ # Objective-C superclass reference cursor refers to an Objective-C class.
2715
+ # This function produces the cursor for the Objective-C class from the
2716
+ # cursor for the superclass reference. If the input cursor is a declaration or
2717
+ # definition, it returns that declaration or definition unchanged.
2718
+ # Otherwise, returns the NULL cursor.
2719
+ #
2720
+ # @method get_cursor_referenced(cursor)
2721
+ # @param [Cursor] cursor
2722
+ # @return [Cursor]
2723
+ # @scope class
2724
+ attach_function :get_cursor_referenced, :clang_getCursorReferenced, [Cursor.by_value], Cursor.by_value
2725
+
2726
+ # For a cursor that is either a reference to or a declaration
2727
+ # of some entity, retrieve a cursor that describes the definition of
2728
+ # that entity.
2729
+ #
2730
+ # Some entities can be declared multiple times within a translation
2731
+ # unit, but only one of those declarations can also be a
2732
+ # definition. For example, given:
2733
+ #
2734
+ # \code
2735
+ # int f(int, int);
2736
+ # int g(int x, int y) { return f(x, y); }
2737
+ # int f(int a, int b) { return a + b; }
2738
+ # int f(int, int);
2739
+ # \endcode
2740
+ #
2741
+ # there are three declarations of the function "f", but only the
2742
+ # second one is a definition. The clang_getCursorDefinition()
2743
+ # function will take any cursor pointing to a declaration of "f"
2744
+ # (the first or fourth lines of the example) or a cursor referenced
2745
+ # that uses "f" (the call to "f' inside "g") and will return a
2746
+ # declaration cursor pointing to the definition (the second "f"
2747
+ # declaration).
2748
+ #
2749
+ # If given a cursor for which there is no corresponding definition,
2750
+ # e.g., because there is no definition of that entity within this
2751
+ # translation unit, returns a NULL cursor.
2752
+ #
2753
+ # @method get_cursor_definition(cursor)
2754
+ # @param [Cursor] cursor
2755
+ # @return [Cursor]
2756
+ # @scope class
2757
+ attach_function :get_cursor_definition, :clang_getCursorDefinition, [Cursor.by_value], Cursor.by_value
2758
+
2759
+ # Determine whether the declaration pointed to by this cursor
2760
+ # is also a definition of that entity.
2761
+ #
2762
+ # @method is_cursor_definition(cursor)
2763
+ # @param [Cursor] cursor
2764
+ # @return [Integer]
2765
+ # @scope class
2766
+ attach_function :is_cursor_definition, :clang_isCursorDefinition, [Cursor.by_value], :uint
2767
+
2768
+ # Retrieve the canonical cursor corresponding to the given cursor.
2769
+ #
2770
+ # In the C family of languages, many kinds of entities can be declared several
2771
+ # times within a single translation unit. For example, a structure type can
2772
+ # be forward-declared (possibly multiple times) and later defined:
2773
+ #
2774
+ # \code
2775
+ # struct X;
2776
+ # struct X;
2777
+ # struct X {
2778
+ # int member;
2779
+ # };
2780
+ # \endcode
2781
+ #
2782
+ # The declarations and the definition of \c X are represented by three
2783
+ # different cursors, all of which are declarations of the same underlying
2784
+ # entity. One of these cursor is considered the "canonical" cursor, which
2785
+ # is effectively the representative for the underlying entity. One can
2786
+ # determine if two cursors are declarations of the same underlying entity by
2787
+ # comparing their canonical cursors.
2788
+ #
2789
+ # @method get_canonical_cursor(cursor)
2790
+ # @param [Cursor] cursor
2791
+ # @return [Cursor] The canonical cursor for the entity referred to by the given cursor.
2792
+ # @scope class
2793
+ attach_function :get_canonical_cursor, :clang_getCanonicalCursor, [Cursor.by_value], Cursor.by_value
2794
+
2795
+ # Determine if a C++ member function or member function template is
2796
+ # declared 'static'.
2797
+ #
2798
+ # @method cxx_method_is_static(c)
2799
+ # @param [Cursor] c
2800
+ # @return [Integer]
2801
+ # @scope class
2802
+ attach_function :cxx_method_is_static, :clang_CXXMethod_isStatic, [Cursor.by_value], :uint
2803
+
2804
+ # Determine if a C++ member function or member function template is
2805
+ # explicitly declared 'virtual' or if it overrides a virtual method from
2806
+ # one of the base classes.
2807
+ #
2808
+ # @method cxx_method_is_virtual(c)
2809
+ # @param [Cursor] c
2810
+ # @return [Integer]
2811
+ # @scope class
2812
+ attach_function :cxx_method_is_virtual, :clang_CXXMethod_isVirtual, [Cursor.by_value], :uint
2813
+
2814
+ # Given a cursor that represents a template, determine
2815
+ # the cursor kind of the specializations would be generated by instantiating
2816
+ # the template.
2817
+ #
2818
+ # This routine can be used to determine what flavor of function template,
2819
+ # class template, or class template partial specialization is stored in the
2820
+ # cursor. For example, it can describe whether a class template cursor is
2821
+ # declared with "struct", "class" or "union".
2822
+ #
2823
+ # @method get_template_cursor_kind(c)
2824
+ # @param [Cursor] c The cursor to query. This cursor should represent a template
2825
+ # declaration.
2826
+ # @return [Symbol from _enum_cursor_kind_] The cursor kind of the specializations that would be generated
2827
+ # by instantiating the template \p C. If \p C is not a template, returns
2828
+ # \c CXCursor_NoDeclFound.
2829
+ # @scope class
2830
+ attach_function :get_template_cursor_kind, :clang_getTemplateCursorKind, [Cursor.by_value], :cursor_kind
2831
+
2832
+ # Given a cursor that may represent a specialization or instantiation
2833
+ # of a template, retrieve the cursor that represents the template that it
2834
+ # specializes or from which it was instantiated.
2835
+ #
2836
+ # This routine determines the template involved both for explicit
2837
+ # specializations of templates and for implicit instantiations of the template,
2838
+ # both of which are referred to as "specializations". For a class template
2839
+ # specialization (e.g., \c std::vector<bool>), this routine will return
2840
+ # either the primary template (\c std::vector) or, if the specialization was
2841
+ # instantiated from a class template partial specialization, the class template
2842
+ # partial specialization. For a class template partial specialization and a
2843
+ # function template specialization (including instantiations), this
2844
+ # this routine will return the specialized template.
2845
+ #
2846
+ # For members of a class template (e.g., member functions, member classes, or
2847
+ # static data members), returns the specialized or instantiated member.
2848
+ # Although not strictly "templates" in the C++ language, members of class
2849
+ # templates have the same notions of specializations and instantiations that
2850
+ # templates do, so this routine treats them similarly.
2851
+ #
2852
+ # @method get_specialized_cursor_template(c)
2853
+ # @param [Cursor] c A cursor that may be a specialization of a template or a member
2854
+ # of a template.
2855
+ # @return [Cursor] If the given cursor is a specialization or instantiation of a
2856
+ # template or a member thereof, the template or member that it specializes or
2857
+ # from which it was instantiated. Otherwise, returns a NULL cursor.
2858
+ # @scope class
2859
+ attach_function :get_specialized_cursor_template, :clang_getSpecializedCursorTemplate, [Cursor.by_value], Cursor.by_value
2860
+
2861
+ # Given a cursor that references something else, return the source range
2862
+ # covering that reference.
2863
+ #
2864
+ # @method get_cursor_reference_name_range(c, name_flags, piece_index)
2865
+ # @param [Cursor] c A cursor pointing to a member reference, a declaration reference, or
2866
+ # an operator call.
2867
+ # @param [Integer] name_flags A bitset with three independent flags:
2868
+ # CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
2869
+ # CXNameRange_WantSinglePiece.
2870
+ # @param [Integer] piece_index For contiguous names or when passing the flag
2871
+ # CXNameRange_WantSinglePiece, only one piece with index 0 is
2872
+ # available. When the CXNameRange_WantSinglePiece flag is not passed for a
2873
+ # non-contiguous names, this index can be used to retreive the individual
2874
+ # pieces of the name. See also CXNameRange_WantSinglePiece.
2875
+ # @return [SourceRange] The piece of the name pointed to by the given cursor. If there is no
2876
+ # name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
2877
+ # @scope class
2878
+ attach_function :get_cursor_reference_name_range, :clang_getCursorReferenceNameRange, [Cursor.by_value, :uint, :uint], SourceRange.by_value
2879
+
2880
+ # (Not documented)
2881
+ #
2882
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:name_ref_flags).</em>
2883
+ #
2884
+ # === Options:
2885
+ # :want_qualifier ::
2886
+ # Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
2887
+ # range.
2888
+ # :want_template_args ::
2889
+ # Include the explicit template arguments, e.g. <int> in x.f<int>, in
2890
+ # the range.
2891
+ # :want_single_piece ::
2892
+ # If the name is non-contiguous, return the full spanning range.
2893
+ #
2894
+ # Non-contiguous names occur in Objective-C when a selector with two or more
2895
+ # parameters is used, or in C++ when using an operator:
2896
+ # \code
2897
+ # (object doSomething:here withValue:there); // ObjC
2898
+ # return some_vector(1); // C++
2899
+ # \endcode
2900
+ #
2901
+ # @method _enum_name_ref_flags_
2902
+ # @return [Symbol]
2903
+ # @scope class
2904
+ enum :name_ref_flags, [
2905
+ :want_qualifier, 0x1,
2906
+ :want_template_args, 0x2,
2907
+ :want_single_piece, 0x4
2908
+ ]
2909
+
2910
+ # Describes a kind of token.
2911
+ #
2912
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:token_kind).</em>
2913
+ #
2914
+ # === Options:
2915
+ # :punctuation ::
2916
+ # A token that contains some kind of punctuation.
2917
+ # :keyword ::
2918
+ # A language keyword.
2919
+ # :identifier ::
2920
+ # An identifier (that is not a keyword).
2921
+ # :literal ::
2922
+ # A numeric, string, or character literal.
2923
+ # :comment ::
2924
+ # A comment.
2925
+ #
2926
+ # @method _enum_token_kind_
2927
+ # @return [Symbol]
2928
+ # @scope class
2929
+ enum :token_kind, [
2930
+ :punctuation,
2931
+ :keyword,
2932
+ :identifier,
2933
+ :literal,
2934
+ :comment
2935
+ ]
2936
+
2937
+ class Token < FFI::Struct
2938
+ layout :int_data, [:uint, 4],
2939
+ :ptr_data, :pointer
2940
+ end
2941
+
2942
+ # Determine the kind of the given token.
2943
+ #
2944
+ # @method get_token_kind(token)
2945
+ # @param [Token] token
2946
+ # @return [Symbol from _enum_token_kind_]
2947
+ # @scope class
2948
+ attach_function :get_token_kind, :clang_getTokenKind, [Token.by_value], :token_kind
2949
+
2950
+ # Determine the spelling of the given token.
2951
+ #
2952
+ # The spelling of a token is the textual representation of that token, e.g.,
2953
+ # the text of an identifier or keyword.
2954
+ #
2955
+ # @method get_token_spelling(translation_unit_impl, token)
2956
+ # @param [TranslationUnitImpl] translation_unit_impl
2957
+ # @param [Token] token
2958
+ # @return [String]
2959
+ # @scope class
2960
+ attach_function :get_token_spelling, :clang_getTokenSpelling, [TranslationUnitImpl, Token.by_value], String.by_value
2961
+
2962
+ # Retrieve the source location of the given token.
2963
+ #
2964
+ # @method get_token_location(translation_unit_impl, token)
2965
+ # @param [TranslationUnitImpl] translation_unit_impl
2966
+ # @param [Token] token
2967
+ # @return [SourceLocation]
2968
+ # @scope class
2969
+ attach_function :get_token_location, :clang_getTokenLocation, [TranslationUnitImpl, Token.by_value], SourceLocation.by_value
2970
+
2971
+ # Retrieve a source range that covers the given token.
2972
+ #
2973
+ # @method get_token_extent(translation_unit_impl, token)
2974
+ # @param [TranslationUnitImpl] translation_unit_impl
2975
+ # @param [Token] token
2976
+ # @return [SourceRange]
2977
+ # @scope class
2978
+ attach_function :get_token_extent, :clang_getTokenExtent, [TranslationUnitImpl, Token.by_value], SourceRange.by_value
2979
+
2980
+ # Tokenize the source code described by the given range into raw
2981
+ # lexical tokens.
2982
+ #
2983
+ # @method tokenize(tu, range, tokens, num_tokens)
2984
+ # @param [TranslationUnitImpl] tu the translation unit whose text is being tokenized.
2985
+ # @param [SourceRange] range the source range in which text should be tokenized. All of the
2986
+ # tokens produced by tokenization will fall within this source range,
2987
+ # @param [FFI::Pointer(**Token)] tokens this pointer will be set to point to the array of tokens
2988
+ # that occur within the given source range. The returned pointer must be
2989
+ # freed with clang_disposeTokens() before the translation unit is destroyed.
2990
+ # @param [FFI::Pointer(*UInt)] num_tokens will be set to the number of tokens in the \c *Tokens
2991
+ # array.
2992
+ # @return [nil]
2993
+ # @scope class
2994
+ attach_function :tokenize, :clang_tokenize, [TranslationUnitImpl, SourceRange.by_value, :pointer, :pointer], :void
2995
+
2996
+ # Annotate the given set of tokens by providing cursors for each token
2997
+ # that can be mapped to a specific entity within the abstract syntax tree.
2998
+ #
2999
+ # This token-annotation routine is equivalent to invoking
3000
+ # clang_getCursor() for the source locations of each of the
3001
+ # tokens. The cursors provided are filtered, so that only those
3002
+ # cursors that have a direct correspondence to the token are
3003
+ # accepted. For example, given a function call \c f(x),
3004
+ # clang_getCursor() would provide the following cursors:
3005
+ #
3006
+ # * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
3007
+ # * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
3008
+ # * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
3009
+ #
3010
+ # Only the first and last of these cursors will occur within the
3011
+ # annotate, since the tokens "f" and "x' directly refer to a function
3012
+ # and a variable, respectively, but the parentheses are just a small
3013
+ # part of the full syntax of the function call expression, which is
3014
+ # not provided as an annotation.
3015
+ #
3016
+ # @method annotate_tokens(tu, tokens, num_tokens, cursors)
3017
+ # @param [TranslationUnitImpl] tu the translation unit that owns the given tokens.
3018
+ # @param [Token] tokens the set of tokens to annotate.
3019
+ # @param [Integer] num_tokens the number of tokens in \p Tokens.
3020
+ # @param [Cursor] cursors an array of \p NumTokens cursors, whose contents will be
3021
+ # replaced with the cursors corresponding to each token.
3022
+ # @return [nil]
3023
+ # @scope class
3024
+ attach_function :annotate_tokens, :clang_annotateTokens, [TranslationUnitImpl, Token, :uint, Cursor], :void
3025
+
3026
+ # Free the given set of tokens.
3027
+ #
3028
+ # @method dispose_tokens(tu, tokens, num_tokens)
3029
+ # @param [TranslationUnitImpl] tu
3030
+ # @param [Token] tokens
3031
+ # @param [Integer] num_tokens
3032
+ # @return [nil]
3033
+ # @scope class
3034
+ attach_function :dispose_tokens, :clang_disposeTokens, [TranslationUnitImpl, Token, :uint], :void
3035
+
3036
+ # for debug/testing
3037
+ #
3038
+ # @method get_cursor_kind_spelling(kind)
3039
+ # @param [Symbol from _enum_cursor_kind_] kind
3040
+ # @return [String]
3041
+ # @scope class
3042
+ attach_function :get_cursor_kind_spelling, :clang_getCursorKindSpelling, [:cursor_kind], String.by_value
3043
+
3044
+ # (Not documented)
3045
+ #
3046
+ # @method get_definition_spelling_and_extent(cursor, start_buf, end_buf, start_line, start_column, end_line, end_column)
3047
+ # @param [Cursor] cursor
3048
+ # @param [FFI::Pointer(**Char_S)] start_buf
3049
+ # @param [FFI::Pointer(**Char_S)] end_buf
3050
+ # @param [FFI::Pointer(*UInt)] start_line
3051
+ # @param [FFI::Pointer(*UInt)] start_column
3052
+ # @param [FFI::Pointer(*UInt)] end_line
3053
+ # @param [FFI::Pointer(*UInt)] end_column
3054
+ # @return [nil]
3055
+ # @scope class
3056
+ attach_function :get_definition_spelling_and_extent, :clang_getDefinitionSpellingAndExtent, [Cursor.by_value, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :void
3057
+
3058
+ # (Not documented)
3059
+ #
3060
+ # @method enable_stack_traces()
3061
+ # @return [nil]
3062
+ # @scope class
3063
+ attach_function :enable_stack_traces, :clang_enableStackTraces, [], :void
3064
+
3065
+ # (Not documented)
3066
+ #
3067
+ # @method execute_on_thread(fn, user_data, stack_size)
3068
+ # @param [FFI::Pointer(*)] fn
3069
+ # @param [FFI::Pointer(*Void)] user_data
3070
+ # @param [Integer] stack_size
3071
+ # @return [nil]
3072
+ # @scope class
3073
+ attach_function :execute_on_thread, :clang_executeOnThread, [:pointer, :pointer, :uint], :void
3074
+
3075
+ # A single result of code completion.
3076
+ #
3077
+ # = Fields:
3078
+ # :cursor_kind ::
3079
+ # (Symbol from _enum_cursor_kind_) The kind of entity that this completion refers to.
3080
+ #
3081
+ # The cursor kind will be a macro, keyword, or a declaration (one of the
3082
+ # *Decl cursor kinds), describing the entity that the completion is
3083
+ # referring to.
3084
+ #
3085
+ # \todo In the future, we would like to provide a full cursor, to allow
3086
+ # the client to extract additional information from declaration.
3087
+ # :completion_string ::
3088
+ # (FFI::Pointer(CompletionString)) The code-completion string that describes how to insert this
3089
+ # code-completion result into the editing buffer.
3090
+ class CompletionResult < FFI::Struct
3091
+ layout :cursor_kind, :cursor_kind,
3092
+ :completion_string, :pointer
3093
+ end
3094
+
3095
+ # Describes a single piece of text within a code-completion string.
3096
+ #
3097
+ # Each "chunk" within a code-completion string (\c CXCompletionString) is
3098
+ # either a piece of text with a specific "kind" that describes how that text
3099
+ # should be interpreted by the client or is another completion string.
3100
+ #
3101
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:completion_chunk_kind).</em>
3102
+ #
3103
+ # === Options:
3104
+ # :optional ::
3105
+ # A code-completion string that describes "optional" text that
3106
+ # could be a part of the template (but is not required).
3107
+ #
3108
+ # The Optional chunk is the only kind of chunk that has a code-completion
3109
+ # string for its representation, which is accessible via
3110
+ # \c clang_getCompletionChunkCompletionString(). The code-completion string
3111
+ # describes an additional part of the template that is completely optional.
3112
+ # For example, optional chunks can be used to describe the placeholders for
3113
+ # arguments that match up with defaulted function parameters, e.g. given:
3114
+ #
3115
+ # \code
3116
+ # void f(int x, float y = 3.14, double z = 2.71828);
3117
+ # \endcode
3118
+ #
3119
+ # The code-completion string for this function would contain:
3120
+ # - a TypedText chunk for "f".
3121
+ # - a LeftParen chunk for "(".
3122
+ # - a Placeholder chunk for "int x"
3123
+ # - an Optional chunk containing the remaining defaulted arguments, e.g.,
3124
+ # - a Comma chunk for ","
3125
+ # - a Placeholder chunk for "float y"
3126
+ # - an Optional chunk containing the last defaulted argument:
3127
+ # - a Comma chunk for ","
3128
+ # - a Placeholder chunk for "double z"
3129
+ # - a RightParen chunk for ")"
3130
+ #
3131
+ # There are many ways to handle Optional chunks. Two simple approaches are:
3132
+ # - Completely ignore optional chunks, in which case the template for the
3133
+ # function "f" would only include the first parameter ("int x").
3134
+ # - Fully expand all optional chunks, in which case the template for the
3135
+ # function "f" would have all of the parameters.
3136
+ # :typed_text ::
3137
+ # Text that a user would be expected to type to get this
3138
+ # code-completion result.
3139
+ #
3140
+ # There will be exactly one "typed text" chunk in a semantic string, which
3141
+ # will typically provide the spelling of a keyword or the name of a
3142
+ # declaration that could be used at the current code point. Clients are
3143
+ # expected to filter the code-completion results based on the text in this
3144
+ # chunk.
3145
+ # :text ::
3146
+ # Text that should be inserted as part of a code-completion result.
3147
+ #
3148
+ # A "text" chunk represents text that is part of the template to be
3149
+ # inserted into user code should this particular code-completion result
3150
+ # be selected.
3151
+ # :placeholder ::
3152
+ # Placeholder text that should be replaced by the user.
3153
+ #
3154
+ # A "placeholder" chunk marks a place where the user should insert text
3155
+ # into the code-completion template. For example, placeholders might mark
3156
+ # the function parameters for a function declaration, to indicate that the
3157
+ # user should provide arguments for each of those parameters. The actual
3158
+ # text in a placeholder is a suggestion for the text to display before
3159
+ # the user replaces the placeholder with real code.
3160
+ # :informative ::
3161
+ # Informative text that should be displayed but never inserted as
3162
+ # part of the template.
3163
+ #
3164
+ # An "informative" chunk contains annotations that can be displayed to
3165
+ # help the user decide whether a particular code-completion result is the
3166
+ # right option, but which is not part of the actual template to be inserted
3167
+ # by code completion.
3168
+ # :current_parameter ::
3169
+ # Text that describes the current parameter when code-completion is
3170
+ # referring to function call, message send, or template specialization.
3171
+ #
3172
+ # A "current parameter" chunk occurs when code-completion is providing
3173
+ # information about a parameter corresponding to the argument at the
3174
+ # code-completion point. For example, given a function
3175
+ #
3176
+ # \code
3177
+ # int add(int x, int y);
3178
+ # \endcode
3179
+ #
3180
+ # and the source code \c add(, where the code-completion point is after the
3181
+ # "(", the code-completion string will contain a "current parameter" chunk
3182
+ # for "int x", indicating that the current argument will initialize that
3183
+ # parameter. After typing further, to \c add(17, (where the code-completion
3184
+ # point is after the ","), the code-completion string will contain a
3185
+ # "current paremeter" chunk to "int y".
3186
+ # :left_paren ::
3187
+ # A left parenthesis ('('), used to initiate a function call or
3188
+ # signal the beginning of a function parameter list.
3189
+ # :right_paren ::
3190
+ # A right parenthesis (')'), used to finish a function call or
3191
+ # signal the end of a function parameter list.
3192
+ # :left_bracket ::
3193
+ # A left bracket ('(').
3194
+ # :right_bracket ::
3195
+ # A right bracket (')').
3196
+ # :left_brace ::
3197
+ # A left brace ('{').
3198
+ # :right_brace ::
3199
+ # A right brace ('}').
3200
+ # :left_angle ::
3201
+ # A left angle bracket ('<').
3202
+ # :right_angle ::
3203
+ # A right angle bracket ('>').
3204
+ # :comma ::
3205
+ # A comma separator (',').
3206
+ # :result_type ::
3207
+ # Text that specifies the result type of a given result.
3208
+ #
3209
+ # This special kind of informative chunk is not meant to be inserted into
3210
+ # the text buffer. Rather, it is meant to illustrate the type that an
3211
+ # expression using the given completion string would have.
3212
+ # :colon ::
3213
+ # A colon (':').
3214
+ # :semi_colon ::
3215
+ # A semicolon (';').
3216
+ # :equal ::
3217
+ # An '=' sign.
3218
+ # :horizontal_space ::
3219
+ # Horizontal space (' ').
3220
+ # :vertical_space ::
3221
+ # Vertical space ('\n'), after which it is generally a good idea to
3222
+ # perform indentation.
3223
+ #
3224
+ # @method _enum_completion_chunk_kind_
3225
+ # @return [Symbol]
3226
+ # @scope class
3227
+ enum :completion_chunk_kind, [
3228
+ :optional,
3229
+ :typed_text,
3230
+ :text,
3231
+ :placeholder,
3232
+ :informative,
3233
+ :current_parameter,
3234
+ :left_paren,
3235
+ :right_paren,
3236
+ :left_bracket,
3237
+ :right_bracket,
3238
+ :left_brace,
3239
+ :right_brace,
3240
+ :left_angle,
3241
+ :right_angle,
3242
+ :comma,
3243
+ :result_type,
3244
+ :colon,
3245
+ :semi_colon,
3246
+ :equal,
3247
+ :horizontal_space,
3248
+ :vertical_space
3249
+ ]
3250
+
3251
+ # Determine the kind of a particular chunk within a completion string.
3252
+ #
3253
+ # @method get_completion_chunk_kind(completion_string, chunk_number)
3254
+ # @param [FFI::Pointer(CompletionString)] completion_string the completion string to query.
3255
+ # @param [Integer] chunk_number the 0-based index of the chunk in the completion string.
3256
+ # @return [Symbol from _enum_completion_chunk_kind_] the kind of the chunk at the index \c chunk_number.
3257
+ # @scope class
3258
+ attach_function :get_completion_chunk_kind, :clang_getCompletionChunkKind, [:pointer, :uint], :completion_chunk_kind
3259
+
3260
+ # Retrieve the text associated with a particular chunk within a
3261
+ # completion string.
3262
+ #
3263
+ # @method get_completion_chunk_text(completion_string, chunk_number)
3264
+ # @param [FFI::Pointer(CompletionString)] completion_string the completion string to query.
3265
+ # @param [Integer] chunk_number the 0-based index of the chunk in the completion string.
3266
+ # @return [String] the text associated with the chunk at index \c chunk_number.
3267
+ # @scope class
3268
+ attach_function :get_completion_chunk_text, :clang_getCompletionChunkText, [:pointer, :uint], String.by_value
3269
+
3270
+ # Retrieve the completion string associated with a particular chunk
3271
+ # within a completion string.
3272
+ #
3273
+ # @method get_completion_chunk_completion_string(completion_string, chunk_number)
3274
+ # @param [FFI::Pointer(CompletionString)] completion_string the completion string to query.
3275
+ # @param [Integer] chunk_number the 0-based index of the chunk in the completion string.
3276
+ # @return [FFI::Pointer(CompletionString)] the completion string associated with the chunk at index
3277
+ # \c chunk_number.
3278
+ # @scope class
3279
+ attach_function :get_completion_chunk_completion_string, :clang_getCompletionChunkCompletionString, [:pointer, :uint], :pointer
3280
+
3281
+ # Retrieve the number of chunks in the given code-completion string.
3282
+ #
3283
+ # @method get_num_completion_chunks(completion_string)
3284
+ # @param [FFI::Pointer(CompletionString)] completion_string
3285
+ # @return [Integer]
3286
+ # @scope class
3287
+ attach_function :get_num_completion_chunks, :clang_getNumCompletionChunks, [:pointer], :uint
3288
+
3289
+ # Determine the priority of this code completion.
3290
+ #
3291
+ # The priority of a code completion indicates how likely it is that this
3292
+ # particular completion is the completion that the user will select. The
3293
+ # priority is selected by various internal heuristics.
3294
+ #
3295
+ # @method get_completion_priority(completion_string)
3296
+ # @param [FFI::Pointer(CompletionString)] completion_string The completion string to query.
3297
+ # @return [Integer] The priority of this completion string. Smaller values indicate
3298
+ # higher-priority (more likely) completions.
3299
+ # @scope class
3300
+ attach_function :get_completion_priority, :clang_getCompletionPriority, [:pointer], :uint
3301
+
3302
+ # Determine the availability of the entity that this code-completion
3303
+ # string refers to.
3304
+ #
3305
+ # @method get_completion_availability(completion_string)
3306
+ # @param [FFI::Pointer(CompletionString)] completion_string The completion string to query.
3307
+ # @return [Symbol from _enum_availability_kind_] The availability of the completion string.
3308
+ # @scope class
3309
+ attach_function :get_completion_availability, :clang_getCompletionAvailability, [:pointer], :availability_kind
3310
+
3311
+ # Retrieve the number of annotations associated with the given
3312
+ # completion string.
3313
+ #
3314
+ # @method get_completion_num_annotations(completion_string)
3315
+ # @param [FFI::Pointer(CompletionString)] completion_string the completion string to query.
3316
+ # @return [Integer] the number of annotations associated with the given completion
3317
+ # string.
3318
+ # @scope class
3319
+ attach_function :get_completion_num_annotations, :clang_getCompletionNumAnnotations, [:pointer], :uint
3320
+
3321
+ # Retrieve the annotation associated with the given completion string.
3322
+ #
3323
+ # @method get_completion_annotation(completion_string, annotation_number)
3324
+ # @param [FFI::Pointer(CompletionString)] completion_string the completion string to query.
3325
+ # @param [Integer] annotation_number the 0-based index of the annotation of the
3326
+ # completion string.
3327
+ # @return [String] annotation string associated with the completion at index
3328
+ # \c annotation_number, or a NULL string if that annotation is not available.
3329
+ # @scope class
3330
+ attach_function :get_completion_annotation, :clang_getCompletionAnnotation, [:pointer, :uint], String.by_value
3331
+
3332
+ # Retrieve a completion string for an arbitrary declaration or macro
3333
+ # definition cursor.
3334
+ #
3335
+ # @method get_cursor_completion_string(cursor)
3336
+ # @param [Cursor] cursor The cursor to query.
3337
+ # @return [FFI::Pointer(CompletionString)] A non-context-sensitive completion string for declaration and macro
3338
+ # definition cursors, or NULL for other kinds of cursors.
3339
+ # @scope class
3340
+ attach_function :get_cursor_completion_string, :clang_getCursorCompletionString, [Cursor.by_value], :pointer
3341
+
3342
+ # Contains the results of code-completion.
3343
+ #
3344
+ # This data structure contains the results of code completion, as
3345
+ # produced by \c clang_codeCompleteAt(). Its contents must be freed by
3346
+ # \c clang_disposeCodeCompleteResults.
3347
+ #
3348
+ # = Fields:
3349
+ # :results ::
3350
+ # (CompletionResult) The code-completion results.
3351
+ # :num_results ::
3352
+ # (Integer) The number of code-completion results stored in the
3353
+ # \c Results array.
3354
+ class CodeCompleteResults < FFI::Struct
3355
+ layout :results, CompletionResult,
3356
+ :num_results, :uint
3357
+ end
3358
+
3359
+ # Flags that can be passed to \c clang_codeCompleteAt() to
3360
+ # modify its behavior.
3361
+ #
3362
+ # The enumerators in this enumeration can be bitwise-OR'd together to
3363
+ # provide multiple options to \c clang_codeCompleteAt().
3364
+ #
3365
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:code_complete_flags).</em>
3366
+ #
3367
+ # === Options:
3368
+ # :include_macros ::
3369
+ # Whether to include macros within the set of code
3370
+ # completions returned.
3371
+ # :include_code_patterns ::
3372
+ # Whether to include code patterns for language constructs
3373
+ # within the set of code completions, e.g., for loops.
3374
+ #
3375
+ # @method _enum_code_complete_flags_
3376
+ # @return [Symbol]
3377
+ # @scope class
3378
+ enum :code_complete_flags, [
3379
+ :include_macros, 0x01,
3380
+ :include_code_patterns, 0x02
3381
+ ]
3382
+
3383
+ # Bits that represent the context under which completion is occurring.
3384
+ #
3385
+ # The enumerators in this enumeration may be bitwise-OR'd together if multiple
3386
+ # contexts are occurring simultaneously.
3387
+ #
3388
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:completion_context).</em>
3389
+ #
3390
+ # === Options:
3391
+ # :completion_context_unexposed ::
3392
+ # The context for completions is unexposed, as only Clang results
3393
+ # should be included. (This is equivalent to having no context bits set.)
3394
+ #
3395
+ # @method _enum_completion_context_
3396
+ # @return [Symbol]
3397
+ # @scope class
3398
+ enum :completion_context, [
3399
+ :completion_context_unexposed, 0
3400
+ ]
3401
+
3402
+ # Returns a default set of code-completion options that can be
3403
+ # passed to\c clang_codeCompleteAt().
3404
+ #
3405
+ # @method default_code_complete_options()
3406
+ # @return [Integer]
3407
+ # @scope class
3408
+ attach_function :default_code_complete_options, :clang_defaultCodeCompleteOptions, [], :uint
3409
+
3410
+ # Perform code completion at a given location in a translation unit.
3411
+ #
3412
+ # This function performs code completion at a particular file, line, and
3413
+ # column within source code, providing results that suggest potential
3414
+ # code snippets based on the context of the completion. The basic model
3415
+ # for code completion is that Clang will parse a complete source file,
3416
+ # performing syntax checking up to the location where code-completion has
3417
+ # been requested. At that point, a special code-completion token is passed
3418
+ # to the parser, which recognizes this token and determines, based on the
3419
+ # current location in the C/Objective-C/C++ grammar and the state of
3420
+ # semantic analysis, what completions to provide. These completions are
3421
+ # returned via a new \c CXCodeCompleteResults structure.
3422
+ #
3423
+ # Code completion itself is meant to be triggered by the client when the
3424
+ # user types punctuation characters or whitespace, at which point the
3425
+ # code-completion location will coincide with the cursor. For example, if \c p
3426
+ # is a pointer, code-completion might be triggered after the "-" and then
3427
+ # after the ">" in \c p->. When the code-completion location is afer the ">",
3428
+ # the completion results will provide, e.g., the members of the struct that
3429
+ # "p" points to. The client is responsible for placing the cursor at the
3430
+ # beginning of the token currently being typed, then filtering the results
3431
+ # based on the contents of the token. For example, when code-completing for
3432
+ # the expression \c p->get, the client should provide the location just after
3433
+ # the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
3434
+ # client can filter the results based on the current token text ("get"), only
3435
+ # showing those results that start with "get". The intent of this interface
3436
+ # is to separate the relatively high-latency acquisition of code-completion
3437
+ # results from the filtering of results on a per-character basis, which must
3438
+ # have a lower latency.
3439
+ #
3440
+ # @method code_complete_at(tu, complete_filename, complete_line, complete_column, unsaved_files, num_unsaved_files, options)
3441
+ # @param [TranslationUnitImpl] tu The translation unit in which code-completion should
3442
+ # occur. The source files for this translation unit need not be
3443
+ # completely up-to-date (and the contents of those source files may
3444
+ # be overridden via \p unsaved_files). Cursors referring into the
3445
+ # translation unit may be invalidated by this invocation.
3446
+ # @param [String] complete_filename The name of the source file where code
3447
+ # completion should be performed. This filename may be any file
3448
+ # included in the translation unit.
3449
+ # @param [Integer] complete_line The line at which code-completion should occur.
3450
+ # @param [Integer] complete_column The column at which code-completion should occur.
3451
+ # Note that the column should point just after the syntactic construct that
3452
+ # initiated code completion, and not in the middle of a lexical token.
3453
+ # @param [UnsavedFile] unsaved_files the Tiles that have not yet been saved to disk
3454
+ # but may be required for parsing or code completion, including the
3455
+ # contents of those files. The contents and name of these files (as
3456
+ # specified by CXUnsavedFile) are copied when necessary, so the
3457
+ # client only needs to guarantee their validity until the call to
3458
+ # this function returns.
3459
+ # @param [Integer] num_unsaved_files The number of unsaved file entries in \p
3460
+ # unsaved_files.
3461
+ # @param [Integer] options Extra options that control the behavior of code
3462
+ # completion, expressed as a bitwise OR of the enumerators of the
3463
+ # CXCodeComplete_Flags enumeration. The
3464
+ # \c clang_defaultCodeCompleteOptions() function returns a default set
3465
+ # of code-completion options.
3466
+ # @return [CodeCompleteResults] If successful, a new \c CXCodeCompleteResults structure
3467
+ # containing code-completion results, which should eventually be
3468
+ # freed with \c clang_disposeCodeCompleteResults(). If code
3469
+ # completion fails, returns NULL.
3470
+ # @scope class
3471
+ attach_function :code_complete_at, :clang_codeCompleteAt, [TranslationUnitImpl, :string, :uint, :uint, UnsavedFile, :uint, :uint], CodeCompleteResults
3472
+
3473
+ # Sort the code-completion results in case-insensitive alphabetical
3474
+ # order.
3475
+ #
3476
+ # @method sort_code_completion_results(results, num_results)
3477
+ # @param [CompletionResult] results The set of results to sort.
3478
+ # @param [Integer] num_results The number of results in \p Results.
3479
+ # @return [nil]
3480
+ # @scope class
3481
+ attach_function :sort_code_completion_results, :clang_sortCodeCompletionResults, [CompletionResult, :uint], :void
3482
+
3483
+ # Free the given set of code-completion results.
3484
+ #
3485
+ # @method dispose_code_complete_results(results)
3486
+ # @param [CodeCompleteResults] results
3487
+ # @return [nil]
3488
+ # @scope class
3489
+ attach_function :dispose_code_complete_results, :clang_disposeCodeCompleteResults, [CodeCompleteResults], :void
3490
+
3491
+ # Determine the number of diagnostics produced prior to the
3492
+ # location where code completion was performed.
3493
+ #
3494
+ # @method code_complete_get_num_diagnostics(results)
3495
+ # @param [CodeCompleteResults] results
3496
+ # @return [Integer]
3497
+ # @scope class
3498
+ attach_function :code_complete_get_num_diagnostics, :clang_codeCompleteGetNumDiagnostics, [CodeCompleteResults], :uint
3499
+
3500
+ # Retrieve a diagnostic associated with the given code completion.
3501
+ #
3502
+ # Result:
3503
+ # the code completion results to query.
3504
+ #
3505
+ # @method code_complete_get_diagnostic(results, index)
3506
+ # @param [CodeCompleteResults] results
3507
+ # @param [Integer] index the zero-based diagnostic number to retrieve.
3508
+ # @return [FFI::Pointer(Diagnostic)] the requested diagnostic. This diagnostic must be freed
3509
+ # via a call to \c clang_disposeDiagnostic().
3510
+ # @scope class
3511
+ attach_function :code_complete_get_diagnostic, :clang_codeCompleteGetDiagnostic, [CodeCompleteResults, :uint], :pointer
3512
+
3513
+ # Determines what compeltions are appropriate for the context
3514
+ # the given code completion.
3515
+ #
3516
+ # @method code_complete_get_contexts(results)
3517
+ # @param [CodeCompleteResults] results the code completion results to query
3518
+ # @return [Integer] the kinds of completions that are appropriate for use
3519
+ # along with the given code completion results.
3520
+ # @scope class
3521
+ attach_function :code_complete_get_contexts, :clang_codeCompleteGetContexts, [CodeCompleteResults], :ulong_long
3522
+
3523
+ # Returns the cursor kind for the container for the current code
3524
+ # completion context. The container is only guaranteed to be set for
3525
+ # contexts where a container exists (i.e. member accesses or Objective-C
3526
+ # message sends); if there is not a container, this function will return
3527
+ # CXCursor_InvalidCode.
3528
+ #
3529
+ # @method code_complete_get_container_kind(results, is_incomplete)
3530
+ # @param [CodeCompleteResults] results the code completion results to query
3531
+ # @param [FFI::Pointer(*UInt)] is_incomplete on return, this value will be false if Clang has complete
3532
+ # information about the container. If Clang does not have complete
3533
+ # information, this value will be true.
3534
+ # @return [Symbol from _enum_cursor_kind_] the container kind, or CXCursor_InvalidCode if there is not a
3535
+ # container
3536
+ # @scope class
3537
+ attach_function :code_complete_get_container_kind, :clang_codeCompleteGetContainerKind, [CodeCompleteResults, :pointer], :cursor_kind
3538
+
3539
+ # Returns the USR for the container for the current code completion
3540
+ # context. If there is not a container for the current context, this
3541
+ # function will return the empty string.
3542
+ #
3543
+ # @method code_complete_get_container_usr(results)
3544
+ # @param [CodeCompleteResults] results the code completion results to query
3545
+ # @return [String] the USR for the container
3546
+ # @scope class
3547
+ attach_function :code_complete_get_container_usr, :clang_codeCompleteGetContainerUSR, [CodeCompleteResults], String.by_value
3548
+
3549
+ # Returns the currently-entered selector for an Objective-C message
3550
+ # send, formatted like "initWithFoo:bar:". Only guaranteed to return a
3551
+ # non-empty string for CXCompletionContext_ObjCInstanceMessage and
3552
+ # CXCompletionContext_ObjCClassMessage.
3553
+ #
3554
+ # @method code_complete_get_obj_c_selector(results)
3555
+ # @param [CodeCompleteResults] results the code completion results to query
3556
+ # @return [String] the selector (or partial selector) that has been entered thus far
3557
+ # for an Objective-C message send.
3558
+ # @scope class
3559
+ attach_function :code_complete_get_obj_c_selector, :clang_codeCompleteGetObjCSelector, [CodeCompleteResults], String.by_value
3560
+
3561
+ # Return a version string, suitable for showing to a user, but not
3562
+ # intended to be parsed (the format is not guaranteed to be stable).
3563
+ #
3564
+ # @method get_clang_version()
3565
+ # @return [String]
3566
+ # @scope class
3567
+ attach_function :get_clang_version, :clang_getClangVersion, [], String.by_value
3568
+
3569
+ # Enable/disable crash recovery.
3570
+ #
3571
+ # Flag:
3572
+ # to indicate if crash recovery is enabled. A non-zero value
3573
+ # enables crash recovery, while 0 disables it.
3574
+ #
3575
+ # @method toggle_crash_recovery(is_enabled)
3576
+ # @param [Integer] is_enabled
3577
+ # @return [nil]
3578
+ # @scope class
3579
+ attach_function :toggle_crash_recovery, :clang_toggleCrashRecovery, [:uint], :void
3580
+
3581
+ # Visitor invoked for each file in a translation unit
3582
+ # (used with clang_getInclusions()).
3583
+ #
3584
+ # This visitor function will be invoked by clang_getInclusions() for each
3585
+ # file included (either at the top-level or by #include directives) within
3586
+ # a translation unit. The first argument is the file being included, and
3587
+ # the second and third arguments provide the inclusion stack. The
3588
+ # array is sorted in order of immediate inclusion. For example,
3589
+ # the first element refers to the location that included 'included_file'.
3590
+ #
3591
+ # <em>This entry is only for documentation and no real method.</em>
3592
+ #
3593
+ # @method _callback_inclusion_visitor_(inclusion_stack, include_len, client_data)
3594
+ # @param [SourceLocation] inclusion_stack
3595
+ # @param [Integer] include_len
3596
+ # @param [FFI::Pointer(ClientData)] client_data
3597
+ # @return [FFI::Pointer(File)]
3598
+ # @scope class
3599
+ callback :inclusion_visitor, [SourceLocation, :uint, :pointer], :pointer
3600
+
3601
+ # Visit the set of preprocessor inclusions in a translation unit.
3602
+ # The visitor function is called with the provided data for every included
3603
+ # file. This does not include headers included by the PCH file (unless one
3604
+ # is inspecting the inclusions in the PCH file itself).
3605
+ #
3606
+ # @method get_inclusions(tu, visitor, client_data)
3607
+ # @param [TranslationUnitImpl] tu
3608
+ # @param [Proc(_callback_inclusion_visitor_)] visitor
3609
+ # @param [FFI::Pointer(ClientData)] client_data
3610
+ # @return [nil]
3611
+ # @scope class
3612
+ attach_function :get_inclusions, :clang_getInclusions, [TranslationUnitImpl, :inclusion_visitor, :pointer], :void
3613
+
3614
+ # Retrieve a remapping.
3615
+ #
3616
+ # @method get_remappings(path)
3617
+ # @param [String] path the path that contains metadata about remappings.
3618
+ # @return [FFI::Pointer(Remapping)] the requested remapping. This remapping must be freed
3619
+ # via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
3620
+ # @scope class
3621
+ attach_function :get_remappings, :clang_getRemappings, [:string], :pointer
3622
+
3623
+ # Determine the number of remappings.
3624
+ #
3625
+ # @method remap_get_num_files(remapping)
3626
+ # @param [FFI::Pointer(Remapping)] remapping
3627
+ # @return [Integer]
3628
+ # @scope class
3629
+ attach_function :remap_get_num_files, :clang_remap_getNumFiles, [:pointer], :uint
3630
+
3631
+ # Get the original and the associated filename from the remapping.
3632
+ #
3633
+ # @method remap_get_filenames(remapping, index, original, transformed)
3634
+ # @param [FFI::Pointer(Remapping)] remapping
3635
+ # @param [Integer] index
3636
+ # @param [String] original If non-NULL, will be set to the original filename.
3637
+ # @param [String] transformed If non-NULL, will be set to the filename that the original
3638
+ # is associated with.
3639
+ # @return [nil]
3640
+ # @scope class
3641
+ attach_function :remap_get_filenames, :clang_remap_getFilenames, [:pointer, :uint, String, String], :void
3642
+
3643
+ # Dispose the remapping.
3644
+ #
3645
+ # @method remap_dispose(remapping)
3646
+ # @param [FFI::Pointer(Remapping)] remapping
3647
+ # @return [nil]
3648
+ # @scope class
3649
+ attach_function :remap_dispose, :clang_remap_dispose, [:pointer], :void
3650
+
3651
+ # \defgroup CINDEX_HIGH Higher level API functions
3652
+ #
3653
+ # @{
3654
+ #
3655
+ # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:visitor_result).</em>
3656
+ #
3657
+ # === Options:
3658
+ # :break ::
3659
+ #
3660
+ # :continue ::
3661
+ #
3662
+ #
3663
+ # @method _enum_visitor_result_
3664
+ # @return [Symbol]
3665
+ # @scope class
3666
+ enum :visitor_result, [
3667
+ :break,
3668
+ :continue
3669
+ ]
3670
+
3671
+ # \defgroup CINDEX_HIGH Higher level API functions
3672
+ #
3673
+ # @{
3674
+ #
3675
+ # = Fields:
3676
+ # :context ::
3677
+ # (FFI::Pointer(*Void))
3678
+ # :visit ::
3679
+ # (FFI::Pointer(*))
3680
+ class CursorAndRangeVisitor < FFI::Struct
3681
+ layout :context, :pointer,
3682
+ :visit, :pointer
3683
+ end
3684
+
3685
+ # Find references of a declaration in a specific file.
3686
+ #
3687
+ # @method find_references_in_file(cursor, file, visitor)
3688
+ # @param [Cursor] cursor pointing to a declaration or a reference of one.
3689
+ # @param [FFI::Pointer(File)] file to search for references.
3690
+ # @param [CursorAndRangeVisitor] visitor callback that will receive pairs of CXCursor/CXSourceRange for
3691
+ # each reference found.
3692
+ # The CXSourceRange will point inside the file; if the reference is inside
3693
+ # a macro (and not a macro argument) the CXSourceRange will be invalid.
3694
+ # @return [nil]
3695
+ # @scope class
3696
+ attach_function :find_references_in_file, :clang_findReferencesInFile, [Cursor.by_value, :pointer, CursorAndRangeVisitor.by_value], :void
3697
+
3698
+ end
3699
+ end