diff --git a/main/debug.c b/main/debug.c index 95e94bb938..d68aaeece6 100644 --- a/main/debug.c +++ b/main/debug.c @@ -23,6 +23,7 @@ #include "options.h" #include "parse_p.h" #include "read.h" +#include "read_p.h" /* * FUNCTION DEFINITIONS diff --git a/main/entry.c b/main/entry.c index aa805292d6..654f741e55 100644 --- a/main/entry.c +++ b/main/entry.c @@ -43,11 +43,12 @@ #include "field.h" #include "fmt_p.h" #include "kind.h" -#include "main.h" +#include "main_p.h" #include "nestlevel.h" #include "options_p.h" #include "ptag_p.h" #include "read.h" +#include "read_p.h" #include "routines.h" #include "routines_p.h" #include "parse_p.h" @@ -57,7 +58,7 @@ #include "subparser_p.h" #include "trashbox.h" #include "writer_p.h" -#include "xtag.h" +#include "xtag_p.h" /* * MACROS diff --git a/main/entry.h b/main/entry.h index c033bf3fba..becd41de65 100644 --- a/main/entry.h +++ b/main/entry.h @@ -20,6 +20,8 @@ #include "field.h" #include "xtag.h" #include "mio.h" +#include "ptrarray.h" +#include "nestlevel.h" /* * MACROS @@ -142,12 +144,4 @@ extern bool isTagExtraBitMarked (const tagEntryInfo *const tag, xtagType extra); extern void attachParserField (tagEntryInfo *const tag, fieldType ftype, const char* value); extern void attachParserFieldToCorkEntry (int index, fieldType ftype, const char* value); -CTAGS_INLINE roleBitsType makeRoleBit(int roleIndex) -{ - if (roleIndex == ROLE_INDEX_DEFINITION) - return 0; - else - return ((roleBitsType)1) << roleIndex; -} - #endif /* CTAGS_MAIN_ENTRY_H */ diff --git a/main/entry_p.h b/main/entry_p.h index 533ea7631a..74047c07a9 100644 --- a/main/entry_p.h +++ b/main/entry_p.h @@ -65,4 +65,13 @@ extern void makeFileTag (const char *const fileName); extern const tagField* getParserField (const tagEntryInfo * tag, int index); + +CTAGS_INLINE roleBitsType makeRoleBit(int roleIndex) +{ + if (roleIndex == ROLE_INDEX_DEFINITION) + return 0; + else + return ((roleBitsType)1) << roleIndex; +} + #endif /* CTAGS_PRIVATE_ENTRY_H */ diff --git a/main/field.c b/main/field.c index e5db9fe000..d31b204475 100644 --- a/main/field.c +++ b/main/field.c @@ -27,6 +27,7 @@ #include "read.h" #include "routines.h" #include "trashbox.h" +#include "xtag_p.h" typedef struct sFieldObject { diff --git a/main/kind.h b/main/kind.h index a686824127..3a80be947b 100644 --- a/main/kind.h +++ b/main/kind.h @@ -8,10 +8,17 @@ #ifndef CTAGS_MAIN_KIND_H #define CTAGS_MAIN_KIND_H +/* +* INCLUDE FILES +*/ + #include "general.h" #include "types.h" #include "routines.h" -#include "vstring.h" + +/* +* DATA DECLARATIONS +*/ struct sRoleDefinition { bool enabled; @@ -21,9 +28,6 @@ struct sRoleDefinition { int id; }; -typedef void (* freeRoleDefFunc) (roleDefinition *); -extern const char *renderRole (const roleDefinition* const def, vString* b); - /* * Predefined kinds */ @@ -81,49 +85,10 @@ struct sKindDefinition { #define ATTACH_ROLES(RS) .nRoles = ARRAY_SIZE(RS), .roles = RS #define ATTACH_SEPARATORS(S) .separators = S, .separatorCount = ARRAY_SIZE(S) -/* for the obsolete --list-kinds option */ -extern void printKind (const kindDefinition* const kind, bool indent); +/* +* FUNCTION PROTOTYPES +*/ extern const char *scopeSeparatorFor (langType lang, int kindIndex, int parentKindIndex); -extern void enableKind (kindDefinition *kind, bool enable); - -struct kindControlBlock; -typedef void (* freeKindDefFunc) (kindDefinition *); -extern struct kindControlBlock* allocKindControlBlock (parserDefinition *parser); -extern void freeKindControlBlock (struct kindControlBlock* kcb); -extern int defineKind (struct kindControlBlock* kcb, kindDefinition *def, - freeKindDefFunc freeKindDef); -extern int defineRole (struct kindControlBlock* kcb, int kindIndex, - roleDefinition *def, freeRoleDefFunc freeRoleDef); -extern bool isRoleEnabled (struct kindControlBlock* kcb, int kindIndex, int roleIndex); - -extern unsigned int countKinds (struct kindControlBlock* kcb); -extern unsigned int countRoles (struct kindControlBlock* kcb, int kindIndex); -extern kindDefinition *getKind (struct kindControlBlock* kcb, int kindIndex); -extern kindDefinition *getKindForLetter (struct kindControlBlock* kcb, int letter); -extern kindDefinition *getKindForName (struct kindControlBlock* kcb, const char* name); -extern roleDefinition* getRole(struct kindControlBlock* kcb, int kindIndex, int roleIndex); -extern roleDefinition* getRoleForName(struct kindControlBlock* kcb, int kindIndex, const char* name); -extern void linkKindDependency (struct kindControlBlock *masterKCB, - struct kindControlBlock *slaveKCB); - -/* for --list-kinds-full option. LANGUAGE must be initialized. */ -extern struct colprintTable * kindColprintTableNew (void); -extern void kindColprintAddLanguageLines (struct colprintTable *table, - struct kindControlBlock* kcb); -extern void kindColprintTablePrint (struct colprintTable *table, bool noparser, - bool withListHeader, bool machinable, FILE *fp); - -extern struct colprintTable * roleColprintTableNew (void); -extern void roleColprintAddRoles (struct colprintTable *table, - struct kindControlBlock* kcb, - const char *kindspecs); -extern void roleColprintTablePrint (struct colprintTable *table, bool noparser, - bool withListHeader, bool machinable, FILE *fp); - -#ifdef DEBUG -extern bool doesParserUseKind (struct kindControlBlock* kcb, char letter); -#endif - #endif /* CTAGS_MAIN_KIND_H */ diff --git a/main/kind_p.h b/main/kind_p.h new file mode 100644 index 0000000000..b3414b206c --- /dev/null +++ b/main/kind_p.h @@ -0,0 +1,74 @@ +/* +* Copyright (c) 1998-2003, Darren Hiebert +* +* This source code is released for free distribution under the terms of the +* GNU General Public License version 2 or (at your option) any later version. +* +*/ +#ifndef CTAGS_MAIN_KIND_PRIVATE_H +#define CTAGS_MAIN_KIND_PRIVATE_H + +/* +* INCLUDE FILES +*/ + +#include "general.h" +#include "vstring.h" + + +/* +* DATA DECLARATIONS +*/ + +struct kindControlBlock; +typedef void (* freeKindDefFunc) (kindDefinition *); +typedef void (* freeRoleDefFunc) (roleDefinition *); + + +/* +* FUNCTION PROTOTYPES +*/ +extern void enableKind (kindDefinition *kind, bool enable); +extern const char *renderRole (const roleDefinition* const def, vString* b); + +extern struct kindControlBlock* allocKindControlBlock (parserDefinition *parser); +extern void freeKindControlBlock (struct kindControlBlock* kcb); + +extern int defineKind (struct kindControlBlock* kcb, kindDefinition *def, + freeKindDefFunc freeKindDef); +extern int defineRole (struct kindControlBlock* kcb, int kindIndex, + roleDefinition *def, freeRoleDefFunc freeRoleDef); +extern bool isRoleEnabled (struct kindControlBlock* kcb, int kindIndex, int roleIndex); + +extern unsigned int countKinds (struct kindControlBlock* kcb); +extern unsigned int countRoles (struct kindControlBlock* kcb, int kindIndex); +extern kindDefinition *getKind (struct kindControlBlock* kcb, int kindIndex); +extern kindDefinition *getKindForLetter (struct kindControlBlock* kcb, int letter); +extern kindDefinition *getKindForName (struct kindControlBlock* kcb, const char* name); +extern roleDefinition* getRole(struct kindControlBlock* kcb, int kindIndex, int roleIndex); +extern roleDefinition* getRoleForName(struct kindControlBlock* kcb, int kindIndex, const char* name); +extern void linkKindDependency (struct kindControlBlock *masterKCB, + struct kindControlBlock *slaveKCB); + +/* for the obsolete --list-kinds option */ +extern void printKind (const kindDefinition* const kind, bool indent); + +/* for --list-kinds-full option. LANGUAGE must be initialized. */ +extern struct colprintTable * kindColprintTableNew (void); +extern void kindColprintAddLanguageLines (struct colprintTable *table, + struct kindControlBlock* kcb); +extern void kindColprintTablePrint (struct colprintTable *table, bool noparser, + bool withListHeader, bool machinable, FILE *fp); + +extern struct colprintTable * roleColprintTableNew (void); +extern void roleColprintAddRoles (struct colprintTable *table, + struct kindControlBlock* kcb, + const char *kindspecs); +extern void roleColprintTablePrint (struct colprintTable *table, bool noparser, + bool withListHeader, bool machinable, FILE *fp); + +#ifdef DEBUG +extern bool doesParserUseKind (struct kindControlBlock* kcb, char letter); +#endif + +#endif /* CTAGS_MAIN_KIND_PRIVATE_H */ diff --git a/main/lregex.c b/main/lregex.c index ec269f3900..00767a23a2 100644 --- a/main/lregex.c +++ b/main/lregex.c @@ -27,16 +27,18 @@ #include "debug.h" #include "colprint_p.h" -#include "entry.h" +#include "entry_p.h" #include "flags_p.h" #include "htable.h" #include "kind.h" #include "options.h" #include "parse_p.h" #include "read.h" +#include "read_p.h" #include "routines.h" #include "routines_p.h" #include "trashbox.h" +#include "xtag_p.h" static bool regexAvailable = false; diff --git a/main/lregex_p.h b/main/lregex_p.h index a39fa9fa61..40c3f2fac3 100644 --- a/main/lregex_p.h +++ b/main/lregex_p.h @@ -19,6 +19,7 @@ * INCLUDE FILES */ #include "general.h" +#include "kind_p.h" #include "lregex.h" /* diff --git a/main/lxpath.c b/main/lxpath.c index 69c9131d81..6fda56b928 100644 --- a/main/lxpath.c +++ b/main/lxpath.c @@ -14,6 +14,7 @@ #include "options.h" #include "parse_p.h" #include "read.h" +#include "read_p.h" #include "routines.h" #include "xtag.h" diff --git a/main/lxpath.h b/main/lxpath.h index 23f4235f92..3e3b98e403 100644 --- a/main/lxpath.h +++ b/main/lxpath.h @@ -10,6 +10,10 @@ #ifndef CTAGS_LXPATH_PARSE_H #define CTAGS_LXPATH_PARSE_H +/* +* INCLUDE FILES +*/ + #include "general.h" /* must always come first */ #include "types.h" @@ -22,6 +26,11 @@ #define xmlXPathContext void #endif + +/* +* DATA DECLARATIONS +*/ + typedef struct sTagXpathMakeTagSpec { int kind; int role; @@ -72,10 +81,14 @@ typedef struct sXpathFileSpec { const char *rootNSHref; } xpathFileSpec; + +/* +* FUNCTION PROTOTYPES +*/ + /* Xpath interface */ extern void findXMLTags (xmlXPathContext *ctx, xmlNode *root, const tagXpathTableTable *xpathTableTable, const kindDefinition* const kinds, void *userData); -extern void addTagXpath (const langType language, tagXpathTable *xpathTable); #endif /* CTAGS_LXPATH_PARSE_H */ diff --git a/main/lxpath_p.h b/main/lxpath_p.h new file mode 100644 index 0000000000..6488fbe294 --- /dev/null +++ b/main/lxpath_p.h @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2016, Masatake YAMATO +* Copyright (c) 2016, Red Hat, Inc. +* +* This source code is released for free distribution under the terms of the +* GNU General Public License version 2 or (at your option) any later version. +* +* Xpath based parer API for the main part +*/ +#ifndef CTAGS_LXPATH_PARSE_PRIVATE_H +#define CTAGS_LXPATH_PARSE_PRIVATE_H + +/* +* INCLUDE FILES +*/ + +#include "general.h" /* must always come first */ +#include "types.h" + + +/* +* FUNCTION PROTOTYPES +*/ + +extern void addTagXpath (const langType language, tagXpathTable *xpathTable); + +#endif /* CTAGS_LXPATH_PARSE_PRIVATE_H */ diff --git a/main/main.c b/main/main.c index a36be08cec..a6548c63d3 100644 --- a/main/main.c +++ b/main/main.c @@ -67,14 +67,15 @@ #include "error_p.h" #include "field.h" #include "keyword_p.h" -#include "main.h" +#include "main_p.h" #include "options_p.h" #include "parse_p.h" -#include "read.h" +#include "read_p.h" #include "routines_p.h" #include "trace.h" -#include "trashbox.h" +#include "trashbox_p.h" #include "writer_p.h" +#include "xtag_p.h" #ifdef HAVE_JANSSON #include "interactive_p.h" diff --git a/main/main.h b/main/main_p.h similarity index 77% rename from main/main.h rename to main/main_p.h index da29e089a9..e1de5bb2d6 100644 --- a/main/main.h +++ b/main/main_p.h @@ -4,18 +4,16 @@ * This source code is released for free distribution under the terms of the * GNU General Public License version 2 or (at your option) any later version. * -* External interface to main.c +* Main part private interface to main.c */ -#ifndef CTAGS_MAIN_MAIN_H -#define CTAGS_MAIN_MAIN_H +#ifndef CTAGS_MAIN_MAIN_PRIVATE_H +#define CTAGS_MAIN_MAIN_PRIVATE_H /* * INCLUDE FILES */ #include "general.h" /* must always come first */ -#include - /* * FUNCTION PROTOTYPES */ @@ -23,4 +21,4 @@ extern void addTotals (const unsigned int files, const long unsigned int lines, extern bool isDestinationStdout (void); extern int main (int argc, char **argv); -#endif /* CTAGS_MAIN_MAIN_H */ +#endif /* CTAGS_MAIN_MAIN_PRIVATE_H */ diff --git a/main/nestlevel.c b/main/nestlevel.c index feba045bdf..d762179811 100644 --- a/main/nestlevel.c +++ b/main/nestlevel.c @@ -13,7 +13,6 @@ */ #include "general.h" /* must always come first */ -#include "main.h" #include "debug.h" #include "entry.h" #include "routines.h" diff --git a/main/nestlevel.h b/main/nestlevel.h index a95236fb80..a209ae706c 100644 --- a/main/nestlevel.h +++ b/main/nestlevel.h @@ -20,6 +20,7 @@ /* * DATA DECLARATIONS */ +typedef struct NestingLevel NestingLevel; typedef struct NestingLevels NestingLevels; struct NestingLevel diff --git a/main/options.c b/main/options.c index 638fed5494..7f7ffa0ead 100644 --- a/main/options.c +++ b/main/options.c @@ -27,12 +27,12 @@ #include "debug.h" #include "field.h" #include "gvars.h" -#include "keyword.h" -#include "main.h" +#include "keyword_p.h" +#include "main_p.h" #include "parse_p.h" #include "ptag_p.h" #include "routines_p.h" -#include "xtag.h" +#include "xtag_p.h" #include "param_p.h" #include "error_p.h" #include "interactive_p.h" diff --git a/main/options.h b/main/options.h index 5bb0e87aab..bd0f6fde5b 100644 --- a/main/options.h +++ b/main/options.h @@ -14,7 +14,6 @@ */ #include "general.h" /* must always come first */ #include "gvars.h" -#include "keyword_p.h" #include diff --git a/main/parse.c b/main/parse.c index e733a6beb3..5e44e280e4 100644 --- a/main/parse.c +++ b/main/parse.c @@ -25,7 +25,8 @@ #include "flags_p.h" #include "htable.h" #include "keyword.h" -#include "main.h" +#include "lxpath_p.h" +#include "main_p.h" #include "param.h" #include "param_p.h" #include "parse_p.h" @@ -35,17 +36,19 @@ #include "ptag_p.h" #include "ptrarray.h" #include "read.h" +#include "read_p.h" #include "routines.h" #include "routines_p.h" #include "subparser.h" #include "subparser_p.h" #include "trace.h" #include "trashbox.h" +#include "trashbox_p.h" #include "vstring.h" #ifdef HAVE_ICONV # include "mbcs_p.h" #endif -#include "xtag.h" +#include "xtag_p.h" /* * DATA TYPES diff --git a/main/parse.h b/main/parse.h index 8336af01d4..c84606ad2b 100644 --- a/main/parse.h +++ b/main/parse.h @@ -18,6 +18,7 @@ #include "kind.h" #include "lregex.h" #include "lxpath.h" +#include "vstring.h" /* * MACROS diff --git a/main/promise.c b/main/promise.c index 6b0d1d34f0..ad538a2ef0 100644 --- a/main/promise.c +++ b/main/promise.c @@ -16,7 +16,7 @@ #include "promise_p.h" #include "ptrarray.h" #include "debug.h" -#include "read.h" +#include "read_p.h" #include "trashbox.h" #include "xtag.h" #include "numarray.h" diff --git a/main/ptrarray.h b/main/ptrarray.h index 2c0fd7794f..cf412728c9 100644 --- a/main/ptrarray.h +++ b/main/ptrarray.h @@ -18,10 +18,11 @@ /* * DATA DECLARATIONS */ +struct sPtrArray; +typedef struct sPtrArray ptrArray; typedef void (*ptrArrayDeleteFunc) (void *data); -struct sPtrArray; /* * FUNCTION PROTOTYPES diff --git a/main/read.c b/main/read.c index 39150757b2..eddf603bc9 100644 --- a/main/read.c +++ b/main/read.c @@ -19,9 +19,10 @@ #define FILE_WRITE #include "read.h" +#include "read_p.h" #include "debug.h" #include "entry_p.h" -#include "main.h" +#include "main_p.h" #include "routines.h" #include "routines_p.h" #include "options_p.h" diff --git a/main/read.h b/main/read.h index 671606e9b0..a95e239cf5 100644 --- a/main/read.h +++ b/main/read.h @@ -60,73 +60,25 @@ extern const char *getInputFileName (void); extern MIOPos getInputFilePosition (void); extern MIOPos getInputFilePositionForLine (unsigned int line); extern langType getInputLanguage (void); -extern const char *getInputLanguageName (void); -extern const char *getInputFileTagPath (void); extern bool isInputLanguage (langType lang); extern bool isInputHeaderFile (void); extern bool isInputLanguageKindEnabled (int kindIndex); - extern bool isInputLanguageRoleEnabled (int kindIndex, int roleIndex); -extern unsigned int countInputLanguageKinds (void); -extern unsigned int countInputLanguageRoles (int kindIndex); - -extern bool doesInputLanguageAllowNullTag (void); -extern bool doesInputLanguageRequestAutomaticFQTag (void); -extern bool doesParserRunAsGuest (void); -extern bool doesSubparserRun (void); -extern bool isParserMarkedNoEmission (void); -extern void freeInputFileResources (void); extern const unsigned char *getInputFileData (size_t *size); -/* Stream opened by getMio can be passed to openInputFile as the 3rd - argument. If the 3rd argument is NULL, openInputFile calls getMio - internally. The 3rd argument is introduced for reusing mio object - created in parser guessing stage. */ -extern bool openInputFile (const char *const fileName, const langType language, MIO *mio); -extern MIO *getMio (const char *const fileName, const char *const openMode, - bool memStreamRequired); -extern void resetInputFile (const langType language); - -extern void closeInputFile (void); -extern void *getInputFileUserData(void); extern int getcFromInputFile (void); extern int getNthPrevCFromInputFile (unsigned int nth, int def); extern int skipToCharacterInInputFile (int c); extern void ungetcToInputFile (int c); extern const unsigned char *readLineFromInputFile (void); -enum nestedInputBoundaryFlag { - BOUNDARY_START = 1UL << 0, - BOUNDARY_END = 1UL << 1, -}; -extern unsigned int getNestedInputBoundaryInfo (unsigned long lineNumber); - -extern const char *getSourceFileTagPath (void); -extern langType getSourceLanguage (void); extern unsigned long getSourceLineNumber (void); /* Raw: reading from given a parameter, mio */ extern char *readLineRaw (vString *const vLine, MIO *const mio); -/* Bypass: reading from fp in inputFile WITHOUT updating fields in input fields */ -extern char *readLineFromBypass (vString *const vLine, MIOPos location, long *const pSeekValue); - -extern void pushNarrowedInputStream ( - unsigned long startLine, long startCharOffset, - unsigned long endLine, long endCharOffset, - unsigned long sourceLineOffset, - int promise); -extern void popNarrowedInputStream (void); - extern void pushLanguage(const langType language); extern langType popLanguage (void); -extern unsigned long getInputLineNumberForFileOffset(long offset); - -#define THIN_STREAM_SPEC 0, 0, 0, 0, 0 -extern bool isThinStreamSpec(unsigned long startLine, long startCharOffset, - unsigned long endLine, long endCharOffset, - unsigned long sourceLineOffset); - #endif /* CTAGS_MAIN_READ_H */ diff --git a/main/read_p.h b/main/read_p.h new file mode 100644 index 0000000000..64e2336df2 --- /dev/null +++ b/main/read_p.h @@ -0,0 +1,80 @@ +/* +* Copyright (c) 1998-2002, Darren Hiebert +* +* This source code is released for free distribution under the terms of the +* GNU General Public License version 2 or (at your option) any later version. +* +* Main part private interface to read.c +*/ +#ifndef CTAGS_MAIN_READ_PRIVATE_H +#define CTAGS_MAIN_READ_PRIVATE_H + +/* +* INCLUDE FILES +*/ +#include "general.h" /* must always come first */ + +#include "mio.h" +#include "types.h" +#include "vstring.h" + +/* +* DATA DECLARATIONS +*/ + +enum nestedInputBoundaryFlag { + BOUNDARY_START = 1UL << 0, + BOUNDARY_END = 1UL << 1, +}; + +/* +* FUNCTION PROTOTYPES +*/ + +extern const char *getInputLanguageName (void); +extern const char *getInputFileTagPath (void); + +extern unsigned int countInputLanguageKinds (void); +extern unsigned int countInputLanguageRoles (int kindIndex); + +extern bool doesInputLanguageAllowNullTag (void); +extern bool doesInputLanguageRequestAutomaticFQTag (void); +extern bool doesParserRunAsGuest (void); +extern bool doesSubparserRun (void); + +extern bool isParserMarkedNoEmission (void); +extern void freeInputFileResources (void); + +/* Stream opened by getMio can be passed to openInputFile as the 3rd + argument. If the 3rd argument is NULL, openInputFile calls getMio + internally. The 3rd argument is introduced for reusing mio object + created in parser guessing stage. */ +extern bool openInputFile (const char *const fileName, const langType language, MIO *mio); +extern MIO *getMio (const char *const fileName, const char *const openMode, + bool memStreamRequired); +extern void resetInputFile (const langType language); +extern void closeInputFile (void); +extern void *getInputFileUserData(void); + +extern unsigned int getNestedInputBoundaryInfo (unsigned long lineNumber); + +extern const char *getSourceFileTagPath (void); +extern langType getSourceLanguage (void); + +/* Bypass: reading from fp in inputFile WITHOUT updating fields in input fields */ +extern char *readLineFromBypass (vString *const vLine, MIOPos location, long *const pSeekValue); +extern void pushNarrowedInputStream ( + unsigned long startLine, long startCharOffset, + unsigned long endLine, long endCharOffset, + unsigned long sourceLineOffset, + int promise); +extern void popNarrowedInputStream (void); + +extern unsigned long getInputLineNumberForFileOffset(long offset); + +#define THIN_STREAM_SPEC 0, 0, 0, 0, 0 +extern bool isThinStreamSpec(unsigned long startLine, long startCharOffset, + unsigned long endLine, long endCharOffset, + unsigned long sourceLineOffset); + +#endif /* CTAGS_MAIN_READ_PRIVATE_H */ diff --git a/main/trashbox.h b/main/trashbox.h index fef93e5bec..0b01dd72b3 100644 --- a/main/trashbox.h +++ b/main/trashbox.h @@ -13,16 +13,23 @@ #ifndef CTAGS_MAIN_TRASH_H #define CTAGS_MAIN_TRASH_H +/* +* INCLUDE FILES +*/ + +#include "general.h" /* must always come first */ + + +/* +* DATA DECLARATIONS +*/ + typedef void (* TrashBoxDestroyItemProc) (void *); typedef struct sTrashBox TrashBox; -extern TrashBox* trashBoxNew (void); -extern TrashBox* trashBoxStack (TrashBox* trash_box); -extern void trashBoxDelete (TrashBox* trash_box); -extern void* trashBoxPut (TrashBox* trash_box, void* item, TrashBoxDestroyItemProc destroy); -extern TrashBoxDestroyItemProc trashBoxTakeBack (TrashBox* trash_box, void* item); -extern void trashBoxFree (TrashBox* trash_box, void* item); -extern void trashBoxMakeEmpty (TrashBox* trash_box); +/* +* MACROS +*/ #define DEFAULT_TRASH_BOX(PTR,PROC) trashBoxPut(NULL,PTR,(TrashBoxDestroyItemProc)PROC) #define DEFAULT_TRASH_BOX_TAKE_BACK(PTR) trashBoxTakeBack(NULL,PTR) @@ -30,11 +37,19 @@ extern void trashBoxMakeEmpty (TrashBox* trash_box); #define PARSER_TRASH_BOX(PTR,PROC) parserTrashBoxPut(PTR,(TrashBoxDestroyItemProc)PROC) #define PARSER_TRASH_BOX_TAKE_BACK(PTR) parserTrashBoxTakeBack(PTR) -extern void initDefaultTrashBox (void); -extern void finiDefaultTrashBox (void); -extern void initParserTrashBox (void); -extern void finiParserTrashBox (void); +/* +* FUNCTION PROTOTYPES +*/ + +extern TrashBox* trashBoxNew (void); +extern TrashBox* trashBoxStack (TrashBox* trash_box); +extern void trashBoxDelete (TrashBox* trash_box); +extern void* trashBoxPut (TrashBox* trash_box, void* item, TrashBoxDestroyItemProc destroy); +extern TrashBoxDestroyItemProc trashBoxTakeBack (TrashBox* trash_box, void* item); +extern void trashBoxFree (TrashBox* trash_box, void* item); +extern void trashBoxMakeEmpty (TrashBox* trash_box); + extern void* parserTrashBoxPut (void* item, TrashBoxDestroyItemProc destroy); extern TrashBoxDestroyItemProc parserTrashBoxTakeBack (void* item); diff --git a/main/trashbox_p.h b/main/trashbox_p.h new file mode 100644 index 0000000000..9959e0c53d --- /dev/null +++ b/main/trashbox_p.h @@ -0,0 +1,30 @@ +/* +* +* Copyright (c) 2017, Red Hat, Inc. +* Copyright (c) 2017, Masatake YAMATO +* +* This source code is released for free distribution under the terms of the +* GNU General Public License version 2 or (at your option) any later version. +*/ + +#ifndef CTAGS_MAIN_TRASH_PRIVATE_H +#define CTAGS_MAIN_TRASH_PRIVATE_H + +/* +* INCLUDE FILES +*/ + +#include "general.h" /* must always come first */ + + +/* +* FUNCTION PROTOTYPES +*/ + +extern void initDefaultTrashBox (void); +extern void finiDefaultTrashBox (void); + +extern void initParserTrashBox (void); +extern void finiParserTrashBox (void); + +#endif /* CTAGS_MAIN_TRASH_PRIVATE_H */ diff --git a/main/types.h b/main/types.h index 3b61eac5c9..b36bf7711a 100644 --- a/main/types.h +++ b/main/types.h @@ -48,10 +48,4 @@ typedef struct sXtagDefinition xtagDefinition; struct sParameterHandlerTable; typedef struct sParameterHandlerTable parameterHandlerTable; -struct NestingLevel; -typedef struct NestingLevel NestingLevel; - -struct sPtrArray; -typedef struct sPtrArray ptrArray; - #endif /* CTAGS_MAIN_TYPES_H */ diff --git a/main/writer-etags.c b/main/writer-etags.c index 6af0829bd7..089e44eb6a 100644 --- a/main/writer-etags.c +++ b/main/writer-etags.c @@ -16,6 +16,7 @@ #include "mio.h" #include "options_p.h" #include "read.h" +#include "routines.h" #include "routines_p.h" #include "vstring.h" #include "writer_p.h" diff --git a/main/writer-json.c b/main/writer-json.c index 789eecd3db..dc76a07b3b 100644 --- a/main/writer-json.c +++ b/main/writer-json.c @@ -14,6 +14,7 @@ #include "mio.h" #include "options_p.h" #include "read.h" +#include "routines.h" #include "ptag_p.h" #include "writer_p.h" diff --git a/main/xtag.c b/main/xtag.c index 6371e93f6e..8534abeafe 100644 --- a/main/xtag.c +++ b/main/xtag.c @@ -13,13 +13,14 @@ #include "general.h" /* must always come first */ #include "ctags.h" #include "debug.h" -#include "main.h" +#include "main_p.h" #include "options.h" #include "parse_p.h" #include "routines.h" #include "trashbox.h" #include "writer_p.h" #include "xtag.h" +#include "xtag_p.h" #include #include diff --git a/main/xtag.h b/main/xtag.h index 4240ad9197..0eccddd40e 100644 --- a/main/xtag.h +++ b/main/xtag.h @@ -12,9 +12,15 @@ #ifndef CTAGS_MAIN_XTAG_H #define CTAGS_MAIN_XTAG_H +/* +* INCLUDE FILES +*/ + #include "general.h" -#include "colprint_p.h" +/* +* DATA DECLARATIONS +*/ typedef enum eXtagType { /* extra tag content control */ XTAG_UNKNOWN = -1, @@ -56,28 +62,6 @@ struct sXtagDefinition { unsigned int xtype; /* Given from the main part */ }; -extern xtagDefinition* getXtagDefinition (xtagType type); -extern xtagType getXtagTypeForLetter (char letter); -extern xtagType getXtagTypeForNameAndLanguage (const char *name, langType language); extern bool isXtagEnabled (xtagType type); -extern bool enableXtag (xtagType type, bool state); -extern bool isXtagFixed (xtagType type); -extern bool isCommonXtag (xtagType type); -extern int getXtagOwner (xtagType type); - -const char* getXtagName (xtagType type); - -extern void initXtagObjects (void); -extern int countXtags (void); - -extern int defineXtag (xtagDefinition *def, langType language); -extern xtagType nextSiblingXtag (xtagType type); - -/* --list-extras implementation. LANGUAGE must be initialized. */ -extern struct colprintTable * xtagColprintTableNew (void); -extern void xtagColprintAddCommonLines (struct colprintTable *table); -extern void xtagColprintAddLanguageLines (struct colprintTable *table, langType language); -extern void xtagColprintTablePrint (struct colprintTable *table, - bool withListHeader, bool machinable, FILE *fp); #endif /* CTAGS_MAIN_FIELD_H */ diff --git a/main/xtag_p.h b/main/xtag_p.h new file mode 100644 index 0000000000..c0bc527649 --- /dev/null +++ b/main/xtag_p.h @@ -0,0 +1,51 @@ +/* + * + * Copyright (c) 2015, Red Hat, Inc. + * Copyright (c) 2015, Masatake YAMATO + * + * Author: Masatake YAMATO + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + */ +#ifndef CTAGS_MAIN_XTAG_PRIVATE_H +#define CTAGS_MAIN_XTAG_PRIVATE_H + +/* +* INCLUDE FILES +*/ + +#include "general.h" + +#include "colprint_p.h" + +/* +* FUNCTION PROTOTYPES +*/ + +extern xtagDefinition* getXtagDefinition (xtagType type); +extern xtagType getXtagTypeForLetter (char letter); +extern xtagType getXtagTypeForNameAndLanguage (const char *name, langType language); + +extern bool enableXtag (xtagType type, bool state); +extern bool isXtagFixed (xtagType type); +extern bool isCommonXtag (xtagType type); +extern int getXtagOwner (xtagType type); + +const char* getXtagName (xtagType type); + +extern void initXtagObjects (void); +extern int countXtags (void); + +extern int defineXtag (xtagDefinition *def, langType language); +extern xtagType nextSiblingXtag (xtagType type); + +/* --list-extras implementation. LANGUAGE must be initialized. */ +extern struct colprintTable * xtagColprintTableNew (void); +extern void xtagColprintAddCommonLines (struct colprintTable *table); +extern void xtagColprintAddLanguageLines (struct colprintTable *table, langType language); +extern void xtagColprintTablePrint (struct colprintTable *table, + bool withListHeader, bool machinable, FILE *fp); + +#endif /* CTAGS_MAIN_FIELD_PRIVATE_H */ diff --git a/misc/optlib2c b/misc/optlib2c index 19daccb8ba..b339242eaa 100755 --- a/misc/optlib2c +++ b/misc/optlib2c @@ -61,7 +61,7 @@ my $options = unless ($_[0]->{'langdef'} eq $1); my $refonly = 0; $refonly = 1 if defined $5; - push @{$_[0]->{'kinddefs'}}, { letter => $2, name => $3, desc => $4, + push @{$_[0]->{'kinddefs'}}, { enabled => 1, letter => $2, name => $3, desc => $4, refonly => $refonly, roles => [] }; } ], [ qr/^--_extradef-(.*)=([^,]+),(.+)/, sub { @@ -356,7 +356,12 @@ sub extend_table { sub parse_kinds { my ($kinds, $opts) = @_; for (split //, $kinds) { - push @{$opts->{'disabledKinds'}}, $_; + my $letter = $_; + for (@{$opts->{'kinddefs'}}) { + if ($_->{'letter'} eq $letter) { + $_->{'enabled'} = 0; + } + } } } @@ -443,21 +448,12 @@ EOF sub emit_initializer { my $opts = shift; - my $may_unused = (@{$opts->{'disabledKinds'}}) ? "": " CTAGS_ATTR_UNUSED"; + my $may_unused = $opts->{'tablenames'} ? "": " CTAGS_ATTR_UNUSED"; print <{'Clangdef'}Parser (const langType language$may_unused) { EOF - for (@{$opts->{'disabledKinds'}}) { - print <{'tablenames'}) { print "\n"; @@ -551,11 +547,12 @@ sub emit_kinddefs { static kindDefinition $opts->{'Clangdef'}KindTable [] = { EOF for (@{$opts->{'kinddefs'}}) { + my $enabled = $_->{"enabled"}? "true": "false"; print <{'letter'}\', "$_->{'name'}", "$_->{'desc'}", + $enabled, \'$_->{'letter'}\', "$_->{'name'}", "$_->{'desc'}", EOF if ($_->{'refonly'}) { print < [], extensions => [], aliases => [], - disabledKinds => [], regexs => [# { regex => "", name => "", kind => "", flags => "", mline => 1|0 }, ], kinddefs => [# { letter => '', name => "", desc => "" }, diff --git a/optlib/cmake.c b/optlib/cmake.c index 0aac16862c..5962d10743 100644 --- a/optlib/cmake.c +++ b/optlib/cmake.c @@ -8,7 +8,7 @@ #include "xtag.h" -static void initializeCMakeParser (const langType language CTAGS_ATTR_UNUSED) +static void initializeCMakeParser (const langType language) { addLanguageRegexTable (language, "main"); diff --git a/optlib/gdbinit.c b/optlib/gdbinit.c index e74bb053ce..83cbaf2fd7 100644 --- a/optlib/gdbinit.c +++ b/optlib/gdbinit.c @@ -8,16 +8,8 @@ #include "xtag.h" -static void initializeGdbinitParser (const langType language) +static void initializeGdbinitParser (const langType language CTAGS_ATTR_UNUSED) { - { - kindDefinition *kdef = getLanguageKindForLetter (language, 'D'); - enableKind (kdef, false); - } - { - kindDefinition *kdef = getLanguageKindForLetter (language, 'l'); - enableKind (kdef, false); - } } extern parserDefinition* GdbinitParser (void) @@ -41,13 +33,13 @@ extern parserDefinition* GdbinitParser (void) true, 'd', "definition", "definitions", }, { - true, 'D', "document", "documents", + false, 'D', "document", "documents", }, { true, 't', "toplevelVariable", "toplevel variables", }, { - true, 'l', "localVariable", "local variables", + false, 'l', "localVariable", "local variables", }, }; static tagRegexTable GdbinitTagRegexTable [] = { diff --git a/optlib/markdown.c b/optlib/markdown.c index 89f32bf30e..9026b84248 100644 --- a/optlib/markdown.c +++ b/optlib/markdown.c @@ -8,7 +8,7 @@ #include "xtag.h" -static void initializeMarkdownParser (const langType language CTAGS_ATTR_UNUSED) +static void initializeMarkdownParser (const langType language) { addLanguageRegexTable (language, "main"); diff --git a/optlib/puppetManifest.c b/optlib/puppetManifest.c index e3de2486d5..b35ad9968d 100644 --- a/optlib/puppetManifest.c +++ b/optlib/puppetManifest.c @@ -8,7 +8,7 @@ #include "xtag.h" -static void initializePuppetManifestParser (const langType language CTAGS_ATTR_UNUSED) +static void initializePuppetManifestParser (const langType language) { addLanguageRegexTable (language, "main"); diff --git a/parsers/go.c b/parsers/go.c index 370be3cc08..fea9db1021 100644 --- a/parsers/go.c +++ b/parsers/go.c @@ -10,7 +10,6 @@ #include "entry.h" #include "keyword.h" #include "read.h" -#include "main.h" #include "numarray.h" #include "objpool.h" #include "parse.h" diff --git a/parsers/python.c b/parsers/python.c index afd9432eb9..71a3bfe6f0 100644 --- a/parsers/python.c +++ b/parsers/python.c @@ -16,7 +16,6 @@ #include "entry.h" #include "nestlevel.h" #include "read.h" -#include "main.h" #include "parse.h" #include "vstring.h" #include "keyword.h" diff --git a/parsers/rust.c b/parsers/rust.c index 7249ca273c..87cc244863 100644 --- a/parsers/rust.c +++ b/parsers/rust.c @@ -10,7 +10,6 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ -#include "main.h" #include diff --git a/source.mak b/source.mak index a82d47f90b..1b4d3b2b93 100644 --- a/source.mak +++ b/source.mak @@ -19,7 +19,9 @@ MAIN_PUBLIC_HEADS = \ main/htable.h \ main/inline.h \ main/keyword.h \ + main/kind.h \ main/lregex.h \ + main/lxpath.h \ main/mbcs.h \ main/nestlevel.h\ main/numarray.h \ @@ -29,13 +31,17 @@ MAIN_PUBLIC_HEADS = \ main/parse.h \ main/promise.h \ main/ptrarray.h \ + main/read_p.h \ main/routines.h \ + main/selectors.h\ main/strlist.h \ main/subparser.h\ main/tokeninfo.h\ main/trace.h \ + main/trashbox_p.h\ main/types.h \ main/vstring.h \ + main/xtag.h \ \ $(NULL) @@ -49,7 +55,10 @@ MAIN_PRIVATE_HEADS = \ main/fmt_p.h \ main/interactive_p.h \ main/keyword_p.h \ + main/kind_p.h \ main/lregex_p.h \ + main/lxpath_p.h \ + main/main_p.h \ main/mbcs_p.h \ main/options_p.h \ main/param_p.h \ @@ -58,10 +67,13 @@ MAIN_PRIVATE_HEADS = \ main/portable-dirent_p.h\ main/promise_p.h \ main/ptag_p.h \ + main/read_p.h \ main/routines_p.h \ main/sort_p.h \ main/subparser_p.h \ + main/trashbox_p.h \ main/writer_p.h \ + main/xtag_p.h \ \ $(NULL) @@ -69,13 +81,6 @@ MAIN_HEADS = \ main/ctags.h \ main/field.h \ main/general.h \ - main/kind.h \ - main/lxpath.h \ - main/main.h \ - main/read.h \ - main/selectors.h \ - main/trashbox.h \ - main/xtag.h \ \ $(MAIN_PUBLIC_HEADS) \ $(MAIN_PRIVATE_HEADS) \ diff --git a/win32/ctags_vs2013.vcxproj b/win32/ctags_vs2013.vcxproj index 3229b48e92..f09e594e81 100644 --- a/win32/ctags_vs2013.vcxproj +++ b/win32/ctags_vs2013.vcxproj @@ -269,10 +269,12 @@ + - + + @@ -290,6 +292,7 @@ + @@ -299,10 +302,12 @@ + + diff --git a/win32/ctags_vs2013.vcxproj.filters b/win32/ctags_vs2013.vcxproj.filters index 77199e51c6..1028ed45bf 100644 --- a/win32/ctags_vs2013.vcxproj.filters +++ b/win32/ctags_vs2013.vcxproj.filters @@ -560,6 +560,9 @@ Header Files + + Header Files + Header Files @@ -569,7 +572,10 @@ Header Files - + + Header Files + + Header Files @@ -623,6 +629,9 @@ Header Files + + Header Files + Header Files @@ -650,6 +659,9 @@ Header Files + + Header Files + Header Files @@ -662,6 +674,9 @@ Header Files + + Header Files + Header Files