Class: CFrida::IOStream
- Inherits:
-
GObject
- Object
- GObject
- CFrida::IOStream
- Defined in:
- ext/c_frida/IOStream.c
Instance Method Summary collapse
- #close ⇒ Object
- #inspect ⇒ Object (also: #to_s)
- #is_closed ⇒ Object
- #read(count) ⇒ Object
- #read_all(count) ⇒ Object
- #write(data) ⇒ Object
- #write_all(data) ⇒ Object
Instance Method Details
#close ⇒ Object
197 198 199 200 201 202 203 204 205 206 |
# File 'ext/c_frida/IOStream.c', line 197
static VALUE IOStream_close(VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
CALL_GVL_FREE_WITH_RET(void *dummy, close, d->handle);
return (Qnil);
GERROR_BLOCK
}
|
#inspect ⇒ Object Also known as: to_s
37 38 39 40 41 42 43 44 |
# File 'ext/c_frida/IOStream.c', line 37
static VALUE IOStream_inspect(VALUE self)
{
GET_GOBJECT_DATA();
VALUE s;
s = rb_sprintf("#<IOStream: handle=\"%p\", is_closed=%+"PRIsVALUE">", d->handle, rb_funcall(self, rb_intern("is_closed"), 0, NULL));
return (s);
}
|
#is_closed ⇒ Object
30 31 32 33 34 35 |
# File 'ext/c_frida/IOStream.c', line 30
static VALUE IOStream_is_closed(VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
return (g_io_stream_is_closed(d->handle) ? Qtrue : Qfalse);
}
|
#read(count) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'ext/c_frida/IOStream.c', line 126
static VALUE IOStream_read(VALUE self, VALUE count)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
GET_DATA_EX(IOStream, self, io_d);
if (!FIXNUM_P(count)) {
raise_argerror("count should be a number.");
return (Qnil);
}
VALUE buffer = rb_str_new(NULL, NUM2ULONG(count));
read_proxy_args args = {
.input = io_d->input,
.buffer = RSTRING_PTR(buffer),
.count = NUM2ULONG(count)
};
CALL_GVL_FREE_WITH_RET(void *read, read, &args);
if ((gsize)read != NUM2ULONG(count))
buffer = rb_str_new(RSTRING_PTR(buffer), (gsize)read);
return (buffer);
GERROR_BLOCK
}
|
#read_all(count) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'ext/c_frida/IOStream.c', line 163
static VALUE IOStream_read_all(VALUE self, VALUE count)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
GET_DATA_EX(IOStream, self, io_d);
if (!FIXNUM_P(count)) {
raise_argerror("count should be a number.");
return (Qnil);
}
VALUE buffer = rb_str_new(NULL, NUM2ULONG(count));
read_proxy_args args = {
.input = io_d->input,
.buffer = RSTRING_PTR(buffer),
.count = NUM2ULONG(count)
};
CALL_GVL_FREE_WITH_RET(void *dummy, read_all, &args);
return (buffer);
GERROR_BLOCK
}
|
#write(data) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'ext/c_frida/IOStream.c', line 59
static VALUE IOStream_write(VALUE self, VALUE data)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
GET_DATA_EX(IOStream, self, io_d);
if (!RB_TYPE_P(data, T_STRING)) {
raise_argerror("data should be a string.");
return (Qnil);
}
write_proxy_args args = {
.output = io_d->output,
.data = RSTRING_PTR(data),
.size = RSTRING_LEN(data)
};
CALL_GVL_FREE_WITH_RET(void *written, write, &args);
return (ULONG2NUM((gsize)written));
GERROR_BLOCK
}
|
#write_all(data) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'ext/c_frida/IOStream.c', line 92
static VALUE IOStream_write_all(VALUE self, VALUE data)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
GET_DATA_EX(IOStream, self, io_d);
if (!RB_TYPE_P(data, T_STRING)) {
raise_argerror("data should be a string.");
return (Qnil);
}
write_proxy_args args = {
.output = io_d->output,
.data = RSTRING_PTR(data),
.size = RSTRING_LEN(data)
};
CALL_GVL_FREE_WITH_RET(void *dummy, write_all, &args);
return (Qnil);
GERROR_BLOCK
}
|