From 1932d3fae938a21c1a0b22c4ae205f63f8ff8d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Sun, 18 Apr 2010 21:42:38 +0000 Subject: [PATCH] Add tm_source_file_set_tag_arglist() to manually set the argument list of a tag. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4833 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 9 ++++++++ tagmanager/entry.c | 6 ++++++ tagmanager/entry.h | 1 + tagmanager/include/tm_source_file.h | 3 +++ tagmanager/parse.c | 1 + tagmanager/parse.h | 2 ++ tagmanager/tm_source_file.c | 32 +++++++++++++++++++++++++++++ 7 files changed, 54 insertions(+) diff --git a/ChangeLog b/ChangeLog index aa27b031..e83d8a2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-04-18 Enrico Tröger + + * tagmanager/entry.c, tagmanager/entry.h, + tagmanager/include/tm_source_file.h, tagmanager/parse.c, + tagmanager/parse.h, tagmanager/tm_source_file.c: + Add tm_source_file_set_tag_arglist() to manually set the argument + list of a tag. + + 2010-04-17 Enrico Tröger * tagmanager/txt2tags.c: diff --git a/tagmanager/entry.c b/tagmanager/entry.c index 4c2537cc..f09b0955 100644 --- a/tagmanager/entry.c +++ b/tagmanager/entry.c @@ -395,6 +395,12 @@ extern void makeTagEntry (const tagEntryInfo *const tag) } } +extern void setTagArglistByName (const char *tag_name, const char *arglist) +{ + if (NULL != TagEntrySetArglistFunction) + TagEntrySetArglistFunction(tag_name, arglist); +} + extern void initTagEntry (tagEntryInfo *const e, const char *const name) { Assert (File.source.name != NULL); diff --git a/tagmanager/entry.h b/tagmanager/entry.h index a065881a..7a19f116 100644 --- a/tagmanager/entry.h +++ b/tagmanager/entry.h @@ -95,6 +95,7 @@ extern void closeTagFile (const boolean resize); extern void beginEtagsFile (void); extern void endEtagsFile (const char *const name); extern void makeTagEntry (const tagEntryInfo *const tag); +extern void setTagArglistByName (const char *tag_name, const char *arglist); extern void initTagEntry (tagEntryInfo *const e, const char *const name); #endif /* _ENTRY_H */ diff --git a/tagmanager/include/tm_source_file.h b/tagmanager/include/tm_source_file.h index 1dc8f601..4120e781 100644 --- a/tagmanager/include/tm_source_file.h +++ b/tagmanager/include/tm_source_file.h @@ -150,6 +150,9 @@ const gchar *tm_source_file_get_lang_name(gint lang); */ gint tm_source_file_get_named_lang(const gchar *name); +/* Set the argument list of tag identified by its name */ +void tm_source_file_set_tag_arglist(const char *tag_name, const char *arglist); + #ifdef __cplusplus } #endif diff --git a/tagmanager/parse.c b/tagmanager/parse.c index 239a0059..a9c23efd 100644 --- a/tagmanager/parse.c +++ b/tagmanager/parse.c @@ -32,6 +32,7 @@ static parserDefinitionFunc* BuiltInParsers[] = { PARSER_LIST }; parserDefinition** LanguageTable = NULL; static unsigned int LanguageCount = 0; tagEntryFunction TagEntryFunction = NULL; +tagEntrySetArglistFunction TagEntrySetArglistFunction = NULL; /* * FUNCTION DEFINITIONS diff --git a/tagmanager/parse.h b/tagmanager/parse.h index 16f01bfd..8ba5dac2 100644 --- a/tagmanager/parse.h +++ b/tagmanager/parse.h @@ -37,6 +37,7 @@ typedef void (*simpleParser) (void); typedef boolean (*rescanParser) (const unsigned int passCount); typedef void (*parserInitialize) (langType language); typedef int (*tagEntryFunction) (const tagEntryInfo *const tag); +typedef void (*tagEntrySetArglistFunction) (const char *tag_name, const char *arglist); typedef struct sKindOption { boolean enabled; /* are tags for kind enabled? */ @@ -128,6 +129,7 @@ extern void checkRegex (void); /* Extra stuff for Tag Manager */ extern tagEntryFunction TagEntryFunction; +extern tagEntrySetArglistFunction TagEntrySetArglistFunction; extern void setTagEntryFunction(tagEntryFunction entry_function); #endif /* _PARSE_H */ diff --git a/tagmanager/tm_source_file.c b/tagmanager/tm_source_file.c index 2e7601bf..e0133689 100644 --- a/tagmanager/tm_source_file.c +++ b/tagmanager/tm_source_file.c @@ -55,6 +55,8 @@ gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; + if (NULL == TagEntrySetArglistFunction) + TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } if (name == NULL) @@ -120,6 +122,8 @@ gboolean tm_source_file_parse(TMSourceFile *source_file) installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; + if (NULL == TagEntrySetArglistFunction) + TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } current_source_file = source_file; @@ -178,6 +182,8 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; + if (NULL == TagEntrySetArglistFunction) + TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } current_source_file = source_file; if (LANG_AUTO == source_file->lang) @@ -225,6 +231,28 @@ gboolean tm_source_file_buffer_parse(TMSourceFile *source_file, guchar* text_buf return status; } +void tm_source_file_set_tag_arglist(const char *tag_name, const char *arglist) +{ + int count; + TMTag **tags, *tag; + + if (NULL == arglist || + NULL == tag_name || + NULL == current_source_file || + NULL == current_source_file->work_object.tags_array) + { + return; + } + + tags = tm_tags_find(current_source_file->work_object.tags_array, tag_name, FALSE, &count); + if (tags != NULL && count == 1) + { + tag = tags[0]; + g_free(tag->atts.entry.arglist); + tag->atts.entry.arglist = g_strdup(arglist); + } +} + int tm_source_file_tags(const tagEntryInfo *tag) { if (NULL == current_source_file) @@ -319,6 +347,8 @@ const gchar *tm_source_file_get_lang_name(gint lang) installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; + if (NULL == TagEntrySetArglistFunction) + TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } return getLanguageName(lang); } @@ -331,6 +361,8 @@ gint tm_source_file_get_named_lang(const gchar *name) installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; + if (NULL == TagEntrySetArglistFunction) + TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } return getNamedLanguage(name); }