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.
34 35 36 37 38 39 40 |
# File 'lib/ffi/clang/source_range.rb', line 34 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 |
Class Method Details
.null_range ⇒ Object
30 31 32 |
# File 'lib/ffi/clang/source_range.rb', line 30 def self.null_range SourceRange.new Lib.get_null_range end |
Instance Method Details
#==(other) ⇒ Object
69 70 71 |
# File 'lib/ffi/clang/source_range.rb', line 69 def ==(other) Lib.equal_range(@range, other.range) != 0 end |
#bytesize ⇒ Object
The size, in bytes, of the source range.
51 52 53 |
# File 'lib/ffi/clang/source_range.rb', line 51 def bytesize self.end.offset - self.start.offset end |
#end ⇒ Object
46 47 48 |
# File 'lib/ffi/clang/source_range.rb', line 46 def end @end ||= ExpansionLocation.new(Lib.get_range_end @range) end |
#null? ⇒ Boolean
63 64 65 |
# File 'lib/ffi/clang/source_range.rb', line 63 def null? Lib.range_is_null(@range) != 0 end |
#start ⇒ Object
42 43 44 |
# File 'lib/ffi/clang/source_range.rb', line 42 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.
56 57 58 59 60 61 |
# File 'lib/ffi/clang/source_range.rb', line 56 def text ::File.open(self.start.file, "r") do |file| file.seek(self.start.offset) return file.read(self.bytesize) end end |