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.



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ffi/clang/source_location.rb', line 121

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)



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

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

#filenameObject (readonly)



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

def filename
  @filename
end

#lineObject (readonly)



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

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

#offsetObject (readonly)

Returns the value of attribute offset.



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

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

Instance Method Details

#as_stringObject

Get a string representation of this location.



137
138
139
# File 'lib/ffi/clang/source_location.rb', line 137

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

#to_sObject

Get a detailed string representation.



143
144
145
# File 'lib/ffi/clang/source_location.rb', line 143

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