Class: FFI::Clang::Cursor

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ffi/clang/cursor.rb

Overview

Represents a cursor in the abstract syntax tree (AST).

Defined Under Namespace

Classes: PlatformAvailability

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cxcursor, translation_unit) ⇒ Cursor

Initialize a cursor with a libclang cursor structure.



52
53
54
55
# File 'lib/ffi/clang/cursor.rb', line 52

def initialize(cxcursor, translation_unit)
	@cursor = cxcursor
	@translation_unit = translation_unit
end

Instance Attribute Details

#cursorObject (readonly)

Returns the value of attribute cursor.



31
32
33
# File 'lib/ffi/clang/cursor.rb', line 31

def cursor
  @cursor
end

#The translation unit this cursor belongs to.(translationunitthiscursorbelongsto.) ⇒ Object (readonly)



34
# File 'lib/ffi/clang/cursor.rb', line 34

attr_reader :translation_unit

#The underlying libclang cursor structure.(underlyinglibclangcursorstructure.) ⇒ Object (readonly)



31
# File 'lib/ffi/clang/cursor.rb', line 31

attr_reader :cursor

#translation_unitObject (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

Get the spelling of a cursor kind.



45
46
47
# File 'lib/ffi/clang/cursor.rb', line 45

def self.kind_spelling(kind)
	Lib.extract_string Lib.get_cursor_kind_spelling(kind)
end

.null_cursorObject

Get a null cursor.



38
39
40
# File 'lib/ffi/clang/cursor.rb', line 38

def self.null_cursor
	Cursor.new Lib.get_null_cursor, nil
end

Instance Method Details

#abstract?Boolean

Check if this cursor is abstract.

Returns:

  • (Boolean)


718
719
720
# File 'lib/ffi/clang/cursor.rb', line 718

def abstract?
	Lib.is_abstract(@cursor) != 0
end

#access_specifierObject

Get the C++ access specifier.



405
406
407
# File 'lib/ffi/clang/cursor.rb', line 405

def access_specifier
	Lib.get_cxx_access_specifier @cursor
end

#ancestors_by_kind(*kinds) ⇒ Object

Find ancestors of this cursor by kind.



458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/ffi/clang/cursor.rb', line 458

def ancestors_by_kind(*kinds)
	result = Array.new
	
	parent = self
	while parent != self.semantic_parent
		parent = self.semantic_parent
		if kinds.include?(parent.kind)
			result << parent
		end
	end
	result
end

#anonymous?Boolean

Check if this cursor is anonymous.

Returns:

  • (Boolean)


89
90
91
# File 'lib/ffi/clang/cursor.rb', line 89

def anonymous?
	Lib.cursor_is_anonymous(@cursor) != 0
end

#anonymous_record_declaration?Boolean

Check if this cursor is an anonymous record declaration.

Returns:

  • (Boolean)


95
96
97
# File 'lib/ffi/clang/cursor.rb', line 95

def anonymous_record_declaration?
	Lib.cursor_is_anonymous_record_decl(@cursor) != 0
end

#argument(i) ⇒ Object

Get a function or method argument by index.



614
615
616
# File 'lib/ffi/clang/cursor.rb', line 614

def argument(i)
	Cursor.new Lib.cursor_get_argument(@cursor, i), @translation_unit
end

#attribute?Boolean

Check if this cursor is an attribute.

Returns:

  • (Boolean)


125
126
127
# File 'lib/ffi/clang/cursor.rb', line 125

def attribute?
	Lib.is_attribute(kind) != 0
end

#availabilityObject

Get the availability of this cursor.



521
522
523
# File 'lib/ffi/clang/cursor.rb', line 521

def availability
	Lib.get_cursor_availability(@cursor)
end

#bitfield?Boolean

Check if this cursor represents a bitfield.

Returns:

  • (Boolean)


582
583
584
# File 'lib/ffi/clang/cursor.rb', line 582

def bitfield?
	Lib.is_bit_field(@cursor) != 0
end

#bitwidthObject

Get the bit width of a bitfield.



588
589
590
# File 'lib/ffi/clang/cursor.rb', line 588

def bitwidth
	Lib.get_field_decl_bit_width(@cursor)
end

#canonicalObject

Get the canonical cursor for this cursor.



350
351
352
# File 'lib/ffi/clang/cursor.rb', line 350

def canonical
	Cursor.new Lib.get_canonical_cursor(@cursor), @translation_unit
