[geany/geany] c05e3e: Split tm_ctags_callback into two

Jiří Techet git-noreply at xxxxx
Fri Jun 10 21:57:36 UTC 2016


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Fri, 06 May 2016 15:29:54 UTC
Commit:      c05e3eabf14df61d7de54a18f713cb50ef2dc8b8
             https://github.com/geany/geany/commit/c05e3eabf14df61d7de54a18f713cb50ef2dc8b8

Log Message:
-----------
Split tm_ctags_callback into two

One to inform about a new tag, the other informing about a start of a new
pass.


Modified Paths:
--------------
    tagmanager/src/tm_ctags_wrappers.c
    tagmanager/src/tm_ctags_wrappers.h
    tagmanager/src/tm_source_file.c

Modified: tagmanager/src/tm_ctags_wrappers.c
12 lines changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -27,7 +27,7 @@
 
 
 typedef struct {
-	tm_ctags_callback callback;
+	TMCtagsNewTagCallback tag_callback;
 	gpointer user_data;
 } CallbackUserData;
 
@@ -43,15 +43,15 @@ static gboolean parse_callback(const tagEntryInfo *tag, gpointer user_data)
 {
 	CallbackUserData *callback_data = user_data;
 
-	return callback_data->callback(tag, FALSE, callback_data->user_data);
+	return callback_data->tag_callback(tag, callback_data->user_data);
 }
 
 
 void tm_ctags_parse(guchar *buffer, gsize buffer_size,
-	const gchar *file_name, TMParserType lang, tm_ctags_callback callback,
-	gpointer user_data)
+	const gchar *file_name, TMParserType lang, TMCtagsNewTagCallback tag_callback,
+	TMCtagsPassStartCallback pass_callback, gpointer user_data)
 {
-	CallbackUserData callback_data = {callback, user_data};
+	CallbackUserData callback_data = {tag_callback, user_data};
 	gboolean retry = TRUE;
 	guint passCount = 0;
 
@@ -68,7 +68,7 @@ void tm_ctags_parse(guchar *buffer, gsize buffer_size,
 	setTagEntryFunction(parse_callback, &callback_data);
 	while (retry && passCount < 3)
 	{
-		callback(NULL, TRUE, user_data);
+		pass_callback(user_data);
 		if (!buffer && fileOpen (file_name, lang))
 		{
 			if (LanguageTable [lang]->parser != NULL)


Modified: tagmanager/src/tm_ctags_wrappers.h
14 lines changed, 10 insertions(+), 4 deletions(-)
===================================================================
@@ -30,15 +30,21 @@
 
 G_BEGIN_DECLS
 
-typedef gboolean (*tm_ctags_callback) (const tagEntryInfo *const tag,
-	gboolean invalidate, void *user_data);
+/* Callback invoked for every tag found by the parser. The return value is
+ * currently unused. */
+typedef gboolean (*TMCtagsNewTagCallback) (const tagEntryInfo *const tag,
+	void *user_data);
+
+/* Callback invoked at the beginning of every parsing pass. The return value is
+ * currently unused */
+typedef gboolean (*TMCtagsPassStartCallback) (void *user_data);
 
 
 void tm_ctags_init(void);
 
 void tm_ctags_parse(guchar *buffer, gsize buffer_size,
-	const gchar *file_name, TMParserType lang, tm_ctags_callback callback,
-	gpointer user_data);
+	const gchar *file_name, TMParserType lang, TMCtagsNewTagCallback tag_callback,
+	TMCtagsPassStartCallback pass_callback, gpointer user_data);
 
 const gchar *tm_ctags_get_lang_name(TMParserType lang);
 


Modified: tagmanager/src/tm_source_file.c
28 lines changed, 12 insertions(+), 16 deletions(-)
===================================================================
@@ -627,25 +627,21 @@ static void update_python_arglist(const TMTag *tag, TMSourceFile *current_source
 	}
 }
 
-/*
- This function is registered into the ctags parser when a file is parsed for
- the first time. The function is then called by the ctags parser each time
- it finds a new tag. You should not have to use this function.
- @see tm_source_file_parse()
-*/
-static gboolean tm_source_file_tags(const tagEntryInfo *const tag,
-	gboolean invalidate, void *user_data)
+/* new parsing pass ctags callback function */
+static gboolean ctags_pass_start(void *user_data)
 {
 	TMSourceFile *current_source_file = user_data;
-	TMTag *tm_tag;
 
-	if (invalidate)
-	{
-		tm_tags_array_free(current_source_file->tags_array, FALSE);
-		return TRUE;
-	}
+	tm_tags_array_free(current_source_file->tags_array, FALSE);
+	return TRUE;
+}
 
-	tm_tag = tm_tag_new();
+/* new tag ctags callback function */
+static gboolean ctags_new_tag(const tagEntryInfo *const tag,
+	void *user_data)
+{
+	TMSourceFile *current_source_file = user_data;
+	TMTag *tm_tag = tm_tag_new();
 
 	if (!init_tag(tm_tag, current_source_file, tag))
 	{
@@ -838,7 +834,7 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gsize
 	tm_tags_array_free(source_file->tags_array, FALSE);
 
 	tm_ctags_parse(parse_file ? NULL : text_buf, buf_size, file_name,
-		source_file->lang, tm_source_file_tags, source_file);
+		source_file->lang, ctags_new_tag, ctags_pass_start, source_file);
 
 	if (free_buf)
 		g_free(text_buf);



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list