class FFI::Clang::SourceRange

Attributes

range[R]

Public Class Methods

new(range_or_begin_location, end_location = nil) click to toggle source
# File lib/ffi/clang/source_range.rb, line 33
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
null_range() click to toggle source
# File lib/ffi/clang/source_range.rb, line 29
def self.null_range
        SourceRange.new Lib.get_null_range
end

Public Instance Methods

==(other) click to toggle source
# File lib/ffi/clang/source_range.rb, line 68
def ==(other)
        Lib.equal_range(@range, other.range) != 0
end
bytesize() click to toggle source

The size, in bytes, of the source range.

# File lib/ffi/clang/source_range.rb, line 50
def bytesize
        self.end.offset - self.start.offset
end
end() click to toggle source
# File lib/ffi/clang/source_range.rb, line 45
def end
        @end ||= ExpansionLocation.new(Lib.get_range_end @range)
end
null?() click to toggle source
# File lib/ffi/clang/source_range.rb, line 62
def null?
        Lib.range_is_null(@range) != 0
end
start() click to toggle source
# File lib/ffi/clang/source_range.rb, line 41
def start
        @start ||= ExpansionLocation.new(Lib.get_range_start @range)
end
text() click to toggle source

Read the part of the source file referred to by this source range.

# File lib/ffi/clang/source_range.rb, line 55
def text
        ::File.open(self.start.file, "r") do |file|
                file.seek(self.start.offset)
                return file.read(self.bytesize)
        end
end