end

#commentObject

Get the parsed comment associated with this cursor.



71
72
73
# File 'lib/ffi/clang/cursor.rb', line 71

def comment
	Comment.build_from Lib.cursor_get_parsed_comment(@cursor)
end

#comment_rangeObject

Get the source range of the comment.



77
78
79
# File 'lib/ffi/clang/cursor.rb', line 77

def comment_range
	SourceRange.new(Lib.cursor_get_comment_range(@cursor))
end

#completionObject

Get the code completion string for this cursor.



83
84
85
# File 'lib/ffi/clang/cursor.rb', line 83

def completion
	CodeCompletion::String.new Lib.get_cursor_completion_string(@cursor)
end

#const?Boolean

Check if this cursor is const-qualified.

Returns:

  • (Boolean)


730
731
732
# File 'lib/ffi/clang/cursor.rb', line 730

def const?
	Lib.is_const(@cursor) != 0
end

#converting_constructor?Boolean

Check if this is a converting constructor.

Returns:

  • (Boolean)


658
659
660
# File 'lib/ffi/clang/cursor.rb', line 658

def converting_constructor?
	Lib.is_converting_constructor(@cursor) != 0
end

#copy_assignment_operator?Boolean

Check if this is a copy assignment operator.

Returns:

  • (Boolean)


700
701
702
# File 'lib/ffi/clang/cursor.rb', line 700

def copy_assignment_operator?
	Lib.is_copy_assignment_operator(@cursor) != 0
end

#copy_constructor?Boolean

Check if this is a copy constructor.

Returns:

  • (Boolean)


664
665
666
# File 'lib/ffi/clang/cursor.rb', line 664

def copy_constructor?
	Lib.is_copy_constructor(@cursor) != 0
end

#declaration?Boolean

Check if this cursor is a declaration.

Returns:

  • (Boolean)


101
102
103
# File 'lib/ffi/clang/cursor.rb', line 101

def declaration?
	Lib.is_declaration(kind) != 0
end

#default_constructor?Boolean

Check if this is a default constructor.

Returns:

  • (Boolean)


670
671
672
# File 'lib/ffi/clang/cursor.rb', line 670

def default_constructor?
	Lib.is_default_constructor(@cursor) != 0
end

#defaulted?Boolean

Check if this cursor is defaulted.

Returns:

  • (Boolean)


688
689
690
# File 'lib/ffi/clang/cursor.rb', line 688

def defaulted?
	Lib.is_defaulted(@cursor) != 0
end

#definitionObject

Get the definition cursor for this cursor.



356
357
358
# File 'lib/ffi/clang/cursor.rb', line 356

def definition
	Cursor.new Lib.get_cursor_definition(@cursor), @translation_unit
end

#definition?Boolean

Check if this cursor is a definition.

Returns:

  • (Boolean)


302
303
304
# File 'lib/ffi/clang/cursor.rb', line 302

def definition?
	Lib.is_definition(@cursor) != 0
end

#deleted?Boolean

Check if this cursor is deleted.

Returns:

  • (Boolean)


694
695
696
# File 'lib/ffi/clang/cursor.rb', line 694

def deleted?
	Lib.is_deleted(@cursor) != 0
end

#display_nameObject

Get the display name of this cursor.



204
205
206
# File 'lib/ffi/clang/cursor.rb', line 204

def display_name
	Lib.extract_string Lib.get_cursor_display_name(@cursor)
end

#dynamic_call?Boolean

Check if this cursor is a dynamic call.

Returns:

  • (Boolean)


290
291
292
# File 'lib/ffi/clang/cursor.rb', line 290

def dynamic_call?
	Lib.is_dynamic_call(@cursor) != 0
end

#each(recurse = true, &block) ⇒ Object

Iterate over child cursors.



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/ffi/clang/cursor.rb', line 427

def each(recurse = true, &block)
	return to_enum(:each, recurse) unless block_given?
	
	adapter = Proc.new do |cxcursor, parent_cursor, unused|
		# Call the block and capture the result. This lets advanced users
		# modify the recursion on a case by case basis if needed
		result = block.call Cursor.new(cxcursor, @translation_unit), Cursor.new(parent_cursor, @translation_unit)
		case result
		when :continue
			:continue
		when :recurse
			:recurse
		else
			recurse ? :recurse : :continue
		end
	end
	
	Lib.visit_children(@cursor, adapter, nil)
