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 : (String) -> LLVM::MemoryBuffer.
-
.from_stdin ⇒ LLVM::MemoryBuffer
Read STDIN into a memory buffer : -> LLVM::MemoryBuffer.
Instance Method Summary collapse
-
#dispose ⇒ Object
: -> void.
-
#initialize(ptr) ⇒ MemoryBuffer
constructor
: (FFI::Pointer) -> void.
-
#to_ptr ⇒ Object
: -> FFI::Pointer?.
Constructor Details
#initialize(ptr) ⇒ MemoryBuffer
: (FFI::Pointer) -> void
78 79 80 |
# File 'lib/llvm/core/bitcode.rb', line 78 def initialize(ptr) @ptr = ptr #: FFI::Pointer? end |
Class Method Details
.from_file(path) ⇒ LLVM::MemoryBuffer
Read the contents of a file into a memory buffer : (String) -> LLVM::MemoryBuffer
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/llvm/core/bitcode.rb', line 92 def self.from_file(path) buffer = nil #: LLVM::MemoryBuffer? 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 buffer = new(buf_ref.get_pointer(0)) end end buffer #: as !nil end |
.from_stdin ⇒ LLVM::MemoryBuffer
Read STDIN into a memory buffer : -> LLVM::MemoryBuffer
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/llvm/core/bitcode.rb', line 107 def self.from_stdin buffer = nil #: LLVM::MemoryBuffer? 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 buffer = new(buf_ref.get_pointer(0)) end end buffer #: as !nil end |
Instance Method Details
#dispose ⇒ Object
: -> void
120 121 122 123 124 |
# File 'lib/llvm/core/bitcode.rb', line 120 def dispose return if @ptr.nil? C.dispose_memory_buffer(@ptr) @ptr = nil end |
#to_ptr ⇒ Object
: -> FFI::Pointer?
84 85 86 |
# File 'lib/llvm/core/bitcode.rb', line 84 def to_ptr @ptr end |