[gcr/main: 10/13] gck-object-cache: Use G_DECLARE_INTERFACE to define the interface
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcr/main: 10/13] gck-object-cache: Use G_DECLARE_INTERFACE to define the interface
- Date: Tue, 11 Jan 2022 18:28:23 +0000 (UTC)
commit e06b1deeeb11bf8f1f076167e78c020fc0d960cf
Author: Corentin Noël <corentin noel collabora com>
Date: Fri Dec 10 09:24:40 2021 +0100
gck-object-cache: Use G_DECLARE_INTERFACE to define the interface
This means that GckObjectCacheIface becomes GckObjectCacheInterface and
GCK_OBJECT_CACHE_GET_INTERFACE becomes GCK_OBJECT_CACHE_GET_IFACE.
Signed-off-by: Corentin Noël <corentin noel collabora com>
gck/gck-enumerator.c | 2 +-
gck/gck-object-cache.c | 39 ++++++++++++++++-----------------------
gck/gck.h | 14 +++-----------
gck/test-gck-enumerator.c | 4 ++--
gcr/test-subject-public-key.c | 4 ++--
5 files changed, 24 insertions(+), 39 deletions(-)
---
diff --git a/gck/gck-enumerator.c b/gck/gck-enumerator.c
index c1b82ee..957e2a7 100644
--- a/gck/gck-enumerator.c
+++ b/gck/gck-enumerator.c
@@ -1027,7 +1027,7 @@ check_out_enumerator_state (GckEnumerator *self)
GTlsInteraction *old_interaction = NULL;
gpointer old_object_class = NULL;
GckEnumeratorState *chained_state = NULL;
- GckObjectCacheIface *object_iface;
+ GckObjectCacheInterface *object_iface;
GckEnumerator *chained;
chained = gck_enumerator_get_chained (self);
diff --git a/gck/gck-object-cache.c b/gck/gck-object-cache.c
index d86867d..838ff16 100644
--- a/gck/gck-object-cache.c
+++ b/gck/gck-object-cache.c
@@ -37,7 +37,7 @@
*/
/**
- * GckObjectCacheIface:
+ * GckObjectCacheInterface:
* @interface: parent interface
* @default_types: (array length=n_default_types): attribute types that an
* enumerator should retrieve
@@ -53,26 +53,19 @@
* cache. It must be thread safe.
*/
-typedef GckObjectCacheIface GckObjectCacheInterface;
G_DEFINE_INTERFACE (GckObjectCache, gck_object_cache, GCK_TYPE_OBJECT);
static void
-gck_object_cache_default_init (GckObjectCacheIface *iface)
+gck_object_cache_default_init (GckObjectCacheInterface *iface)
{
- static size_t initialized = 0;
- if (g_once_init_enter (&initialized)) {
-
- /**
- * GckObjectCache:attributes:
- *
- * The attributes cached on this object.
- */
- g_object_interface_install_property (iface,
- g_param_spec_boxed ("attributes", "Attributes", "PKCS#11 Attributes",
- GCK_TYPE_ATTRIBUTES, G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
-
- g_once_init_leave (&initialized, 1);
- }
+ /**
+ * GckObjectCache:attributes:
+ *
+ * The attributes cached on this object.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_boxed ("attributes", "Attributes", "PKCS#11 Attributes",
+ GCK_TYPE_ATTRIBUTES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
/**
@@ -129,12 +122,12 @@ void
gck_object_cache_fill (GckObjectCache *object,
GckAttributes *attrs)
{
- GckObjectCacheIface *iface;
+ GckObjectCacheInterface *iface;
g_return_if_fail (GCK_IS_OBJECT_CACHE (object));
g_return_if_fail (attrs != NULL);
- iface = GCK_OBJECT_CACHE_GET_INTERFACE (object);
+ iface = GCK_OBJECT_CACHE_GET_IFACE (object);
g_return_if_fail (iface->fill != NULL);
gck_attributes_ref_sink (attrs);
@@ -164,7 +157,7 @@ gck_object_cache_update (GckObjectCache *object,
GCancellable *cancellable,
GError **error)
{
- GckObjectCacheIface *iface;
+ GckObjectCacheInterface *iface;
GckAttributes *attrs;
g_return_val_if_fail (GCK_IS_OBJECT_CACHE (object), FALSE);
@@ -172,7 +165,7 @@ gck_object_cache_update (GckObjectCache *object,
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- iface = GCK_OBJECT_CACHE_GET_INTERFACE (object);
+ iface = GCK_OBJECT_CACHE_GET_IFACE (object);
if (attr_types == NULL) {
attr_types = iface->default_types;
@@ -240,14 +233,14 @@ gck_object_cache_update_async (GckObjectCache *object,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GckObjectCacheIface *iface;
+ GckObjectCacheInterface *iface;
GTask *task;
g_return_if_fail (GCK_IS_OBJECT_CACHE (object));
g_return_if_fail (attr_types != NULL || n_attr_types == 0);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
- iface = GCK_OBJECT_CACHE_GET_INTERFACE (object);
+ iface = GCK_OBJECT_CACHE_GET_IFACE (object);
if (attr_types == NULL) {
attr_types = iface->default_types;
diff --git a/gck/gck.h b/gck/gck.h
index 1b60308..67fd18e 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -1427,14 +1427,10 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GckObject, g_object_unref);
* OBJECT ATTRIBUTES
*/
-#define GCK_TYPE_OBJECT_CACHE (gck_object_cache_get_type ())
-#define GCK_OBJECT_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCK_TYPE_OBJECT_CACHE,
GckObjectCache))
-#define GCK_IS_OBJECT_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCK_TYPE_OBJECT_CACHE))
-#define GCK_OBJECT_CACHE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst),
GCK_TYPE_OBJECT_CACHE, GckObjectCacheIface))
+#define GCK_TYPE_OBJECT_CACHE gck_object_cache_get_type ()
+G_DECLARE_INTERFACE (GckObjectCache, gck_object_cache, GCK, OBJECT_CACHE, GckObject)
-typedef struct _GckObjectCacheIface GckObjectCacheIface;
-
-struct _GckObjectCacheIface {
+struct _GckObjectCacheInterface {
GTypeInterface interface;
const gulong * default_types;
@@ -1447,8 +1443,6 @@ struct _GckObjectCacheIface {
gpointer reserved[6];
};
-GType gck_object_cache_get_type (void) G_GNUC_CONST;
-
GckAttributes * gck_object_cache_get_attributes (GckObjectCache *object);
void gck_object_cache_set_attributes (GckObjectCache *object,
@@ -1491,8 +1485,6 @@ GckAttributes * gck_object_cache_lookup_finish (GckObject *object,
GAsyncResult *result,
GError **error);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GckObjectCache, g_object_unref);
-
/* ------------------------------------------------------------------------
* PASSWORD
*/
diff --git a/gck/test-gck-enumerator.c b/gck/test-gck-enumerator.c
index e7ad139..6881af3 100644
--- a/gck/test-gck-enumerator.c
+++ b/gck/test-gck-enumerator.c
@@ -408,7 +408,7 @@ typedef struct {
} MockObjectClass;
GType mock_object_get_type (void) G_GNUC_CONST;
-static void mock_object_cache_init (GckObjectCacheIface *iface);
+static void mock_object_cache_init (GckObjectCacheInterface *iface);
#define MOCK_TYPE_OBJECT (mock_object_get_type())
#define MOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), MOCK_TYPE_OBJECT, MockObject))
@@ -498,7 +498,7 @@ mock_object_fill (GckObjectCache *object,
}
static void
-mock_object_cache_init (GckObjectCacheIface *iface)
+mock_object_cache_init (GckObjectCacheInterface *iface)
{
iface->default_types = mock_attribute_types;
iface->n_default_types = G_N_ELEMENTS (mock_attribute_types);
diff --git a/gcr/test-subject-public-key.c b/gcr/test-subject-public-key.c
index a95c38e..1b52dd3 100644
--- a/gcr/test-subject-public-key.c
+++ b/gcr/test-subject-public-key.c
@@ -429,7 +429,7 @@ typedef struct { GckObject parent; GckAttributes *attrs; } MockObject;
typedef struct { GckObjectClass parent; } MockObjectClass;
GType mock_object_get_type (void) G_GNUC_CONST;
-static void mock_object_cache_init (GckObjectCacheIface *iface);
+static void mock_object_cache_init (GckObjectCacheInterface *iface);
G_DEFINE_TYPE_WITH_CODE (MockObject, mock_object, GCK_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GCK_TYPE_OBJECT_CACHE, mock_object_cache_init)
);
@@ -495,7 +495,7 @@ mock_object_fill (GckObjectCache *object,
}
static void
-mock_object_cache_init (GckObjectCacheIface *iface)
+mock_object_cache_init (GckObjectCacheInterface *iface)
{
iface->default_types = NULL;
iface->n_default_types = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]