class FFI::Clang::TranslationUnit
Public Class Methods
default_editing_translation_unit_options()
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 41 def self.default_editing_translation_unit_options bitmask = Lib.default_editing_translation_unit_options Lib.opts_from Lib::TranslationUnitFlags, bitmask end
new(pointer, index)
click to toggle source
Calls superclass method
# File lib/ffi/clang/translation_unit.rb, line 32 def initialize(pointer, index) super pointer @index = index end
release(pointer)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 37 def self.release(pointer) Lib.dispose_translation_unit(pointer) end
Public Instance Methods
code_complete(source_file, line, column, unsaved = [], opts = nil)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 113 def code_complete(source_file, line, column, unsaved = [], opts = nil) opts = CodeCompletion.default_code_completion_options if opts.nil? unsaved_files = UnsavedFile.unsaved_pointer_from(unsaved) option_bitmask = Lib.bitmask_from(Lib::CodeCompleteFlags, opts) ptr = Lib.code_complete_at(self, source_file, line, column, unsaved_files, unsaved.length, option_bitmask) CodeCompletion::Results.new ptr, self end
cursor(location = nil)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 78 def cursor(location = nil) if location.nil? Cursor.new Lib.get_translation_unit_cursor(self), self else Cursor.new Lib.get_cursor(self, location.location), self end end
default_reparse_options()
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 58 def default_reparse_options bitmask = Lib.default_save_options(self) Lib.opts_from Lib::ReparseFlags, bitmask end
default_save_options()
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 46 def default_save_options bitmask = Lib.default_save_options(self) Lib.opts_from Lib::SaveTranslationUnitFlags, bitmask end
diagnostics()
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 70 def diagnostics n = Lib.get_num_diagnostics(self) n.times.map do |i| Diagnostic.new(self, Lib.get_diagnostic(self, i)) end end
file(file_name)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 94 def file(file_name) File.new(Lib.get_file(self, file_name), self) end
inclusions(&block)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 121 def inclusions(&block) adapter = Proc.new do |included_file, inclusion_stack, include_len, unused| file = Lib.extract_string Lib.get_file_name(included_file) cur_ptr = inclusion_stack inclusions = [] include_len.times { inclusions << SourceLocation.new(Lib::CXSourceLocation.new(cur_ptr)) cur_ptr += Lib::CXSourceLocation.size } block.call file, inclusions end Lib.get_inclusions(self, adapter, nil) end
location(file, line, column)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 86 def location(file, line, column) ExpansionLocation.new Lib.get_location(self, file, line, column) end
location_offset(file, offset)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 90 def location_offset(file, offset) ExpansionLocation.new Lib.get_location_offset(self, file, offset) end
reparse(unsaved = [], opts = {})
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 63 def reparse(unsaved = [], opts = {}) unsaved_files = UnsavedFile.unsaved_pointer_from(unsaved) if Lib.reparse_translation_unit(self, unsaved.size, unsaved_files, 0) != 0 raise Error, "reparse error" end end
resource_usage()
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 102 def resource_usage FFI::Clang::TranslationUnit::ResourceUsage.new Lib.resource_usage(self) end
save(filename, opts = {})
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 51 def save(filename, opts = {}) ret = Lib.save_translation_unit(self, filename, 0) sym = Lib::SaveError[ret] raise Error, "unknown return values: #{ret} #{sym.inspect}" unless sym raise Error, "save error: #{sym.inspect}, filename: #{filename}" if sym != :none end
spelling()
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 98 def spelling Lib.get_translation_unit_spelling(self) end
tokenize(range)
click to toggle source
# File lib/ffi/clang/translation_unit.rb, line 106 def tokenize(range) token_ptr = MemoryPointer.new :pointer uint_ptr = MemoryPointer.new :uint Lib.tokenize(self, range.range, token_ptr, uint_ptr) Tokens.new(token_ptr.get_pointer(0), uint_ptr.get_uint(0), self) end