Class
Class Methods
ext/fiddle/pinned.c
View on GitHub
static VALUE
initialize(VALUE self, VALUE ref)
{
struct pinned_data *data;
TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
RB_OBJ_WRITE(self, &data->ptr, ref);
return self;
}
Create a new pinned object reference. The Fiddle::Pinned
instance will prevent the GC
from moving object
.
Instance Methods
#
ext/fiddle/pinned.c
View on GitHub
static VALUE
clear(VALUE self)
{
struct pinned_data *data;
TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
data->ptr = 0;
return self;
}
Clear the reference to the object this is pinning.
#
ext/fiddle/pinned.c
View on GitHub
static VALUE
cleared_p(VALUE self)
{
struct pinned_data *data;
TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
if (data->ptr) {
return Qfalse;
} else {
return Qtrue;
}
}
Returns true if the reference has been cleared, otherwise returns false.
#
ext/fiddle/pinned.c
View on GitHub
static VALUE
ref(VALUE self)
{
struct pinned_data *data;
TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
if (data->ptr) {
return data->ptr;
} else {
rb_raise(rb_eFiddleClearedReferenceError, "`ref` called on a cleared object");
}
}
Return the object that this pinned instance references.