xref: /Universal-ctags/main/ptag_p.h (revision b641c661c49c5d035a1b4b61fbfa8d3b22366426)
1 /*
2  *
3  *  Copyright (c) 2016, Red Hat, Inc.
4  *  Copyright (c) 2016, Masatake YAMATO
5  *
6  *  Author: Masatake YAMATO <yamato@redhat.com>
7  *
8  *   This source code is released for free distribution under the terms of the
9  *   GNU General Public License version 2 or (at your option) any later version.
10  *
11  */
12 #ifndef CTAGS_MAIN_PTAG_PRIVATE_H
13 #define CTAGS_MAIN_PTAG_PRIVATE_H
14 
15 #include "general.h"
16 #include "types.h"
17 
18 #define PSEUDO_TAG_PREFIX       "!_"
19 #define PSEUDO_TAG_SEPARATOR    "!"
20 
21 typedef enum ePtagType { /* pseudo tag content control */
22 	PTAG_UNKNOWN = -1,
23 	/* Only --output-format=json use this ptag.
24 	   Applications of the output may expect this comes first in the output. */
25 	PTAG_JSON_OUTPUT_VERSION,
26 
27 	PTAG_FILE_FORMAT,
28 	PTAG_FILE_SORTED,
29 	PTAG_PROGRAM_AUTHOR,
30 	PTAG_PROGRAM_NAME,
31 	PTAG_PROGRAM_URL,
32 	PTAG_PROGRAM_VERSION,
33 #ifdef HAVE_ICONV
34 	PTAG_FILE_ENCODING,
35 #endif
36 	PTAG_KIND_SEPARATOR,
37 	PTAG_KIND_DESCRIPTION,
38 	PTAG_FIELD_DESCRIPTION,
39 	PTAG_EXTRA_DESCRIPTION,
40 	PTAG_ROLE_DESCRIPTION,
41 	PTAG_OUTPUT_MODE,
42 	PTAG_OUTPUT_FILESEP,
43 	PTAG_PATTERN_TRUNCATION,
44 	PTAG_PROC_CWD,
45 	PTAG_OUTPUT_EXCMD,
46 	PTAG_COUNT
47 } ptagType;
48 
49 typedef enum ePtagFlag {
50 	/* use isPtagCommonInParsers() for testing. */
51 	PTAGF_COMMON = 1 << 0,
52 	/* use isPtagParserSpecific for testing.
53 	 * PSEUDO_TAG_SEPARATOR is used for printing. */
54 	PTAGF_PARSER = 1 << 1,
55 } ptagFlag;
56 
57 struct sPtagDesc {
58 	bool enabled;
59 	const char* name;
60 	const char* description;  /* displayed in --list-pseudo-tags output */
61 
62 	/* For making ptags for common in parsers, LANG_IGNOR is for the second
63 	 * argument and a pointer for optionValues type value for the third argument
64 	 * are passed.
65 	 *
66 	 * For parser specific ptags, the pointer for parserObject
67 	 * of the parser is passed as the thrid argument.
68 	 */
69 	bool (* makeTag) (ptagDesc *, langType, const void *);
70 
71 	ptagFlag flags;
72 };
73 
74 extern bool makePtagIfEnabled (ptagType type, langType language, const void *data);
75 extern ptagDesc* getPtagDesc (ptagType type);
76 extern ptagType  getPtagTypeForName (const char *name);
77 extern void printPtags (bool withListHeader, bool machinable, FILE *fp);
78 extern bool isPtagEnabled (ptagType type);
79 extern bool isPtagCommonInParsers (ptagType type);
80 extern bool isPtagParserSpecific (ptagType type);
81 extern bool enablePtag (ptagType type, bool state);
82 
83 #endif	/* CTAGS_MAIN_PTAG_PRIVATE_H */
84