end

#enum_scoped?Boolean

Check if this is a scoped enum.

Returns:

  • (Boolean)


724
725
726
# File 'lib/ffi/clang/cursor.rb', line 724

def enum_scoped?
	Lib.is_enum_scoped(@cursor) != 0
end

#enum_typeObject

Get the integer type of an enum declaration.



338
339
340
# File 'lib/ffi/clang/cursor.rb', line 338

def enum_type
	Types::Type.create Lib.get_enum_decl_integer_type(@cursor), @translation_unit
end

#enum_unsigned_valueObject

Get the unsigned value of an enum constant.



332
333
334
# File 'lib/ffi/clang/cursor.rb', line 332

def enum_unsigned_value
	Lib.get_enum_unsigned_value @cursor
end

#enum_valueObject

Get the value of an enum constant.



326
327
328
# File 'lib/ffi/clang/cursor.rb', line 326

def enum_value
	Lib.get_enum_value @cursor
end

#eql?(other) ⇒ Boolean Also known as: ==

Check if this cursor equals another cursor.

Returns:

  • (Boolean)


627
628
629
# File 'lib/ffi/clang/cursor.rb', line 627

def eql?(other)
	Lib.are_equal(@cursor, other.cursor) != 0
end

#exception_specificationObject

Get the exception specification type for this cursor.



515
516
517
# File 'lib/ffi/clang/cursor.rb', line 515

def exception_specification
	Lib.get_cursor_exception_specification_type(@cursor)
end

#expansion_locationObject Also known as: location

Get the expansion location of this cursor.



173
174
175
# File 'lib/ffi/clang/cursor.rb', line 173

def expansion_location
	ExpansionLocation.new(Lib.get_cursor_location(@cursor))
end

#explicit?Boolean

Check if this cursor is explicit.

Returns:

  • (Boolean)


712
713
714
# File 'lib/ffi/clang/cursor.rb', line 712

def explicit?
	Lib.is_explicit(@cursor) != 0
end

#expression?Boolean

Check if this cursor is an expression.

Returns:

  • (Boolean)


113
114
115
# File 'lib/ffi/clang/cursor.rb', line 113

def expression?
	Lib.is_expression(kind) != 0
end

#extentObject

Get the source extent of this cursor.



198
199
200
# File 'lib/ffi/clang/cursor.rb', line 198

def extent
	SourceRange.new(Lib.get_cursor_extent(@cursor))
end

#file_locationObject

Get the file location of this cursor.



192
193
194
# File 'lib/ffi/clang/cursor.rb', line 192

def file_location
	FileLocation.new(Lib.get_cursor_location(@cursor))
end

#find_by_kind(recurse, *kinds) ⇒ Object

Find child cursors by kind.



476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/ffi/clang/cursor.rb', line 476

def find_by_kind(recurse, *kinds)
	unless (recurse == nil || recurse == true || recurse == false)
		raise("Recurse parameter must be nil or a boolean value. Value was: #{recurse}")
	end
	
	result = Array.new
	self.each(recurse) do |child, parent|
		if kinds.include?(child.kind)
			result << child
		end
	end
	result
end

#find_references_in_file(file = nil, &block) ⇒ Object

Find all references to this cursor in a file.



495
496
497
498
499
500
501
502
503
504
505
# File 'lib/ffi/clang/cursor.rb', line 495

def find_references_in_file(file = nil, &block)
	file ||= Lib.extract_string Lib.get_translation_unit_spelling(@translation_unit)
	
	visit_adapter = Proc.new do |unused, cxcursor, cxsource_range|
		block.call Cursor.new(cxcursor, @translation_unit), SourceRange.new(cxsource_range)
	end
	visitor = FFI::Clang::Lib::CXCursorAndRangeVisitor.new
	visitor[:visit] = visit_adapter
	
	Lib.find_references_in_file(@cursor, Lib.get_file(@translation_unit, file), visitor)
end

#forward_declaration?Boolean

Check if this is a forward declaration.

Returns:

  • (Boolean)


369
370
371
372
373
374
375
376
377
# File 'lib/ffi/clang/cursor.rb', line 369

def forward_declaration?
	# Is this a forward declaration for a definition contained in the same translation_unit?
	# https://joshpeterson.github.io/identifying-a-forward-declaration-with-libclang
	#
	# Possible alternate implementations?
	# self.declaration? && !self.definition? && self.definition
	# !self.definition? && self.definition
	self.declaration? && !self.eql?(self.definition) && !self.definition.invalid?
