Class: FFI::Clang::UnsavedFile
- Inherits:
-
Object
- Object
- FFI::Clang::UnsavedFile
- Defined in:
- lib/ffi/clang/unsaved_file.rb
Overview
Represents an unsaved file with in-memory contents for parsing.
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#filename ⇒ Object
Returns the value of attribute filename.
- #The in-memory contents of the file. ⇒ Object readonly
- #The path to the unsaved file.(pathtotheunsavedfile.) ⇒ Object readonly
Class Method Summary collapse
-
.unsaved_pointer_from(unsaved) ⇒ Object
Convert an array of unsaved files to a libclang pointer structure.
Instance Method Summary collapse
-
#initialize(filename, contents) ⇒ UnsavedFile
constructor
Initialize an unsaved file with filename and contents.
Constructor Details
#initialize(filename, contents) ⇒ UnsavedFile
Initialize an unsaved file with filename and contents.
15 16 17 18 |
# File 'lib/ffi/clang/unsaved_file.rb', line 15 def initialize(filename, contents) @filename = filename @contents = contents end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
24 25 26 |
# File 'lib/ffi/clang/unsaved_file.rb', line 24 def contents @contents end |
#filename ⇒ Object
Returns the value of attribute filename.
21 22 23 |
# File 'lib/ffi/clang/unsaved_file.rb', line 21 def filename @filename end |
#The in-memory contents of the file. ⇒ Object (readonly)
24 |
# File 'lib/ffi/clang/unsaved_file.rb', line 24 attr_accessor :contents |
#The path to the unsaved file.(pathtotheunsavedfile.) ⇒ Object (readonly)
21 |
# File 'lib/ffi/clang/unsaved_file.rb', line 21 attr_accessor :filename |
Class Method Details
.unsaved_pointer_from(unsaved) ⇒ Object
Convert an array of unsaved files to a libclang pointer structure.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ffi/clang/unsaved_file.rb', line 29 def self.unsaved_pointer_from(unsaved) return nil if unsaved.length == 0 vec = MemoryPointer.new(Lib::CXUnsavedFile, unsaved.length) unsaved.each_with_index do |file, i| uf = Lib::CXUnsavedFile.new(vec + i * Lib::CXUnsavedFile.size) uf[:filename] = MemoryPointer.from_string(file.filename) uf[:contents] = MemoryPointer.from_string(file.contents) uf[:length] = file.contents.length end vec end |