Sha256: 4d6d93fa6e253ab0f24a8c88e106b1929eb5e1b7f28eaed1d9b2f39afe5a1723

Contents?: true

Size: 830 Bytes

Versions: 5

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2013, by Carlos Martín Nieto.
# Copyright, 2013-2022, by Samuel Williams.
# Copyright, 2014, by Masahiro Sano.

module FFI
	module Clang
		class UnsavedFile
			def initialize(filename, contents)
				@filename = filename
				@contents = contents
			end

			attr_accessor :filename, :contents


			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
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ffi-clang-0.12.0 lib/ffi/clang/unsaved_file.rb
ffi-clang-0.11.0 lib/ffi/clang/unsaved_file.rb
ffi-clang-0.10.0 lib/ffi/clang/unsaved_file.rb
ffi-clang-0.9.0 lib/ffi/clang/unsaved_file.rb
ffi-clang-0.8.0 lib/ffi/clang/unsaved_file.rb