FFI::ClangSourceFFIClangPresumedLocation

class PresumedLocation

Represents a presumed location in source code. This is the location that appears to the user after macro expansion and #line directives.

Definitions

attr_reader :filename, :line, :column, :offset

Signature

attribute r

filename

returns String

The presumed filename.

attribute r

line

returns Integer

The presumed line number.

attribute r

column

returns Integer

The presumed column number.

attribute r

offset

returns Integer

The presumed byte offset.

def initialize(location)

Create a new presumed location and extract its components.

Signature

parameter location FFI::Pointer

The low-level location handle.

Implementation

def initialize(location)
	super(location)
	
	cxstring = MemoryPointer.new Lib::CXString
	line = MemoryPointer.new :uint
	column = MemoryPointer.new :uint
	
	Lib::get_presumed_location(@location, cxstring, line, column)
	
	@filename = Lib.extract_string cxstring
	@line = line.get_uint(0)
	@column = column.get_uint(0)
end

def as_string

Get a string representation of this location.

Signature

returns String

The location in format "filename:line:column".

Implementation

def as_string
	"#{@filename}:#{@line}:#{@column}"
end

def to_s

Get a detailed string representation.

Signature

returns String

A string describing this presumed location.

Implementation

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