class ExpansionLocation
Represents the expansion location of a macro. This provides the location where a macro was expanded, including file, line, column, and byte offset.
Definitions
attr_reader :file, :line, :column, :offset
Signature
-
attribute
r file
-
returns
String The file path.
-
returns
-
attribute
r line
-
returns
Integer The line number.
-
returns
-
attribute
r column
-
returns
Integer The column number.
-
returns
-
attribute
r offset
-
returns
Integer The byte offset in the file.
-
returns
def initialize(location)
Create a new expansion location and extract its components.
Signature
-
parameter
locationFFI::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_expansion_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 expansion location.
Implementation
def to_s
"ExpansionLocation <#{self.as_string}>"
end