Class: FFI::Clang::Tokens
- Inherits:
-
AutoPointer
- Object
- AutoPointer
- FFI::Clang::Tokens
- Includes:
- Enumerable
- Defined in:
- lib/ffi/clang/token.rb
Overview
Represents a collection of tokens from a source range.
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
- #The array of tokens.(arrayoftokens.) ⇒ Object readonly
- #The number of tokens.(numberoftokens.) ⇒ Object readonly
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Class Method Summary collapse
-
.release(pointer) ⇒ Object
Release the tokens pointer.
Instance Method Summary collapse
-
#cursors ⇒ Object
Get cursors corresponding to each token.
-
#each(&block) ⇒ Object
Iterate over each token.
-
#initialize(pointer, token_size, translation_unit) ⇒ Tokens
constructor
Initialize a token collection.
Constructor Details
#initialize(pointer, token_size, translation_unit) ⇒ Tokens
Initialize a token collection.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ffi/clang/token.rb', line 27 def initialize(pointer, token_size, translation_unit) ptr = Lib::TokensPointer.new(pointer,token_size, translation_unit) super ptr @translation_unit = translation_unit @size = token_size @tokens = [] cur_ptr = pointer token_size.times {@tokens << Token.new(cur_ptr, translation_unit) cur_ptr += Lib::CXToken.size } end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
18 19 20 |
# File 'lib/ffi/clang/token.rb', line 18 def size @size end |
#The array of tokens.(arrayoftokens.) ⇒ Object (readonly)
21 |
# File 'lib/ffi/clang/token.rb', line 21 attr_reader :tokens |
#The number of tokens.(numberoftokens.) ⇒ Object (readonly)
18 |
# File 'lib/ffi/clang/token.rb', line 18 attr_reader :size |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
21 22 23 |
# File 'lib/ffi/clang/token.rb', line 21 def tokens @tokens end |
Class Method Details
.release(pointer) ⇒ Object
Release the tokens pointer.
43 44 45 |
# File 'lib/ffi/clang/token.rb', line 43 def self.release(pointer) Lib.dispose_tokens(pointer.translation_unit, pointer, pointer.token_size) end |
Instance Method Details
#cursors ⇒ Object
Get cursors corresponding to each token.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ffi/clang/token.rb', line 58 def cursors ptr = MemoryPointer.new(Lib::CXCursor, @size) Lib.annotate_tokens(@translation_unit, self, @size, ptr) cur_ptr = ptr arr = [] @size.times {arr << Cursor.new(cur_ptr, @translation_unit) cur_ptr += Lib::CXCursor.size } arr end |
#each(&block) ⇒ Object
Iterate over each token.
50 51 52 53 54 |
# File 'lib/ffi/clang/token.rb', line 50 def each(&block) @tokens.each do |token| block.call(token) end end |