FFI::ClangSourceFFIClangSpellingLocation

class SpellingLocation

Represents the spelling location of a token in source code. This is the actual location where the token was written in the source file.

Definitions

attr_reader :file, :line, :column, :offset

Signature

attribute r

file

returns String

The file path.

attribute r

line

returns Integer

The line number.

attribute r

column

returns Integer

The column number.

attribute r

offset

returns Integer

The byte offset in the file.

def initialize(location)

Create a new spelling location and extract its components.

Signature

parameter location FFI::Pointer

The low-level location handle.

Implementation

def initialize(location)
	super(location)
	
	cxfile = MemoryPointer.new :pointer
	line   = MemoryPointer.new :uint
	column = MemoryPointer.new :uint
	offset = MemoryPointer.new :uint
	
	Lib::get_spelling_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

def as_string

Get a string representation of this location.

Signature

returns String

The location in format "file:line:column:offset".

Implementation

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

def to_s

Get a detailed string representation.

Signature

returns String

A string describing this spelling location.

Implementation

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