end

#hashObject

Get the hash code for this cursor.



634
635
636
# File 'lib/ffi/clang/cursor.rb', line 634

def hash
	Lib.get_cursor_hash(@cursor)
end

#included_fileObject

Get the file included by this cursor.



527
528
529
# File 'lib/ffi/clang/cursor.rb', line 527

def included_file
	File.new Lib.get_included_file(@cursor), @translation_unit
end

#invalid?Boolean

Check if this cursor is invalid.

Returns:

  • (Boolean)


149
150
151
# File 'lib/ffi/clang/cursor.rb', line 149

def invalid?
	Lib.is_invalid(kind) != 0
end

#kindObject

Get the kind of this cursor.



254
255
256
# File 'lib/ffi/clang/cursor.rb', line 254

def kind
	@cursor ? @cursor[:kind] : nil
end

#kind_spellingObject

Get the spelling of the cursor kind.



260
261
262
# File 'lib/ffi/clang/cursor.rb', line 260

def kind_spelling
	Cursor.kind_spelling @cursor[:kind]
end

#languageObject

Get the programming language of this cursor.



411
412
413
# File 'lib/ffi/clang/cursor.rb', line 411

def language
	Lib.get_language @cursor
end

#lexical_parentObject

Get the lexical parent of this cursor.



393
394
395
# File 'lib/ffi/clang/cursor.rb', line 393

def lexical_parent
	Cursor.new Lib.get_cursor_lexical_parent(@cursor), @translation_unit
end

#linkageObject

Get the linkage of this cursor.



509
510
511
# File 'lib/ffi/clang/cursor.rb', line 509

def linkage
	Lib.get_cursor_linkage(@cursor)
end

#move_assignment_operator?Boolean

Check if this is a move assignment operator.

Returns:

  • (Boolean)


706
707
708
# File 'lib/ffi/clang/cursor.rb', line 706

def move_assignment_operator?
	Lib.is_move_assignment_operator(@cursor) != 0
end

#move_constructor?Boolean

Check if this is a move constructor.

Returns:

  • (Boolean)


676
677
678
# File 'lib/ffi/clang/cursor.rb', line 676

def move_constructor?
	Lib.is_move_constructor(@cursor) != 0
end

#mutable?Boolean

Check if this cursor is mutable.

Returns:

  • (Boolean)


682
683
684
# File 'lib/ffi/clang/cursor.rb', line 682

def mutable?
	Lib.is_mutable(@cursor) != 0
end

#null?Boolean

Check if this cursor is null.

Returns:

  • (Boolean)


59
60
61
# File 'lib/ffi/clang/cursor.rb', line 59

def null?
	Lib.cursor_is_null(@cursor) != 0
end

#num_argsObject

Get the number of arguments for this cursor.



417
418
419
# File 'lib/ffi/clang/cursor.rb', line 417

def num_args
	Lib.get_num_args @cursor
end

#num_argumentsObject

Get the number of arguments.



620
621
622
# File 'lib/ffi/clang/cursor.rb', line 620

def num_arguments
	Lib.cursor_get_num_arguments(@cursor)
end

#num_overloaded_declsObject

Get the number of overloaded declarations.



601
602
603
# File 'lib/ffi/clang/cursor.rb', line 601

def num_overloaded_decls
	Lib.get_num_overloaded_decls(@cursor)
end

#objc_type_encodingObject

Get the Objective-C type encoding.



607
608
609
# File 'lib/ffi/clang/cursor.rb', line 607

def objc_type_encoding
	Lib.extract_string Lib.get_decl_objc_type_encoding(@cursor)
end

#opaque_declaration?Boolean

Check if this is an opaque declaration without a definition.

Returns:

  • (Boolean)


362
363
364
365
# File 'lib/ffi/clang/cursor.rb', line 362

def opaque_declaration?
	# Is this a declaration that does not have a definition in the translation unit
	self.declaration? && !self.definition? && self.definition.invalid?
end

#overloaded_decl(i) ⇒ Object

Get an overloaded declaration by index.



595
596
597
# File 'lib/ffi/clang/cursor.rb', line 595

def overloaded_decl(i)
	Cursor.new Lib.get_overloaded_decl(@cursor, i), @translation_unit
end

#overriddensObject

Get all cursors that this cursor overrides.



