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.



25
26
27
28
# File 'lib/ffi/clang/unsaved_file.rb', line 25

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

Instance Attribute Details

#contentsObject

Returns the value of attribute contents.



30
31
32
# File 'lib/ffi/clang/unsaved_file.rb', line 30

def contents
  @contents
end

#filenameObject

Returns the value of attribute filename.



30
31
32
# File 'lib/ffi/clang/unsaved_file.rb', line 30

def filename
  @filename
end

Class Method Details

.unsaved_pointer_from(unsaved) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ffi/clang/unsaved_file.rb', line 33

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