summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-07-04 12:44:37 -0400
committerDan Winship <danw@gnome.org>2012-07-13 14:18:36 -0400
commit0d0b2f7717f88c8e837399548bfa2ebfc12c8587 (patch)
tree36236d0f3cfb0a64a1f2e4b8d8fc1c07a6a340b4
parent06f64f9db08ec4140b66c118f3fcf5edd6bdeec3 (diff)
downloadlibsoup-0d0b2f7717f88c8e837399548bfa2ebfc12c8587.tar.gz
libsoup-0d0b2f7717f88c8e837399548bfa2ebfc12c8587.tar.bz2
libsoup-0d0b2f7717f88c8e837399548bfa2ebfc12c8587.zip
Use G_DEFINE_INTERFACE and G_DEFINE_BOXED_TYPE
-rwxr-xr-xlibsoup/soup-cookie.c15
-rw-r--r--libsoup/soup-date.c15
-rw-r--r--libsoup/soup-message-body.c30
-rw-r--r--libsoup/soup-message-headers.c15
-rw-r--r--libsoup/soup-multipart.c15
-rw-r--r--libsoup/soup-password-manager.c24
-rw-r--r--libsoup/soup-proxy-resolver.c27
-rw-r--r--libsoup/soup-proxy-uri-resolver.c21
-rw-r--r--libsoup/soup-server.c15
-rw-r--r--libsoup/soup-session-feature.c24
-rw-r--r--libsoup/soup-uri.c16
-rw-r--r--libsoup/soup-value-utils.c18
12 files changed, 29 insertions, 206 deletions
diff --git a/libsoup/soup-cookie.c b/libsoup/soup-cookie.c
index f148afa4..7d6b583f 100755
--- a/libsoup/soup-cookie.c
+++ b/libsoup/soup-cookie.c
@@ -74,20 +74,7 @@
* Since: 2.24
**/
-GType
-soup_cookie_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupCookie"),
- (GBoxedCopyFunc) soup_cookie_copy,
- (GBoxedFreeFunc) soup_cookie_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupCookie, soup_cookie, soup_cookie_copy, soup_cookie_free)
/**
* soup_cookie_copy:
diff --git a/libsoup/soup-date.c b/libsoup/soup-date.c
index a8a32e9a..cf338e54 100644
--- a/libsoup/soup-date.c
+++ b/libsoup/soup-date.c
@@ -88,20 +88,7 @@ days_in_month (int month, int year)
return nonleap_days_in_month[month];
}
-GType
-soup_date_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupDate"),
- (GBoxedCopyFunc) soup_date_copy,
- (GBoxedFreeFunc) soup_date_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupDate, soup_date, soup_date_copy, soup_date_free)
static void
soup_date_fixup (SoupDate *date)
diff --git a/libsoup/soup-message-body.c b/libsoup/soup-message-body.c
index cfcc0bc4..6cff98da 100644
--- a/libsoup/soup-message-body.c
+++ b/libsoup/soup-message-body.c
@@ -328,20 +328,7 @@ soup_buffer_get_as_bytes (SoupBuffer *buffer)
copy);
}
-GType
-soup_buffer_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupBuffer"),
- (GBoxedCopyFunc) soup_buffer_copy,
- (GBoxedFreeFunc) soup_buffer_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupBuffer, soup_buffer, soup_buffer_copy, soup_buffer_free)
/**
@@ -753,17 +740,4 @@ soup_message_body_free (SoupMessageBody *body)
}
}
-GType
-soup_message_body_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupMessageBody"),
- (GBoxedCopyFunc) soup_message_body_copy,
- (GBoxedFreeFunc) soup_message_body_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupMessageBody, soup_message_body, soup_message_body_copy, soup_message_body_free)
diff --git a/libsoup/soup-message-headers.c b/libsoup/soup-message-headers.c
index 60033e1e..eb50034b 100644
--- a/libsoup/soup-message-headers.c
+++ b/libsoup/soup-message-headers.c
@@ -108,20 +108,7 @@ soup_message_headers_free (SoupMessageHeaders *hdrs)
}
}
-GType
-soup_message_headers_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupMessageHeaders"),
- (GBoxedCopyFunc) soup_message_headers_copy,
- (GBoxedFreeFunc) soup_message_headers_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupMessageHeaders, soup_message_headers, soup_message_headers_copy, soup_message_headers_free)
/**
* soup_message_headers_clear:
diff --git a/libsoup/soup-multipart.c b/libsoup/soup-multipart.c
index 64694900..a88281fe 100644
--- a/libsoup/soup-multipart.c
+++ b/libsoup/soup-multipart.c
@@ -488,17 +488,4 @@ soup_multipart_copy (SoupMultipart *multipart)
return copy;
}
-GType
-soup_multipart_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupMultipart"),
- (GBoxedCopyFunc) soup_multipart_copy,
- (GBoxedFreeFunc) soup_multipart_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupMultipart, soup_multipart, soup_multipart_copy, soup_multipart_free)
diff --git a/libsoup/soup-password-manager.c b/libsoup/soup-password-manager.c
index 5f629eeb..fed0156b 100644
--- a/libsoup/soup-password-manager.c
+++ b/libsoup/soup-password-manager.c
@@ -14,25 +14,13 @@
#include "soup-password-manager.h"
#include "soup-session-feature.h"
-GType
-soup_password_manager_get_type (void)
+G_DEFINE_INTERFACE_WITH_CODE (SoupPasswordManager, soup_password_manager, G_TYPE_OBJECT,
+ g_type_interface_add_prerequisite (g_define_type_id, SOUP_TYPE_SESSION_FEATURE);
+ )
+
+static void
+soup_password_manager_default_init (SoupPasswordManagerInterface *iface)
{
- static volatile gsize g_define_type_id__volatile = 0;
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- GType g_define_type_id =
- g_type_register_static_simple (G_TYPE_INTERFACE,
- g_intern_static_string ("SoupPasswordManager"),
- sizeof (SoupPasswordManagerInterface),
- (GClassInitFunc)NULL,
- 0,
- (GInstanceInitFunc)NULL,
- (GTypeFlags) 0);
- g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
- g_type_interface_add_prerequisite (g_define_type_id, SOUP_TYPE_SESSION_FEATURE);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
- return g_define_type_id__volatile;
}
/**
diff --git a/libsoup/soup-proxy-resolver.c b/libsoup/soup-proxy-resolver.c
index 837a1f77..ca604119 100644
--- a/libsoup/soup-proxy-resolver.c
+++ b/libsoup/soup-proxy-resolver.c
@@ -16,29 +16,12 @@
#include "soup-session-feature.h"
#include "soup-uri.h"
-static void soup_proxy_resolver_interface_init (GTypeInterface *iface);
+static void soup_proxy_resolver_default_init (SoupProxyResolverInterface *iface);
static void soup_proxy_resolver_uri_resolver_interface_init (SoupProxyURIResolverInterface *uri_resolver_interface);
-GType
-soup_proxy_resolver_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- GType g_define_type_id =
- g_type_register_static_simple (G_TYPE_INTERFACE,
- g_intern_static_string ("SoupProxyResolver"),
- sizeof (SoupProxyResolverInterface),
- (GClassInitFunc)soup_proxy_resolver_interface_init,
- 0,
- (GInstanceInitFunc)NULL,
- (GTypeFlags) 0);
- g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
- g_type_interface_add_prerequisite (g_define_type_id, SOUP_TYPE_SESSION_FEATURE);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
- return g_define_type_id__volatile;
-}
+G_DEFINE_INTERFACE_WITH_CODE (SoupProxyResolver, soup_proxy_resolver, G_TYPE_OBJECT,
+ g_type_interface_add_prerequisite (g_define_type_id, SOUP_TYPE_SESSION_FEATURE);
+ )
static void
proxy_resolver_interface_check (gpointer func_data, gpointer g_iface)
@@ -63,7 +46,7 @@ proxy_resolver_interface_check (gpointer func_data, gpointer g_iface)
static void
-soup_proxy_resolver_interface_init (GTypeInterface *iface)
+soup_proxy_resolver_default_init (SoupProxyResolverInterface *iface)
{
/* Add an interface_check where we can kludgily add the
* SoupProxyURIResolver interface to all SoupProxyResolvers.
diff --git a/libsoup/soup-proxy-uri-resolver.c b/libsoup/soup-proxy-uri-resolver.c
index 556ba781..01f4f4fd 100644
--- a/libsoup/soup-proxy-uri-resolver.c
+++ b/libsoup/soup-proxy-uri-resolver.c
@@ -12,24 +12,11 @@
#include "soup-proxy-uri-resolver.h"
#include "soup-session-feature.h"
-GType
-soup_proxy_uri_resolver_get_type (void)
+G_DEFINE_INTERFACE (SoupProxyURIResolver, soup_proxy_uri_resolver, G_TYPE_OBJECT)
+
+static void
+soup_proxy_uri_resolver_default_init (SoupProxyURIResolverInterface *iface)
{
- static volatile gsize g_define_type_id__volatile = 0;
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- GType g_define_type_id =
- g_type_register_static_simple (G_TYPE_INTERFACE,
- g_intern_static_string ("SoupProxyURIResolver"),
- sizeof (SoupProxyURIResolverInterface),
- (GClassInitFunc)NULL,
- 0,
- (GInstanceInitFunc)NULL,
- (GTypeFlags) 0);
- g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
- return g_define_type_id__volatile;
}
/**
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 8ba0eaac..e6a77110 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -1137,20 +1137,7 @@ soup_server_get_async_context (SoupServer *server)
* also be of use in some situations (eg, tracking when multiple
* requests are made on the same connection).
**/
-GType
-soup_client_context_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupClientContext"),
- (GBoxedCopyFunc) soup_client_context_ref,
- (GBoxedFreeFunc) soup_client_context_unref);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupClientContext, soup_client_context, soup_client_context_ref, soup_client_context_unref)
/**
* soup_client_context_get_socket:
diff --git a/libsoup/soup-session-feature.c b/libsoup/soup-session-feature.c
index f572a3a0..e7fe4532 100644
--- a/libsoup/soup-session-feature.c
+++ b/libsoup/soup-session-feature.c
@@ -51,33 +51,15 @@
* Since: 2.24
**/
-static void soup_session_feature_interface_init (SoupSessionFeatureInterface *interface);
+static void soup_session_feature_default_init (SoupSessionFeatureInterface *interface);
static void attach (SoupSessionFeature *feature, SoupSession *session);
static void detach (SoupSessionFeature *feature, SoupSession *session);
-GType
-soup_session_feature_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
- if (g_once_init_enter (&g_define_type_id__volatile))
- {
- GType g_define_type_id =
- g_type_register_static_simple (G_TYPE_INTERFACE,
- g_intern_static_string ("SoupSessionFeature"),
- sizeof (SoupSessionFeatureInterface),
- (GClassInitFunc)soup_session_feature_interface_init,
- 0,
- (GInstanceInitFunc)NULL,
- (GTypeFlags) 0);
- g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
- return g_define_type_id__volatile;
-}
+G_DEFINE_INTERFACE (SoupSessionFeature, soup_session_feature, G_TYPE_OBJECT)
static void
-soup_session_feature_interface_init (SoupSessionFeatureInterface *interface)
+soup_session_feature_default_init (SoupSessionFeatureInterface *interface)
{
interface->attach = attach;
interface->detach = detach;
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index 24cd6b0a..c2fc4342 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -1220,18 +1220,4 @@ soup_uri_host_equal (gconstpointer v1, gconstpointer v2)
return g_ascii_strcasecmp (one->host, two->host) == 0;
}
-
-GType
-soup_uri_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupURI"),
- (GBoxedCopyFunc) soup_uri_copy,
- (GBoxedFreeFunc) soup_uri_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+G_DEFINE_BOXED_TYPE (SoupURI, soup_uri, soup_uri_copy, soup_uri_free)
diff --git a/libsoup/soup-value-utils.c b/libsoup/soup-value-utils.c
index 41f8c920..d9f6bdc7 100644
--- a/libsoup/soup-value-utils.c
+++ b/libsoup/soup-value-utils.c
@@ -482,20 +482,8 @@ soup_byte_array_free (GByteArray *ba)
/**
* SOUP_TYPE_BYTE_ARRAY:
*
- * glib does not define a #GType for #GByteArray, so libsoup
+ * glib did not used to define a #GType for #GByteArray, so libsoup
* defines this one itself.
**/
-GType
-soup_byte_array_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("SoupByteArray"),
- (GBoxedCopyFunc) soup_byte_array_copy,
- (GBoxedFreeFunc) soup_byte_array_free);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
+typedef GByteArray SoupByteArray;
+G_DEFINE_BOXED_TYPE (SoupByteArray, soup_byte_array, soup_byte_array_copy, soup_byte_array_free)