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.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ffi/clang/token.rb', line 33

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.



30
31
32
# File 'lib/ffi/clang/token.rb', line 30

def size
  @size
end

#tokensObject (readonly)

Returns the value of attribute tokens.



31
32
33
# File 'lib/ffi/clang/token.rb', line 31

def tokens
  @tokens
end

Class Method Details

.release(pointer) ⇒ Object



48
49
50
# File 'lib/ffi/clang/token.rb', line 48

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

Instance Method Details

#cursorsObject



58
59
60
61
62
63
64
65
66
67
68
69
# 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



52
53
54
55
56
# File 'lib/ffi/clang/token.rb', line 52

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