1 /* 2 * Copyright (c) 1999-2002, Darren Hiebert 3 * Copyright 2009-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 4 * 5 * This source code is released for free distribution under the terms of the 6 * GNU General Public License version 2 or (at your option) any later version. 7 * 8 * Defines external interface to scope nesting levels for tags. 9 */ 10 #ifndef CTAGS_MAIN_NESTLEVEL_H 11 #define CTAGS_MAIN_NESTLEVEL_H 12 13 /* 14 * INCLUDE FILES 15 */ 16 #include "general.h" /* must always come first */ 17 18 #include "vstring.h" 19 20 /* 21 * DATA DECLARATIONS 22 */ 23 typedef struct NestingLevel NestingLevel; 24 typedef struct NestingLevels NestingLevels; 25 26 struct NestingLevel 27 { 28 int corkIndex; 29 char userData []; 30 }; 31 32 struct NestingLevels 33 { 34 void *levels; 35 int n; /* number of levels in use */ 36 int allocated; 37 size_t userDataSize; 38 /* The second argument is given via nestinglevelsPopFull 39 * or nestinglevelFreeFull */ 40 void (* deleteUserData) (NestingLevel *, void *); 41 }; 42 43 /* 44 * FUNCTION PROTOTYPES 45 */ 46 extern NestingLevels *nestingLevelsNew(size_t userDataSize); 47 extern NestingLevels *nestingLevelsNewFull(size_t userDataSize, 48 void (* deleteUserData)(NestingLevel *, void *)); 49 #define nestingLevelsFree(NLS) nestingLevelsFreeFull(NLS, NULL) 50 extern void nestingLevelsFreeFull(NestingLevels *nls, void *ctxData); 51 extern NestingLevel *nestingLevelsPush(NestingLevels *nls, int corkIndex); 52 extern NestingLevel * nestingLevelsTruncate(NestingLevels *nls, int depth, int corkIndex); 53 #define nestingLevelsPop(NLS) nestingLevelsPopFull(NLS, NULL) 54 extern void nestingLevelsPopFull(NestingLevels *nls, void *ctxData); 55 #define nestingLevelsGetCurrent(NLS) nestingLevelsGetNthParent((NLS), 0) 56 extern NestingLevel *nestingLevelsGetNthFromRoot(const NestingLevels *nls, int n); 57 extern NestingLevel *nestingLevelsGetNthParent(const NestingLevels *nls, int n); 58 59 extern void *nestingLevelGetUserData (const NestingLevel *nl); 60 61 #endif /* CTAGS_MAIN_NESTLEVEL_H */ 62