Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 05 Oct 2014 20:40:15 UTC Commit: 464632387837ef0ebe237b79fbf7debef25a2860 https://github.com/geany/geany/commit/464632387837ef0ebe237b79fbf7debef25a28...
Log Message: ----------- Remove unused tm_symbol
Modified Paths: -------------- tagmanager/src/Makefile.am tagmanager/src/tm_symbol.c tagmanager/src/tm_symbol.h tagmanager/src/tm_tagmanager.h wscript
Modified: tagmanager/src/Makefile.am 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -16,7 +16,6 @@ tagmanager_include_HEADERS = \ tm_file_entry.h \ tm_parser.h \ tm_source_file.h \ - tm_symbol.h \ tm_tag.h \ tm_tagmanager.h \ tm_work_object.h \ @@ -26,7 +25,6 @@ tagmanager_include_HEADERS = \ libtagmanager_a_SOURCES =\ tm_file_entry.c \ tm_source_file.c \ - tm_symbol.c \ tm_tag.c \ tm_tagmanager.c \ tm_work_object.c \
Modified: tagmanager/src/tm_symbol.c 319 lines changed, 0 insertions(+), 319 deletions(-) =================================================================== @@ -1,319 +0,0 @@ -/* -* -* Copyright (c) 2001-2002, Biswapesh Chattopadhyay -* -* This source code is released for free distribution under the terms of the -* GNU General Public License. -* -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "tm_symbol.h" - - -#define SYM_NEW(T) ((T) = g_slice_new0(TMSymbol)) -#define SYM_FREE(T) g_slice_free(TMSymbol, (T)) - - -void tm_symbol_print(TMSymbol *sym, guint level) -{ - guint i; - - g_return_if_fail (sym != NULL); - for (i=0; i < level; ++i) - fputc('\t', stderr); - fprintf(stderr, "%s\n", (sym->tag)?sym->tag->name:"Root"); - if (sym->info.children) - { - if (sym->tag && tm_tag_function_t == sym->tag->type) - tm_tag_print(sym->info.equiv, stderr); - else - { - for (i=0; i < sym->info.children->len; ++i) - tm_symbol_print(TM_SYMBOL(sym->info.children->pdata[i]) - , level + 1); - } - } -} - -#define SYM_ORDER(T) (((tm_tag_class_t == (T)->type) || (tm_tag_struct_t ==\ - (T)->type))?1:(((tm_tag_enum_t == (T)->type) || (tm_tag_interface_t ==\ - (T)->type))?2:3)) - -/* Comparison function for sorting symbols alphabetically */ -int tm_symbol_compare(const void *p1, const void *p2) -{ - TMSymbol *s1, *s2; - - if (!p1 && !p2) - return 0; - else if (!p2) - return 1; - else if (!p1) - return -1; - s1 = *(TMSymbol **) p1; - s2 = *(TMSymbol **) p2; - if (!s1 && !s2) - return 0; - else if (!s2) - return 1; - else if (!s1) - return -1; - if (!s1->tag && !s2->tag) - return 0; - else if (!s2->tag) - return 1; - else if (!s1->tag) - return -1; - return strcmp(s1->tag->name, s2->tag->name); -} - -/* - * Compares function argument lists. - * FIXME: Compare based on types, not an exact string match. - */ -int tm_arglist_compare(const TMTag* t1, const TMTag* t2) -{ - return strcmp(FALLBACK(t1->atts.entry.arglist, ""), - FALLBACK(t2->atts.entry.arglist, "")); -} - -/* Need this custom compare function to generate a symbol tree -in a simgle pass from tag list */ -int tm_symbol_tag_compare(const TMTag **t1, const TMTag **t2) -{ - gint s1, s2; - - if (!t1 && !t2) - return 0; - if (t1 && t2 && !*t1 && !*t2) - return 0; - else if (!t1 || !*t1) - return -1; - else if (!t2 || !*t2) - return 1; - if ((tm_tag_file_t == (*t1)->type) && (tm_tag_file_t == (*t2)->type)) - return 0; - else if (tm_tag_file_t == (*t1)->type) - return -1; - else if (tm_tag_file_t == (*t2)->type) - return 1; - - /* Compare on depth of scope - less depth gets higher priortity */ - s1 = tm_tag_scope_depth(*t1); - s2 = tm_tag_scope_depth(*t2); - if (s1 != s2) - return (s1 - s2); - - /* Compare of tag type using a symbol ordering routine */ - s1 = SYM_ORDER(*t1); - s2 = SYM_ORDER(*t2); - if (s1 != s2) - return (s1 - s2); - - /* Compare names alphabetically */ - s1 = strcmp((*t1)->name, (*t2)->name); - if (s1 != 0) - return (s1); - - /* Compare scope alphabetically */ - s1 = strcmp(FALLBACK((*t1)->atts.entry.scope, ""), - FALLBACK((*t2)->atts.entry.scope, "")); - if (s1 != 0) - return s1; - - /* If none of them are function/prototype, they are effectively equal */ - if ((tm_tag_function_t != (*t1)->type) && - (tm_tag_prototype_t != (*t1)->type)&& - (tm_tag_function_t != (*t2)->type) && - (tm_tag_prototype_t != (*t2)->type)) - return 0; - - /* Whichever is not a function/prototype goes first */ - if ((tm_tag_function_t != (*t1)->type) && - (tm_tag_prototype_t != (*t1)->type)) - return -1; - if ((tm_tag_function_t != (*t2)->type) && - (tm_tag_prototype_t != (*t2)->type)) - return 1; - - /* Compare the argument list */ - s1 = tm_arglist_compare(*t1, *t2); - if (s1 != 0) - return s1; - - /* Functions go before prototypes */ - if ((tm_tag_function_t == (*t1)->type) && - (tm_tag_function_t != (*t2)->type)) - return -1; - if ((tm_tag_function_t != (*t1)->type) && - (tm_tag_function_t == (*t2)->type)) - return 1; - - /* Give up */ - return 0; -} - -TMSymbol *tm_symbol_tree_new(GPtrArray *tags_array) -{ - TMSymbol *root = NULL; - GPtrArray *tags; - -#ifdef TM_DEBUG - g_message("Building symbol tree.."); -#endif - - if ((!tags_array) || (tags_array->len <= 0)) - return NULL; - -#ifdef TM_DEBUG - fprintf(stderr, "Dumping all tags..\n"); - tm_tags_array_print(tags_array, stderr); -#endif - - tags = tm_tags_extract(tags_array, tm_tag_max_t); -#ifdef TM_DEBUG - fprintf(stderr, "Dumping unordered tags..\n"); - tm_tags_array_print(tags, stderr); -#endif - - if (tags && (tags->len > 0)) - { - guint i; - int j; - int max_parents = -1; - TMTag *tag; - TMSymbol *sym = NULL, *sym1; - char *parent_name; - char *scope_end; - gboolean matched; - int str_match; - - SYM_NEW(root); - tm_tags_custom_sort(tags, (TMTagCompareFunc) tm_symbol_tag_compare - , FALSE); - -#ifdef TM_DEBUG - fprintf(stderr, "Dumping ordered tags.."); - tm_tags_array_print(tags, stderr); - fprintf(stderr, "Rebuilding symbol table..\n"); -#endif - for (i=0; i < tags->len; ++i) - { - tag = TM_TAG(tags->pdata[i]); - - if (tm_tag_prototype_t == tag->type) - { - if (sym && (tm_tag_function_t == sym->tag->type) && - (!sym->info.equiv) && - (0 == strcmp(FALLBACK(tag->atts.entry.scope, "") - , FALLBACK(sym->tag->atts.entry.scope, "")))) - { - sym->info.equiv = tag; - continue; - } - } - if (max_parents < 0) - { - if (SYM_ORDER(tag) > 2) - { - max_parents = i; - if (max_parents > 0) - qsort(root->info.children->pdata, max_parents - , sizeof(gpointer), tm_symbol_compare); - } - } - SYM_NEW(sym); - sym->tag = tag; - if ((max_parents <= 0) || (!tag->atts.entry.scope)) - { - sym->parent = root; - if (!root->info.children) - root->info.children = g_ptr_array_new(); - g_ptr_array_add(root->info.children, sym); - } - else - { - parent_name = tag->atts.entry.scope; - scope_end = strstr(tag->atts.entry.scope, "::"); - if (scope_end) - *scope_end = '\0'; - matched = FALSE; - if (('\0' != parent_name[0]) && - (0 != strcmp(parent_name, "<anonymous>"))) - { - for (j=0; j < max_parents; ++j) - { - sym1 = TM_SYMBOL(root->info.children->pdata[j]); - str_match = strcmp(sym1->tag->name, parent_name); - if (str_match == 0) - { - matched = TRUE; - sym->parent = sym1; - if (!sym1->info.children) - sym1->info.children = g_ptr_array_new(); - g_ptr_array_add(sym1->info.children, sym); - break; - } - else if (str_match > 0) - break; - } - } - if (!matched) - { - sym->parent = root; - if (!root->info.children) - root->info.children = g_ptr_array_new(); - g_ptr_array_add(root->info.children, sym); - } - if (scope_end) - *scope_end = ':'; - } - } -#ifdef TM_DEBUG - fprintf(stderr, "Done.Dumping symbol tree.."); - tm_symbol_print(root, 0); -#endif - } - if (tags) - g_ptr_array_free(tags, TRUE); - - return root; -} - -static void tm_symbol_free(TMSymbol *sym) -{ - if (!sym) - return; - if ((!sym->tag) || ((tm_tag_function_t != sym->tag->type) && - (tm_tag_prototype_t != sym->tag->type))) - { - if (sym->info.children) - { - guint i; - for (i=0; i < sym->info.children->len; ++i) - tm_symbol_free(TM_SYMBOL(sym->info.children->pdata[i])); - g_ptr_array_free(sym->info.children, TRUE); - sym->info.children = NULL; - } - } - SYM_FREE(sym); -} - -void tm_symbol_tree_free(gpointer root) -{ - if (root) - tm_symbol_free(TM_SYMBOL(root)); -} - -TMSymbol *tm_symbol_tree_update(TMSymbol *root, GPtrArray *tags) -{ - if (root) - tm_symbol_free(root); - if ((tags) && (tags->len > 0)) - return tm_symbol_tree_new(tags); - else - return NULL; -}
Modified: tagmanager/src/tm_symbol.h 80 lines changed, 0 insertions(+), 80 deletions(-) =================================================================== @@ -1,80 +0,0 @@ -/* -* -* Copyright (c) 2001-2002, Biswapesh Chattopadhyay -* -* This source code is released for free distribution under the terms of the -* GNU General Public License. -* -*/ - -#ifndef TM_SYMBOL_H -#define TM_SYMBOL_H - - -/*! \file - The TMSymbol structure and related routines are used by TMProject to maintain a symbol - hierarchy. The top level TMSymbol maintains a pretty simple hierarchy, consisting of - compounds (classes and structs) and their children (member variables and functions). -*/ - -#include <glib.h> - -#include "tm_tag.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*! This structure defines a symbol */ -typedef struct _TMSymbol -{ - TMTag *tag; /*!< The tag corresponding to this symbol */ - struct _TMSymbol *parent; /*!< Parent class/struct for functions/variables */ - union - { - GPtrArray *children; /*!< Array of child symbols */ - TMTag *equiv; /*!< Prototype tag for functions */ - } info; -} TMSymbol; - -#define TM_SYMBOL(S) ((TMSymbol *) (S)) - -/*! Creates a symbol tree from an array of tags. -\param tags The array of tags from which to create the symbol tree. -\return The root symbol (starting point of the symbol tree) -*/ -TMSymbol *tm_symbol_tree_new(GPtrArray *tags); - -/*! Given a symbol, frees it and all its children. -\param root The symbol to free. -*/ -void tm_symbol_tree_free(gpointer root); - -/*! Given a symbol tree and an array of tags, updates the symbol tree. Note -that the returned pointer may be different from the passed root pointer, -so don't throw it away. This is basically a convinience function that calls -tm_symbol_tree_free() and tm_symbol_tree_new(). -\param root The original root symbol. -\param tags The array of tags from which to rebuild the tree. -\return The new root symbol. -*/ -TMSymbol *tm_symbol_tree_update(TMSymbol *root, GPtrArray *tags); - -/*! Arglist comparison function */ -int tm_arglist_compare(const TMTag *t1, const TMTag *t2); - -/*! Symbol comparison function - can be used for sorting purposes. */ -int tm_symbol_compare(const void *p1, const void *p2); - -/*! Tag comparison function tailor made for creating symbol view */ -int tm_symbol_tag_compare(const TMTag **t1, const TMTag **t2); - -/*! Prints the symbol hierarchy to standard error */ -void tm_symbol_print(TMSymbol *sym, guint level); - -#ifdef __cplusplus -} -#endif - -#endif /* TM_SYMBOL_H */
Modified: tagmanager/src/tm_tagmanager.h 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -11,7 +11,6 @@ #define TM_TAGMANAGER_H
#include "tm_tag.h" -#include "tm_symbol.h" #include "tm_file_entry.h" #include "tm_workspace.h" #include "tm_work_object.h"
Modified: wscript 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -120,7 +120,6 @@ ctags_sources = set([ tagmanager_sources = set([ 'tagmanager/src/tm_file_entry.c', 'tagmanager/src/tm_source_file.c', - 'tagmanager/src/tm_symbol.c', 'tagmanager/src/tm_tag.c', 'tagmanager/src/tm_tagmanager.c', 'tagmanager/src/tm_work_object.c', @@ -552,7 +551,7 @@ def build(bld): bld.install_files('${PREFIX}/include/geany/tagmanager', ''' tagmanager/src/tm_file_entry.h tagmanager/src/tm_source_file.h tagmanager/src/tm_parser.h - tagmanager/src/tm_symbol.h tagmanager/src/tm_tag.h + tagmanager/src/tm_tag.h tagmanager/src/tm_tagmanager.h tagmanager/src/tm_work_object.h tagmanager/src/tm_workspace.h ''') # Docs
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).