FFI::ClangSourceFFIClangCompilationDatabase

class CompilationDatabase

Represents a compilation database for a project.

Nested

Definitions

def initialize(dirpath)

Initialize a compilation database from a directory.

Signature

parameter dirpath String

The directory path containing the compilation database.

raises DatabaseLoadError

If the database cannot be loaded.

Implementation

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

def self.release(pointer)

Release the compilation database pointer.

Signature

parameter pointer FFI::Pointer

The pointer to release.

Implementation

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

def compile_commands(filename)

Get compile commands for a specific file.

Signature

parameter filename String

The filename to get commands for.

returns CompileCommands

The compile commands for the file.

Implementation

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

def all_compile_commands

Get all compile commands in the database.

Signature

returns CompileCommands

All compile commands.

Implementation

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