[geany/geany] 51dc2e: Support plugins written in C++
Matthew Brush
git-noreply at xxxxx
Sat Mar 31 06:35:10 UTC 2012
Branch: refs/heads/master
Author: Matthew Brush <matt at geany.org>
Committer: Matthew Brush <matt at geany.org>
Date: Sat, 31 Mar 2012 06:35:10
Commit: 51dc2e9baff2ef9391ce8d5acbad7df3b834fb18
https://github.com/geany/geany/commit/51dc2e9baff2ef9391ce8d5acbad7df3b834fb18
Log Message:
-----------
Support plugins written in C++
Rename use of C++ `template` keyword in plugin API function argument
and add `G_BEGIN_DECLS` and `G_END_DECLS` to public header files to
make them easier to include in C++ code. TagManager and Scintilla
headers already have these `extern "C"` blocks so they shouldn't
require any modifications.
The Autotools build system already adds in a `dummy.cxx` to hint
Automake into C++ linking to support Scintilla, which is quite
convenient for dynamically loading of C++ plugins at run-time into
the otherwise C-only program. The other build systems seem to also
use the correct linking.
Modified Paths:
--------------
doc/plugins.dox
src/build.h
src/document.h
src/editor.h
src/encodings.h
src/filetypes.h
src/geany.h
src/highlighting.h
src/keybindings.h
src/msgwindow.h
src/plugindata.h
src/prefs.h
src/project.h
src/search.h
src/stash.h
src/support.h
src/templates.c
src/templates.h
src/toolbar.h
src/ui_utils.h
src/utils.h
Modified: doc/plugins.dox
23 files changed, 22 insertions(+), 1 deletions(-)
===================================================================
@@ -145,7 +145,7 @@
*
* Since Geany 0.12 there is a plugin interface to extend Geany's functionality and
* add new features. This document gives a brief overview about how to add new
- * plugins by writing a simple "Hello World" plugin in C.
+ * plugins by writing a simple "Hello World" plugin in C or C++.
*
*
* @section buildenv Build environment
@@ -249,6 +249,22 @@ void plugin_cleanup(void)
* some memory, you are right. But it should compile and load/unload in Geany nicely.
* Now you have the very basic layout of a new plugin. Great, isn't it?
*
+ * @note
+ *
+ * If you would rather write the plugin in C++, you can do that by marking the
+ * plugin functions that it implements as @c extern @c "C", for example:
+ *
+ * @code
+ *
+extern "C" void plugin_init(GeanyData *data)
+{
+}
+
+extern "C" void plugin_cleanup(void)
+{
+}
+ * @endcode
+ *
* @section building Building
*
* First make plugin.o:
@@ -262,6 +278,11 @@ void plugin_cleanup(void)
* If all went OK, put the library into one of the paths Geany looks for plugins,
* e.g. $prefix/lib/geany. See @ref paths "Installation paths" for details.
*
+ * @note
+ *
+ * If you are writing the plugin in C++, then you will need to use your C++
+ * compiler here, for example @c g++.
+ *
* @section realfunc Adding functionality
*
* Let's go on and implement some real functionality.
Modified: src/build.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -24,6 +24,8 @@
#ifndef GEANY_BUILD_H
#define GEANY_BUILD_H 1
+G_BEGIN_DECLS
+
/* Order is important (see GBO_TO_GBG, GBO_TO_CMD below) */
/* * Geany Known Build Commands.
* These commands are named after their default use.
@@ -202,4 +204,6 @@ void build_set_menu_item(const GeanyBuildSource src, const GeanyBuildGroup grp,
gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, guint *from);
+G_END_DECLS
+
#endif
Modified: src/document.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -29,6 +29,8 @@
#ifndef GEANY_DOCUMENT_H
#define GEANY_DOCUMENT_H 1
+G_BEGIN_DECLS
+
#include "Scintilla.h"
#include "ScintillaWidget.h"
#include "editor.h"
@@ -279,4 +281,6 @@ void document_replace_sel(GeanyDocument *doc, const gchar *find_text, const gcha
void document_grab_focus(GeanyDocument *doc);
+G_END_DECLS
+
#endif
Modified: src/editor.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,8 @@
#ifndef GEANY_EDITOR_H
#define GEANY_EDITOR_H 1
+G_BEGIN_DECLS
+
#include "Scintilla.h"
#include "ScintillaWidget.h"
@@ -317,4 +319,6 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text,
void editor_insert_snippet(GeanyEditor *editor, gint pos, const gchar *snippet);
+G_END_DECLS
+
#endif
Modified: src/encodings.h
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -36,6 +36,7 @@
#ifndef GEANY_ENCODINGS_H
#define GEANY_ENCODINGS_H
+G_BEGIN_DECLS
typedef enum
{
@@ -187,4 +188,6 @@ gboolean encodings_convert_to_utf8_auto(gchar **buf, gsize *size, const gchar *f
GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset);
+G_END_DECLS
+
#endif
Modified: src/filetypes.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,8 @@
#ifndef GEANY_FILETYPES_H
#define GEANY_FILETYPES_H 1
+G_BEGIN_DECLS
+
#include "Scintilla.h"
#include "ScintillaWidget.h"
@@ -212,4 +214,6 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean single_first,
const gchar **co, const gchar **cc);
+G_END_DECLS
+
#endif
Modified: src/geany.h
8 files changed, 6 insertions(+), 2 deletions(-)
===================================================================
@@ -25,12 +25,14 @@
#ifndef GEANY_H
#define GEANY_H
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
#if defined(HAVE_CONFIG_H) && defined(GEANY_PRIVATE)
# include "config.h"
#endif
-#include <gtk/gtk.h>
-
#include "tm_tagmanager.h"
#ifndef PLAT_GTK
@@ -96,4 +98,6 @@
#define G_GNUC_WARN_UNUSED_RESULT
#endif
+G_END_DECLS
+
#endif
Modified: src/highlighting.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,8 @@
#ifndef GEANY_HIGHLIGHTING_H
#define GEANY_HIGHLIGHTING_H 1
+G_BEGIN_DECLS
+
#include "Scintilla.h"
#include "ScintillaWidget.h"
@@ -53,4 +55,6 @@
gboolean highlighting_is_comment_style(gint lexer, gint style);
gboolean highlighting_is_code_style(gint lexer, gint style);
+G_END_DECLS
+
#endif
Modified: src/keybindings.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -22,6 +22,8 @@
#ifndef GEANY_KEYBINDINGS_H
#define GEANY_KEYBINDINGS_H 1
+G_BEGIN_DECLS
+
/** Function pointer type used for keybinding callbacks. */
typedef void (*GeanyKeyCallback) (guint key_id);
@@ -279,4 +281,6 @@ enum GeanyKeyBindingID
gboolean keybindings_check_event(GdkEventKey *ev, GeanyKeyBinding *kb);
+G_END_DECLS
+
#endif
Modified: src/msgwindow.h
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -22,6 +22,7 @@
#ifndef GEANY_MSGWINDOW_H
#define GEANY_MSGWINDOW_H 1
+G_BEGIN_DECLS
/**
* Various colors for use in the compiler and messages treeviews when adding messages.
@@ -101,4 +102,6 @@ void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir,
gboolean msgwin_goto_messages_file_line(gboolean focus_editor);
+G_END_DECLS
+
#endif
Modified: src/plugindata.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -33,6 +33,8 @@
#ifndef GEANY_PLUGINDATA_H
#define GEANY_PLUGINDATA_H
+G_BEGIN_DECLS
+
/* Compatibility for sharing macros between API and core.
* First include geany.h, then plugindata.h, then other API headers. */
#undef GEANY
@@ -739,4 +741,6 @@
#endif /* GEANY_DISABLE_DEPRECATED */
+G_END_DECLS
+
#endif
Modified: src/prefs.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,8 @@
#ifndef GEANY_PREFS_H
#define GEANY_PREFS_H 1
+G_BEGIN_DECLS
+
/** General Preferences dialog settings. */
typedef struct GeanyPrefs
{
@@ -57,4 +59,6 @@
void prefs_show_dialog(void);
+G_END_DECLS
+
#endif
Modified: src/project.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,8 @@
#ifndef GEANY_PROJECT_H
#define GEANY_PROJECT_H 1
+G_BEGIN_DECLS
+
#define GEANY_PROJECT_EXT "geany"
@@ -94,4 +96,6 @@
void project_apply_prefs(void);
+G_END_DECLS
+
#endif
Modified: src/search.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -28,6 +28,8 @@
#ifndef GEANY_SEARCH_H
#define GEANY_SEARCH_H 1
+G_BEGIN_DECLS
+
/* the flags given in the search dialog for "find next", also used by the search bar */
typedef struct GeanySearchData
{
@@ -98,4 +100,6 @@ gint search_replace_target(struct _ScintillaObject *sci, const gchar *replace_te
guint search_replace_range(struct _ScintillaObject *sci, struct Sci_TextToFind *ttf,
gint flags, const gchar *replace_text);
+G_END_DECLS
+
#endif
Modified: src/stash.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,8 @@
#ifndef GEANY_STASH_H
#define GEANY_STASH_H
+G_BEGIN_DECLS
+
/** Opaque type for a group of settings. */
typedef struct StashGroup StashGroup;
@@ -96,4 +98,6 @@ void stash_group_add_widget_property(StashGroup *group, gpointer setting,
void stash_tree_update(GtkTreeView *tree);
+G_END_DECLS
+
#endif
Modified: src/support.h
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -25,6 +25,7 @@
* @see GLib's @c gi18n-lib.h.
**/
+G_BEGIN_DECLS
#include "geany.h"
@@ -39,3 +40,5 @@
# define Q_(String) g_strip_context((String), (String))
# define N_(String) String
#endif
+
+G_END_DECLS
Modified: src/templates.c
10 files changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -128,7 +128,7 @@ static void init_general_templates(void)
}
-void templates_replace_common(GString *template, const gchar *fname,
+void templates_replace_common(GString *tmpl, const gchar *fname,
GeanyFiletype *ft, const gchar *func_name)
{
gchar *shortname;
@@ -143,18 +143,18 @@ void templates_replace_common(GString *template, const gchar *fname,
else
shortname = g_path_get_basename(fname);
- templates_replace_valist(template,
+ templates_replace_valist(tmpl,
"{filename}", shortname,
"{project}", app->project ? app->project->name : "",
"{description}", app->project ? app->project->description : "",
NULL);
g_free(shortname);
- templates_replace_default_dates(template);
- templates_replace_command(template, fname, ft->name, func_name);
+ templates_replace_default_dates(tmpl);
+ templates_replace_command(tmpl, fname, ft->name, func_name);
/* Bug: command results could have {ob} {cb} strings in! */
/* replace braces last */
- templates_replace_valist(template,
+ templates_replace_valist(tmpl,
"{ob}", "{",
"{cb}", "}",
NULL);
Modified: src/templates.h
6 files changed, 5 insertions(+), 1 deletions(-)
===================================================================
@@ -28,6 +28,8 @@
#ifndef GEANY_TEMPLATES_H
#define GEANY_TEMPLATES_H 1
+G_BEGIN_DECLS
+
#define GEANY_TEMPLATES_INDENT 3
enum
@@ -70,7 +72,7 @@ enum
gchar *templates_get_template_licence(GeanyDocument *doc, gint licence_type);
-void templates_replace_common(GString *template, const gchar *fname,
+void templates_replace_common(GString *tmpl, const gchar *fname,
GeanyFiletype *ft, const gchar *func_name);
void templates_replace_valist(GString *text,
@@ -78,4 +80,6 @@ void templates_replace_valist(GString *text,
void templates_free_templates(void);
+G_END_DECLS
+
#endif
Modified: src/toolbar.h
4 files changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -22,6 +22,8 @@
#ifndef GEANY_TOOLBAR_H
#define GEANY_TOOLBAR_H
+G_BEGIN_DECLS
+
/** Toolbar settings. */
typedef struct GeanyToolbarPrefs
{
@@ -59,4 +61,6 @@
void toolbar_configure(GtkWindow *parent);
+G_END_DECLS
+
#endif
Modified: src/ui_utils.h
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -22,6 +22,8 @@
#ifndef GEANY_UI_UTILS_H
#define GEANY_UI_UTILS_H 1
+G_BEGIN_DECLS
+
/** Sets a name to lookup @a widget from @a owner.
* @param owner Usually a window, dialog or popup menu.
@@ -345,5 +347,6 @@ void ui_menu_add_document_items_sorted(GtkMenu *menu, GeanyDocument *active,
void ui_focus_current_document(void);
+G_END_DECLS
#endif
Modified: src/utils.h
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -27,6 +27,7 @@
#ifndef GEANY_UTILS_H
#define GEANY_UTILS_H 1
+G_BEGIN_DECLS
#include <time.h>
@@ -276,4 +277,6 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
gchar **utils_copy_environment(const gchar **exclude_vars, const gchar *first_varname, ...) G_GNUC_NULL_TERMINATED;
+G_END_DECLS
+
#endif
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Commits
mailing list