Class: FFI::Clang::SourceRange
- Inherits:
-
Object
- Object
- FFI::Clang::SourceRange
- Defined in:
- lib/ffi/clang/source_range.rb
Overview
Represents a source range in a file.
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
- #The underlying range structure.(underlyingrangestructure.) ⇒ Object readonly
Class Method Summary collapse
-
.null_range ⇒ Object
Get a null source range.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Check if this range equals another range.
-
#bytesize ⇒ Object
Get the size in bytes of the source range.
-
#end ⇒ Object
Get the end location of this range.
-
#initialize(range_or_begin_location, end_location = nil) ⇒ SourceRange
constructor
Initialize a source range.
-
#null? ⇒ Boolean
Check if this range is null.
-
#start ⇒ Object
Get the start location of this range.
-
#text ⇒ Object
Read the text from the source file for this range.
Constructor Details
#initialize(range_or_begin_location, end_location = nil) ⇒ SourceRange
Initialize a source range.
25 26 27 28 29 30 31 |
# File 'lib/ffi/clang/source_range.rb', line 25 def initialize(range_or_begin_location, end_location = nil) if end_location.nil? @range = range_or_begin_location else @range = Lib.get_range(range_or_begin_location.location, end_location.location) end end |
Instance Attribute Details
#range ⇒ Object (readonly)
Returns the value of attribute range.
67 68 69 |
# File 'lib/ffi/clang/source_range.rb', line 67 def range @range end |
#The underlying range structure.(underlyingrangestructure.) ⇒ Object (readonly)
67 |
# File 'lib/ffi/clang/source_range.rb', line 67 attr_reader :range |
Class Method Details
.null_range ⇒ Object
Get a null source range.
18 19 20 |
# File 'lib/ffi/clang/source_range.rb', line 18 def self.null_range SourceRange.new Lib.get_null_range end |
Instance Method Details
#==(other) ⇒ Object
Check if this range equals another range.
72 73 74 |
# File 'lib/ffi/clang/source_range.rb', line 72 def ==(other) Lib.equal_range(@range, other.range) != 0 end |
#bytesize ⇒ Object
Get the size in bytes of the source range.
47 48 49 |
# File 'lib/ffi/clang/source_range.rb', line 47 def bytesize self.end.offset - self.start.offset end |
#end ⇒ Object
Get the end location of this range.
41 42 43 |
# File 'lib/ffi/clang/source_range.rb', line 41 def end @end ||= ExpansionLocation.new(Lib.get_range_end @range) end |
#null? ⇒ Boolean
Check if this range is null.
62 63 64 |
# File 'lib/ffi/clang/source_range.rb', line 62 def null? Lib.range_is_null(@range) != 0 end |
#start ⇒ Object
Get the start location of this range.
35 36 37 |
# File 'lib/ffi/clang/source_range.rb', line 35 def start @start ||= ExpansionLocation.new(Lib.get_range_start @range) end |
#text ⇒ Object
Read the text from the source file for this range.
53 54 55 56 57 58 |
# File 'lib/ffi/clang/source_range.rb', line 53 def text ::File.open(self.start.file, "r") do |file| file.seek(self.start.offset) return file.read(self.bytesize) end end |