Class: FFI::Clang::SpellingLocation
- Inherits:
-
SourceLocation
- Object
- SourceLocation
- FFI::Clang::SpellingLocation
- Defined in:
- lib/ffi/clang/source_location.rb
Overview
Represents the spelling location of a token in source code. This is the actual location where the token was written in the source file.
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) ⇒ SpellingLocation
constructor
Create a new spelling 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) ⇒ SpellingLocation
Create a new spelling location and extract its components.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/ffi/clang/source_location.rb', line 163 def initialize(location) super(location) cxfile = MemoryPointer.new :pointer line = MemoryPointer.new :uint column = MemoryPointer.new :uint offset = MemoryPointer.new :uint Lib::get_spelling_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)
159 |
# File 'lib/ffi/clang/source_location.rb', line 159 attr_reader :file, :line, :column, :offset |
#file ⇒ Object (readonly)
159 160 161 |
# File 'lib/ffi/clang/source_location.rb', line 159 def file @file end |
#line ⇒ Object (readonly)
159 |
# File 'lib/ffi/clang/source_location.rb', line 159 attr_reader :file, :line, :column, :offset |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
159 |
# File 'lib/ffi/clang/source_location.rb', line 159 attr_reader :file, :line, :column, :offset |
Instance Method Details
#as_string ⇒ Object
Get a string representation of this location.
181 182 183 |
# File 'lib/ffi/clang/source_location.rb', line 181 def as_string "#{@file}:#{@line}:#{@column}:#{@offset}" end |
#to_s ⇒ Object
Get a detailed string representation.
187 188 189 |
# File 'lib/ffi/clang/source_location.rb', line 187 def to_s "SpellingLocation <#{self.as_string}>" end |