Class: FFI::Clang::Token
- Inherits:
-
Object
- Object
- FFI::Clang::Token
- Defined in:
- lib/ffi/clang/token.rb
Overview
Represents a single token in the source code.
Defined Under Namespace
Classes: Owner
Class Method Summary collapse
-
.from_location(translation_unit, location) ⇒ Object
Look up the token that starts at the given source location.
Instance Method Summary collapse
-
#extent ⇒ Object
Get the extent (source range) of this token.
-
#initialize(token, translation_unit, owner = nil) ⇒ Token
constructor
Initialize a token.
-
#kind ⇒ Object
Get the kind of this token.
-
#location ⇒ Object
Get the location of this token.
-
#spelling ⇒ Object
Get the spelling (text) of this token.
Constructor Details
#initialize(token, translation_unit, owner = nil) ⇒ Token
Initialize a token.
109 110 111 112 113 |
# File 'lib/ffi/clang/token.rb', line 109 def initialize(token, translation_unit, owner = nil) @token = token @translation_unit = translation_unit @owner = owner end |
Class Method Details
.from_location(translation_unit, location) ⇒ Object
Look up the token that starts at the given source location.
97 98 99 100 101 102 103 |
# File 'lib/ffi/clang/token.rb', line 97 def self.from_location(translation_unit, location) token_pointer = Lib.get_token(translation_unit, location.location) return nil if token_pointer.null? owner = Owner.new(token_pointer, translation_unit) Token.new(owner, translation_unit, owner) end |
Instance Method Details
#extent ⇒ Object
Get the extent (source range) of this token.
135 136 137 |
# File 'lib/ffi/clang/token.rb', line 135 def extent SourceRange.new Lib.get_token_extent(@translation_unit, @token) end |
#kind ⇒ Object
Get the kind of this token.
117 118 119 |
# File 'lib/ffi/clang/token.rb', line 117 def kind Lib.get_token_kind(@token) end |
#location ⇒ Object
Get the location of this token.
129 130 131 |
# File 'lib/ffi/clang/token.rb', line 129 def location ExpansionLocation.new Lib.get_token_location(@translation_unit, @token) end |
#spelling ⇒ Object
Get the spelling (text) of this token.
123 124 125 |
# File 'lib/ffi/clang/token.rb', line 123 def spelling Lib.extract_string Lib.get_token_spelling(@translation_unit, @token) end |