Class: FFI::Clang::CompilationDatabase

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

Overview

Represents a compilation database for a project.

Defined Under Namespace

Classes: CompileCommand, CompileCommands, DatabaseLoadError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dirpath) ⇒ CompilationDatabase

Initialize a compilation database from a directory.



19
20
21
22
23
24
25
26
27
# File 'lib/ffi/clang/compilation_database.rb', line 19

def initialize(dirpath)
	uint_ptr = MemoryPointer.new :uint
	cdb_ptr = Lib.compilation_database_from_directory(dirpath, uint_ptr)
	error_code = Lib::CompilationDatabaseError[uint_ptr.read_uint]
	if error_code != :no_error
		raise DatabaseLoadError, "Cannot load database: #{error_code}"
	end
	super cdb_ptr
end

Class Method Details

.release(pointer) ⇒ Object

Release the compilation database pointer.



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

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

Instance Method Details

#all_compile_commandsObject

Get all compile commands in the database.



44
45
46
# File 'lib/ffi/clang/compilation_database.rb', line 44

def all_compile_commands
	CompileCommands.new Lib.compilation_database_get_all_compile_commands(self), self
end

#compile_commands(filename) ⇒ Object

Get compile commands for a specific file.



38
39
40
# File 'lib/ffi/clang/compilation_database.rb', line 38

def compile_commands(filename)
	CompileCommands.new Lib.compilation_database_get_compile_commands(self, filename), self
end