xref: /Universal-ctags/main/kind.h (revision fde8667799e7eecefafcb088506f5a708763b710)
1d548ab51SMasatake YAMATO /*
2d548ab51SMasatake YAMATO *   Copyright (c) 1998-2003, Darren Hiebert
3d548ab51SMasatake YAMATO *
4d548ab51SMasatake YAMATO *   This source code is released for free distribution under the terms of the
50ce38835Sviccuad *   GNU General Public License version 2 or (at your option) any later version.
6d548ab51SMasatake YAMATO *
7d548ab51SMasatake YAMATO */
85474c2e5SMasatake YAMATO #ifndef CTAGS_MAIN_KIND_H
95474c2e5SMasatake YAMATO #define CTAGS_MAIN_KIND_H
10d548ab51SMasatake YAMATO 
11934a26beSMasatake YAMATO /*
12934a26beSMasatake YAMATO *   INCLUDE FILES
13934a26beSMasatake YAMATO */
14934a26beSMasatake YAMATO 
15b430253fSMike Burns #include "general.h"
16355b5d96SMasatake YAMATO #include "types.h"
179601d44cSMasatake YAMATO #include "routines.h"
18934a26beSMasatake YAMATO 
19934a26beSMasatake YAMATO /*
20934a26beSMasatake YAMATO *   DATA DECLARATIONS
21934a26beSMasatake YAMATO */
22e2755fdeSMasatake YAMATO 
2313457258SMasatake YAMATO struct sRoleDefinition {
24ce990805SThomas Braun 	bool enabled;
257adc9db2SMasatake YAMATO 	char* name;		  /* role name */
267adc9db2SMasatake YAMATO 	char* description;	  /* displayed in --help output */
27e2755fdeSMasatake YAMATO 
2813457258SMasatake YAMATO 	int id;
2913457258SMasatake YAMATO };
3013457258SMasatake YAMATO 
31d548ab51SMasatake YAMATO /*
32d548ab51SMasatake YAMATO  * Predefined kinds
33d548ab51SMasatake YAMATO  */
347e1bd430SMasatake YAMATO #define KIND_REGEX_DEFAULT_LETTER 'r'
357e1bd430SMasatake YAMATO #define KIND_REGEX_DEFAULT_NAME "regex"
36d548ab51SMasatake YAMATO 
377e1bd430SMasatake YAMATO #define KIND_NULL_LETTER    '\0'
38d548ab51SMasatake YAMATO 
39*fde86677SMasatake YAMATO /* GHOST kind can be used for a value for
40*fde86677SMasatake YAMATO  * initializing a variable holding a kind index,
41*fde86677SMasatake YAMATO  * or filling a struct member holding a kind index.
42*fde86677SMasatake YAMATO  *
43*fde86677SMasatake YAMATO  * Typical case is filling a scope related struct
44*fde86677SMasatake YAMATO  * member with GHOST to represent root name scope.
45*fde86677SMasatake YAMATO  *
46*fde86677SMasatake YAMATO  * input.c:
47*fde86677SMasatake YAMATO  *
48*fde86677SMasatake YAMATO  *     int main (void) { return 0; }
49*fde86677SMasatake YAMATO  *
50*fde86677SMasatake YAMATO  * Consider that tagging "main" in above input.
51*fde86677SMasatake YAMATO  * You may wonder what kind of value
52*fde86677SMasatake YAMATO  * should be used to fill tag.extensionFields.scopeKindIndex.
53*fde86677SMasatake YAMATO  * KIND_GHOST_INDEX can be used for the purpose.
54*fde86677SMasatake YAMATO  */
5511cbaeceSMasatake YAMATO #define KIND_GHOST_INDEX -1
567e1bd430SMasatake YAMATO #define KIND_GHOST_LETTER   ' '
577e1bd430SMasatake YAMATO #define KIND_GHOST_NAME "ghost"
58d548ab51SMasatake YAMATO 
5911cbaeceSMasatake YAMATO #define KIND_FILE_INDEX -2
607e1bd430SMasatake YAMATO #define KIND_FILE_DEFAULT_LETTER 'F'
617e1bd430SMasatake YAMATO #define KIND_FILE_DEFAULT_NAME "file"
62d548ab51SMasatake YAMATO 
63f92e6bf2SMasatake YAMATO #define KIND_WILDCARD_INDEX -3
647e1bd430SMasatake YAMATO #define KIND_WILDCARD_LETTER '*'
65415c1e30SMasatake YAMATO 
66519bc47fSMasatake YAMATO typedef struct sScopeSeparator {
67f92e6bf2SMasatake YAMATO 	int parentKindIndex;
68519bc47fSMasatake YAMATO 	const char *separator;
69519bc47fSMasatake YAMATO } scopeSeparator;
70519bc47fSMasatake YAMATO 
71e112e8abSMasatake YAMATO struct sKindDefinition {
72ce990805SThomas Braun 	bool enabled;          /* are tags for kind enabled? */
733525c8f1SMasatake YAMATO 	char  letter;               /* kind letter */
743b7988cfSMasatake YAMATO 	char* name;		  /* kind name */
753b7988cfSMasatake YAMATO 	char* description;	  /* displayed in --help output */
76ce990805SThomas Braun 	bool referenceOnly;
77e2755fdeSMasatake YAMATO 	int nRoles;		/* The number of role elements. */
7813457258SMasatake YAMATO 	roleDefinition *roles;
79519bc47fSMasatake YAMATO 	scopeSeparator *separators;
80519bc47fSMasatake YAMATO 	unsigned int separatorCount;
81355b5d96SMasatake YAMATO 
829a5a18e6SMasatake YAMATO 	int id;
839a5a18e6SMasatake YAMATO 
849a5a18e6SMasatake YAMATO 	/* TODO:Following fields should be moved to kindObject. */
85be831f5cSMasatake YAMATO 	/* Usage of `syncWith' field is a bit tricky.
86355b5d96SMasatake YAMATO 
87be831f5cSMasatake YAMATO 	   If `LANG_AUTO' is specified to `syncWith' field of a kind
88759d281dSK.Takata 	   (target kind), the main part of ctags updates the field with
89be831f5cSMasatake YAMATO 	   the id of a  parser (master parser) when initializing
90be831f5cSMasatake YAMATO 	   parsers. It also updates `slave' and `master' fields.
91355b5d96SMasatake YAMATO 
92be831f5cSMasatake YAMATO 	   If the value other than `LANG_AUTO' is specified,
93be831f5cSMasatake YAMATO 	   the main part does nothing. */
94be831f5cSMasatake YAMATO 	langType syncWith;
95e112e8abSMasatake YAMATO 	kindDefinition *slave;
96e112e8abSMasatake YAMATO 	kindDefinition *master;
97135b4bc5SMasatake YAMATO };
98d548ab51SMasatake YAMATO 
99e2755fdeSMasatake YAMATO #define ATTACH_ROLES(RS) .nRoles = ARRAY_SIZE(RS), .roles = RS
100dd37c63cSMasatake YAMATO #define ATTACH_SEPARATORS(S) .separators = S, .separatorCount = ARRAY_SIZE(S)
101908570b8SMasatake YAMATO 
102934a26beSMasatake YAMATO /*
103934a26beSMasatake YAMATO *   FUNCTION PROTOTYPES
104934a26beSMasatake YAMATO */
1059601d44cSMasatake YAMATO 
106f92e6bf2SMasatake YAMATO extern const char *scopeSeparatorFor (langType lang, int kindIndex, int parentKindIndex);
107519bc47fSMasatake YAMATO 
1085474c2e5SMasatake YAMATO #endif	/* CTAGS_MAIN_KIND_H */
109