geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

entry.h
Go to the documentation of this file.
1/*
2* Copyright (c) 1998-2002, 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* External interface to entry.c
8*/
9#ifndef CTAGS_MAIN_ENTRY_H
10#define CTAGS_MAIN_ENTRY_H
11
12/*
13* INCLUDE FILES
14*/
15#include "general.h" /* must always come first */
16#include "types.h"
17
18#include <stdint.h>
19
20#include "field.h"
21#include "xtag.h"
22#include "mio.h"
23#include "ptrarray.h"
24#include "nestlevel.h"
25
26/*
27* MACROS
28*/
29
30/*
31* DATA DECLARATIONS
32*/
33typedef struct sTagField {
35 const char* value;
36 bool valueOwner; /* used only in parserFieldsDynamic */
38
39typedef uint64_t roleBitsType;
40
41/* Information about the current tag candidate.
42 */
44 unsigned int lineNumberEntry:1; /* pattern or line number entry */
45 unsigned int isFileScope :1; /* is tag visible only within input file? */
46 unsigned int isFileEntry :1; /* is this just an entry for a file name? */
47 unsigned int truncateLineAfterTag :1; /* truncate tag line at end of tag name? */
48 unsigned int placeholder :1; /* This is just a part of scope context.
49 Put this entry to cork queue but
50 don't print it to tags file. */
51 unsigned int skipAutoFQEmission:1; /* If a parser makes a fq tag for the
52 current tag by itself, set this. */
53 unsigned int isPseudoTag:1; /* Used only in xref output.
54 If a tag is a pseudo, set this. */
55
56 unsigned long lineNumber; /* line number of tag */
57 const char* pattern; /* pattern for locating input line
58 * (may be NULL if not present) *//* */
59 unsigned int boundaryInfo; /* info about nested input stream */
60 MIOPos filePosition; /* file position of line containing tag */
61 langType langType; /* language of input file */
62 const char *inputFileName; /* name of input file */
63 const char *name; /* name of the tag */
64 int kindIndex; /* kind descriptor */
65 uint8_t extra[ ((XTAG_COUNT) / 8) + 1 ];
66 uint8_t *extraDynamic; /* Dynamically allocated but freed by per parser TrashBox */
67
68 struct {
69 const char* access;
70 const char* fileScope;
71 const char* implementation;
72 const char* inheritance;
73
74 /* Which scopeKindIndex belong to. If the value is LANG_AUTO,
75 the value for langType field of this structure is used as default value.
76 LANG_AUTO is set automatically in initTagEntryInfo. */
79 const char* scopeName;
80 int scopeIndex; /* cork queue entry for upper scope tag.
81 This field is meaningful if the value
82 is not CORK_NIL and scope[0] and scope[1] are
83 NULL. */
84
85 const char* signature;
86
87 /* type (union/struct/etc.) and name for a variable or typedef. */
88 const char* typeRef [2]; /* e.g., "struct" and struct name */
89
90#define ROLE_DEFINITION_INDEX -1
91#define ROLE_DEFINITION_NAME "def"
92#define ROLE_MAX_COUNT (sizeof(roleBitsType) * 8)
93 roleBitsType roleBits; /* for role of reference tag */
94
95#ifdef HAVE_LIBXML
96 const char* xpath;
97#endif
98 unsigned long endLine;
99 } extensionFields; /* list of extension fields*/
100
101 /* `usedParserFields' tracks how many parser own fields are
102 used. If it is a few (less than PRE_ALLOCATED_PARSER_FIELDS),
103 statically allocated parserFields is used. If more fields than
104 PRE_ALLOCATED_PARSER_FIELDS is defined and attached, parserFieldsDynamic
105 is used. */
106 unsigned int usedParserFields;
107#define PRE_ALLOCATED_PARSER_FIELDS 5
108#define NO_PARSER_FIELD -1
111
112 /* Following source* fields are used only when #line is found
113 in input and --line-directive is given in ctags command line. */
115 const char *sourceFileName;
117};
118
119typedef bool (* entryForeachFunc) (int corkIndex,
121 void * data);
122
123/*
124* GLOBAL VARIABLES
125*/
126
127
128/*
129* FUNCTION PROTOTYPES
130*/
131extern int makeTagEntry (const tagEntryInfo *const tag);
132extern void initTagEntry (tagEntryInfo *const e, const char *const name,
133 int kindIndex);
134extern void initRefTagEntry (tagEntryInfo *const e, const char *const name,
135 int kindIndex, int roleIndex);
136extern void initForeignRefTagEntry (tagEntryInfo *const e, const char *const name,
137 langType type,
138 int kindIndex, int roleIndex);
139extern void assignRole(tagEntryInfo *const e, int roleIndex);
140extern bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex);
141
142extern int makeQualifiedTagEntry (const tagEntryInfo *const e);
143
144
145#define CORK_NIL 0
148size_t countEntryInCorkQueue (void);
149
150/* If a parser sets (CORK_QUEUE and )CORK_SYMTAB to useCork,
151 * the parsesr can use symbol lookup tables for the current input.
152 * Each scope has a symbol lookup table.
153 * To register an tag to the table, use registerEntry().
154 * registerEntry registers CORKINDEX to a symbol table of a parent tag
155 * specified in the scopeIndex field of the tag specified with CORKINDEX.
156 */
157void registerEntry (int corkIndex);
158
159/* foreachEntriesInScope is for traversing the symbol table for a table
160 * specified with CORKINDEX. If CORK_NIL is given, this function traverses
161 * top-level entries. If name is NULL, this function traverses all entries
162 * under the scope.
163 *
164 * If FUNC returns false, this function returns false.
165 * If FUNC never returns false, this func returns true.
166 * If FUNC is not called because no node for NAME in the symbol table.
167 */
168bool foreachEntriesInScope (int corkIndex,
169 const char *name, /* or NULL */
170 entryForeachFunc func,
171 void *data);
172
173/* Return the cork index for NAME in the scope specified with CORKINDEX.
174 * Even if more than one entries for NAME are in the scope, this function
175 * just returns one of them. Returning CORK_NIL means there is no entry
176 * for NAME.
177 */
178int anyEntryInScope (int corkIndex,
179 const char *name);
180
181int anyKindEntryInScope (int corkIndex,
182 const char *name, int kind);
183
184int anyKindsEntryInScope (int corkIndex,
185 const char *name,
186 const int * kinds, int count);
187
188int anyKindsEntryInScopeRecursive (int corkIndex,
189 const char *name,
190 const int * kinds, int count);
191
192extern void markTagExtraBit (tagEntryInfo *const tag, xtagType extra);
193extern bool isTagExtraBitMarked (const tagEntryInfo *const tag, xtagType extra);
194
195/* If any extra bit is on, return true. */
196extern bool isTagExtra (const tagEntryInfo *const tag);
197
198/* Functions for attaching parser specific fields
199 *
200 * Which function you should use?
201 * ------------------------------
202 * Case A:
203 *
204 * If your parser uses the Cork API, and your parser called
205 * makeTagEntry () already, you can use both
206 * attachParserFieldToCorkEntry () and attachParserField (). Your
207 * parser has the cork index returned from makeTagEntry (). With the
208 * cork index, your parser can call attachParserFieldToCorkEntry ().
209 * If your parser already call getEntryInCorkQueue () to get the tag
210 * entry for the cork index, your parser can call attachParserField ()
211 * with passing true for `inCorkQueue' parameter. attachParserField ()
212 * is a bit faster than attachParserFieldToCorkEntry ().
213 *
214 * attachParserField () and attachParserFieldToCorkEntry () duplicates
215 * the memory object specified with `value' and stores the duplicated
216 * object to the entry on the cork queue. So the parser must/can free
217 * the original one passed to the functions after calling. The cork
218 * queue manages the life of the duplicated object. It is not the
219 * parser's concern.
220 *
221 *
222 * Case B:
223 *
224 * If your parser called one of initTagEntry () family but didn't call
225 * makeTagEntry () for a tagEntry yet, use attachParserField () with
226 * false for `inCorkQueue' whether your parser uses the Cork API or
227 * not.
228 *
229 * The parser (== caller) keeps the memory object specified with `value'
230 * till calling makeTagEntry (). The parser must free the memory object
231 * after calling makeTagEntry () if it is allocated dynamically in the
232 * parser side.
233 *
234 * Interpretation of VALUE
235 * -----------------------
236 * For FIELDTYPE_STRING:
237 * Both json writer and xref writer prints it as-is.
238 *
239 * For FIELDTYPE_STRING|FIELDTYPE_BOOL:
240 * If VALUE points "" (empty C string), the json writer prints it as
241 * false, and the xref writer prints it as -.
242 * If VALUE points a non-empty C string, Both json writer and xref
243 * writer print it as-is.
244 *
245 * For FIELDTYPE_BOOL
246 * The json writer always prints true.
247 * The xref writer always prints the name of field.
248 * Set "" explicitly though the value pointed by VALUE is not referred,
249 *
250 *
251 * The other data type and the combination of types are not implemented yet.
252 *
253 */
254extern void attachParserField (tagEntryInfo *const tag, bool inCorkQueue, fieldType ftype, const char* value);
255extern void attachParserFieldToCorkEntry (int index, fieldType ftype, const char* value);
256extern const char* getParserFieldValueForType (tagEntryInfo *const tag, fieldType ftype);
257
258extern int makePlaceholder (const char *const name);
259
260/* Marking all tag entries entries under the scope specified
261 * with index recursively.
262 *
263 * The parser calling this function enables CORK_SYMTAB.
264 * Entries to be marked must be registered to the scope
265 * specified with index or its descendant scopes with
266 * registerEntry ().
267 *
268 * Call makePlaceholder () at the start of your parser for
269 * making the root scope where the entries are registered.
270 */
272
273#endif /* CTAGS_MAIN_ENTRY_H */
gint index
Definition: build.c:2680
const gchar * name
Definition: document.c:3219
void initForeignRefTagEntry(tagEntryInfo *const e, const char *const name, langType type, int kindIndex, int roleIndex)
Definition: entry.c:1844
int makeTagEntry(const tagEntryInfo *const tag)
Definition: entry.c:1675
tagEntryInfo * getEntryOfNestingLevel(const NestingLevel *nl)
Definition: entry.c:1643
void assignRole(tagEntryInfo *const e, int roleIndex)
Definition: entry.c:1964
void markTagExtraBit(tagEntryInfo *const tag, xtagType extra)
Definition: entry.c:1899
void attachParserFieldToCorkEntry(int index, fieldType ftype, const char *value)
Definition: entry.c:987
bool isTagExtra(const tagEntryInfo *const tag)
Definition: entry.c:1932
bool isTagExtraBitMarked(const tagEntryInfo *const tag, xtagType extra)
Definition: entry.c:1904
uint64_t roleBitsType
Definition: entry.h:39
#define PRE_ALLOCATED_PARSER_FIELDS
Definition: entry.h:107
int makeQualifiedTagEntry(const tagEntryInfo *const e)
Definition: entry.c:1705
void initRefTagEntry(tagEntryInfo *const e, const char *const name, int kindIndex, int roleIndex)
Definition: entry.c:1838
bool(* entryForeachFunc)(int corkIndex, tagEntryInfo *entry, void *data)
Definition: entry.h:119
tagEntryInfo * getEntryInCorkQueue(int n)
Definition: entry.c:1635
void registerEntry(int corkIndex)
Definition: entry.c:1417
int anyKindsEntryInScopeRecursive(int corkIndex, const char *name, const int *kinds, int count)
Definition: entry.c:1388
int anyKindsEntryInScope(int corkIndex, const char *name, const int *kinds, int count)
Definition: entry.c:1372
void initTagEntry(tagEntryInfo *const e, const char *const name, int kindIndex)
Definition: entry.c:1823
void markAllEntriesInScopeAsPlaceholder(int index)
Definition: entry.c:2036
size_t countEntryInCorkQueue(void)
Definition: entry.c:1650
bool foreachEntriesInScope(int corkIndex, const char *name, entryForeachFunc func, void *data)
Definition: entry.c:1229
struct sTagField tagField
int anyEntryInScope(int corkIndex, const char *name)
Definition: entry.c:1334
void attachParserField(tagEntryInfo *const tag, bool inCorkQueue, fieldType ftype, const char *value)
Definition: entry.c:969
bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex)
Definition: entry.c:1969
int anyKindEntryInScope(int corkIndex, const char *name, int kind)
Definition: entry.c:1366
const char * getParserFieldValueForType(tagEntryInfo *const tag, fieldType ftype)
Definition: entry.c:1010
int makePlaceholder(const char *const name)
Definition: entry.c:1655
enum eFieldType fieldType
unsigned int count
GtkWidget * entry
Definition: search.c:118
MIOPos:
Definition: mio.h:101
struct sTagEntryInfo::@3 extensionFields
roleBitsType roleBits
Definition: entry.h:93
const char * implementation
Definition: entry.h:71
MIOPos filePosition
Definition: entry.h:60
const char * fileScope
Definition: entry.h:70
unsigned int lineNumberEntry
Definition: entry.h:44
unsigned int boundaryInfo
Definition: entry.h:59
const char * name
Definition: entry.h:63
unsigned int isFileScope
Definition: entry.h:45
langType sourceLangType
Definition: entry.h:114
const char * inputFileName
Definition: entry.h:62
const char * access
Definition: entry.h:69
uint8_t * extraDynamic
Definition: entry.h:66
unsigned long lineNumber
Definition: entry.h:56
ptrArray * parserFieldsDynamic
Definition: entry.h:110
tagField parserFields[5]
Definition: entry.h:109
unsigned int skipAutoFQEmission
Definition: entry.h:51
int kindIndex
Definition: entry.h:64
langType langType
Definition: entry.h:61
unsigned int isPseudoTag
Definition: entry.h:53
unsigned long sourceLineNumberDifference
Definition: entry.h:116
unsigned int truncateLineAfterTag
Definition: entry.h:47
unsigned int usedParserFields
Definition: entry.h:106
langType scopeLangType
Definition: entry.h:77
const char * typeRef[2]
Definition: entry.h:88
const char * pattern
Definition: entry.h:57
unsigned long endLine
Definition: entry.h:98
uint8_t extra[((XTAG_COUNT)/8)+1]
Definition: entry.h:65
const char * sourceFileName
Definition: entry.h:115
int scopeIndex
Definition: entry.h:80
int scopeKindIndex
Definition: entry.h:78
unsigned int placeholder
Definition: entry.h:48
const char * inheritance
Definition: entry.h:72
const char * signature
Definition: entry.h:85
unsigned int isFileEntry
Definition: entry.h:46
const char * scopeName
Definition: entry.h:79
const char * value
Definition: entry.h:35
bool valueOwner
Definition: entry.h:36
fieldType ftype
Definition: entry.h:34
int langType
Definition: types.h:13
@ XTAG_COUNT
Definition: xtag.h:38
enum eXtagType xtagType