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.



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

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.



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

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

Instance Method Details

#all_compile_commandsObject

Get all compile commands in the database.



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

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.



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

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