util: convert virIdentity class to use GObject

Converting from virObject to GObject is reasonably straightforward,
as illustrated by this patch for virIdentity

In the header file

 - Remove

     typedef struct _virIdentity virIdentity

 - Add

     #define VIR_TYPE_IDENTITY virIdentity_get_type ()
     G_DECLARE_FINAL_TYPE (virIdentity, vir_identity, VIR, IDENTITY, GObject);

   Which provides the typedef we just removed, and class
   declaration boilerplate and various other constants/macros.

In the source file

 - Change 'virObject parent' to 'GObject parent' in the struct
 - Remove the virClass variable and its initializing call
 - Add

      G_DEFINE_TYPE(virIdentity, vir_identity, G_TYPE_OBJECT)

   which declares the instance & class constructor functions

 - Add an impl of the instance & class constructors
   wiring up the finalize method to point to our dispose impl

In all files

 - Replace VIR_AUTOUNREF(virIdentityPtr) with g_autoptr(virIdentity)

 - Replace virObjectRef/Unref with g_object_ref/unref. Note
   the latter functions do *NOT* accept a NULL object where as
   libvirt's do. If you replace g_object_unref with g_clear_object
   it is NULL safe, but also clears the pointer.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2019-09-19 15:38:03 +01:00
parent b74a95d6a2
commit 16121a88a7
6 changed files with 49 additions and 39 deletions

View File

@@ -24,10 +24,10 @@ AC_DEFUN([LIBVIRT_ARG_GLIB], [
AC_DEFUN([LIBVIRT_CHECK_GLIB],[
GLIB_REQUIRED=2.48.0
LIBVIRT_CHECK_PKG([GLIB], [glib-2.0], [$GLIB_REQUIRED])
LIBVIRT_CHECK_PKG([GLIB], [glib-2.0 gobject-2.0], [$GLIB_REQUIRED])
if test "$with_glib" = "no" ; then
AC_MSG_ERROR([glib-2.0 >= $GLIB_REQUIRED is required for libvirt])
AC_MSG_ERROR([glib-2.0, gobject-2.0 >= $GLIB_REQUIRED are required for libvirt])
fi
])