Revision: 1318 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1318&view=re... Author: colombanw Date: 2010-04-29 00:21:54 +0000 (Thu, 29 Apr 2010)
Log Message: ----------- GeanyGenDoc: Make the plugin's symbols internal
Set the "internal" visibility for plugin's symbols. This cleans the symbol table of the plugin, as well as it might allow the compiler to do some optimizations.
This is currently only supported when building with GCC >= 4.2. Builds with other/older compilers will simply keep their default symbol visibility.
Modified Paths: -------------- trunk/geanygendoc/src/ggd-doc-setting.h trunk/geanygendoc/src/ggd-doc-type.h trunk/geanygendoc/src/ggd-file-type-loader.h trunk/geanygendoc/src/ggd-file-type-manager.h trunk/geanygendoc/src/ggd-file-type.h trunk/geanygendoc/src/ggd-options.h trunk/geanygendoc/src/ggd-plugin.h trunk/geanygendoc/src/ggd-tag-utils.h trunk/geanygendoc/src/ggd-utils.h trunk/geanygendoc/src/ggd.h
Added Paths: ----------- trunk/geanygendoc/src/ggd-macros.h
Modified: trunk/geanygendoc/src/ggd-doc-setting.h =================================================================== --- trunk/geanygendoc/src/ggd-doc-setting.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-doc-setting.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -25,8 +25,10 @@ #include <ctpl/ctpl.h>
#include "ggd-tag-utils.h" +#include "ggd-macros.h"
G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
/** @@ -89,6 +91,7 @@ gssize match_len);
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-doc-type.h =================================================================== --- trunk/geanygendoc/src/ggd-doc-type.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-doc-type.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -24,8 +24,10 @@ #include <glib.h>
#include "ggd-doc-setting.h" +#include "ggd-macros.h"
G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
typedef struct _GgdDocType GgdDocType; @@ -50,6 +52,7 @@ gint *nth_child);
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-file-type-loader.h =================================================================== --- trunk/geanygendoc/src/ggd-file-type-loader.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-file-type-loader.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -23,8 +23,10 @@ #include <glib.h>
#include "ggd-file-type.h" +#include "ggd-macros.h"
G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
/** @@ -51,6 +53,7 @@ GError **error);
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-file-type-manager.h =================================================================== --- trunk/geanygendoc/src/ggd-file-type-manager.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-file-type-manager.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -25,8 +25,10 @@
#include "ggd-file-type.h" #include "ggd-utils.h" +#include "ggd-macros.h"
G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
void ggd_file_type_manager_init (void); @@ -41,6 +43,7 @@ const gchar *docname);
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-file-type.h =================================================================== --- trunk/geanygendoc/src/ggd-file-type.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-file-type.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -26,8 +26,10 @@ #include <geanyplugin.h>
#include "ggd-doc-type.h" +#include "ggd-macros.h"
G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
typedef struct _GgdFileType GgdFileType; @@ -58,6 +60,7 @@ const gchar *name);
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Added: trunk/geanygendoc/src/ggd-macros.h =================================================================== --- trunk/geanygendoc/src/ggd-macros.h (rev 0) +++ trunk/geanygendoc/src/ggd-macros.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -0,0 +1,90 @@ +/* + * + * Copyright (C) 2010 Colomban Wendling ban@herbesfolles.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + */ + +#ifndef H_GGD_MACROS +#define H_GGD_MACROS + + +#if defined (__GNUC__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) +# define __GGD_DO_PRAGMA(s) _Pragma (#s) +/** + * GGD_PUSH_VISIBILITY: + * @v: The visibility to push (one of default, hidden, internal or protected) + * + * Pushes a visibility, applying to the following symbols until the next + * GGD_POP_VISIBILITY(). + * You must have a corresponding GGD_POP_VISIBILITY() to each + * GGD_PUSH_VISIBILITY(). + */ +# define GGD_PUSH_VISIBILITY(v) __GGD_DO_PRAGMA (GCC visibility push(v)) +/** + * GGD_POP_VISIBILITY: + * + * Pops the latest visibility pushed by GGD_PUSH_VISIBILITY(). + */ +# define GGD_POP_VISIBILITY() __GGD_DO_PRAGMA (GCC visibility pop) +#else /* ! GNUC >= 4.2 */ +# define GGD_PUSH_VISIBILITY(v) /* nothing */ +# define GGD_POP_VISIBILITY() /* nothing */ +#endif /* GNUC >= 4.2 */ + +/** + * GGD_BEGIN_PLUGIN_API: + * + * Marks the beginning of some plugin API definitions. + * In practice, this makes the symbols have the internal visibility -- not to + * pollute the symbol table of the built plugin for example. + * You must add a corresponding %GGD_END_PLUGIN_API to end the declarations. + * + * <warning><para> + * You must not include anything that must be accessible from outside the plugin + * between %GGD_BEGIN_PLUGIN_API and %GGD_END_PLUGIN_API. Doing so would lead to + * strange crashes since the symbols are not exported at all. An example are the + * Geany's variables such as geany_functions, since Geany will need to access it + * at runtime. + * </para></warning> + * + * <example> + * <title>Defining some plugin API</title> + * <programlisting> + * #include <glib.h> + * + * #include "ggd-macros.h" + * + * G_BEGIN_DECLS + * GGD_BEGIN_PLUGIN_API + * + * gint ggd_wonderful_function (void); + * + * GGD_END_PLUGIN_API + * G_END_DECLS + * </programlisting> + * </example> + */ +#define GGD_BEGIN_PLUGIN_API GGD_PUSH_VISIBILITY (internal) +/** + * GGD_END_PLUGIN_API: + * + * Marks the end of some plugin API definitions. See %GGD_BEGIN_PLUGIN_API. + */ +#define GGD_END_PLUGIN_API GGD_POP_VISIBILITY () + + +#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-options.h =================================================================== --- trunk/geanygendoc/src/ggd-options.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-options.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -23,7 +23,10 @@ #include <glib.h> #include <gtk/gtk.h>
+#include "ggd-macros.h" + G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
/** @@ -81,6 +84,7 @@ GTK_OBJECT (proxy), "active"))
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-plugin.h =================================================================== --- trunk/geanygendoc/src/ggd-plugin.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-plugin.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -27,27 +27,36 @@ #include <glib.h> #include <geanyplugin.h>
+#include "ggd-macros.h" + G_BEGIN_DECLS
-#define GGD_PLUGIN_ONAME geanygendoc -#define GGD_PLUGIN_CNAME PACKAGE_TARNAME -#define GGD_PLUGIN_NAME "GeanyGenDoc" - - /* pretty funny hack, because Geany doesn't use a shared library for it's API, * then we need that global function table pointer, that Geany gives at plugin * loading time */ +/* Note that this cannot be hidden since it is accessed by the Geany instance */ extern GeanyPlugin *geany_plugin; extern GeanyData *geany_data; extern GeanyFunctions *geany_functions;
+ +/* Begin of the plugin's self API */ +GGD_BEGIN_PLUGIN_API + + +#define GGD_PLUGIN_ONAME geanygendoc +#define GGD_PLUGIN_CNAME PACKAGE_TARNAME +#define GGD_PLUGIN_NAME "GeanyGenDoc" + + /* global plugin options */ extern gchar *GGD_OPT_doctype; extern gboolean GGD_OPT_save_to_refresh; extern gboolean GGD_OPT_indent;
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-tag-utils.h =================================================================== --- trunk/geanygendoc/src/ggd-tag-utils.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-tag-utils.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -23,7 +23,10 @@ #include <glib.h> #include <geanyplugin.h>
+#include "ggd-macros.h" + G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
/** @@ -64,6 +67,7 @@ TMTagType ggd_tag_type_from_name (const gchar *name);
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd-utils.h =================================================================== --- trunk/geanygendoc/src/ggd-utils.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd-utils.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -23,7 +23,10 @@ #include <glib.h> #include <geanyplugin.h> /* Geany's utils for some wrappers */
+#include "ggd-macros.h" + G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
/** @@ -60,6 +63,7 @@ foreach_ptr_array ((item), (idx), (ptr_array))
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
Modified: trunk/geanygendoc/src/ggd.h =================================================================== --- trunk/geanygendoc/src/ggd.h 2010-04-28 21:30:47 UTC (rev 1317) +++ trunk/geanygendoc/src/ggd.h 2010-04-29 00:21:54 UTC (rev 1318) @@ -23,7 +23,10 @@ #include <glib.h> #include <geanyplugin.h>
+#include "ggd-macros.h" + G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API
gboolean ggd_insert_comment (GeanyDocument *doc, @@ -33,6 +36,7 @@ const gchar *doc_type);
+GGD_END_PLUGIN_API G_END_DECLS
#endif /* guard */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org