/* TODO: Should this take an array instead? */ static VALUE rg_s_new_from_bytes(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) { VALUE rbbytes, rbfamily; guint8 *bytes; GSocketFamily family; rb_scan_args(argc, argv, "11", &rbbytes, &rbfamily); bytes = (guint8 *)RVAL2CSTR(rbbytes); family = RVAL2GSOCKETFAMILY(rbfamily); /* TODO: Should check encoding. */ /* TODO: We can't pass bytes as such, as it will be NULL-terminated. */ /* TODO: Do we need to deal with G_SOCKET_FAMILY_UNIX? */ switch (family) { case G_SOCKET_FAMILY_IPV4: if (RSTRING_LEN(rbbytes) != 4) rb_raise(rb_eArgError, "string containing 4 bytes expected"); break; case G_SOCKET_FAMILY_IPV6: if (RSTRING_LEN(rbbytes) != 16) rb_raise(rb_eArgError, "string containing 16 bytes expected"); break; case G_SOCKET_FAMILY_INVALID: case G_SOCKET_FAMILY_UNIX: rb_raise(rb_eArgError, "invalid family: %d", family); default: rb_raise(rb_eArgError, "unknown family: %d", family); break; } return GOBJ2RVAL_UNREF(g_inet_address_new_from_bytes(bytes, family)); }
static VALUE ioscheduler_job_callback_call(VALUE data) { static VALUE s_id_call; struct ioscheduler_job_callback_data *real; if (s_id_call == 0) s_id_call = rb_intern("call"); real = (struct ioscheduler_job_callback_data *)data; /* TODO: Totally unsure if _UNREF is correct here or not. */ return rb_funcall(USE_BLOCK_AND_SAVE(real->data), s_id_call, 2, GOBJ2RVAL_UNREF(real->job), GOBJ2RVAL_UNREF(real->cancellable)); }
static VALUE unixsocketaddress_new_abstract(G_GNUC_UNUSED VALUE self, VALUE path) { StringValue(path); return GOBJ2RVAL_UNREF(g_unix_socket_address_new_abstract(RSTRING_PTR(path), RSTRING_LEN(path))); }
static VALUE client_create_event_loop(VALUE self, VALUE use_default_context) { MilterEventLoop *event_loop; event_loop = milter_client_create_event_loop(SELF(self), RVAL2CBOOL(use_default_context)); return GOBJ2RVAL_UNREF(event_loop); }
static VALUE appinfo_get_default_for_type(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) { VALUE content_type, must_support_uris; rb_scan_args(argc, argv, "11", &content_type, &must_support_uris); return GOBJ2RVAL_UNREF(g_app_info_get_default_for_type(RVAL2CSTR(content_type), RVAL2CBOOL(must_support_uris))); }
static VALUE connection_finish_method(ConnectionFinishMethod method, VALUE self, VALUE result) { GError *error = NULL; GSocketConnection *connection; connection = method(_SELF(self), RVAL2GASYNCRESULT(result), &error); if (connection == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(connection); }
VALUE rbgio_glist_to_ary_unref_free(GList *list) { VALUE ary; GList *i; ary = rb_ary_new(); for (i = list; i != NULL; i = i->next) rb_ary_push(ary, GOBJ2RVAL_UNREF(i->data)); g_list_free(list); return ary; }
static VALUE rg_query_info_finish(VALUE self, VALUE result) { GError *error = NULL; GFileInfo *info; info = g_file_input_stream_query_info_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error); if (info == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(info); }
static VALUE rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE host_and_port, VALUE default_port) { GError *error = NULL; GSocketConnectable *connectable; connectable = g_network_address_parse(RVAL2CSTR(host_and_port), RVAL2GUINT16(default_port), &error); if (connectable == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(connectable); }
static VALUE fileenumerator_next_file(int argc, VALUE *argv, VALUE self) { VALUE cancellable; GError *error = NULL; GFileInfo *info; rb_scan_args(argc, argv, "01", &cancellable); info = g_file_enumerator_next_file(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error); if (error != NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(info); }
static VALUE appinfo_create_from_commandline(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) { VALUE commandline, application_name, flags; GError *error = NULL; GAppInfo *info; rb_scan_args(argc, argv, "12", &commandline, &application_name, &flags); info = g_app_info_create_from_commandline(RVAL2CSTR(commandline), RVAL2CSTR_ACCEPT_NIL(application_name), RVAL2GAPPINFOCREATEFLAGSDEFAULT(flags), &error); if (info == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(info); }
static VALUE rg_query_info(int argc, VALUE *argv, VALUE self) { VALUE attributes, cancellable; GError *error = NULL; GFileInfo *info; rb_scan_args(argc, argv, "02", &attributes, &cancellable); info = g_file_input_stream_query_info(_SELF(self), RVAL2ATTRIBUTESDEFAULT(attributes), RVAL2GCANCELLABLE(cancellable), &error); if (info == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(info); }
static VALUE rg_connect(int argc, VALUE *argv, VALUE self) { VALUE connectable, cancellable; GError *error = NULL; GSocketConnection *connection; rb_scan_args(argc, argv, "11", &connectable, &cancellable); connection = g_socket_client_connect(_SELF(self), RVAL2GSOCKETCONNECTABLE(connectable), RVAL2GCANCELLABLE(cancellable), &error); if (connection == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(connection); }
static VALUE rbgio_async_ready_callback_call(VALUE data) { static VALUE s_id_call; struct async_ready_callback_data *real; VALUE block; if (s_id_call == 0) s_id_call = rb_intern("call"); real = (struct async_ready_callback_data *)data; block = USE_BLOCK(real->data); if (!NIL_P(block)) rb_funcall(block, s_id_call, 1, GOBJ2RVAL_UNREF(real->result)); return Qnil; }
static VALUE rg_connect_to_service(int argc, VALUE *argv, VALUE self) { VALUE domain, service, cancellable; GError *error = NULL; GSocketConnection *connection; rb_scan_args(argc, argv, "21", &domain, &service, &cancellable); connection = g_socket_client_connect_to_service(_SELF(self), RVAL2CSTR(domain), RVAL2CSTR(service), RVAL2GCANCELLABLE(cancellable), &error); if (connection == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(connection); }
static VALUE rg_connect_to_host(int argc, VALUE *argv, VALUE self) { VALUE host_and_port, default_port, cancellable; GError *error = NULL; GSocketConnection *connection; rb_scan_args(argc, argv, "21", &host_and_port, &default_port, &cancellable); connection = g_socket_client_connect_to_host(_SELF(self), RVAL2CSTR(host_and_port), RVAL2GUINT16(default_port), RVAL2GCANCELLABLE(cancellable), &error); if (connection == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(connection); }
/* * Class method: make(factory_name, element_name) * factory_name: a name of an existing factory. * element_name: a name which will be attributed to the element. * * Creates a new Gst::Element of the type defined by the given element factory. * * If element name is ommited (or nil), then the element will receive a guaranteed * unique name, consisting of the element factory name and a number. * If name is given, it will be given the name supplied. * * # Creates a 'mad' GStreamer element, named 'foo': * elem1 = Gst::ElementFactory.make("mad", "foo") * * # This line does exactly the same thing: * elem2 = Gst::ElementFactory.find("mad").create("foo") * * Returns: a newly created object based on Gst::Element. */ static VALUE rb_gst_elementfactory_make(int argc, VALUE *argv, VALUE self) { GstElement *element; VALUE fname, ename; VALUE ret; rb_scan_args(argc, argv, "11", &fname, &ename); element = gst_element_factory_make(RVAL2CSTR(fname), RVAL2CSTR_ACCEPT_NIL(ename)); if (element == NULL) return Qnil; /* This add another ref to the element, but it was already ours so * unref it again */ ret = GOBJ2RVAL(element); GOBJ2RVAL_UNREF(element); return ret; }
static VALUE rg_s_new_from_keyfile(G_GNUC_UNUSED VALUE self, VALUE keyfile) { return GOBJ2RVAL_UNREF(g_desktop_app_info_new_from_keyfile(RVAL2GKEYFILE(keyfile))); }
static VALUE rg_s_new_from_filename(G_GNUC_UNUSED VALUE self, VALUE filename) { return GOBJ2RVAL_UNREF(g_desktop_app_info_new_from_filename(RVAL2CSTR(filename))); }
static VALUE rg_activation_root(VALUE self) { return GOBJ2RVAL_UNREF(g_volume_get_activation_root(_SELF(self))); }
static VALUE rg_get_mount(VALUE self) { return GOBJ2RVAL_UNREF(g_volume_get_mount(_SELF(self))); }
static VALUE vfs_parse_name(VALUE self, VALUE parse_name) { return GOBJ2RVAL_UNREF(g_vfs_parse_name(_SELF(self), RVAL2CSTR(parse_name))); }
static VALUE asyncresult_get_source_object(VALUE self) { return GOBJ2RVAL_UNREF(g_async_result_get_source_object(_SELF(self))); }
static VALUE vfs_get_file_for_path(VALUE self, VALUE path) { return GOBJ2RVAL_UNREF(g_vfs_get_file_for_path(_SELF(self), RVAL2CSTR(path))); }
static VALUE vfs_get_file_for_uri(VALUE self, VALUE uri) { return GOBJ2RVAL_UNREF(g_vfs_get_file_for_uri(_SELF(self), RVAL2CSTR(uri))); }
static VALUE rg_s_default(G_GNUC_UNUSED VALUE self) { return GOBJ2RVAL_UNREF(g_resolver_get_default()); }
static VALUE client_create_context (VALUE self) { return GOBJ2RVAL_UNREF(milter_client_create_context(SELF(self))); }
static VALUE rg_icon(VALUE self) { return GOBJ2RVAL_UNREF(g_volume_get_icon(_SELF(self))); }
static VALUE rg_s_get_icon(G_GNUC_UNUSED VALUE type) { return GOBJ2RVAL_UNREF(g_content_type_get_icon(RVAL2CSTR(type))); }
static VALUE rg_drive(VALUE self) { return GOBJ2RVAL_UNREF(g_volume_get_drive(_SELF(self))); }