Class: FFI::Clang::Index
- Inherits:
-
AutoPointer
- Object
- AutoPointer
- FFI::Clang::Index
- Defined in:
- lib/ffi/clang/index.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_translation_unit(ast_filename) ⇒ Object
-
#initialize(exclude_declarations = true, display_diagnostics = false) ⇒ Index
constructor
A new instance of Index.
- #parse_translation_unit(source_file, command_line_args = nil, unsaved = [], opts = {}) ⇒ Object
Constructor Details
#initialize(exclude_declarations = true, display_diagnostics = false) ⇒ Index
Returns a new instance of Index.
18 19 20 |
# File 'lib/ffi/clang/index.rb', line 18 def initialize(exclude_declarations = true, display_diagnostics = false) super Lib.create_index(exclude_declarations ? 1 : 0, display_diagnostics ? 1 : 0) end |
Class Method Details
.release(pointer) ⇒ Object
22 23 24 |
# File 'lib/ffi/clang/index.rb', line 22 def self.release(pointer) Lib.dispose_index(pointer) end |
Instance Method Details
#create_translation_unit(ast_filename) ⇒ Object
43 44 45 46 47 |
# File 'lib/ffi/clang/index.rb', line 43 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 = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ffi/clang/index.rb', line 26 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_out = FFI::MemoryPointer.new(:pointer) error_code = Lib.parse_translation_unit2(self, source_file, args_pointer_from(command_line_args), command_line_args.size, unsaved_files, unsaved.length, (opts), translation_unit_pointer_out) if error_code != :cx_error_success error_name = Lib::ErrorCodes.from_native(error_code, nil) = "Error parsing file. Code: #{error_name}. File: #{source_file.inspect}" raise(Error, ) end translation_unit_pointer = translation_unit_pointer_out.read_pointer TranslationUnit.new translation_unit_pointer, self end |