class UnsavedFile
Represents an unsaved file with in-memory contents for parsing.
Definitions
def initialize(filename, contents)
Initialize an unsaved file with filename and contents.
Signature
-
parameter
filenameString The path to the unsaved file.
-
parameter
contentsString The in-memory contents of the file.
Implementation
def initialize(filename, contents)
@filename = filename
@contents = contents
end
attr_accessor :filename
Signature
-
attribute
String The path to the unsaved file.
attr_accessor :contents
Signature
-
attribute
String The in-memory contents of the file.
def self.unsaved_pointer_from(unsaved)
Convert an array of unsaved files to a libclang pointer structure.
Signature
-
parameter
unsavedArray(UnsavedFile) The array of unsaved files.
-
returns
FFI::MemoryPointer | Nil A pointer to the unsaved file structures, or
nilif empty.
Implementation
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