[geany/geany] 00cb49: Don't use ctags types inside Geany

Jiří Techet git-noreply at xxxxx
Fri Feb 26 00:10:00 UTC 2016


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Fri, 26 Feb 2016 00:10:00 UTC
Commit:      00cb498ebcc6b73499b9c5d2991490f64a5c765e
             https://github.com/geany/geany/commit/00cb498ebcc6b73499b9c5d2991490f64a5c765e

Log Message:
-----------
Don't use ctags types inside Geany

We should isolate ctags from Geany completely and use separate types. At
the moment langType is shared by both Geany and ctags. For Geany redefine
it as TMParserType (which was currently used as the name of the enum and
was unused) and use everywhere in Geany. At the same time convert some
ints to TMParserType where they denote the parser.

This is strictly speaking an API change but no plugin uses langType at the
moment so its renaming doesn't cause any problems.

The only remaining visible ctags type is tagEntryInfo - it is however
used only inside tagmanager (and can be later removed quite easily too
by slightly reorganizing TM source files).


Modified Paths:
--------------
    src/filetypes.h
    tagmanager/src/tm_parser.h
    tagmanager/src/tm_source_file.c
    tagmanager/src/tm_source_file.h
    tagmanager/src/tm_tag.c
    tagmanager/src/tm_tag.h
    tagmanager/src/tm_workspace.c
    tagmanager/src/tm_workspace.h

Modified: src/filetypes.h
8 lines changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -24,7 +24,7 @@
 #define GEANY_FILETYPES_H 1
 
 #include "geany.h" /* for GEANY() macro */
-#include "tm_source_file.h" /* for langType */
+#include "tm_parser.h" /* for TMParserType */
 
 #include "gtkcompat.h" /* Needed by ScintillaWidget.h */
 #include "Scintilla.h" /* Needed by ScintillaWidget.h */
@@ -134,9 +134,9 @@ GeanyFiletypeGroupID;
 typedef struct GeanyFiletype
 {
 	GeanyFiletypeID	  id;				/**< Index in @ref filetypes. */
-	/** Represents the langType of tagmanager (see the table
-	 * in tagmanager/parsers.h), -1 represents all, -2 none. */
-	langType 		  lang;
+	/** Represents the TMParserType of tagmanager (see the table
+	 * in tagmanager/src/tm_parser.h). */
+	TMParserType	  lang;
 	/** Untranslated short name, such as "C", "None".
 	 * Must not be translated as it's used for hash table lookups - use
 	 * filetypes_get_display_name() instead. */


Modified: tagmanager/src/tm_parser.h
5 lines changed, 3 insertions(+), 2 deletions(-)
===================================================================
@@ -10,9 +10,10 @@
 #ifndef TM_PARSER_H
 #define TM_PARSER_H
 
+typedef gint TMParserType;
 
 /* keep in sync with ctags/parsers.h */
-typedef enum
+enum
 {
 	TM_PARSER_NONE = -2, /* keep in sync with ctags LANG_IGNORE */
 	TM_PARSER_C = 0,
@@ -67,7 +68,7 @@ typedef enum
 	TM_PARSER_ZEPHIR,
 	TM_PARSER_POWERSHELL,
 	TM_PARSER_COUNT
-} TMParserType;
+};
 
 
 #endif /* TM_PARSER_H */


Modified: tagmanager/src/tm_source_file.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -399,7 +399,7 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gsize
  @param lang The language index.
  @return The language name, or NULL.
 */
