Class: FFI::Clang::PresumedLocation

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

Overview

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

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

Create a new presumed location and extract its components.



136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/ffi/clang/source_location.rb', line 136

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

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



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

attr_reader :filename, :line, :column

#filenameObject (readonly)



132
133
134
# File 'lib/ffi/clang/source_location.rb', line 132

def filename
  @filename
end

#lineObject (readonly)



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

attr_reader :filename, :line, :column

Instance Method Details

#as_stringObject

Get a string representation of this location.



152
153
154
# File 'lib/ffi/clang/source_location.rb', line 152

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

#to_sObject

Get a detailed string representation.



158
159
160
# File 'lib/ffi/clang/source_location.rb', line 158

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