Class: FFI::Clang::Tokens

Inherits:
AutoPointer
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ffi/clang/token.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pointer, token_size, translation_unit) ⇒ Tokens

Returns a new instance of Tokens.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ffi/clang/token.rb', line 19

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

#sizeObject (readonly)

Returns the value of attribute size.



16
17
18
# File 'lib/ffi/clang/token.rb', line 16

def size
  @size
end

#tokensObject (readonly)

Returns the value of attribute tokens.



17
18
19
# File 'lib/ffi/clang/token.rb', line 17

def tokens
  @tokens
end

Class Method Details

.release(pointer) ⇒ Object



34
35
36
# File 'lib/ffi/clang/token.rb', line 34

def self.release(pointer)
	Lib.dispose_tokens(pointer.translation_unit, pointer, pointer.token_size)
end

Instance Method Details

#cursorsObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ffi/clang/token.rb', line 44

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



38
39
40
41
42
# File 'lib/ffi/clang/token.rb', line 38

def each(&block)
	@tokens.each do |token|
		block.call(token)
	end
end