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.
50 51 52 |
# File 'lib/llvm/core/bitcode.rb', line 50 def initialize(ptr) @ptr = ptr end |
Class Method Details
.from_file(path) ⇒ LLVM::MemoryBuffer
Read the contents of a file into a memory buffer
62 63 64 65 66 67 68 69 70 |
# File 'lib/llvm/core/bitcode.rb', line 62 def self.from_file(path) FFI::MemoryPointer.new(:pointer) do |buf_ref| FFI::MemoryPointer.new(:pointer) do |msg_ref| status = C.LLVMCreateMemoryBufferWithContentsOfFile(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
74 75 76 77 78 79 80 81 82 |
# File 'lib/llvm/core/bitcode.rb', line 74 def self.from_stdin FFI::Buffer.new(:pointer) do |buf_ref| FFI::Buffer.new(:pointer) do |msg_ref| status = C.LLVMCreateMemoryBufferWithSTDIN(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
84 85 86 |
# File 'lib/llvm/core/bitcode.rb', line 84 def dispose C.LLVMDisposeMemoryBuffer(@ptr) end |
#to_ptr ⇒ Object
55 56 57 |
# File 'lib/llvm/core/bitcode.rb', line 55 def to_ptr @ptr end |