Class: FFI::MemoryPointer
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Pointer ,
AbstractMemory
|
|
Instance Chain:
self,
Pointer ,
AbstractMemory
|
|
Inherits: |
FFI::Pointer
|
Defined in: | ext/ffi_c/MemoryPointer.c |
Overview
A MemoryPointer is a specific Pointer
. It points to a memory composed of cells. All cells have the same size.
Constant Summary
Class Method Summary
- .from_string(s)
- .new(size, count = 1, clear = true) constructor
Pointer
- Inherited
Instance Attribute Summary
Instance Method Summary
Pointer
- Inherited
#+, #==, | |
#address | Alias for Pointer#to_i. |
#free, | |
#initialize_copy | This method is internally used by |
#inspect | Alias for Pointer#to_s. |
#order | Get or set |
#read | Read pointer’s contents as |
#read_array_of_type | Read an array of |
#read_string | Read pointer’s contents as a string, or the first |
#read_string_length | Read the first |
#read_string_to_null | Read pointer’s contents as a string. |
#slice, #to_i, #to_ptr, #to_s, #type_size, | |
#write | Write |
#write_array_of_type | Write |
#write_string | Write |
#write_string_length | Write |
AbstractMemory
- Inherited
Constructor Details
.new(size, count = 1, clear = true)
.new(instance)
# File 'ext/ffi_c/MemoryPointer.c', line 89
static VALUE memptr_initialize(int argc, VALUE* argv, VALUE self) { VALUE size = Qnil, count = Qnil, clear = Qnil; int nargs = rb_scan_args(argc, argv, "12", &size, &count, &clear); memptr_malloc(self, rbffi_type_size(size), nargs > 1 ? NUM2LONG(count) : 1, RTEST(clear) || clear == Qnil); if (rb_block_given_p()) { return rb_ensure(rb_yield, self, memptr_free, self); } return self; }
Class Method Details
.from_string(s)
Create(a {MemoryPointer} with {s} inside.)
# File 'ext/ffi_c/MemoryPointer.c', line 181
static VALUE memptr_s_from_string(VALUE klass, VALUE to_str) { VALUE s = StringValue(to_str); VALUE args[] = { INT2FIX(1), LONG2NUM(RSTRING_LEN(s) + 1), Qfalse }; VALUE obj = rb_class_new_instance(3, args, klass); rb_funcall(obj, rb_intern("put_string"), 2, INT2FIX(0), s); return obj; }