class FFI::Clang::Index
Public Class Methods
new(exclude_declarations = true, display_diagnostics = false)
click to toggle source
Calls superclass method
# File lib/ffi/clang/index.rb, line 28 def initialize(exclude_declarations = true, display_diagnostics = false) super Lib.create_index(exclude_declarations ? 1 : 0, display_diagnostics ? 1 : 0) end
release(pointer)
click to toggle source
# File lib/ffi/clang/index.rb, line 32 def self.release(pointer) Lib.dispose_index(pointer) end
Public Instance Methods
create_translation_unit(ast_filename)
click to toggle source
# File lib/ffi/clang/index.rb, line 47 def create_translation_unit(ast_filename) translation_unit_pointer = Lib.create_translation_unit(self, ast_filename) raise Error, "error parsing #{ast_filename.inspect}" if translation_unit_pointer.null? TranslationUnit.new translation_unit_pointer, self end
parse_translation_unit(source_file, command_line_args = nil, unsaved = [], opts = {})
click to toggle source
# File lib/ffi/clang/index.rb, line 36 def parse_translation_unit(source_file, command_line_args = nil, unsaved = [], opts = {}) command_line_args = Array(command_line_args) unsaved_files = UnsavedFile.unsaved_pointer_from(unsaved) translation_unit_pointer = Lib.parse_translation_unit(self, source_file, args_pointer_from(command_line_args), command_line_args.size, unsaved_files, unsaved.length, options_bitmask_from(opts)) raise Error, "error parsing #{source_file.inspect}" if translation_unit_pointer.null? TranslationUnit.new translation_unit_pointer, self end
Private Instance Methods
args_pointer_from(command_line_args)
click to toggle source
# File lib/ffi/clang/index.rb, line 55 def args_pointer_from(command_line_args) args_pointer = MemoryPointer.new(:pointer, command_line_args.length) strings = command_line_args.map do |arg| MemoryPointer.from_string(arg.to_s) end args_pointer.put_array_of_pointer(0, strings) unless strings.empty? args_pointer end
options_bitmask_from(opts)
click to toggle source
# File lib/ffi/clang/index.rb, line 66 def options_bitmask_from(opts) Lib.bitmask_from Lib::TranslationUnitFlags, opts end