From a5f703799f8da2b20eba949d2d053d4b307490c9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 12 May 2016 10:32:17 -0400 Subject: [PATCH] Make enum generation private by default, export stub symbol When we added enum type generation, the generated symbols used the `ostree_` prefix, and at the time that implied they were public. So we started (if built with libsoup) exporting `ostree_fetcher_config_flags_get_type`. I think it's not worth confusing ABI checkers, so let's export the dummy symbol forever, and switch enums to be private by default. We should revisit this and also export some auto-generated enum types for public enums, but that's a separate patch. Closes: #296 Approved by: gatispaeglis --- Makefile-libostree-defines.am | 1 + Makefile-libostree.am | 1 + src/libostree/ostree-dummy-enumtypes.c | 32 +++++++++++++++++++++++ src/libostree/ostree-dummy-enumtypes.h | 29 ++++++++++++++++++++ src/libostree/ostree-enumtypes.c.template | 2 +- src/libostree/ostree-enumtypes.h.template | 5 ++-- 6 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 src/libostree/ostree-dummy-enumtypes.c create mode 100644 src/libostree/ostree-dummy-enumtypes.h diff --git a/Makefile-libostree-defines.am b/Makefile-libostree-defines.am index f623900c..1db75e0c 100644 --- a/Makefile-libostree-defines.am +++ b/Makefile-libostree-defines.am @@ -22,6 +22,7 @@ libostree_public_headers = \ src/libostree/ostree.h \ src/libostree/ostree-async-progress.h \ src/libostree/ostree-core.h \ + src/libostree/ostree-dummy-enumtypes.h \ src/libostree/ostree-mutable-tree.h \ src/libostree/ostree-repo.h \ src/libostree/ostree-types.h \ diff --git a/Makefile-libostree.am b/Makefile-libostree.am index a50b2b9d..affdd745 100644 --- a/Makefile-libostree.am +++ b/Makefile-libostree.am @@ -69,6 +69,7 @@ libostree_1_la_SOURCES = \ src/libostree/ostree-cmdprivate.c \ src/libostree/ostree-core-private.h \ src/libostree/ostree-core.c \ + src/libostree/ostree-dummy-enumtypes.c \ src/libostree/ostree-checksum-input-stream.c \ src/libostree/ostree-checksum-input-stream.h \ src/libostree/ostree-chain-input-stream.c \ diff --git a/src/libostree/ostree-dummy-enumtypes.c b/src/libostree/ostree-dummy-enumtypes.c new file mode 100644 index 00000000..27fc7b4d --- /dev/null +++ b/src/libostree/ostree-dummy-enumtypes.c @@ -0,0 +1,32 @@ +/* This file declares a stub function that is only exported + * to pacify ABI checkers - no one could really have used it. + * + * Copyright (C) 2015 Red Hat, Inc. + * + * 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 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, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "ostree-dummy-enumtypes.h" + +/* Exported for backwards compat - see + * https://bugzilla.gnome.org/show_bug.cgi?id=764131 + * https://github.com/ostreedev/ostree/pull/294 + */ +GType +ostree_fetcher_config_flags_get_type (void) +{ + return G_TYPE_INVALID; +} diff --git a/src/libostree/ostree-dummy-enumtypes.h b/src/libostree/ostree-dummy-enumtypes.h new file mode 100644 index 00000000..e58e1884 --- /dev/null +++ b/src/libostree/ostree-dummy-enumtypes.h @@ -0,0 +1,29 @@ +/* This file declares a stub function that is only exported + * to pacify ABI checkers - no one could really have used it. + * + * Copyright (C) 2015 Red Hat, Inc. + * + * 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 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, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#include + +#ifndef __GI_SCANNER__ +_OSTREE_PUBLIC GType +ostree_fetcher_config_flags_get_type (void); +#endif diff --git a/src/libostree/ostree-enumtypes.c.template b/src/libostree/ostree-enumtypes.c.template index fe8807ae..ab1b2aec 100644 --- a/src/libostree/ostree-enumtypes.c.template +++ b/src/libostree/ostree-enumtypes.c.template @@ -28,7 +28,7 @@ /*** BEGIN value-header ***/ GType -@enum_name@_get_type (void) +_@enum_name@_get_type (void) { static volatile gsize the_type__volatile = 0; diff --git a/src/libostree/ostree-enumtypes.h.template b/src/libostree/ostree-enumtypes.h.template index 40899d7f..ec20fe0d 100644 --- a/src/libostree/ostree-enumtypes.h.template +++ b/src/libostree/ostree-enumtypes.h.template @@ -32,9 +32,8 @@ G_BEGIN_DECLS /*** END file-production ***/ /*** BEGIN enumeration-production ***/ -#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) -_OSTREE_PUBLIC -GType @enum_name@_get_type (void) G_GNUC_CONST; +#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (_@enum_name@_get_type ()) +GType _@enum_name@_get_type (void) G_GNUC_CONST; /*** END enumeration-production ***/