Class: FFI::Clang::FileLocation
- Inherits:
-
SourceLocation
- Object
- SourceLocation
- FFI::Clang::FileLocation
- Defined in:
- lib/ffi/clang/source_location.rb
Overview
Represents a file location in source code. This provides the physical location in the file system where code appears.
Instance Attribute Summary collapse
- #column ⇒ Object readonly
- #file ⇒ Object readonly
- #line ⇒ Object readonly
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Attributes inherited from SourceLocation
Instance Method Summary collapse
-
#as_string ⇒ Object
Get a string representation of this location.
-
#initialize(location) ⇒ FileLocation
constructor
Create a new file location and extract its components.
-
#to_s ⇒ Object
Get a detailed string representation.
Methods inherited from SourceLocation
#==, #from_main_file?, #in_system_header?, #null?, null_location
Constructor Details
#initialize(location) ⇒ FileLocation
Create a new file location and extract its components.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/ffi/clang/source_location.rb', line 207 def initialize(location) super(location) cxfile = MemoryPointer.new :pointer line = MemoryPointer.new :uint column = MemoryPointer.new :uint offset = MemoryPointer.new :uint Lib::get_file_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
#column ⇒ Object (readonly)
203 |
# File 'lib/ffi/clang/source_location.rb', line 203 attr_reader :file, :line, :column, :offset |
#file ⇒ Object (readonly)
203 204 205 |
# File 'lib/ffi/clang/source_location.rb', line 203 def file @file end |
#line ⇒ Object (readonly)
203 |
# File 'lib/ffi/clang/source_location.rb', line 203 attr_reader :file, :line, :column, :offset |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
203 |
# File 'lib/ffi/clang/source_location.rb', line 203 attr_reader :file, :line, :column, :offset |
Instance Method Details
#as_string ⇒ Object
Get a string representation of this location.
225 226 227 |
# File 'lib/ffi/clang/source_location.rb', line 225 def as_string "#{@file}:#{@line}:#{@column}:#{@offset}" end |
#to_s ⇒ Object
Get a detailed string representation.
231 232 233 |
# File 'lib/ffi/clang/source_location.rb', line 231 def to_s "FileLocation <#{self.as_string}>" end |