Class: FFI::Clang::CompilationDatabase::CompileCommands

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

Overview

Represents a collection of compile commands.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pointer, database) ⇒ CompileCommands

Initialize compile commands.



56
57
58
59
# File 'lib/ffi/clang/compilation_database.rb', line 56

def initialize(pointer, database)
	super pointer
	@database = database
end

Class Method Details

.release(pointer) ⇒ Object

Release the compile commands pointer.



63
64
65
# File 'lib/ffi/clang/compilation_database.rb', line 63

def self.release(pointer)
	Lib.compile_commands_dispose(pointer)
end

Instance Method Details

#command(i) ⇒ Object

Get a compile command by index.



76
77
78
# File 'lib/ffi/clang/compilation_database.rb', line 76

def command(i)
	CompileCommand.new Lib.compile_commands_get_command(self, i)
end

#commandsObject

Get all compile commands.



82
83
84
# File 'lib/ffi/clang/compilation_database.rb', line 82

def commands
	size.times.map{|i| command(i)}
end

#each(&block) ⇒ Object

Iterate over each compile command.



90
91
92
93
94
95
96
97
98
# File 'lib/ffi/clang/compilation_database.rb', line 90

def each(&block)
	return to_enum(__method__) unless block_given?
	
	size.times do |i|
		block.call(command(i))
	end
	
	self
end

#sizeObject

Get the number of compile commands.



69
70
71
# File 'lib/ffi/clang/compilation_database.rb', line 69

def size
	Lib.compile_commands_get_size(self)
end