-const gchar *tm_source_file_get_lang_name(gint lang)
+const gchar *tm_source_file_get_lang_name(TMParserType lang)
 {
 	if (NULL == LanguageTable)
 	{
@@ -417,7 +417,7 @@ const gchar *tm_source_file_get_lang_name(gint lang)
  @param name The language name.
  @return The language index, or TM_PARSER_NONE.
 */
-gint tm_source_file_get_named_lang(const gchar *name)
+TMParserType tm_source_file_get_named_lang(const gchar *name)
 {
 	if (NULL == LanguageTable)
 	{


Modified: tagmanager/src/tm_source_file.h
12 lines changed, 5 insertions(+), 7 deletions(-)
===================================================================
@@ -14,14 +14,12 @@
 #include <glib.h>
 #include <glib-object.h>
 
+#include "tm_parser.h"
+
 #ifndef LIBCTAGS_DEFINED
-typedef int langType;
 typedef void tagEntryInfo;
 #endif
 
-#if !defined(tagEntryInfo)
-#endif
-
 #ifdef __cplusplus
 extern "C"
 {
@@ -39,7 +37,7 @@ extern "C"
 */
 typedef struct
 {
-	langType lang; /**< Programming language used */
+	TMParserType lang; /**< Programming language used */
 	char *file_name; /**< Full file name (inc. path) */
 	char *short_name; /**< Just the name of the file (without the path) */
 	GPtrArray *tags_array; /**< Sorted tag array obtained by parsing the object */
@@ -56,9 +54,9 @@ gchar *tm_get_real_path(const gchar *file_name);
 
 #ifdef GEANY_PRIVATE
 
-const gchar *tm_source_file_get_lang_name(gint lang);
+const gchar *tm_source_file_get_lang_name(TMParserType lang);
 
-gint tm_source_file_get_named_lang(const gchar *name);
+TMParserType tm_source_file_get_named_lang(const gchar *name);
 
 gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gsize buf_size,
 	gboolean use_buffer);


Modified: tagmanager/src/tm_tag.c
8 lines changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -562,9 +562,9 @@ static gboolean tm_tag_init_from_file_ctags(TMTag *tag, TMSourceFile *file, FILE
 
 /*
  Same as tm_tag_new() except that the tag attributes are read from file.
- @param mode langType to use for the tag.
+ @param mode TMParserType to use for the tag.
 */
-TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode, TMFileFormat format)
+TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, TMParserType mode, TMFileFormat format)
 {
 	TMTag *tag;
 	gboolean result = FALSE;
@@ -1182,7 +1182,7 @@ tm_get_current_tag (GPtrArray * file_tags, const gulong line, const TMTagType ta
 	return matching_tag;
 }
 
-const gchar *tm_tag_context_separator(langType lang)
+const gchar *tm_tag_context_separator(TMParserType lang)
 {
 	switch (lang)
 	{
@@ -1226,7 +1226,7 @@ gboolean tm_tag_is_anon(const TMTag *tag)
 }
 
 
-gboolean tm_tag_langs_compatible(langType lang, langType other)
+gboolean tm_tag_langs_compatible(TMParserType lang, TMParserType other)
 {
 	if (lang == TM_PARSER_NONE || other == TM_PARSER_NONE)
 		return FALSE;


Modified: tagmanager/src/tm_tag.h
8 lines changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -137,7 +137,7 @@ typedef struct _TMTag
 	char *var_type; /**< Variable type (maps to struct for typedefs) */
 	char access; /**< Access type (public/protected/private/etc.) */
 	char impl; /**< Implementation (e.g. virtual) */
-	langType lang; /**< Programming language of the file */
+	TMParserType lang; /**< Programming language of the file */
 } TMTag;
 
 
@@ -160,7 +160,7 @@ GType tm_tag_get_type(void) G_GNUC_CONST;
 
 TMTag *tm_tag_new(TMSourceFile *file, const tagEntryInfo *tag_entry);
 
-TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, gint mode, TMFileFormat format);
+TMTag *tm_tag_new_from_file(TMSourceFile *file, FILE *fp, TMParserType mode, TMFileFormat format);
 
 gboolean tm_tag_write(TMTag *tag, FILE *file, guint attrs);
 
@@ -191,11 +191,11 @@ TMTag *tm_tag_ref(TMTag *tag);
 
 gboolean tm_tags_equal(const TMTag *a, const TMTag *b);
 
-const gchar *tm_tag_context_separator(langType lang);
+const gchar *tm_tag_context_separator(TMParserType lang);
 
 gboolean tm_tag_is_anon(const TMTag *tag);
 
-gboolean tm_tag_langs_compatible(langType lang, langType other);
+gboolean tm_tag_langs_compatible(TMParserType lang, TMParserType other);
 
 #ifdef TM_DEBUG /* various debugging functions */
 


Modified: tagmanager/src/tm_workspace.c
22 lines changed, 11 insertions(+), 11 deletions(-)
===================================================================
@@ -502,7 +502,7 @@ static gchar *create_temp_file(const gchar *tpl)
  @return TRUE on success, FALSE on failure.
 */
 gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
-	int includes_count, const char *tags_file, int lang)
+	int includes_count, const char *tags_file, TMParserType lang)
 {
 #ifdef HAVE_GLOB_H
 	glob_t globbuf;
@@ -686,7 +686,7 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
 
 
 static void fill_find_tags_array(GPtrArray *dst, const GPtrArray *src,
-	const char *name, const char *scope, TMTagType type, langType lang)
+	const char *name, const char *scope, TMTagType type, TMParserType lang)
 {
 	TMTag **tag;
 	guint i, num;
@@ -718,7 +718,7 @@ static void fill_find_tags_array(GPtrArray *dst, const GPtrArray *src,
  @return Array of matching tags.
 */
 GPtrArray *tm_workspace_find(const char *name, const char *scope, TMTagType type,
-	TMTagAttrType *attrs, langType lang)
+	TMTagAttrType *attrs, TMParserType lang)
 {
 	GPtrArray *tags = g_ptr_array_new();
 
@@ -733,7 +733,7 @@ GPtrArray *tm_workspace_find(const char *name, const char *scope, TMTagType type
 
 
 static void fill_find_tags_array_prefix(GPtrArray *dst, const GPtrArray *src,
-	const char *name, langType lang, guint max_num)
+	const char *name, TMParserType lang, guint max_num)
 {
 	TMTag **tag, *last = NULL;
 	guint i, count, num;
@@ -766,7 +766,7 @@ static void fill_find_tags_array_prefix(GPtrArray *dst, const GPtrArray *src,
  @param max_num The maximum number of tags to return.
  @return Array of matching tags sorted by their name.
 */
-GPtrArray *tm_workspace_find_prefix(const char *prefix, langType lang, guint max_num)
+GPtrArray *tm_workspace_find_prefix(const char *prefix, TMParserType lang, guint max_num)
 {
 	TMTagAttrType attrs[] = { tm_tag_attr_name_t, 0 };
 	GPtrArray *tags = g_ptr_array_new();
@@ -831,7 +831,7 @@ find_scope_members_tags (const GPtrArray *all, TMTag *type_tag, gboolean namespa
 }
 
 
-static gchar *strip_type(const gchar *scoped_name, langType lang)
+static gchar *strip_type(const gchar *scoped_name, TMParserType lang)
 {
 	if (scoped_name != NULL)
 	{
@@ -853,7 +853,7 @@ static gchar *strip_type(const gchar *scoped_name, langType lang)
 /* Gets all members of the type with the given name; search them inside tags_array */
 static GPtrArray *
 find_scope_members (const GPtrArray *tags_array, const gchar *name, TMSourceFile *file,
-	langType lang, gboolean namespace)
+	TMParserType lang, gboolean namespace)
 {
 	GPtrArray *res = NULL;
 	gchar *type_name;
@@ -930,7 +930,7 @@ find_scope_members (const GPtrArray *tags_array, const gchar *name, TMSourceFile
 
 /* Checks whether a member tag is directly accessible from method with method_scope */
 static gboolean member_at_method_scope(const GPtrArray *tags, const gchar *method_scope, TMTag *member_tag,
-	langType lang)
+	TMParserType lang)
 {
 	const gchar *sep = tm_tag_context_separator(lang);
 	gboolean ret = FALSE;
@@ -980,7 +980,7 @@ static gboolean member_at_method_scope(const GPtrArray *tags, const gchar *metho
 
 /* For an array of variable/type tags, find members inside the types */
 static GPtrArray *
-find_scope_members_all(const GPtrArray *tags, const GPtrArray *searched_array, langType lang,
+find_scope_members_all(const GPtrArray *tags, const GPtrArray *searched_array, TMParserType lang,
 	gboolean member, const gchar *current_scope)
 {
 	GPtrArray *member_tags = NULL;
@@ -1024,7 +1024,7 @@ find_scope_members_all(const GPtrArray *tags, const GPtrArray *searched_array, l
 }
 
 
-static GPtrArray *find_namespace_members_all(const GPtrArray *tags, const GPtrArray *searched_array, langType lang)
+static GPtrArray *find_namespace_members_all(const GPtrArray *tags, const GPtrArray *searched_array, TMParserType lang)
 {
 	GPtrArray *member_tags = NULL;
 	guint i;
@@ -1053,7 +1053,7 @@ GPtrArray *
 tm_workspace_find_scope_members (TMSourceFile *source_file, const char *name,
 	gboolean function, gboolean member, const gchar *current_scope, gboolean search_namespace)
 {
-	langType lang = source_file ? source_file->lang : -1;
+	TMParserType lang = source_file ? source_file->lang : -1;
 	GPtrArray *tags, *member_tags = NULL;
 	TMTagType function_types = tm_tag_function_t | tm_tag_method_t |
 		tm_tag_macro_with_arg_t | tm_tag_prototype_t;


Modified: tagmanager/src/tm_workspace.h
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -53,12 +53,12 @@ const TMWorkspace *tm_get_workspace(void);
 gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode);
 
 gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
-	int includes_count, const char *tags_file, int lang);
+	int includes_count, const char *tags_file, TMParserType lang);
 
 GPtrArray *tm_workspace_find(const char *name, const char *scope, TMTagType type,
-	TMTagAttrType *attrs, langType lang);
+	TMTagAttrType *attrs, TMParserType lang);
 
-GPtrArray *tm_workspace_find_prefix(const char *prefix, langType lang, guint max_num);
+GPtrArray *tm_workspace_find_prefix(const char *prefix, TMParserType lang, guint max_num);
 
 GPtrArray *tm_workspace_find_scope_members (TMSourceFile *source_file, const char *name,
 	gboolean function, gboolean member, const gchar *current_scope, gboolean search_namespace);



--------------
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