Class: FFI::StructByReference
- Inherits:
-
Object
- Object
- FFI::StructByReference
show all
- Defined in:
- ext/ffi_c/StructByReference.c
Instance Method Summary
(collapse)
Constructor Details
- (Object) initialize
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'ext/ffi_c/StructByReference.c', line 73
static VALUE
sbr_initialize(VALUE self, VALUE rbStructClass)
{
StructByReference* sbr = NULL;
if (!rb_class_inherited_p(rbStructClass, rbffi_StructClass)) {
rb_raise(rb_eTypeError, "wrong type (expected subclass of FFI::Struct)");
}
Data_Get_Struct(self, StructByReference, sbr);
sbr->rbStructClass = rbStructClass;
return self;
}
|
Instance Method Details
- (Object) from_native
133
134
135
136
137
138
139
140
141
|
# File 'ext/ffi_c/StructByReference.c', line 133
static VALUE
sbr_from_native(VALUE self, VALUE value, VALUE ctx)
{
StructByReference* sbr;
Data_Get_Struct(self, StructByReference, sbr);
return rb_class_new_instance(1, &value, sbr->rbStructClass);
}
|
- (Object) native_type
105
106
107
108
109
|
# File 'ext/ffi_c/StructByReference.c', line 105
static VALUE
sbr_native_type(VALUE self)
{
return rb_const_get(rbffi_TypeClass, rb_intern("POINTER"));
}
|
- (Object) struct_class
95
96
97
98
99
100
101
102
103
|
# File 'ext/ffi_c/StructByReference.c', line 95
static VALUE
sbr_struct_class(VALUE self)
{
StructByReference* sbr;
Data_Get_Struct(self, StructByReference, sbr);
return sbr->rbStructClass;
}
|
- (Object) to_native
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'ext/ffi_c/StructByReference.c', line 111
static VALUE
sbr_to_native(VALUE self, VALUE value, VALUE ctx)
{
StructByReference* sbr;
Struct* s;
if (unlikely(value == Qnil)) {
return rbffi_NullPointerSingleton;
}
Data_Get_Struct(self, StructByReference, sbr);
if (!rb_obj_is_kind_of(value, sbr->rbStructClass)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
rb_obj_classname(value),
RSTRING_PTR(rb_class_name(sbr->rbStructClass)));
}
Data_Get_Struct(value, Struct, s);
return s->rbPointer;
}
|