123456789_123456789_123456789_123456789_123456789_

Class: Fiddle::Pointer

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: ext/fiddle/pointer.c

Overview

Pointer is a class to handle C pointers

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(address) ⇒ fiddle_cptr .new(address, size) ⇒ fiddle_cptr .new(address, size, freefunc) ⇒ fiddle_cptr

Create a new pointer to address with an optional #size and freefunc.

freefunc will be called when the instance is garbage collected.

Class Method Details

Fiddle::Pointercptr .to_ptr(val) ⇒ cptr
Also known as: .to_ptr

Get the underlying pointer for ruby object val and return it as a Pointer object.

Fiddle::Pointercptr .to_ptr(val) ⇒ cptr

Alias for .[].

Instance Attribute Details

#freeFiddle::Function (rw)

Get the free function for this pointer.

Returns a new instance of Function.

See Function.new

#free=(function) (rw)

Set the free function for this pointer to function in the given Function.

#null?Boolean (readonly)

Returns true if this is a null pointer.

#size (rw)

Get the size of this pointer.

#size=(size) (rw)

Set the size of this pointer to #size

Instance Method Details

#+(n) ⇒ new cptr

Returns a new pointer instance that has been advanced n bytes.

#+@ Also known as: #ptr

Returns a new Pointer instance that is a dereferenced pointer for this pointer.

Analogous to the star operator in C.

#-(n) ⇒ new cptr

Returns a new pointer instance that has been moved back n bytes.

#-@ Also known as: #ref

Returns a new Pointer instance that is a reference pointer for this pointer.

Analogous to the ampersand operator in C.

#<=>(other) ⇒ 1, ...

Returns -1 if less than, 0 if equal to, 1 if greater than other.

Returns nil if #ptr cannot be compared to other.

#==(other) ⇒ Boolean #eql?(other) ⇒ Boolean
Also known as: #eql?

Returns true if other wraps the same pointer, otherwise returns false.

#[](index) ⇒ Integer #[](start, length) ⇒ String

Returns integer stored at index.

If start and length are given, a string containing the bytes from start of length will be returned.

#[]=(index, int) ⇒ Integer #[]=(start, length, string or cptr or addr) ⇒ String, ...

Set the value at index to int.

Or, set the memory at start until length with the contents of string, the memory from dl_cptr, or the memory pointed at by the memory address addr.

#==(other) ⇒ Boolean #eql?(other) ⇒ Boolean

Alias for #==.

#inspect

Returns a string formatted with an easily readable representation of the internal state of the pointer.

#+@ #ptr

Alias for #+@.

#-@ #ref

Alias for #-@.

#to_iInteger Also known as: #to_int

Returns the integer memory location of this pointer.

#to_iInteger #to_intInteger

Alias for #to_i.

#to_sString #to_s(len) ⇒ String

Returns the pointer contents as a string.

When called with no arguments, this method will return the contents until the first NULL byte.

When called with len, a string of len bytes will be returned.

See to_str

#to_strString #to_str(len) ⇒ String

Returns the pointer contents as a string.

When called with no arguments, this method will return the contents with the length of this pointer's #size.

When called with len, a string of len bytes will be returned.

See to_s

#to_value ⇒ ?

Cast this pointer to a ruby object.