Class: FFI::Clang::SourceRange
- Inherits:
-
Object
- Object
- FFI::Clang::SourceRange
- Defined in:
- lib/ffi/clang/source_range.rb
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#bytesize ⇒ Object
The size, in bytes, of the source range.
- #end ⇒ Object
-
#initialize(range_or_begin_location, end_location = nil) ⇒ SourceRange
constructor
A new instance of SourceRange.
- #null? ⇒ Boolean
- #start ⇒ Object
-
#text ⇒ Object
Read the part of the source file referred to by this source range.
Constructor Details
#initialize(range_or_begin_location, end_location = nil) ⇒ SourceRange
Returns a new instance of SourceRange.
19 20 21 22 23 24 25 |
# File 'lib/ffi/clang/source_range.rb', line 19 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.
52 53 54 |
# File 'lib/ffi/clang/source_range.rb', line 52 def range @range end |
Class Method Details
.null_range ⇒ Object
15 16 17 |
# File 'lib/ffi/clang/source_range.rb', line 15 def self.null_range SourceRange.new Lib.get_null_range end |
Instance Method Details
#==(other) ⇒ Object
54 55 56 |
# File 'lib/ffi/clang/source_range.rb', line 54 def ==(other) Lib.equal_range(@range, other.range) != 0 end |
#bytesize ⇒ Object
The size, in bytes, of the source range.
36 37 38 |
# File 'lib/ffi/clang/source_range.rb', line 36 def bytesize self.end.offset - self.start.offset end |
#end ⇒ Object
31 32 33 |
# File 'lib/ffi/clang/source_range.rb', line 31 def end @end ||= ExpansionLocation.new(Lib.get_range_end @range) end |
#null? ⇒ Boolean
48 49 50 |
# File 'lib/ffi/clang/source_range.rb', line 48 def null? Lib.range_is_null(@range) != 0 end |
#start ⇒ Object
27 28 29 |
# File 'lib/ffi/clang/source_range.rb', line 27 def start @start ||= ExpansionLocation.new(Lib.get_range_start @range) end |
#text ⇒ Object
Read the part of the source file referred to by this source range.
41 42 43 44 45 46 |
# File 'lib/ffi/clang/source_range.rb', line 41 def text ::File.open(self.start.file, "r") do |file| file.seek(self.start.offset) return file.read(self.bytesize) end end |