[Xfce4-commits] [xfce/xfconf] 01/02: Add support for GObject introspection and vala

noreply at xfce.org noreply at xfce.org
Mon Jun 24 22:01:24 CEST 2019


This is an automated email from the git hooks/post-receive script.

s   k   u   n   n   y   k       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfconf.

commit 8d4284058bd7acd951f112ac6d3fd42c02eefe7f
Author: Olivier Duchateau <duchateau.olivier at gmail.com>
Date:   Fri Feb 15 20:47:43 2019 +0100

    Add support for GObject introspection and vala
    
    - Fix bug #15135
---
 Makefile.am             |   8 +++-
 configure.ac.in         |   8 ++++
 m4/introspection.m4     |  96 +++++++++++++++++++++++++++++++++++++++++++++
 m4/vapigen.m4           | 101 ++++++++++++++++++++++++++++++++++++++++++++++++
 xfconf/Makefile.am      |  51 ++++++++++++++++++++++++
 xfconf/libxfconf-0.deps |   3 ++
 xfconf/xfconf-cache.c   |  17 ++++----
 xfconf/xfconf-channel.c |  31 +++++++--------
 xfconf/xfconf.c         |   2 +-
 9 files changed, 289 insertions(+), 28 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 754067a..f0e0405 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,8 +29,12 @@ EXTRA_DIST = \
 	ChangeLog \
 	INSTALL \
 	NEWS \
-	README
+	README \
+	m4/introspection.m4 \
+	m4/vapigen.m4
 
 DISTCHECK_CONFIGURE_FLAGS = \
 	--enable-gtk-doc \
-	--disable-perl-bindings
+	--disable-perl-bindings \
+	--enable-introspection \
+	--disable-vala
diff --git a/configure.ac.in b/configure.ac.in
index 51ab2b1..2f95255 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -196,6 +196,12 @@ if test "x$ac_gsettings_backend"; then
     AC_SUBST(GIO_MODULE_DIR)
 fi
 
+dnl check for GObject Introspection
+GOBJECT_INTROSPECTION_CHECK([1.30.0])
+
+dnl check for Vala support
+VAPIGEN_CHECK()
+
 dnl check for debugging support
 XDT_FEATURE_DEBUG([xfconf_default_debug])
 dnl gtk-doc is broken
@@ -269,6 +275,8 @@ echo
 echo "Build Configuration:"
 echo
 echo "  * GSettings Backend:         $ac_gsettings_backend"
