[folks] Declare internal function folks_persona_store_set_is_user_set_default()



commit 7a9c8133468c1f8eb7fbb0e68a6a7e061b9452fb
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Fri Apr 12 12:20:43 2013 +0100

    Declare internal function folks_persona_store_set_is_user_set_default()
    
    As explained in the comment, I can't find any better way to do this.
    Implicit declarations are Bad, so we should be making them into errors
    by default.
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=697354
    Reviewed-by: Philip Withnall <philip tecnocode co uk>
    [added a comment as requested -smcv]
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>

 backends/eds/lib/Makefile.am   |    1 +
 folks/Makefile.am              |    1 +
 folks/persona-store.vala       |    4 +++
 folks/redeclare-internal-api.h |   46 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/backends/eds/lib/Makefile.am b/backends/eds/lib/Makefile.am
index 804cc47..e8ad9cf 100644
--- a/backends/eds/lib/Makefile.am
+++ b/backends/eds/lib/Makefile.am
@@ -4,6 +4,7 @@ AM_CPPFLAGS = \
        -I$(top_srcdir) \
        -I$(top_srcdir)/folks \
        -include $(CONFIG_HEADER) \
+       -include folks/redeclare-internal-api.h \
        -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
        -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
        -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
diff --git a/folks/Makefile.am b/folks/Makefile.am
index abd1bdf..fe12f10 100644
--- a/folks/Makefile.am
+++ b/folks/Makefile.am
@@ -169,6 +169,7 @@ pkgconfig_DATA = $(pkgconfig_in:.in=)
 EXTRA_DIST = \
        $(pkgconfig_in) \
        build-conf.vapi \
+       redeclare-internal-api.h \
        $(NULL)
 
 BUILT_SOURCES = \
diff --git a/folks/persona-store.vala b/folks/persona-store.vala
index f59bf6a..00eb8dd 100644
--- a/folks/persona-store.vala
+++ b/folks/persona-store.vala
@@ -758,6 +758,10 @@ public abstract class Folks.PersonaStore : Object
    */
   public bool is_primary_store { get; internal set; default = false; }
 
+  /* The setter folks_persona_store_set_is_user_set_default() is redeclared
+   * in folks/redeclare-internal-api.h so that libfolks-eds can use it.
+   * If you alter this property, check the generated C and update that
+   * header if necessary. https://bugzilla.gnome.org/show_bug.cgi?id=697354 */
   /**
    * Whether this { link PersonaStore} has been marked as the default
    * store (in its backend) by the user. I.e.: a PersonaStore for the e-d-s
diff --git a/folks/redeclare-internal-api.h b/folks/redeclare-internal-api.h
new file mode 100644
index 0000000..1a94f4d
--- /dev/null
+++ b/folks/redeclare-internal-api.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * 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 version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FOLKS_REDECLARE_INTERNAL_API_H
+#define FOLKS_REDECLARE_INTERNAL_API_H
+
+#include <folks/folks.h>
+
+/* These functions are marked 'internal', which means Vala makes them ABI
+ * but omits them from header files.
+ *
+ * We can't just tell valac to generate an "internal" VAPI and header
+ * via -h and --internal-vapi, because the "internal" header redefines
+ * things like "typedef struct _FolksPersonaStore FolksPersonaStore"
+ * which are an error if redefined; so you can only include the "internal"
+ * header or the "public" one, never both. If we use the "internal"
+ * VAPI then libfolks-eds' "public" header ends up trying to include
+ * the "internal" header of libfolks, which is unacceptable.
+ *
+ * Redundant declarations of functions and macros, unlike typedefs, are
+ * allowed by C as long as they have identical content. We ought to be able
+ * to check that these declarations match what Vala is currently generating
+ * by including this header when compiling libfolks. Unfortunately,
+ * if we do that we can't include <folks/folks.h>, because Vala-generated
+ * C code redeclares local Vala-generated types, functions, etc. rather than
+ * just including <folks/folks.h>, and then the typedefs conflict.
+ */
+
+void folks_persona_store_set_is_user_set_default (FolksPersonaStore* self,
+    gboolean value);
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]