Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Wed, 29 Jan 2014 00:34:26 UTC Commit: 6a85a50d21b6297fe1ea51ecc8792f6a1f81cf58 https://github.com/geany/geany/commit/6a85a50d21b6297fe1ea51ecc8792f6a1f81cf...
Log Message: ----------- Replace bare CTags parser ID numbers with an enumeration
Avoid using magic numbers in the source for better readability and easier maintenance.
Modified Paths: -------------- HACKING src/filetypes.c tagmanager/ctags/parsers.h tagmanager/src/Makefile.am tagmanager/src/tm_parser.h tagmanager/src/tm_tagmanager.h wscript
Modified: HACKING 9 files changed, 5 insertions(+), 4 deletions(-) =================================================================== @@ -402,8 +402,7 @@ update the ``[Groups]`` section in ``filetype_extensions.conf``.
* Add GEANY_FILETYPES_FOO to filetypes.h. * Initialize GEANY_FILETYPES_FOO in init_builtin_filetypes() of - filetypes.c. You should use filetype_make_title() to avoid a - translation whenever possible. + filetypes.c. * Update data/filetype_extensions.conf.
The remaining notes relate mostly to built-in filetypes. @@ -527,14 +526,16 @@ Method * Add foo.c to SRCS in Makefile.am. * Add foo.o to OBJS in makefile.win32. * Add path/foo.c to geany_sources in wscript. -* Add Foo to parsers.h & fill in comment with parser number for foo. +* Add Foo to parsers.h +* Add TM_PARSER_FOO to tagmanager/src/tm_parser.h. The list here must follow + exactly the order in parsers.h.
In foo.c: Edit FooKinds 3rd column to match a s_tag_type_names string in tm_tag.c. (You may want to make the symbols.c change before doing this).
In filetypes.c, init_builtin_filetypes(): -Set filetypes[GEANY_FILETYPES_FOO].lang = foo's parser number. +Set the 2nd argument of the FT_INIT() macro for this filetype to FOO.
In symbols.c: Unless your parser uses C-like tag type kinds, update
Modified: src/filetypes.c 126 files changed, 64 insertions(+), 62 deletions(-) =================================================================== @@ -44,6 +44,8 @@ #include "ui_utils.h" #include "symbols.h"
+#include "tm_parser.h" + #include <stdlib.h>
#define GEANY_FILETYPE_SEARCH_LINES 2 /* lines of file to search for filetype */ @@ -112,8 +114,8 @@ static void ft_init(filetype_id ft_id, int lang, const char *name, }
/* Evil macro to save typing and make init_builtin_filetypes() more readable */ -#define FT_INIT(ft_id, lang_id, name, title_name, title_type, mime_type, group_id) \ - ft_init(GEANY_FILETYPES_##ft_id, lang_id, name, title_name, \ +#define FT_INIT(ft_id, parser_id, name, title_name, title_type, mime_type, group_id) \ + ft_init(GEANY_FILETYPES_##ft_id, TM_PARSER_##parser_id, name, title_name, \ TITLE_##title_type, mime_type, GEANY_FILETYPE_GROUP_##group_id)
@@ -122,72 +124,72 @@ static void init_builtin_filetypes(void) { /* Column legend: * [0] = Filetype constant (GEANY_FILETYPES_*) - * [1] = CTags parser (see tagmanager/ctags/src/parsers.h) + * [1] = CTags parser (TM_PARSER_*) * [2] = Non-translated filetype name (*not* label for display) * [3] = Translatable human filetype title prefix or NULL to use [2] * [4] = Title type (TITLE_*) constant (ex. TITLE_SOURCE_FILE is 'source file' suffix) * [5] = Mime type or NULL for none/unknown * [6] = The filetype group constant (GEANY_FILETYPE_GROUP_*) * -------------------------------------------------------------------------------------------------------------------------- - * [0] [1] [2] [3] [4] [5] [6] */ - FT_INIT( NONE, -2, "None", _("None"), NONE, NULL, NONE ); - FT_INIT( C, 0, "C", NULL, SOURCE_FILE, "text/x-csrc", COMPILED ); - FT_INIT( CPP, 1, "C++", NULL, SOURCE_FILE, "text/x-c++src", COMPILED ); - FT_INIT( OBJECTIVEC, 42, "Objective-C", NULL, SOURCE_FILE, "text/x-objc", COMPILED ); - FT_INIT( CS, 25, "C#", NULL, SOURCE_FILE, "text/x-csharp", COMPILED ); - FT_INIT( VALA, 33, "Vala", NULL, SOURCE_FILE, "text/x-vala", COMPILED ); - FT_INIT( D, 17, "D", NULL, SOURCE_FILE, "text/x-dsrc", COMPILED ); - FT_INIT( JAVA, 2, "Java", NULL, SOURCE_FILE, "text/x-java", COMPILED ); - FT_INIT( PASCAL, 4, "Pascal", NULL, SOURCE_FILE, "text/x-pascal", COMPILED ); - FT_INIT( ASM, 9, "ASM", "Assembler", SOURCE_FILE, NULL, COMPILED ); - FT_INIT( BASIC, 26, "FreeBasic", NULL, SOURCE_FILE, NULL, COMPILED ); - FT_INIT( FORTRAN, 18, "Fortran", "Fortran (F90)", SOURCE_FILE, "text/x-fortran", COMPILED ); - FT_INIT( F77, 30, "F77", "Fortran (F77)", SOURCE_FILE, "text/x-fortran", COMPILED ); - FT_INIT( GLSL, 31, "GLSL", NULL, SOURCE_FILE, NULL, COMPILED ); - FT_INIT( CAML, -2, "CAML", "(O)Caml", SOURCE_FILE, "text/x-ocaml", COMPILED ); - FT_INIT( PERL, 5, "Perl", NULL, SOURCE_FILE, "application/x-perl", SCRIPT ); - FT_INIT( PHP, 6, "PHP", NULL, SOURCE_FILE, "application/x-php", SCRIPT ); - FT_INIT( JS, 23, "Javascript", NULL, SOURCE_FILE, "application/javascript", SCRIPT ); - FT_INIT( PYTHON, 7, "Python", NULL, SOURCE_FILE, "text/x-python", SCRIPT ); - FT_INIT( RUBY, 14, "Ruby", NULL, SOURCE_FILE, "application/x-ruby", SCRIPT ); - FT_INIT( TCL, 15, "Tcl", NULL, SOURCE_FILE, "text/x-tcl", SCRIPT ); - FT_INIT( LUA, 22, "Lua", NULL, SOURCE_FILE, "text/x-lua", SCRIPT ); - FT_INIT( FERITE, 19, "Ferite", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( HASKELL, 24, "Haskell", NULL, SOURCE_FILE, "text/x-haskell", COMPILED ); - FT_INIT( MARKDOWN, 36, "Markdown", NULL, SOURCE_FILE, "text/x-markdown", MARKUP ); - FT_INIT( TXT2TAGS, 37, "Txt2tags", NULL, SOURCE_FILE, "text/x-txt2tags", MARKUP ); - FT_INIT( ABC, 38, "Abc", NULL, FILE, NULL, MISC ); - FT_INIT( SH, 16, "Sh", _("Shell"), SCRIPT, "application/x-shellscript", SCRIPT ); - FT_INIT( MAKE, 3, "Make", _("Makefile"), NONE, "text/x-makefile", SCRIPT ); - FT_INIT( XML, -2, "XML", NULL, DOCUMENT, "application/xml", MARKUP ); - FT_INIT( DOCBOOK, 12, "Docbook", NULL, DOCUMENT, "application/docbook+xml", MARKUP ); - FT_INIT( HTML, 29, "HTML", NULL, DOCUMENT, "text/html", MARKUP ); - FT_INIT( CSS, 13, "CSS", _("Cascading Stylesheet"), NONE, "text/css", MARKUP ); /* not really markup but fit quite well to HTML */ - FT_INIT( SQL, 11, "SQL", NULL, FILE, "text/x-sql", MISC ); - FT_INIT( COBOL, 41, "COBOL", NULL, SOURCE_FILE, "text/x-cobol", COMPILED ); - FT_INIT( LATEX, 8, "LaTeX", NULL, SOURCE_FILE, "text/x-tex", MARKUP ); - FT_INIT( VHDL, 21, "VHDL", NULL, SOURCE_FILE, "text/x-vhdl", COMPILED ); - FT_INIT( VERILOG, 39, "Verilog", NULL, SOURCE_FILE, "text/x-verilog", COMPILED ); - FT_INIT( DIFF, 20, "Diff", NULL, FILE, "text/x-patch", MISC ); - FT_INIT( LISP, -2, "Lisp", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( ERLANG, -2, "Erlang", NULL, SOURCE_FILE, "text/x-erlang", COMPILED ); - FT_INIT( CONF, 10, "Conf", _("Config"), FILE, NULL, MISC ); - FT_INIT( PO, -2, "Po", _("Gettext translation"), FILE, "text/x-gettext-translation", MISC ); - FT_INIT( HAXE, 27, "Haxe", NULL, SOURCE_FILE, NULL, COMPILED ); - FT_INIT( AS, 34, "ActionScript", NULL, SOURCE_FILE, "application/ecmascript", SCRIPT ); - FT_INIT( R, 40, "R", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( REST, 28, "reStructuredText", NULL, SOURCE_FILE, NULL, MARKUP ); - FT_INIT( MATLAB, 32, "Matlab/Octave", NULL, SOURCE_FILE, "text/x-matlab", SCRIPT ); - FT_INIT( YAML, -2, "YAML", NULL, FILE, "application/x-yaml", MISC ); - FT_INIT( CMAKE, -2, "CMake", NULL, SOURCE_FILE, "text/x-cmake", SCRIPT ); - FT_INIT( NSIS, 35, "NSIS", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( ADA, -2, "Ada", NULL, SOURCE_FILE, "text/x-adasrc", COMPILED ); - FT_INIT( FORTH, -2, "Forth", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( ASCIIDOC, 43, "Asciidoc", NULL, SOURCE_FILE, NULL, MARKUP ); - FT_INIT( ABAQUS, 44, "Abaqus", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( BATCH, -2, "Batch", NULL, SCRIPT, NULL, SCRIPT ); - FT_INIT( POWERSHELL, -2, "PowerShell", NULL, SOURCE_FILE, NULL, SCRIPT ); - FT_INIT( RUST, 45, "Rust", NULL, SOURCE_FILE, "text/x-rustsrc", COMPILED ); + * [0] [1] [2] [3] [4] [5] [6] */ + FT_INIT( NONE, NONE, "None", _("None"), NONE, NULL, NONE ); + FT_INIT( C, C, "C", NULL, SOURCE_FILE, "text/x-csrc", COMPILED ); + FT_INIT( CPP, CPP, "C++", NULL, SOURCE_FILE, "text/x-c++src", COMPILED ); + FT_INIT( OBJECTIVEC, OBJC, "Objective-C", NULL, SOURCE_FILE, "text/x-objc", COMPILED ); + FT_INIT( CS, CSHARP, "C#", NULL, SOURCE_FILE, "text/x-csharp", COMPILED ); + FT_INIT( VALA, VALA, "Vala", NULL, SOURCE_FILE, "text/x-vala", COMPILED ); + FT_INIT( D, D, "D", NULL, SOURCE_FILE, "text/x-dsrc", COMPILED ); + FT_INIT( JAVA, JAVA, "Java", NULL, SOURCE_FILE, "text/x-java", COMPILED ); + FT_INIT( PASCAL, PASCAL, "Pascal", NULL, SOURCE_FILE, "text/x-pascal", COMPILED ); + FT_INIT( ASM, ASM, "ASM", "Assembler", SOURCE_FILE, NULL, COMPILED ); + FT_INIT( BASIC, FREEBASIC, "FreeBasic", NULL, SOURCE_FILE, NULL, COMPILED ); + FT_INIT( FORTRAN, FORTRAN, "Fortran", "Fortran (F90)", SOURCE_FILE, "text/x-fortran", COMPILED ); + FT_INIT( F77, F77, "F77", "Fortran (F77)", SOURCE_FILE, "text/x-fortran", COMPILED ); + FT_INIT( GLSL, GLSL, "GLSL", NULL, SOURCE_FILE, NULL, COMPILED ); + FT_INIT( CAML, NONE, "CAML", "(O)Caml", SOURCE_FILE, "text/x-ocaml", COMPILED ); + FT_INIT( PERL, PERL, "Perl", NULL, SOURCE_FILE, "application/x-perl", SCRIPT ); + FT_INIT( PHP, PHP, "PHP", NULL, SOURCE_FILE, "application/x-php", SCRIPT ); + FT_INIT( JS, JAVASCRIPT, "Javascript", NULL, SOURCE_FILE, "application/javascript", SCRIPT ); + FT_INIT( PYTHON, PYTHON, "Python", NULL, SOURCE_FILE, "text/x-python", SCRIPT ); + FT_INIT( RUBY, RUBY, "Ruby", NULL, SOURCE_FILE, "application/x-ruby", SCRIPT ); + FT_INIT( TCL, TCL, "Tcl", NULL, SOURCE_FILE, "text/x-tcl", SCRIPT ); + FT_INIT( LUA, LUA, "Lua", NULL, SOURCE_FILE, "text/x-lua", SCRIPT ); + FT_INIT( FERITE, FERITE, "Ferite", NULL, SOURCE_FILE, NULL, SCRIPT ); + FT_INIT( HASKELL, HASKELL, "Haskell", NULL, SOURCE_FILE, "text/x-haskell", COMPILED ); + FT_INIT( MARKDOWN, MARKDOWN, "Markdown", NULL, SOURCE_FILE, "text/x-markdown", MARKUP ); + FT_INIT( TXT2TAGS, TXT2TAGS, "Txt2tags", NULL, SOURCE_FILE, "text/x-txt2tags", MARKUP ); + FT_INIT( ABC, ABC, "Abc", NULL, FILE, NULL, MISC ); + FT_INIT( SH, SH, "Sh", _("Shell"), SCRIPT, "application/x-shellscript", SCRIPT ); + FT_INIT( MAKE, MAKEFILE, "Make", _("Makefile"), NONE, "text/x-makefile", SCRIPT ); + FT_INIT( XML, NONE, "XML", NULL, DOCUMENT, "application/xml", MARKUP ); + FT_INIT( DOCBOOK, DOCBOOK, "Docbook", NULL, DOCUMENT, "application/docbook+xml", MARKUP ); + FT_INIT( HTML, HTML, "HTML", NULL, DOCUMENT, "text/html", MARKUP ); + FT_INIT( CSS, CSS, "CSS", _("Cascading Stylesheet"), NONE, "text/css", MARKUP ); /* not really markup but fit quite well to HTML */ + FT_INIT( SQL, SQL, "SQL", NULL, FILE, "text/x-sql", MISC ); + FT_INIT( COBOL, COBOL, "COBOL", NULL, SOURCE_FILE, "text/x-cobol", COMPILED ); + FT_INIT( LATEX, LATEX, "LaTeX", NULL, SOURCE_FILE, "text/x-tex", MARKUP ); + FT_INIT( VHDL, VHDL, "VHDL", NULL, SOURCE_FILE, "text/x-vhdl", COMPILED ); + FT_INIT( VERILOG, VERILOG, "Verilog", NULL, SOURCE_FILE, "text/x-verilog", COMPILED ); + FT_INIT( DIFF, DIFF, "Diff", NULL, FILE, "text/x-patch", MISC ); + FT_INIT( LISP, NONE, "Lisp", NULL, SOURCE_FILE, NULL, SCRIPT ); + FT_INIT( ERLANG, NONE, "Erlang", NULL, SOURCE_FILE, "text/x-erlang", COMPILED ); + FT_INIT( CONF, CONF, "Conf", _("Config"), FILE, NULL, MISC ); + FT_INIT( PO, NONE, "Po", _("Gettext translation"), FILE, "text/x-gettext-translation", MISC ); + FT_INIT( HAXE, HAXE, "Haxe", NULL, SOURCE_FILE, NULL, COMPILED ); + FT_INIT( AS, ACTIONSCRIPT, "ActionScript", NULL, SOURCE_FILE, "application/ecmascript", SCRIPT ); + FT_INIT( R, R, "R", NULL, SOURCE_FILE, NULL, SCRIPT ); + FT_INIT( REST, REST, "reStructuredText", NULL, SOURCE_FILE, NULL, MARKUP ); + FT_INIT( MATLAB, MATLAB, "Matlab/Octave", NULL, SOURCE_FILE, "text/x-matlab", SCRIPT ); + FT_INIT( YAML, NONE, "YAML", NULL, FILE, "application/x-yaml", MISC ); + FT_INIT( CMAKE, NONE, "CMake", NULL, SOURCE_FILE, "text/x-cmake", SCRIPT ); + FT_INIT( NSIS, NSIS, "NSIS", NULL, SOURCE_FILE, NULL, SCRIPT ); + FT_INIT( ADA, NONE, "Ada", NULL, SOURCE_FILE, "text/x-adasrc", COMPILED ); + FT_INIT( FORTH, NONE, "Forth", NULL, SOURCE_FILE, NULL, SCRIPT ); + FT_INIT( ASCIIDOC, ASCIIDOC, "Asciidoc", NULL, SOURCE_FILE, NULL, MARKUP ); + FT_INIT( ABAQUS, ABAQUS, "Abaqus", NULL, SOURCE_FILE, NULL, SCRIPT ); + FT_INIT( BATCH, NONE, "Batch", NULL, SCRIPT, NULL, SCRIPT ); + FT_INIT( POWERSHELL, NONE, "PowerShell", NULL, SOURCE_FILE, NULL, SCRIPT ); + FT_INIT( RUST, RUST, "Rust", NULL, SOURCE_FILE, "text/x-rustsrc", COMPILED ); }
Modified: tagmanager/ctags/parsers.h 51 files changed, 2 insertions(+), 49 deletions(-) =================================================================== @@ -14,6 +14,7 @@ #define _PARSERS_H
/* Add the name of any new parser definition function here */ +/* keep tagmanager/src/tm_parser.h in sync */ #define PARSER_LIST \ CParser, \ CppParser, \ @@ -61,55 +62,7 @@ AsciidocParser, \ AbaqusParser, \ RustParser -/* -langType of each parser - 0 CParser - 1 CppParser - 2 JavaParser - 3 MakefileParser - 4 PascalParser - 5 PerlParser - 6 PhpParser - 7 PythonParser - 8 LaTeXParser - 9 AsmParser -10 ConfParser -11 SqlParser -12 DocBookParser -13 CssParser -14 RubyParser -15 TclParser -16 ShParser -17 DParser -18 FortranParser -19 FeriteParser -20 DiffParser -21 VhdlParser -22 LuaParser -23 JavaScriptParser -24 HaskellParser -25 CsharpParser -26 FreeBasicParser -27 HaxeParser -28 RestParser -29 HtmlParser -30 F77Parser -31 GLSLParser -32 MatlabParser -33 ValaParser -34 ActionScriptParser -35 NsisParser -36 MarkdownParser -37 Txt2tagsParser -38 AbcParser -39 Verilog -40 RParser -41 CobolParser -42 ObjcParser -43 AsciidocParser -44 AbaqusParser -45 Rust -*/ + #endif /* _PARSERS_H */
/* vi:set tabstop=8 shiftwidth=4: */
Modified: tagmanager/src/Makefile.am 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -14,6 +14,7 @@ noinst_LIBRARIES = libtagmanager.a tagmanager_includedir = $(includedir)/geany/tagmanager tagmanager_include_HEADERS = \ tm_file_entry.h \ + tm_parser.h \ tm_project.h \ tm_source_file.h \ tm_symbol.h \
Modified: tagmanager/src/tm_parser.h 75 files changed, 75 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,75 @@ +/* +* +* Copyright (c) 2014, Colomban Wendling +* +* This source code is released for free distribution under the terms of the +* GNU General Public License. +* +*/ + +#ifndef TM_PARSER_H +#define TM_PARSER_H + +#ifndef LIBCTAGS_DEFINED +/* from ctags/parse.h */ +# define LANG_AUTO (-1) +# define LANG_IGNORE (-2) +#endif + + +/* keep in sync with ctags/parsers.h */ +typedef enum +{ + TM_PARSER_NONE = LANG_IGNORE, + TM_PARSER_AUTO = LANG_AUTO, + TM_PARSER_C = 0, + TM_PARSER_CPP, + TM_PARSER_JAVA, + TM_PARSER_MAKEFILE, + TM_PARSER_PASCAL, + TM_PARSER_PERL, + TM_PARSER_PHP, + TM_PARSER_PYTHON, + TM_PARSER_LATEX, + TM_PARSER_ASM, + TM_PARSER_CONF, + TM_PARSER_SQL, + TM_PARSER_DOCBOOK, + TM_PARSER_CSS, + TM_PARSER_RUBY, + TM_PARSER_TCL, + TM_PARSER_SH, + TM_PARSER_D, + TM_PARSER_FORTRAN, + TM_PARSER_FERITE, + TM_PARSER_DIFF, + TM_PARSER_VHDL, + TM_PARSER_LUA, + TM_PARSER_JAVASCRIPT, + TM_PARSER_HASKELL, + TM_PARSER_CSHARP, + TM_PARSER_FREEBASIC, + TM_PARSER_HAXE, + TM_PARSER_REST, + TM_PARSER_HTML, + TM_PARSER_F77, + TM_PARSER_GLSL, + TM_PARSER_MATLAB, + TM_PARSER_VALA, + TM_PARSER_ACTIONSCRIPT, + TM_PARSER_NSIS, + TM_PARSER_MARKDOWN, + TM_PARSER_TXT2TAGS, + TM_PARSER_ABC, + TM_PARSER_VERILOG, + TM_PARSER_R, + TM_PARSER_COBOL, + TM_PARSER_OBJC, + TM_PARSER_ASCIIDOC, + TM_PARSER_ABAQUS, + TM_PARSER_RUST, + TM_PARSER_COUNT +} TMParserType; + + +#endif /* TM_PARSER_H */
Modified: tagmanager/src/tm_tagmanager.h 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -17,6 +17,7 @@ #include "tm_work_object.h" #include "tm_source_file.h" #include "tm_project.h" +#include "tm_parser.h"
/*! \mainpage Introduction \section Introduction
Modified: wscript 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -514,7 +514,7 @@ def build(bld): scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''') bld.install_files('${PREFIX}/include/geany/tagmanager', ''' tagmanager/src/tm_file_entry.h tagmanager/src/tm_project.h - tagmanager/src/tm_source_file.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_tagmanager.h tagmanager/src/tm_work_object.h tagmanager/src/tm_workspace.h ''')
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).