+echo "  * GObject Introspection:     $enable_introspection"
+echo "  * Vala support:              $enable_vala"
 echo
 echo "  * Debug:                     $enable_debug"
 echo
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..aa7b3b4
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,96 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),,
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+	dnl Canonicalize enable_introspection
+	enable_introspection=$found_introspection
+    ],dnl
+    [dnl
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])
diff --git a/m4/vapigen.m4 b/m4/vapigen.m4
new file mode 100644
index 0000000..2c435e7
--- /dev/null
+++ b/m4/vapigen.m4
@@ -0,0 +1,101 @@
+dnl vapigen.m4
+dnl
+dnl Copyright 2012 Evan Nemerson
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND_INTROSPECTION], [DEFAULT])
+# --------------------------------------
+# Check vapigen existence and version
+#
+# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
+AC_DEFUN([VAPIGEN_CHECK],
+[
+  AS_IF([test "x$3" != "xyes"], [
+      m4_provide_if([GOBJECT_INTROSPECTION_CHECK], [], [
+          m4_provide_if([GOBJECT_INTROSPECTION_REQUIRE], [], [
+              AC_MSG_ERROR([[You must call GOBJECT_INTROSPECTION_CHECK or GOBJECT_INTROSPECTION_REQUIRE before using VAPIGEN_CHECK unless using the FOUND_INTROSPECTION argument is "yes"]])
+            ])
+        ])
+    ])
+
+  AC_ARG_ENABLE([vala],
+    [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
+      AS_IF([test "x$4" = "x"], [
+          enable_vala=auto
+        ], [
+          enable_vala=$4
+        ])
+    ])
+
+  AS_CASE([$enable_vala], [no], [enable_vala=no],
+      [yes], [
+        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+            AC_MSG_ERROR([Vala bindings require GObject Introspection])
+          ])
+      ], [auto], [
+        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+            enable_vala=no
+          ])
+      ], [
+        AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@])
+      ])
+
+  AS_IF([test "x$2" = "x"], [
+      vapigen_pkg_name=vapigen
+    ], [
+      vapigen_pkg_name=vapigen-$2
+    ])
+  AS_IF([test "x$1" = "x"], [
+      vapigen_pkg="$vapigen_pkg_name"
+    ], [
+      vapigen_pkg="$vapigen_pkg_name >= $1"
+    ])
+
+  PKG_PROG_PKG_CONFIG
+
+  PKG_CHECK_EXISTS([$vapigen_pkg], [
+      AS_IF([test "$enable_vala" = "auto"], [
+          enable_vala=yes
+        ])
+    ], [
+      AS_CASE([$enable_vala], [yes], [
+          AC_MSG_ERROR([$vapigen_pkg not found])
+        ], [auto], [
+          enable_vala=no
+        ])
+    ])
+
+  AC_MSG_CHECKING([for vapigen])
+
+  AS_CASE([$enable_vala],
+    [yes], [
+      VAPIGEN=`$PKG_CONFIG --variable=vapigen $vapigen_pkg_name`
+      VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir $vapigen_pkg_name`/vala/Makefile.vapigen
+      AS_IF([test "x$2" = "x"], [
+          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir $vapigen_pkg_name`
+        ], [
+          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned $vapigen_pkg_name`
+        ])
+    ])
+
+  AC_MSG_RESULT([$enable_vala])
+
+  AC_SUBST([VAPIGEN])
+  AC_SUBST([VAPIGEN_VAPIDIR])
+  AC_SUBST([VAPIGEN_MAKEFILE])
+
+  AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
+])
diff --git a/xfconf/Makefile.am b/xfconf/Makefile.am
index 7cf962d..473daae 100644
--- a/xfconf/Makefile.am
+++ b/xfconf/Makefile.am
@@ -59,6 +59,57 @@ EXTRA_DIST = \
 # required for gtk-doc
 dist-hook: all
 
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ENV = CC="$(CC)"
+INTROSPECTION_SCANNER_ARGS = \
+	--add-include-path=$(srcdir) \
+	--warn-all \
+	-DLIBXFCONF_COMPILATION \
+	--symbol-prefix=xfconf_g_ \
+	--symbol-prefix=xfconf_ \
+	--c-include=xfconf/xfconf.h
+INTROSPECTION_COMPILER_ARGS = \
+	--includedir=$(srcdir) \
+	--includedir=.
+
+if HAVE_INTROSPECTION
+introspection_sources = $(filter-out %private.h %cache.h, $(libxfconf_0_la_SOURCES))
+
+Xfconf-0.gir: libxfconf-0.la Makefile
+Xfconf_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gio-2.0
+Xfconf_0_gir_CFLAGS = $(AM_CPPFLAGS)
+Xfconf_0_gir_LIBS = libxfconf-0.la
+Xfconf_0_gir_FILES = $(introspection_sources)
+Xfconf_0_gir_EXPORT_PACKAGES = libxfconf-0
+INTROSPECTION_GIRS += Xfconf-0.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+DISTCLEANFILES = $(gir_DATA) $(typelib_DATA)
+endif
+
+if ENABLE_VAPIGEN
+-include $(VAPIGEN_MAKEFILE)
+
+libxfconf-0.vapi: Xfconf-0.gir libxfconf-0.deps
+
+VAPIGEN_VAPIS = libxfconf-0.vapi
+VAPIGEN_GIRDIRS = $(prefix)/share/gir-1.0
+
+libxfconf_0_vapi_DEPS = gobject-2.0 glib-2.0 gio-2.0
+libxfconf_0_vapi_FILES = Xfconf-0.gir
+
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps)
+
+DISTCLEANFILES = libxfconf-0.deps
+endif
+
 if HAVE_GNUC_VISIBILITY
 TESTS = abicheck.sh
 endif
diff --git a/xfconf/libxfconf-0.deps b/xfconf/libxfconf-0.deps
new file mode 100644
index 0000000..333a927
--- /dev/null
+++ b/xfconf/libxfconf-0.deps
@@ -0,0 +1,3 @@
+gobject-2.0
+glib-2.0
+gio-2.0
diff --git a/xfconf/xfconf-cache.c b/xfconf/xfconf-cache.c
index d74f05e..ca012f6 100644
--- a/xfconf/xfconf-cache.c
+++ b/xfconf/xfconf-cache.c
@@ -144,7 +144,16 @@ xfconf_cache_item_free(XfconfCacheItem *item)
 
 /******************* XfconfCacheOldItem *******************/
 
-
+/**
+ * XfconfCacheOldItem:
+ * @property:
+ * @item: a #XfconfCacheItem object
+ * @cancellable:
+ * @pending_calls_count:
+ * @variant: Used in xfconf_cache_old_item_end_call to end an already
+ *           started call
+ * @cache: Pointer to the cache object
+ */
 typedef struct
 {
     gchar *property;
@@ -154,14 +163,8 @@ typedef struct
 
     gint pending_calls_count;
 
-    /**
-     * Variant to be send on the wire
-     * Used in xfconf_cache_old_item_end_call
-     * to end an already started call
-     **/
     GVariant *variant;
 
-    /* Pointer to the cache object */
     XfconfCache *cache;
 
 } XfconfCacheOldItem;
diff --git a/xfconf/xfconf-channel.c b/xfconf/xfconf-channel.c
index ce45f05..8e8767d 100644
--- a/xfconf/xfconf-channel.c
+++ b/xfconf/xfconf-channel.c
@@ -520,10 +520,10 @@ xfconf_transform_array(GPtrArray *arr_src,
  *
  * The reference count of the returned channel is owned by libxfconf.
  *
- * Returns: An #XfconfChannel singleton.
+ * Returns: (transfer full): An #XfconfChannel singleton.
  *
  * Since: 4.5.91
- **/
+ */
 XfconfChannel *
 xfconf_channel_get(const gchar *channel_name)
 {
@@ -710,9 +710,9 @@ xfconf_channel_reset_property(XfconfChannel *channel,
  * retrieved.  To retrieve all properties in the channel,
  * specify "/" or %NULL for @property_base.
  *
- * Returns: A newly-allocated #GHashTable, which should be freed with
+ * Returns: (element-type utf8 GValue) (transfer container): A newly-allocated #GHashTable, which should be freed with
  *          g_hash_table_destroy() when no longer needed.
- **/
+ */
 GHashTable *
 xfconf_channel_get_properties(XfconfChannel *channel,
                               const gchar *property_base)
@@ -792,10 +792,10 @@ xfconf_channel_get_string(XfconfChannel *channel,
  *
  * Retrieves the string list value associated with @property on @channel.
  *
- * Returns: A newly-allocated string list which should be freed with
+ * Returns: (transfer full) (element-type utf8) (array zero-terminated=1): A newly-allocated string list which should be freed with
  *          g_strfreev() when no longer needed.  If @property is not in
  *          @channel, %NULL is returned.
- **/
+ */
 gchar **
 xfconf_channel_get_string_list(XfconfChannel *channel,
                                const gchar *property)
@@ -1483,8 +1483,8 @@ out:
  * a #GPtrArray, which can be freed with xfconf_array_free()
  * when no longer needed.
  *
- * Returns: A newly-allocated #GPtrArray on success, or %NULL
- *          on failure.
+ * Returns: (transfer container) (element-type GValue) (nullable): A newly-allocated #GPtrArray on success,
+ * or %NULL on failure.
  **/
 GPtrArray *
 xfconf_channel_get_arrayv(XfconfChannel *channel,
@@ -1507,10 +1507,7 @@ xfconf_channel_get_arrayv(XfconfChannel *channel,
         return NULL;
     }
     
-    /**
-     * Arr is owned by the Gvalue in the cache
-     * do not free it.
-     **/
+    /* Do not free it, it is owned by the GValue in cache */
     arr = g_value_get_boxed(&val);
     if(!arr->len) {
         g_ptr_array_free(arr, TRUE);
@@ -1664,7 +1661,7 @@ out:
  * xfconf_channel_set_arrayv:
  * @channel: An #XfconfChannel.
  * @property: A property string.
- * @values: A #GPtrArray of #GValue<!-- -->s.
+ * @values: (element-type GValue): A #GPtrArray of #GValue<!-- -->s.
  *
  * Sets an array property on @channel, using the values in the
  * provided @values array.
@@ -2238,11 +2235,9 @@ out:
  *
  * Lists all channels known in the Xfconf configuration store.
  *
- * Returns: A newly-allocated array of strings.  Free with
- *          g_strfreev() when no longer needed.
- **/
-/* this really belongs in xfconf.c, but i don't feel like including
- * xfconf-dbus-bindings.h twice, or copying the ERROR macros */
+ * Returns: (transfer none) (array zero-terminated=1) (type utf8): A newly-allocated array of strings.
+ *                                                                 Free with g_strfreev() when no longer needed.
+ */
 gchar **
 xfconf_list_channels(void)
 {
diff --git a/xfconf/xfconf.c b/xfconf/xfconf.c
index fb2934d..228bdc3 100644
--- a/xfconf/xfconf.c
+++ b/xfconf/xfconf.c
@@ -224,7 +224,7 @@ xfconf_array_new(gint n_preallocs)
 
 /**
  * xfconf_array_free:
- * @arr: A #GPtrArray of #GValue<!-- -->s.
+ * @arr: (element-type GValue): A #GPtrArray of #GValue<!-- -->s.
  *
  * Properly frees a #GPtrArray structure containing a list of
  * #GValue<!-- -->s.  This will also cause the contents of the

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list