Class: FFI::Clang::FileLocation

Inherits:
SourceLocation show all
Defined in:
lib/ffi/clang/source_location.rb

Instance Attribute Summary collapse

Attributes inherited from SourceLocation

#location

Instance Method Summary collapse

Methods inherited from SourceLocation

#==, #from_main_file?, #in_system_header?, #null?, null_location

Constructor Details

#initialize(location) ⇒ FileLocation

Returns a new instance of FileLocation.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/ffi/clang/source_location.rb', line 128

def initialize(location)
	super(location)

	cxfile = MemoryPointer.new :pointer
	line   = MemoryPointer.new :uint
	column = MemoryPointer.new :uint
	offset = MemoryPointer.new :uint

	Lib::get_file_location(@location, cxfile, line, column, offset)

	@file = Lib.extract_string Lib.get_file_name(cxfile.read_pointer)
	@line = line.get_uint(0)
	@column = column.get_uint(0)
	@offset = offset.get_uint(0)
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



126
127
128
# File 'lib/ffi/clang/source_location.rb', line 126

def column
  @column
end

#fileObject (readonly)

Returns the value of attribute file.



126
127
128
# File 'lib/ffi/clang/source_location.rb', line 126

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



126
127
128
# File 'lib/ffi/clang/source_location.rb', line 126

def line
  @line
end

#offsetObject (readonly)

Returns the value of attribute offset.



126
127
128
# File 'lib/ffi/clang/source_location.rb', line 126

def offset
  @offset
end

Instance Method Details

#as_stringObject



144
145
146
# File 'lib/ffi/clang/source_location.rb', line 144

def as_string
	"#{@file}:#{@line}:#{@column}:#{@offset}"
end

#to_sObject



148
149
150
# File 'lib/ffi/clang/source_location.rb', line 148

def to_s
	"FileLocation <#{self.as_string}>"
end