ffi_gen 0.7

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