xref: /Universal-ctags/main/kind.h (revision fde8667799e7eecefafcb088506f5a708763b710)
1 /*
2 *   Copyright (c) 1998-2003, Darren Hiebert
3 *
4 *   This source code is released for free distribution under the terms of the
5 *   GNU General Public License version 2 or (at your option) any later version.
6 *
7 */
8 #ifndef CTAGS_MAIN_KIND_H
9 #define CTAGS_MAIN_KIND_H
10 
11 /*
12 *   INCLUDE FILES
13 */
14 
15 #include "general.h"
16 #include "types.h"
17 #include "routines.h"
18 
19 /*
20 *   DATA DECLARATIONS
21 */
22 
23 struct sRoleDefinition {
24 	bool enabled;
25 	char* name;		  /* role name */
26 	char* description;	  /* displayed in --help output */
27 
28 	int id;
29 };
30 
31 /*
32  * Predefined kinds
33  */
34 #define KIND_REGEX_DEFAULT_LETTER 'r'
35 #define KIND_REGEX_DEFAULT_NAME "regex"
36 
37 #define KIND_NULL_LETTER    '\0'
38 
39 /* GHOST kind can be used for a value for
40  * initializing a variable holding a kind index,
41  * or filling a struct member holding a kind index.
42  *
43  * Typical case is filling a scope related struct
44  * member with GHOST to represent root name scope.
45  *
46  * input.c:
47  *
48  *     int main (void) { return 0; }
49  *
50  * Consider that tagging "main" in above input.
51  * You may wonder what kind of value
52  * should be used to fill tag.extensionFields.scopeKindIndex.
53  * KIND_GHOST_INDEX can be used for the purpose.
54  */
55 #define KIND_GHOST_INDEX -1
56 #define KIND_GHOST_LETTER   ' '
57 #define KIND_GHOST_NAME "ghost"
58 
59 #define KIND_FILE_INDEX -2
60 #define KIND_FILE_DEFAULT_LETTER 'F'
61 #define KIND_FILE_DEFAULT_NAME "file"
62 
63 #define KIND_WILDCARD_INDEX -3
64 #define KIND_WILDCARD_LETTER '*'
65 
66 typedef struct sScopeSeparator {
67 	int parentKindIndex;
68 	const char *separator;
69 } scopeSeparator;
70 
71 struct sKindDefinition {
72 	bool enabled;          /* are tags for kind enabled? */
73 	char  letter;               /* kind letter */
74 	char* name;		  /* kind name */
75 	char* description;	  /* displayed in --help output */
76 	bool referenceOnly;
77 	int nRoles;		/* The number of role elements. */
78 	roleDefinition *roles;
79 	scopeSeparator *separators;
80 	unsigned int separatorCount;
81 
82 	int id;
83 
84 	/* TODO:Following fields should be moved to kindObject. */
85 	/* Usage of `syncWith' field is a bit tricky.
86 
87 	   If `LANG_AUTO' is specified to `syncWith' field of a kind
88 	   (target kind), the main part of ctags updates the field with
89 	   the id of a  parser (master parser) when initializing
90 	   parsers. It also updates `slave' and `master' fields.
91 
92 	   If the value other than `LANG_AUTO' is specified,
93 	   the main part does nothing. */
94 	langType syncWith;
95 	kindDefinition *slave;
96 	kindDefinition *master;
97 };
98 
99 #define ATTACH_ROLES(RS) .nRoles = ARRAY_SIZE(RS), .roles = RS
100 #define ATTACH_SEPARATORS(S) .separators = S, .separatorCount = ARRAY_SIZE(S)
101 
102 /*
103 *   FUNCTION PROTOTYPES
104 */
105 
106 extern const char *scopeSeparatorFor (langType lang, int kindIndex, int parentKindIndex);
107 
108 #endif	/* CTAGS_MAIN_KIND_H */
109