565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/ffi/clang/cursor.rb', line 565

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

Get platform availability information for this cursor.



534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/ffi/clang/cursor.rb', line 534

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
	deprecated_message_ptr = FFI::MemoryPointer.new Lib::CXString
	unavailable_message_ptr = FFI::MemoryPointer.new Lib::CXString
	
	actual_availability_size = Lib.get_cursor_platform_availability(
		@cursor,
		always_deprecated_ptr, deprecated_message_ptr,
		always_unavailable_ptr, unavailable_message_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(deprecated_message_ptr)),
		unavailable_message: Lib.extract_string(Lib::CXString.new(unavailable_message_ptr)),
		availability: availability
	}
end

#preprocessing?Boolean

Check if this cursor is a preprocessing directive.

Returns:

  • (Boolean)


161
162
163
# File 'lib/ffi/clang/cursor.rb', line 161

def preprocessing?
	Lib.is_preprocessing(kind) != 0
end

#presumed_locationObject

Get the presumed location of this cursor.



180
181
182
# File 'lib/ffi/clang/cursor.rb', line 180

def presumed_location
	PresumedLocation.new(Lib.get_cursor_location(@cursor))
end

#printing_policyObject

Get the printing policy for this cursor.



242
243
244
# File 'lib/ffi/clang/cursor.rb', line 242

def printing_policy
	PrintingPolicy.new(cursor)
end

#private?Boolean

Check if this cursor has private access.

Returns:

  • (Boolean)


137
138
139
# File 'lib/ffi/clang/cursor.rb', line 137

def private?
	Lib.cxx_get_access_specifier(@cursor) == :private
end

#protected?Boolean

Check if this cursor has protected access.

Returns:

  • (Boolean)


143
144
145
# File 'lib/ffi/clang/cursor.rb', line 143

def protected?
	Lib.cxx_get_access_specifier(@cursor) == :protected
end

#public?Boolean

Check if this cursor has public access.

Returns:

  • (Boolean)


131
132
133
# File 'lib/ffi/clang/cursor.rb', line 131

def public?
	Lib.cxx_get_access_specifier(@cursor) == :public
end

#pure_virtual?Boolean

Check if this is a pure virtual method.

Returns:

  • (Boolean)


320
321
322
# File 'lib/ffi/clang/cursor.rb', line 320

def pure_virtual?
	Lib.cxx_method_is_pure_virtual(@cursor) != 0
end

#qualified_display_nameObject

Get the qualified display name including parent scope.



211
212
213
214
215
216
217
218
219
# File 'lib/ffi/clang/cursor.rb', line 211

def qualified_display_name
	if self.kind != :cursor_translation_unit
		if self.semantic_parent.kind == :cursor_invalid_file
			raise(ArgumentError, "Invalid semantic parent: #{self}")
		end
		result = self.semantic_parent.qualified_display_name
		result ? "#{result}::#{self.display_name}" : self.display_name
	end
end

#qualified_nameObject

Get the fully qualified name of this cursor.



224
225
226
227
228
229
230
231
232
# File 'lib/ffi/clang/cursor.rb', line 224

def qualified_name
	if self.kind != :cursor_translation_unit
		if self.semantic_parent.kind == :cursor_invalid_file
			raise(ArgumentError, "Invalid semantic parent: #{self}")
		end
		result = self.semantic_parent.qualified_name
		result ? "#{result}::#{self.spelling}" : self.spelling
	end
end

#raw_comment_textObject

Get the raw comment text associated with this cursor.



65
66
67
# File 'lib/ffi/clang/cursor.rb', line 65

def raw_comment_text
	Lib.extract_string Lib.cursor_get_raw_comment_text(@cursor)
end

#reference?Boolean

Check if this cursor is a reference.

Returns:

  • (Boolean)


107
108
109
# File 'lib/ffi/clang/cursor.rb', line 107

def reference?
	Lib.is_reference(kind) != 0
end

#referencedObject

Get the cursor referenced by this cursor.



381
382
383
# File 'lib/ffi/clang/cursor.rb', line 381

def referenced
	Cursor.new Lib.get_cursor_referenced(@cursor), @translation_unit
end

#references(file = nil) ⇒ Object

Find all references to this cursor.



647
648
649
650
651
652
653
654
# File 'lib/ffi/clang/cursor.rb', line 647

