Class: LLVM::MemoryBuffer
- Inherits:
-
Object
- Object
- LLVM::MemoryBuffer
- Defined in:
- lib/llvm/core/bitcode.rb
Class Method Summary collapse
-
.from_file(path) ⇒ LLVM::MemoryBuffer
Read the contents of a file into a memory buffer.
-
.from_stdin ⇒ LLVM::MemoryBuffer
Read STDIN into a memory buffer.
Instance Method Summary collapse
- #dispose ⇒ Object
-
#initialize(ptr) ⇒ MemoryBuffer
constructor
A new instance of MemoryBuffer.
- #to_ptr ⇒ Object
Constructor Details
#initialize(ptr) ⇒ MemoryBuffer
Returns a new instance of MemoryBuffer.
44 45 46 |
# File 'lib/llvm/core/bitcode.rb', line 44 def initialize(ptr) @ptr = ptr end |
Class Method Details
.from_file(path) ⇒ LLVM::MemoryBuffer
Read the contents of a file into a memory buffer
56 57 58 59 60 61 62 63 64 |
# File 'lib/llvm/core/bitcode.rb', line 56 def self.from_file(path) FFI::MemoryPointer.new(:pointer) do |buf_ref| FFI::MemoryPointer.new(:pointer) do |msg_ref| status = C.create_memory_buffer_with_contents_of_file(path.to_str, buf_ref, msg_ref) raise msg_ref.get_pointer(0).get_string(0) if status != 0 return new(buf_ref.get_pointer(0)) end end end |
.from_stdin ⇒ LLVM::MemoryBuffer
Read STDIN into a memory buffer
68 69 70 71 72 73 74 75 76 |
# File 'lib/llvm/core/bitcode.rb', line 68 def self.from_stdin FFI::Buffer.new(:pointer) do |buf_ref| FFI::Buffer.new(:pointer) do |msg_ref| status = C.create_memory_buffer_with_stdin(buf_ref, msg_ref) raise msg_ref.get_pointer(0).get_string(0) if status != 0 return new(buf_ref.get_pointer(0)) end end end |
Instance Method Details
#dispose ⇒ Object
78 79 80 81 82 |
# File 'lib/llvm/core/bitcode.rb', line 78 def dispose return if @ptr.nil? C.dispose_memory_buffer(@ptr) @ptr = nil end |
#to_ptr ⇒ Object
49 50 51 |
# File 'lib/llvm/core/bitcode.rb', line 49 def to_ptr @ptr end |