Class: FFI::Clang::ExpansionLocation

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

Overview

Represents the expansion location of a macro. This provides the location where a macro was expanded, including file, line, column, and byte offset.

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) ⇒ ExpansionLocation

Create a new expansion location and extract its components.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/ffi/clang/source_location.rb', line 94

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

Instance Attribute Details

#columnObject (readonly)



90
# File 'lib/ffi/clang/source_location.rb', line 90

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

#fileObject (readonly)



90
91
92
# File 'lib/ffi/clang/source_location.rb', line 90

def file
  @file
end

#lineObject (readonly)



90
# File 'lib/ffi/clang/source_location.rb', line 90

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

#offsetObject (readonly)

Returns the value of attribute offset.



90
# File 'lib/ffi/clang/source_location.rb', line 90

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

Instance Method Details

#as_stringObject

Get a string representation of this location.



112
113
114
# File 'lib/ffi/clang/source_location.rb', line 112

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

#to_sObject

Get a detailed string representation.



118
119
120
# File 'lib/ffi/clang/source_location.rb', line 118

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