Class: FFI::Clang::UnsavedFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/clang/unsaved_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, contents) ⇒ UnsavedFile

Returns a new instance of UnsavedFile.



11
12
13
14
# File 'lib/ffi/clang/unsaved_file.rb', line 11

def initialize(filename, contents)
	@filename = filename
	@contents = contents
end

Instance Attribute Details

#contentsObject

Returns the value of attribute contents.



16
17
18
# File 'lib/ffi/clang/unsaved_file.rb', line 16

def contents
  @contents
end

#filenameObject

Returns the value of attribute filename.



16
17
18
# File 'lib/ffi/clang/unsaved_file.rb', line 16

def filename
  @filename
end

Class Method Details

.unsaved_pointer_from(unsaved) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ffi/clang/unsaved_file.rb', line 19

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