def references(file = nil)
	refs = []
	self.find_references_in_file(file) do |cursor, unused|
		refs << cursor
		:continue
	end
	refs
end

#result_typeObject

Get the result type for a function cursor.



272
273
274
# File 'lib/ffi/clang/cursor.rb', line 272

def result_type
	Types::Type.create Lib.get_cursor_result_type(@cursor), @translation_unit
end

#semantic_parentObject

Get the semantic parent of this cursor.



387
388
389
# File 'lib/ffi/clang/cursor.rb', line 387

def semantic_parent
	Cursor.new Lib.get_cursor_semantic_parent(@cursor), @translation_unit
end

#specialized_templateObject

Get the template that this cursor specializes.



344
345
346
# File 'lib/ffi/clang/cursor.rb', line 344

def specialized_template
	Cursor.new Lib.get_specialized_cursor_template(@cursor), @translation_unit
end

#spellingObject

Get the spelling (name) of this cursor.



236
237
238
# File 'lib/ffi/clang/cursor.rb', line 236

def spelling
	Lib.extract_string Lib.get_cursor_spelling(@cursor)
end

#spelling_locationObject

Get the spelling location of this cursor.



186
187
188
# File 'lib/ffi/clang/cursor.rb', line 186

def spelling_location
	SpellingLocation.new(Lib.get_cursor_location(@cursor))
end

#statement?Boolean

Check if this cursor is a statement.

Returns:

  • (Boolean)


119
120
121
# File 'lib/ffi/clang/cursor.rb', line 119

def statement?
	Lib.is_statement(kind) != 0
end

#static?Boolean

Check if this is a static method.

Returns:

  • (Boolean)


308
309
310
# File 'lib/ffi/clang/cursor.rb', line 308

def static?
	Lib.cxx_method_is_static(@cursor) != 0
end

#template_kindObject

Get the template cursor kind.



399
400
401
# File 'lib/ffi/clang/cursor.rb', line 399

def template_kind
	Lib.get_template_cursor_kind @cursor
end

#to_sObject

Get a string representation of this cursor.



640
641
642
# File 'lib/ffi/clang/cursor.rb', line 640

def to_s
	"Cursor <#{self.kind.to_s.gsub(/^cursor_/, '')}: #{self.spelling}>"
end

#translation_unit?Boolean

Check if this cursor is a translation unit.

Returns:

  • (Boolean)


155
156
157
# File 'lib/ffi/clang/cursor.rb', line 155

def translation_unit?
	Lib.is_translation_unit(kind) != 0
end

#typeObject

Get the type of this cursor.



266
267
268
# File 'lib/ffi/clang/cursor.rb', line 266

def type
	Types::Type.create Lib.get_cursor_type(@cursor), @translation_unit
end

#underlying_typeObject

Get the underlying type for a typedef cursor.



278
279
280
# File 'lib/ffi/clang/cursor.rb', line 278

def underlying_type
	Types::Type.create Lib.get_typedef_decl_underlying_type(@cursor), @translation_unit
end

#unexposed?Boolean

Check if this cursor is unexposed.

Returns:

  • (Boolean)


167
168
169
# File 'lib/ffi/clang/cursor.rb', line 167

def unexposed?
	Lib.is_unexposed(kind) != 0
end

#usrObject

Get the Unified Symbol Resolution (USR) for this cursor.



248
249
250
# File 'lib/ffi/clang/cursor.rb', line 248

def usr
	Lib.extract_string Lib.get_cursor_usr(@cursor)
end

#variadic?Boolean

Check if this cursor is variadic.

Returns:

  • (Boolean)


296
297
298
# File 'lib/ffi/clang/cursor.rb', line 296

def variadic?
	Lib.is_variadic(@cursor) != 0
end

#virtual?Boolean

Check if this is a virtual method.

Returns:

  • (Boolean)


314
315
316
# File 'lib/ffi/clang/cursor.rb', line 314

def virtual?
	Lib.cxx_method_is_virtual(@cursor) != 0
end

#virtual_base?Boolean

Check if this cursor is a virtual base class.

Returns:

  • (Boolean)


284
285
286
# File 'lib/ffi/clang/cursor.rb', line 284

def virtual_base?
	Lib.is_virtual_base(@cursor) != 0
end

#visit_children(&block) ⇒ Object

Visit only direct children without recursing.



451
452
453
# File 'lib/ffi/clang/cursor.rb', line 451

def visit_children(&block)
	each(false, &block)
end