Class: FFI::Clang::SourceLocation
- Inherits:
-
Object
- Object
- FFI::Clang::SourceLocation
- Includes:
- Comparable
- Defined in:
- lib/ffi/clang/source_location.rb
Overview
Represents a location in source code. This base class provides common functionality for source locations, with specific subclasses for different types of location information.
Direct Known Subclasses
ExpansionLocation, FileLocation, PresumedLocation, SpellingLocation
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Class Method Summary collapse
-
.null_location ⇒ Object
Get a null source location.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compare this location with another for ordering.
-
#==(other) ⇒ Object
Compare this location with another for equality.
-
#from_main_file? ⇒ Boolean
Check if this location is from the main file.
-
#in_system_header? ⇒ Boolean
Check if this location is in a system header.
-
#initialize(location) ⇒ SourceLocation
constructor
Create a new source location.
-
#null? ⇒ Boolean
Check if this location is null.
Constructor Details
#initialize(location) ⇒ SourceLocation
Create a new source location.
34 35 36 |
# File 'lib/ffi/clang/source_location.rb', line 34 def initialize(location) @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
30 31 32 |
# File 'lib/ffi/clang/source_location.rb', line 30 def location @location end |
Class Method Details
.null_location ⇒ Object
Get a null source location.
24 25 26 |
# File 'lib/ffi/clang/source_location.rb', line 24 def self.null_location ExpansionLocation.new Lib.get_null_location end |
Instance Method Details
#<=>(other) ⇒ Object
Compare this location with another for ordering. Returns nil for null locations or locations from different translation units, which causes Comparable operators (<, >, etc.) to raise ArgumentError.
68 69 70 71 72 73 74 75 76 |
# File 'lib/ffi/clang/source_location.rb', line 68 def <=>(other) return nil unless other.is_a?(SourceLocation) return 0 if Lib.equal_locations(@location, other.location) != 0 return nil if null? || other.null? return -1 if Lib.is_before_in_translation_unit(@location, other.location) != 0 return 1 if Lib.is_before_in_translation_unit(other.location, @location) != 0 nil end |
#==(other) ⇒ Object
Compare this location with another for equality.
59 60 61 |
# File 'lib/ffi/clang/source_location.rb', line 59 def ==(other) Lib.equal_locations(@location, other.location) != 0 end |
#from_main_file? ⇒ Boolean
Check if this location is from the main file.
46 47 48 |
# File 'lib/ffi/clang/source_location.rb', line 46 def from_main_file? Lib.location_is_from_main_file(@location) != 0 end |
#in_system_header? ⇒ Boolean
Check if this location is in a system header.
40 41 42 |
# File 'lib/ffi/clang/source_location.rb', line 40 def in_system_header? Lib.location_in_system_header(@location) != 0 end |