ext/glib2/rbglib_maincontext.c in glib2-3.4.3 vs ext/glib2/rbglib_maincontext.c in glib2-3.4.4
- old
+ new
@@ -1,8 +1,8 @@
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
- * Copyright (C) 2011-2018 Ruby-GNOME2 Project Team
+ * Copyright (C) 2011-2021 Ruby-GNOME Project Team
* Copyright (C) 2005 Masao Mutoh
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -23,11 +23,11 @@
#ifdef HAVE_RUBY_THREAD_H
# include <ruby/thread.h>
#endif
-GStaticPrivate rg_polling_key = G_STATIC_PRIVATE_INIT;
+GPrivate rg_polling_key = G_PRIVATE_INIT(NULL);
/*
static ID id_poll_func;
*/
static ID id_call;
@@ -85,11 +85,11 @@
info.ufds = ufds;
info.nfsd = nfsd;
info.timeout = timeout;
info.result = 0;
- g_static_private_set(&rg_polling_key, GINT_TO_POINTER(TRUE), NULL);
+ g_private_set(&rg_polling_key, GINT_TO_POINTER(TRUE));
if (g_thread_self() == main_thread) {
#ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
rb_thread_call_without_gvl(rg_poll_in_blocking, &info,
RUBY_UBF_IO, NULL);
#else
@@ -97,11 +97,11 @@
RUBY_UBF_IO, NULL);
#endif
} else {
rg_poll_in_blocking_raw(&info);
}
- g_static_private_set(&rg_polling_key, GINT_TO_POINTER(FALSE), NULL);
+ g_private_set(&rg_polling_key, GINT_TO_POINTER(FALSE));
return info.result;
}
static VALUE
@@ -146,25 +146,10 @@
rbgobj_remove_relative(mGLibSource, (ID)0, info->callback);
xfree(info);
}
-/*****************************************/
-#if !GLIB_CHECK_VERSION(2,30,0)
-GType
-g_main_context_get_type(void)
-{
- static GType our_type = 0;
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("GMainContext",
- (GBoxedCopyFunc)g_main_context_ref,
- (GBoxedFreeFunc)g_main_context_unref);
- return our_type;
-}
-#endif
-/*****************************************/
-
#define RG_TARGET_NAMESPACE cMainContext
#define _SELF(s) ((GMainContext*)RVAL2BOXED(s, G_TYPE_MAIN_CONTEXT))
static VALUE
rg_initialize(VALUE self)
@@ -384,30 +369,27 @@
{
g_main_context_remove_poll(_SELF(self), RVAL2GPOLLFD(fd));
return self;
}
-#ifdef HAVE_G_MAIN_DEPTH
static VALUE
rg_s_depth(G_GNUC_UNUSED VALUE self)
{
return INT2NUM(g_main_depth());
}
-#endif
static VALUE
timeout_source_new(G_GNUC_UNUSED VALUE self, VALUE interval)
{
return BOXED2RVAL(g_timeout_source_new(NUM2UINT(interval)), G_TYPE_SOURCE);
}
-#if GLIB_CHECK_VERSION(2,14,0)
+
static VALUE
timeout_source_new_seconds(G_GNUC_UNUSED VALUE self, VALUE interval)
{
return BOXED2RVAL(g_timeout_source_new_seconds(NUM2UINT(interval)), G_TYPE_SOURCE);
}
-#endif
static VALUE
timeout_add(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
VALUE interval, rb_priority, func, rb_id;
@@ -429,11 +411,10 @@
rb_id = UINT2NUM(id);
rbgobj_add_relative(mGLibSource, func);
return rb_id;
}
-#if GLIB_CHECK_VERSION(2,14,0)
static VALUE
timeout_add_seconds(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
VALUE interval, rb_priority, func, rb_id;
gint priority;
@@ -453,11 +434,10 @@
info->id = id;
rb_id = UINT2NUM(id);
rbgobj_add_relative(mGLibSource, func);
return rb_id;
}
-#endif
static VALUE
idle_source_new(G_GNUC_UNUSED VALUE self)
{
return BOXED2RVAL(g_idle_source_new(), G_TYPE_SOURCE);
@@ -524,11 +504,11 @@
VALUE idle = rb_define_module_under(mGLib, "Idle");
VALUE child_watch = rb_define_module_under(mGLib, "ChildWatch");
id_call = rb_intern("call");
- g_static_private_set(&rg_polling_key, GINT_TO_POINTER(FALSE), NULL);
+ g_private_set(&rg_polling_key, GINT_TO_POINTER(FALSE));
main_thread = g_thread_self();
rbg_define_singleton_method(mGLib, "set_ruby_thread_priority",
ruby_source_set_priority, 1);
@@ -557,20 +537,14 @@
/*
RG_DEF_METHOD(set_poll_func, 0);
*/
RG_DEF_METHOD(add_poll, 2);
RG_DEF_METHOD(remove_poll, 1);
-#ifdef HAVE_G_MAIN_DEPTH
RG_DEF_SMETHOD(depth, 0);
-#endif
rbg_define_singleton_method(timeout, "source_new", timeout_source_new, 1);
-#if GLIB_CHECK_VERSION(2,14,0)
rbg_define_singleton_method(timeout, "source_new_seconds", timeout_source_new_seconds, 1);
-#endif
rbg_define_singleton_method(timeout, "add", timeout_add, -1);
-#if GLIB_CHECK_VERSION(2,14,0)
rbg_define_singleton_method(timeout, "add_seconds", timeout_add_seconds, -1);
-#endif
rbg_define_singleton_method(idle, "source_new", idle_source_new, 0);
rbg_define_singleton_method(idle, "add", idle_add, -1);
rbg_define_singleton_method(child_watch, "source_new", child_watch_source_new, 1);
rbg_define_singleton_method(child_watch, "add", child_watch_add, 1);