SF.net SVN: geany: [2599] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon May 19 12:35:35 UTC 2008
Revision: 2599
http://geany.svn.sourceforge.net/geany/?rev=2599&view=rev
Author: ntrel
Date: 2008-05-19 05:35:35 -0700 (Mon, 19 May 2008)
Log Message:
-----------
Note: this breaks the plugin API.
Split GeanyFunctions out of GeanyData so data pointers can be
appended before the function pointer structs without breaking the
ABI.
Rename GeanyFunctions fields with a p_ prefix to avoid name
conflicts.
Add new plugin symbol geany_functions.
Nearly all plugins will now need to declare the following:
'GeanyFunctions *geany_functions;', which is now used by
pluginmacros.h.
Add doxygen examples for geany_data and geany_functions.
Move deprecated document and filetype typedefs to src/plugindata.h,
as plugins aren't required to use pluginmacros.h.
Initialize geany_data by copying a stack struct so the compiler can
check for any missing field initializers.
Rename plugin macro p_encoding to p_encodings to follow the core
function encodings_ prefix.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/plugin-symbols.c
trunk/plugins/autosave.c
trunk/plugins/classbuilder.c
trunk/plugins/demoplugin.c
trunk/plugins/export.c
trunk/plugins/filebrowser.c
trunk/plugins/htmlchars.c
trunk/plugins/pluginmacros.h
trunk/plugins/vcdiff.c
trunk/src/plugindata.h
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/ChangeLog 2008-05-19 12:35:35 UTC (rev 2599)
@@ -1,3 +1,28 @@
+2008-05-19 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/plugindata.h, src/plugins.c, doc/plugin-symbols.c,
+ plugins/export.c, plugins/vcdiff.c, plugins/demoplugin.c,
+ plugins/filebrowser.c, plugins/htmlchars.c, plugins/autosave.c,
+ plugins/pluginmacros.h, plugins/classbuilder.c:
+ Note: this breaks the plugin API.
+ Split GeanyFunctions out of GeanyData so data pointers can be
+ appended before the function pointer structs without breaking the
+ ABI.
+ Rename GeanyFunctions fields with a p_ prefix to avoid name
+ conflicts.
+ Add new plugin symbol geany_functions.
+ Nearly all plugins will now need to declare the following:
+ 'GeanyFunctions *geany_functions;', which is now used by
+ pluginmacros.h.
+ Add doxygen examples for geany_data and geany_functions.
+ Move deprecated document and filetype typedefs to src/plugindata.h,
+ as plugins aren't required to use pluginmacros.h.
+ Initialize geany_data by copying a stack struct so the compiler can
+ check for any missing field initializers.
+ Rename plugin macro p_encoding to p_encodings to follow the core
+ function encodings_ prefix.
+
+
2008-05-18 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/document.c:
Modified: trunk/doc/plugin-symbols.c
===================================================================
--- trunk/doc/plugin-symbols.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/doc/plugin-symbols.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -40,9 +40,14 @@
/** Use the PLUGIN_INFO() macro to define it. Required by Geany. */
PluginInfo* info();
-/** Geany owned fields and functions. */
+/** Geany owned data pointers.
+ * Example: @c assert(geany_data->app->configdir != NULL); */
GeanyData* geany_data;
+/** Geany owned function pointers, split into groups.
+ * Example: @c geany_functions->p_document->new_file(NULL, NULL, NULL); */
+GeanyFunctions* geany_functions;
+
/** Plugin owned fields, including flags. */
PluginFields* plugin_fields;
Modified: trunk/plugins/autosave.c
===================================================================
--- trunk/plugins/autosave.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/autosave.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -33,6 +33,7 @@
PluginFields *plugin_fields;
GeanyData *geany_data;
+GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(32)
Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/classbuilder.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -35,6 +35,7 @@
PluginFields *plugin_fields;
GeanyData *geany_data;
+GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(7)
Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/demoplugin.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -45,6 +45,7 @@
/* These items are set by Geany before init() is called. */
PluginFields *plugin_fields;
GeanyData *geany_data;
+GeanyFunctions *geany_functions;
/* Check that Geany supports plugin API version 7 or later, and check
Modified: trunk/plugins/export.c
===================================================================
--- trunk/plugins/export.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/export.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -40,6 +40,7 @@
PluginFields *plugin_fields;
GeanyData *geany_data;
+GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(20)
PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."), VERSION,
Modified: trunk/plugins/filebrowser.c
===================================================================
--- trunk/plugins/filebrowser.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/filebrowser.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -42,6 +42,7 @@
PluginFields *plugin_fields;
GeanyData *geany_data;
+GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(26)
Modified: trunk/plugins/htmlchars.c
===================================================================
--- trunk/plugins/htmlchars.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/htmlchars.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -34,6 +34,7 @@
PluginFields *plugin_fields;
GeanyData *geany_data;
+GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(48)
Modified: trunk/plugins/pluginmacros.h
===================================================================
--- trunk/plugins/pluginmacros.h 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/pluginmacros.h 2008-05-19 12:35:35 UTC (rev 2599)
@@ -22,11 +22,12 @@
* $Id$
*/
-/* Useful macros to avoid typing geany_data so often. */
+/* Useful macros to avoid typing geany_data-> or geany_functions-> so often. */
#ifndef PLUGINMACROS_H
#define PLUGINMACROS_H
+/* common data structs */
#define app geany_data->app
#define doc_array geany_data->doc_array /* Allows use of doc_list[] macro */
#define filetypes_array geany_data->filetypes_array /* Allows use of filetypes[] macro */
@@ -37,31 +38,33 @@
/* These macros are named the same as the first word in the core function name,
* but with a 'p_' prefix to prevent conflicts with other tag names.
* Example: document_open_file() -> p_document->open_file() */
-#define p_filetypes geany_data->filetype
-#define p_navqueue geany_data->navqueue
-#define p_editor geany_data->editor
+/* New macros should be added here */
+#define p_filetypes geany_functions->p_filetypes
+#define p_navqueue geany_functions->p_navqueue
+#define p_editor geany_functions->p_editor
+
#ifdef GEANY_DISABLE_DEPRECATED
-#define p_dialogs geany_data->dialogs
-#define p_document geany_data->documents
-#define p_encoding geany_data->encoding
-#define p_highlighting geany_data->highlighting
-#define p_keybindings geany_data->keybindings
-#define p_msgwindow geany_data->msgwindow
-#define p_sci geany_data->sci
-#define p_search geany_data->search
-#define p_support geany_data->support
-#define p_templates geany_data->templates
-#define p_tm geany_data->tm
-#define p_ui geany_data->ui
-#define p_utils geany_data->utils
+#define p_dialogs geany_functions->p_dialogs
+#define p_document geany_functions->p_document
+#define p_encodings geany_functions->p_encodings
+#define p_highlighting geany_functions->p_highlighting
+#define p_keybindings geany_functions->p_keybindings
+#define p_msgwindow geany_functions->p_msgwindow
+#define p_sci geany_functions->p_sci
+#define p_search geany_functions->p_search
+#define p_support geany_functions->p_support
+#define p_templates geany_functions->p_templates
+#define p_tm geany_functions->p_tm
+#define p_ui geany_functions->p_ui
+#define p_utils geany_functions->p_utils
#else
#define p_dialogs dialogs
#define p_document documents
-#define p_encoding encodings
+#define p_encodings encodings
#define p_highlighting highlighting
#define p_keybindings keybindings
#define p_msgwindow msgwindow
@@ -74,24 +77,21 @@
#define p_utils utils
-/* Temporary source compatibility macros - do not use these in new code. */
-#define dialogs geany_data->dialogs
-#define documents geany_data->documents /* avoids conflict with document typedef */
-#define encodings geany_data->encoding /* avoids conflict with document::encoding */
-#define highlighting geany_data->highlighting
-#define keybindings geany_data->keybindings
-#define msgwindow geany_data->msgwindow
-#define scintilla geany_data->sci
-#define search geany_data->search
-#define support geany_data->support
-#define templates geany_data->templates
-#define tagmanager geany_data->tm /* avoids conflict with "struct tm *t" */
-#define ui geany_data->ui
-#define utils geany_data->utils
+/* Temporary source compatibility macros - do not use these in new code, they may get removed. */
+#define dialogs geany_functions->p_dialogs
+#define documents geany_functions->p_document
+#define encodings geany_functions->p_encodings
+#define highlighting geany_functions->p_highlighting
+#define keybindings geany_functions->p_keybindings
+#define msgwindow geany_functions->p_msgwindow
+#define scintilla geany_functions->p_sci
+#define search geany_functions->p_search
+#define support geany_functions->p_support
+#define templates geany_functions->p_templates
+#define tagmanager geany_functions->p_tm
+#define ui geany_functions->p_ui
+#define utils geany_functions->p_utils
-typedef struct _GeanyDocument document;
-typedef struct _GeanyFiletype filetype;
-
#endif
#endif
Modified: trunk/plugins/vcdiff.c
===================================================================
--- trunk/plugins/vcdiff.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/plugins/vcdiff.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -39,6 +39,7 @@
PluginFields *plugin_fields;
GeanyData *geany_data;
+GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(27)
@@ -274,12 +275,12 @@
* UTF-8 because internally Geany always needs UTF-8 */
if (force_encoding)
{
- text = p_encoding->convert_to_utf8_from_charset(
+ text = p_encodings->convert_to_utf8_from_charset(
std_output, (gsize)-1, force_encoding, TRUE);
}
else
{
- text = p_encoding->convert_to_utf8(std_output, (gsize)-1, &detect_enc);
+ text = p_encodings->convert_to_utf8(std_output, (gsize)-1, &detect_enc);
}
if (text)
{
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/src/plugindata.h 2008-05-19 12:35:35 UTC (rev 2599)
@@ -35,12 +35,12 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
-static const gint api_version = 59;
+static const gint api_version = 60;
/* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields
* are only appended, as this doesn't affect existing fields. */
-static const gint abi_version = 29;
+static const gint abi_version = 30;
/** Check the plugin can be loaded by Geany.
* This performs runtime checks that try to ensure:
@@ -149,48 +149,56 @@
PluginFields;
-/** This contains pointers to global variables and functions owned by Geany for plugins to use.
- * Variables and functions will be appended when needed by plugin authors. */
+/** This contains pointers to global variables owned by Geany for plugins to use.
+ * Core variable pointers can be appended when needed by plugin authors, if appropriate. */
typedef struct GeanyData
{
- GeanyApp *app; /**< Geany application data fields */
- GtkWidget *tools_menu; /**< Most plugins should add menu items to the Tools menu only */
- GArray *doc_array; /**< Dynamic array of document structs */
- GPtrArray *filetypes_array; /**< Dynamic array of filetype pointers */
- struct GeanyPrefs *prefs; /**< General settings */
- struct GeanyInterfacePrefs *interface_prefs; /**< Interface settings */
- struct GeanyToolbarPrefs *toolbar_prefs; /**< Toolbar settings */
- struct GeanyEditorPrefs *editor_prefs; /**< Editor settings */
- struct GeanyFilePrefs *file_prefs; /**< File-related settings */
- struct GeanySearchPrefs *search_prefs; /**< Search-related settings */
- struct GeanyToolPrefs *tool_prefs; /**< Tool settings */
- struct GeanyTemplatePrefs *template_prefs; /**< Template settings */
- struct GeanyBuildInfo *build_info; /**< Current build information */
-
- struct DocumentFuncs *documents; /**< See document.h */
- struct ScintillaFuncs *sci; /**< See sciwrappers.h */
- struct TemplateFuncs *templates; /**< See templates.h */
- struct UtilsFuncs *utils; /**< See utils.h */
- struct UIUtilsFuncs *ui; /**< See ui_utils.h */
- struct SupportFuncs *support; /**< See support.h */
- struct DialogFuncs *dialogs; /**< See dialogs.h */
- struct MsgWinFuncs *msgwindow; /**< See msgwindow.h */
- struct EncodingFuncs *encoding; /**< See encodings.h */
- struct KeybindingFuncs *keybindings; /**< See keybindings.h */
- struct TagManagerFuncs *tm; /**< See tagmanager/include */
- struct SearchFuncs *search; /**< See search.h */
- struct HighlightingFuncs *highlighting; /**< See highlighting.h */
- struct FiletypeFuncs *filetype; /**< See filetypes.h */
- struct NavQueueFuncs *navqueue; /**< See navqueue.h */
- struct EditorFuncs *editor; /**< See editor.h */
+ GeanyApp *app; /**< Geany application data fields */
+ GtkWidget *tools_menu; /**< Most plugins should add menu items to the Tools menu only */
+ GArray *doc_array; /**< Dynamic array of document structs */
+ GPtrArray *filetypes_array; /**< Dynamic array of filetype pointers */
+ struct GeanyPrefs *prefs; /**< General settings */
+ struct GeanyInterfacePrefs *interface_prefs; /**< Interface settings */
+ struct GeanyToolbarPrefs *toolbar_prefs; /**< Toolbar settings */
+ struct GeanyEditorPrefs *editor_prefs; /**< Editor settings */
+ struct GeanyFilePrefs *file_prefs; /**< File-related settings */
+ struct GeanySearchPrefs *search_prefs; /**< Search-related settings */
+ struct GeanyToolPrefs *tool_prefs; /**< Tool settings */
+ struct GeanyTemplatePrefs *template_prefs; /**< Template settings */
+ struct GeanyBuildInfo *build_info; /**< Current build information */
}
GeanyData;
-/* For more info about these functions, see the main source code.
- * E.g. for GeanyData::documents->new_file(), see document_new_file() in document.c. */
+/** This contains pointers to functions owned by Geany for plugins to use.
+ * Functions from the core can be appended when needed by plugin authors, but may
+ * require some changes. */
+typedef struct GeanyFunctions
+{
+ struct DocumentFuncs *p_document; /**< See document.h */
+ struct ScintillaFuncs *p_sci; /**< See sciwrappers.h */
+ struct TemplateFuncs *p_templates; /**< See templates.h */
+ struct UtilsFuncs *p_utils; /**< See utils.h */
+ struct UIUtilsFuncs *p_ui; /**< See ui_utils.h */
+ struct SupportFuncs *p_support; /**< See support.h */
+ struct DialogFuncs *p_dialogs; /**< See dialogs.h */
+ struct MsgWinFuncs *p_msgwindow; /**< See msgwindow.h */
+ struct EncodingFuncs *p_encodings; /**< See encodings.h */
+ struct KeybindingFuncs *p_keybindings; /**< See keybindings.h */
+ struct TagManagerFuncs *p_tm; /**< See tagmanager/include */
+ struct SearchFuncs *p_search; /**< See search.h */
+ struct HighlightingFuncs *p_highlighting; /**< See highlighting.h */
+ struct FiletypeFuncs *p_filetypes; /**< See filetypes.h */
+ struct NavQueueFuncs *p_navqueue; /**< See navqueue.h */
+ struct EditorFuncs *p_editor; /**< See editor.h */
+}
+GeanyFunctions;
+/* For more information about these functions, see the main source code.
+ * E.g. for p_document->new_file(), see document_new_file() in document.c. */
+
+
/* See document.h */
typedef struct DocumentFuncs
{
@@ -438,6 +446,9 @@
#define GEANY_FILETYPES_ALL \
GEANY_FILETYPES_NONE
+typedef struct _GeanyDocument document;
+typedef struct _GeanyFiletype filetype;
+
#endif /* GEANY_DISABLE_DEPRECATED */
#endif
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-05-18 16:27:08 UTC (rev 2598)
+++ trunk/src/plugins.c 2008-05-19 12:35:35 UTC (rev 2599)
@@ -244,21 +244,7 @@
&navqueue_goto_line
};
-static GeanyData geany_data = {
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
-
+static GeanyFunctions geany_functions = {
&doc_funcs,
&sci_funcs,
&template_funcs,
@@ -277,23 +263,28 @@
&editor_funcs
};
+static GeanyData geany_data;
+
static void
geany_data_init(void)
{
- geany_data.app = app;
- geany_data.tools_menu = lookup_widget(app->window, "tools1_menu");
- geany_data.doc_array = doc_array;
- geany_data.filetypes_array = filetypes_array;
- geany_data.prefs = &prefs;
- geany_data.interface_prefs = &interface_prefs;
- geany_data.toolbar_prefs = &toolbar_prefs;
- geany_data.editor_prefs = &editor_prefs;
- geany_data.file_prefs = &file_prefs;
- geany_data.search_prefs = &search_prefs;
- geany_data.tool_prefs = &tool_prefs;
- geany_data.template_prefs = &template_prefs;
- geany_data.build_info = &build_info;
+ GeanyData gd = {
+ app,
+ lookup_widget(app->window, "tools1_menu"),
+ doc_array,
+ filetypes_array,
+ &prefs,
+ &interface_prefs,
+ &toolbar_prefs,
+ &editor_prefs,
+ &file_prefs,
+ &search_prefs,
+ &tool_prefs,
+ &template_prefs,
+ &build_info
+ };
+ memcpy(&geany_data, &gd, sizeof(GeanyData));
}
@@ -477,6 +468,7 @@
PluginInfo* (*info)(void);
PluginFields **plugin_fields;
GeanyData **p_geany_data;
+ GeanyFunctions **p_geany_functions;
g_return_val_if_fail(fname, NULL);
g_return_val_if_fail(g_module_supported(), NULL);
@@ -539,6 +531,9 @@
g_module_symbol(module, "geany_data", (void *) &p_geany_data);
if (p_geany_data)
*p_geany_data = &geany_data;
+ g_module_symbol(module, "geany_functions", (void *) &p_geany_functions);
+ if (p_geany_functions)
+ *p_geany_functions = &geany_functions;
g_module_symbol(module, "plugin_fields", (void *) &plugin_fields);
if (plugin_fields)
*plugin_fields = &plugin->fields;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list