Class: FFI::Clang::Cursor
- Inherits:
-
Object
- Object
- FFI::Clang::Cursor
- Defined in:
- lib/ffi/clang/cursor.rb
Defined Under Namespace
Classes: PlatformAvailability
Instance Attribute Summary collapse
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
-
#translation_unit ⇒ Object
readonly
Returns the value of attribute translation_unit.
Class Method Summary collapse
-
.kind_spelling(kind) ⇒ Object
this function is categorized as “Debugging facilities”.
- .null_cursor ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #access_specifier ⇒ Object
- #argument(i) ⇒ Object
- #attribute? ⇒ Boolean
- #availability ⇒ Object
- #bitfield? ⇒ Boolean
- #bitwidth ⇒ Object
- #canonical ⇒ Object
- #comment ⇒ Object
- #comment_range ⇒ Object
- #completion ⇒ Object
- #declaration? ⇒ Boolean
- #definition ⇒ Object
- #definition? ⇒ Boolean
- #display_name ⇒ Object
- #dynamic_call? ⇒ Boolean
- #enum_decl_integer_type ⇒ Object
- #enum_type ⇒ Object
- #enum_unsigned_value ⇒ Object
- #enum_value ⇒ Object
- #expression? ⇒ Boolean
- #extent ⇒ Object
- #filter ⇒ Object
- #find_all(*kinds) ⇒ Object
- #find_first(*kinds) ⇒ Object
- #hash ⇒ Object
- #included_file ⇒ Object
-
#initialize(cxcursor, translation_unit) ⇒ Cursor
constructor
A new instance of Cursor.
- #invalid? ⇒ Boolean
- #kind ⇒ Object
- #kind_spelling ⇒ Object
- #language ⇒ Object
- #lexical_parent ⇒ Object
- #linkage ⇒ Object
- #location ⇒ Object
- #null? ⇒ Boolean
- #num_args ⇒ Object
- #num_arguments ⇒ Object
- #num_overloaded_decls ⇒ Object
- #objc_type_encoding ⇒ Object
- #overloaded_decl(i) ⇒ Object
- #overriddens ⇒ Object
- #platform_availability(max_availability_size = 4) ⇒ Object
- #preprocessing? ⇒ Boolean
- #private? ⇒ Boolean
- #protected? ⇒ Boolean
- #public? ⇒ Boolean
- #pure_virtual? ⇒ Boolean
- #raw_comment_text ⇒ Object
- #reference? ⇒ Boolean
- #referenced ⇒ Object
- #result_type ⇒ Object
- #select ⇒ Object
- #semantic_parent ⇒ Object
- #specialized_template ⇒ Object
- #spelling ⇒ Object
- #statement? ⇒ Boolean
- #static? ⇒ Boolean
- #template_kind ⇒ Object
- #to_a ⇒ Object
- #translation_unit? ⇒ Boolean
- #type ⇒ Object
- #typedef_type ⇒ Object
- #underlying_type ⇒ Object
- #unexposed? ⇒ Boolean
- #usr ⇒ Object
- #variadic? ⇒ Boolean
- #virtual? ⇒ Boolean
- #virtual_base? ⇒ Boolean
- #visit_children(&block) ⇒ Object
Constructor Details
#initialize(cxcursor, translation_unit) ⇒ Cursor
Returns a new instance of Cursor.
45 46 47 48 |
# File 'lib/ffi/clang/cursor.rb', line 45 def initialize(cxcursor, translation_unit) @cursor = cxcursor @translation_unit = translation_unit end |
Instance Attribute Details
#cursor ⇒ Object (readonly)
Returns the value of attribute cursor.
33 34 35 |
# File 'lib/ffi/clang/cursor.rb', line 33 def cursor @cursor end |
#translation_unit ⇒ Object (readonly)
Returns the value of attribute translation_unit.
34 35 36 |
# File 'lib/ffi/clang/cursor.rb', line 34 def translation_unit @translation_unit end |
Class Method Details
.kind_spelling(kind) ⇒ Object
this function is categorized as “Debugging facilities”
41 42 43 |
# File 'lib/ffi/clang/cursor.rb', line 41 def self.kind_spelling(kind) Lib.extract_string Lib.get_cursor_kind_spelling(kind) end |
Instance Method Details
#==(other) ⇒ Object
344 345 346 |
# File 'lib/ffi/clang/cursor.rb', line 344 def ==(other) Lib.are_equal(@cursor, other.cursor) != 0 end |
#access_specifier ⇒ Object
234 235 236 |
# File 'lib/ffi/clang/cursor.rb', line 234 def access_specifier Lib.get_cxx_access_specifier @cursor end |
#argument(i) ⇒ Object
336 337 338 |
# File 'lib/ffi/clang/cursor.rb', line 336 def argument(i) Cursor.new Lib.cursor_get_argument(@cursor, i), @translation_unit end |
#attribute? ⇒ Boolean
86 87 88 |
# File 'lib/ffi/clang/cursor.rb', line 86 def attribute? Lib.is_attribute(kind) != 0 end |
#availability ⇒ Object
258 259 260 |
# File 'lib/ffi/clang/cursor.rb', line 258 def availability Lib.get_cursor_availability(@cursor) end |
#bitfield? ⇒ Boolean
316 317 318 |
# File 'lib/ffi/clang/cursor.rb', line 316 def bitfield? Lib.is_bit_field(@cursor) != 0 end |
#bitwidth ⇒ Object
320 321 322 |
# File 'lib/ffi/clang/cursor.rb', line 320 def bitwidth Lib.get_field_decl_bit_width(@cursor) end |
#canonical ⇒ Object
210 211 212 |
# File 'lib/ffi/clang/cursor.rb', line 210 def canonical Cursor.new Lib.get_canonical_cursor(@cursor), @translation_unit end |
#comment ⇒ Object
58 59 60 |
# File 'lib/ffi/clang/cursor.rb', line 58 def comment Comment.build_from Lib.cursor_get_parsed_comment(@cursor) end |
#comment_range ⇒ Object
62 63 64 |
# File 'lib/ffi/clang/cursor.rb', line 62 def comment_range SourceRange.new(Lib.cursor_get_comment_range(@cursor)) end |
#completion ⇒ Object
66 67 68 |
# File 'lib/ffi/clang/cursor.rb', line 66 def completion CodeCompletion::String.new Lib.get_cursor_completion_string(@cursor) end |
#declaration? ⇒ Boolean
70 71 72 |
# File 'lib/ffi/clang/cursor.rb', line 70 def declaration? Lib.is_declaration(kind) != 0 end |
#definition ⇒ Object
214 215 216 |
# File 'lib/ffi/clang/cursor.rb', line 214 def definition Cursor.new Lib.get_cursor_definition(@cursor), @translation_unit end |
#definition? ⇒ Boolean
178 179 180 |
# File 'lib/ffi/clang/cursor.rb', line 178 def definition? Lib.is_definition(@cursor) != 0 end |
#display_name ⇒ Object
126 127 128 |
# File 'lib/ffi/clang/cursor.rb', line 126 def display_name Lib.extract_string Lib.get_cursor_display_name(@cursor) end |
#dynamic_call? ⇒ Boolean
170 171 172 |
# File 'lib/ffi/clang/cursor.rb', line 170 def dynamic_call? Lib.is_dynamic_call(@cursor) != 0 end |
#enum_decl_integer_type ⇒ Object
158 159 160 |
# File 'lib/ffi/clang/cursor.rb', line 158 def enum_decl_integer_type Type.new Lib.get_enum_decl_integer_type(@cursor), @translation_unit end |
#enum_type ⇒ Object
202 203 204 |
# File 'lib/ffi/clang/cursor.rb', line 202 def enum_type Type.new Lib.get_enum_type(@cursor), @translation_unit end |
#enum_unsigned_value ⇒ Object
198 199 200 |
# File 'lib/ffi/clang/cursor.rb', line 198 def enum_unsigned_value Lib.get_enum_unsigned_value @cursor end |
#enum_value ⇒ Object
194 195 196 |
# File 'lib/ffi/clang/cursor.rb', line 194 def enum_value Lib.get_enum_value @cursor end |
#expression? ⇒ Boolean
78 79 80 |
# File 'lib/ffi/clang/cursor.rb', line 78 def expression? Lib.is_expression(kind) != 0 end |
#extent ⇒ Object
122 123 124 |
# File 'lib/ffi/clang/cursor.rb', line 122 def extent SourceRange.new(Lib.get_cursor_extent(@cursor)) end |
#filter ⇒ Object
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/ffi/clang/cursor.rb', line 358 def filter return to_enum(:select) unless block_given? matching = [] self.visit_children do |child, parent| if yield(child, parent) matching << child end :recurse end return matching end |
#find_all(*kinds) ⇒ Object
348 349 350 351 352 |
# File 'lib/ffi/clang/cursor.rb', line 348 def find_all(*kinds) filter do |child, parent| kinds.include?(child.kind) end end |
#find_first(*kinds) ⇒ Object
354 355 356 |
# File 'lib/ffi/clang/cursor.rb', line 354 def find_first(*kinds) find_all(*kinds).first end |
#hash ⇒ Object
312 313 314 |
# File 'lib/ffi/clang/cursor.rb', line 312 def hash Lib.get_cursor_hash(@cursor) end |
#included_file ⇒ Object
262 263 264 |
# File 'lib/ffi/clang/cursor.rb', line 262 def included_file File.new Lib.get_included_file(@cursor), @translation_unit end |
#invalid? ⇒ Boolean
102 103 104 |
# File 'lib/ffi/clang/cursor.rb', line 102 def invalid? Lib.is_invalid(kind) != 0 end |
#kind ⇒ Object
138 139 140 |
# File 'lib/ffi/clang/cursor.rb', line 138 def kind @cursor[:kind] end |
#kind_spelling ⇒ Object
142 143 144 |
# File 'lib/ffi/clang/cursor.rb', line 142 def kind_spelling Cursor.kind_spelling @cursor[:kind] end |
#language ⇒ Object
238 239 240 |
# File 'lib/ffi/clang/cursor.rb', line 238 def language Lib.get_language @cursor end |
#lexical_parent ⇒ Object
226 227 228 |
# File 'lib/ffi/clang/cursor.rb', line 226 def lexical_parent Cursor.new Lib.get_cursor_lexical_parent(@cursor), @translation_unit end |
#linkage ⇒ Object
254 255 256 |
# File 'lib/ffi/clang/cursor.rb', line 254 def linkage Lib.get_cursor_linkage(@cursor) end |
#location ⇒ Object
118 119 120 |
# File 'lib/ffi/clang/cursor.rb', line 118 def location ExpansionLocation.new(Lib.get_cursor_location(@cursor)) end |
#null? ⇒ Boolean
50 51 52 |
# File 'lib/ffi/clang/cursor.rb', line 50 def null? Lib.cursor_is_null(@cursor) != 0 end |
#num_args ⇒ Object
242 243 244 |
# File 'lib/ffi/clang/cursor.rb', line 242 def num_args Lib.get_num_args @cursor end |
#num_arguments ⇒ Object
340 341 342 |
# File 'lib/ffi/clang/cursor.rb', line 340 def num_arguments Lib.cursor_get_num_arguments(@cursor) end |
#num_overloaded_decls ⇒ Object
328 329 330 |
# File 'lib/ffi/clang/cursor.rb', line 328 def num_overloaded_decls Lib.get_num_overloaded_decls(@cursor) end |
#objc_type_encoding ⇒ Object
332 333 334 |
# File 'lib/ffi/clang/cursor.rb', line 332 def objc_type_encoding Lib.extract_string Lib.get_decl_objc_type_encoding(@cursor) end |
#overloaded_decl(i) ⇒ Object
324 325 326 |
# File 'lib/ffi/clang/cursor.rb', line 324 def overloaded_decl(i) Cursor.new Lib.get_overloaded_decl(@cursor, i), @translation_unit end |
#overriddens ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/ffi/clang/cursor.rb', line 296 def overriddens cursor_ptr = FFI::MemoryPointer.new :pointer num_ptr = FFI::MemoryPointer.new :uint Lib.get_overridden_cursors(@cursor, cursor_ptr, num_ptr) num = num_ptr.get_uint(0) cur_ptr = cursor_ptr.get_pointer(0) overriddens = [] num.times { overriddens << Cursor.new(cur_ptr, @translation_unit) cur_ptr += Lib::CXCursor.size } Lib.dispose_overridden_cursors(cursor_ptr.get_pointer(0)) if num != 0 overriddens end |
#platform_availability(max_availability_size = 4) ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/ffi/clang/cursor.rb', line 266 def platform_availability(max_availability_size = 4) availability_ptr = FFI::MemoryPointer.new(Lib::CXPlatformAvailability, max_availability_size) always_deprecated_ptr = FFI::MemoryPointer.new :int always_unavailable_ptr = FFI::MemoryPointer.new :int = FFI::MemoryPointer.new Lib::CXString = FFI::MemoryPointer.new Lib::CXString actual_availability_size = Lib.get_cursor_platform_availability( @cursor, always_deprecated_ptr, , always_unavailable_ptr, , availability_ptr, max_availability_size) availability = [] cur_ptr = availability_ptr [actual_availability_size, max_availability_size].min.times { availability << PlatformAvailability.new(cur_ptr) cur_ptr += Lib::CXPlatformAvailability.size } # return as Hash { always_deprecated: always_deprecated_ptr.get_int(0), always_unavailable: always_unavailable_ptr.get_int(0), deprecated_message: Lib.extract_string(Lib::CXString.new()), unavailable_message: Lib.extract_string(Lib::CXString.new()), availability: availability } end |
#preprocessing? ⇒ Boolean
110 111 112 |
# File 'lib/ffi/clang/cursor.rb', line 110 def preprocessing? Lib.is_preprocessing(kind) != 0 end |
#private? ⇒ Boolean
94 95 96 |
# File 'lib/ffi/clang/cursor.rb', line 94 def private? Lib.cxx_get_access_specifier(@cursor) == :private end |
#protected? ⇒ Boolean
98 99 100 |
# File 'lib/ffi/clang/cursor.rb', line 98 def protected? Lib.cxx_get_access_specifier(@cursor) == :protected end |
#public? ⇒ Boolean
90 91 92 |
# File 'lib/ffi/clang/cursor.rb', line 90 def public? Lib.cxx_get_access_specifier(@cursor) == :public end |
#pure_virtual? ⇒ Boolean
190 191 192 |
# File 'lib/ffi/clang/cursor.rb', line 190 def pure_virtual? Lib.cxx_method_is_pure_virtual(@cursor) != 0 end |
#raw_comment_text ⇒ Object
54 55 56 |
# File 'lib/ffi/clang/cursor.rb', line 54 def raw_comment_text Lib.extract_string Lib.cursor_get_raw_comment_text(@cursor) end |
#reference? ⇒ Boolean
74 75 76 |
# File 'lib/ffi/clang/cursor.rb', line 74 def reference? Lib.is_reference(kind) != 0 end |
#referenced ⇒ Object
218 219 220 |
# File 'lib/ffi/clang/cursor.rb', line 218 def referenced Cursor.new Lib.get_cursor_referenced(@cursor), @translation_unit end |
#result_type ⇒ Object
150 151 152 |
# File 'lib/ffi/clang/cursor.rb', line 150 def result_type Type.new Lib.get_cursor_result_type(@cursor), @translation_unit end |
#select ⇒ Object
374 375 376 377 378 |
# File 'lib/ffi/clang/cursor.rb', line 374 def select filter do |child, parent| yield(child) end end |
#semantic_parent ⇒ Object
222 223 224 |
# File 'lib/ffi/clang/cursor.rb', line 222 def semantic_parent Cursor.new Lib.get_cursor_semantic_parent(@cursor), @translation_unit end |
#specialized_template ⇒ Object
206 207 208 |
# File 'lib/ffi/clang/cursor.rb', line 206 def specialized_template Cursor.new Lib.get_specialized_cursor_template(@cursor), @translation_unit end |
#spelling ⇒ Object
130 131 132 |
# File 'lib/ffi/clang/cursor.rb', line 130 def spelling Lib.extract_string Lib.get_cursor_spelling(@cursor) end |
#statement? ⇒ Boolean
82 83 84 |
# File 'lib/ffi/clang/cursor.rb', line 82 def statement? Lib.is_statement(kind) != 0 end |
#static? ⇒ Boolean
182 183 184 |
# File 'lib/ffi/clang/cursor.rb', line 182 def static? Lib.cxx_method_is_static(@cursor) != 0 end |
#template_kind ⇒ Object
230 231 232 |
# File 'lib/ffi/clang/cursor.rb', line 230 def template_kind Lib.get_template_cursor_kind @cursor end |
#to_a ⇒ Object
380 381 382 |
# File 'lib/ffi/clang/cursor.rb', line 380 def to_a filter.collect{|child, parent| child} end |
#translation_unit? ⇒ Boolean
106 107 108 |
# File 'lib/ffi/clang/cursor.rb', line 106 def translation_unit? Lib.is_translation_unit(kind) != 0 end |
#type ⇒ Object
146 147 148 |
# File 'lib/ffi/clang/cursor.rb', line 146 def type Type.new Lib.get_cursor_type(@cursor), @translation_unit end |
#typedef_type ⇒ Object
162 163 164 |
# File 'lib/ffi/clang/cursor.rb', line 162 def typedef_type Type.new Lib.(@cursor), @translation_unit end |
#underlying_type ⇒ Object
154 155 156 |
# File 'lib/ffi/clang/cursor.rb', line 154 def Type.new Lib.(@cursor), @translation_unit end |
#unexposed? ⇒ Boolean
114 115 116 |
# File 'lib/ffi/clang/cursor.rb', line 114 def unexposed? Lib.is_unexposed(kind) != 0 end |
#usr ⇒ Object
134 135 136 |
# File 'lib/ffi/clang/cursor.rb', line 134 def usr Lib.extract_string Lib.get_cursor_usr(@cursor) end |
#variadic? ⇒ Boolean
174 175 176 |
# File 'lib/ffi/clang/cursor.rb', line 174 def variadic? Lib.is_variadic(@cursor) != 0 end |
#virtual? ⇒ Boolean
186 187 188 |
# File 'lib/ffi/clang/cursor.rb', line 186 def virtual? Lib.cxx_method_is_virtual(@cursor) != 0 end |
#virtual_base? ⇒ Boolean
166 167 168 |
# File 'lib/ffi/clang/cursor.rb', line 166 def virtual_base? Lib.is_virtual_base(@cursor) != 0 end |
#visit_children(&block) ⇒ Object
246 247 248 249 250 251 252 |
# File 'lib/ffi/clang/cursor.rb', line 246 def visit_children(&block) adapter = Proc.new do |cxcursor, parent_cursor, unused| block.call Cursor.new(cxcursor, @translation_unit), Cursor.new(parent_cursor, @translation_unit) end Lib.visit_children(@cursor, adapter, nil) end |