Doxygen
Loading...
Searching...
No Matches
Preprocessor Class Reference

#include <src/pre.h>

Classes

struct  Private
 

Public Member Functions

 Preprocessor ()
 
 ~Preprocessor ()
 
void processFile (const QCString &fileName, const std::string &input, std::string &output)
 
void addSearchDir (const QCString &dir)
 

Private Attributes

std::unique_ptr< Privatep
 

Detailed Description

Definition at line 27 of file pre.h.

Constructor & Destructor Documentation

◆ Preprocessor()

Preprocessor::Preprocessor ( )

Definition at line 3955 of file pre.l.

3955 : p(std::make_unique<Private>())
3956{
3957 preYYlex_init_extra(&p->state,&p->yyscanner);
3958 addSearchDir(".");
3959}
void addSearchDir(const QCString &dir)
Definition pre.l:3948
std::unique_ptr< Private > p
Definition pre.h:38

References addSearchDir(), and p.

◆ ~Preprocessor()

Preprocessor::~Preprocessor ( )

Definition at line 3961 of file pre.l.

3962{
3963 preYYlex_destroy(p->yyscanner);
3964}

References p.

Member Function Documentation

◆ addSearchDir()

void Preprocessor::addSearchDir ( const QCString & dir)

Definition at line 3948 of file pre.l.

3949{
3950 YY_EXTRA_TYPE state = preYYget_extra(p->yyscanner);
3951 FileInfo fi(dir.str());
3952 if (fi.isDir()) state->pathList.push_back(fi.absFilePath());
3953}
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
const std::string & str() const
Definition qcstring.h:517

References FileInfo::absFilePath(), FileInfo::isDir(), p, and QCString::str().

Referenced by parseFile(), and Preprocessor().

◆ processFile()

void Preprocessor::processFile ( const QCString & fileName,
const std::string & input,
std::string & output )

Definition at line 3966 of file pre.l.

3967{
3968 AUTO_TRACE("fileName={}",fileName);
3969 yyscan_t yyscanner = p->yyscanner;
3970 YY_EXTRA_TYPE state = preYYget_extra(p->yyscanner);
3971 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
3972
3973#ifdef FLEX_DEBUG
3974 preYYset_debug(Debug::isFlagSet(Debug::Lex_pre)?1:0,yyscanner);
3975#endif
3976
3977 DebugLex debugLex(Debug::Lex_pre, __FILE__, qPrint(fileName));
3978 //printf("##########################\n%s\n####################\n",
3979 // qPrint(input));
3980
3981 state->macroExpansion = Config_getBool(MACRO_EXPANSION);
3982 state->expandOnlyPredef = Config_getBool(EXPAND_ONLY_PREDEF);
3983 state->skip=FALSE;
3984 state->curlyCount=0;
3985 state->lexRulesPart=false;
3986 state->nospaces=FALSE;
3987 state->inputBuf=&input;
3988 state->inputBufPos=0;
3989 state->outputBuf=&output;
3990 state->includeStack.clear();
3991 state->expandedDict.clear();
3992 state->contextDefines.clear();
3993 while (!state->condStack.empty()) state->condStack.pop();
3994
3995 setFileName(yyscanner,fileName);
3996
3997 state->inputFileDef = state->yyFileDef;
3998 //yyextra->defineManager.startContext(state->fileName);
3999
4000 initPredefined(yyscanner,fileName);
4001
4002 state->yyLineNr = 1;
4003 state->yyColNr = 1;
4004 state->ifcount = 0;
4005
4006 BEGIN( Start );
4007
4008 state->expectGuard = guessSection(fileName).isHeader();
4009 state->guardName.clear();
4010 state->lastGuardName.clear();
4011 state->guardExpr.clear();
4012
4013 preYYlex(yyscanner);
4014
4015 while (!state->condStack.empty())
4016 {
4017 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
4018 QCString sectionInfo = " ";
4019 if (ctx->sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",qPrint(ctx->sectionId.stripWhiteSpace()));
4020 warn(ctx->fileName,ctx->lineNr,"Conditional section%sdoes not have "
4021 "a corresponding \\endcond command within this file.",qPrint(sectionInfo));
4022 state->condStack.pop();
4023 }
4024 // make sure we don't extend a \cond with missing \endcond over multiple files (see bug 624829)
4025 forceEndCondSection(yyscanner);
4026
4028 {
4029 std::lock_guard<std::mutex> lock(g_debugMutex);
4030 Debug::print(Debug::Preprocessor,0,"Preprocessor output of %s (size: %zu bytes):\n",qPrint(fileName),output.size());
4031 int line=1;
4032 Debug::print(Debug::Preprocessor,0,"---------\n");
4034 size_t pos=0;
4035 while (pos<output.size())
4036 {
4037 putchar(output[pos]);
4038 if (output[pos]=='\n' && !Debug::isFlagSet(Debug::NoLineNo)) Debug::print(Debug::Preprocessor,0,"%05d ",++line);
4039 pos++;
4040 }
4041 Debug::print(Debug::Preprocessor,0,"\n---------\n");
4042 if (yyextra->contextDefines.size()>0)
4043 {
4044 Debug::print(Debug::Preprocessor,0,"Macros accessible in this file (%s):\n", qPrint(fileName));
4045 Debug::print(Debug::Preprocessor,0,"---------\n");
4046 for (auto &kv : yyextra->contextDefines)
4047 {
4048 Debug::print(Debug::Preprocessor,0,"%s ",qPrint(kv.second.name));
4049 }
4050 for (auto &kv : yyextra->localDefines)
4051 {
4052 Debug::print(Debug::Preprocessor,0,"%s ",qPrint(kv.second.name));
4053 }
4054 Debug::print(Debug::Preprocessor,0,"\n---------\n");
4055 }
4056 else
4057 {
4058 Debug::print(Debug::Preprocessor,0,"No macros accessible in this file (%s).\n", qPrint(fileName));
4059 }
4060 }
4061
4062 {
4063 std::lock_guard<std::mutex> lock(g_updateGlobals);
4064 for (const auto &inc : state->includeRelations)
4065 {
4066 auto toKind = [](bool local,bool imported) -> IncludeKind
4067 {
4068 if (local)
4069 {
4070 if (imported)
4071 {
4073 }
4075 }
4076 else if (imported)
4077 {
4079 }
4081 };
4082 if (inc->fromFileDef)
4083 {
4084 inc->fromFileDef->addIncludeDependency(inc->toFileDef,inc->includeName,toKind(inc->local,inc->imported));
4085 }
4086 if (inc->toFileDef && inc->fromFileDef)
4087 {
4088 inc->toFileDef->addIncludedByDependency(inc->fromFileDef,inc->fromFileDef->docName(),toKind(inc->local,inc->imported));
4089 }
4090 }
4091 // add the macro definition for this file to the global map
4092 Doxygen::macroDefinitions.emplace(std::make_pair(state->fileName.str(),std::move(state->macroDefinitions)));
4093 }
4094
4095 //yyextra->defineManager.endContext();
4096}
@ NoLineNo
Definition debug.h:41
@ Lex_pre
Definition debug.h:62
@ Preprocessor
Definition debug.h:29
static void print(DebugMask mask, int prio, const char *fmt,...)
Definition debug.cpp:80
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:134
static DefinesPerFileList macroDefinitions
Definition doxygen.h:127
This is an alternative implementation of QCString.
Definition qcstring.h:94
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
yyguts_t * yyscan_t
Definition code.l:24
#define Config_getBool(name)
Definition config.h:33
#define AUTO_TRACE(...)
Definition docnode.cpp:46
IncludeKind
Definition filedef.h:47
#define warn(file, line, fmt,...)
Definition message.h:59
static void initPredefined(yyscan_t yyscanner, const QCString &fileName)
Definition pre.l:3821
static void setFileName(yyscan_t yyscanner, const QCString &name)
Definition pre.l:2106
static void forceEndCondSection(yyscan_t yyscanner)
Definition pre.l:3677
static std::mutex g_updateGlobals
Definition pre.l:234
static std::mutex g_debugMutex
Definition pre.l:232
const char * qPrint(const char *s)
Definition qcstring.h:652
#define FALSE
Definition qcstring.h:34
EntryType guessSection(const QCString &name)
Definition util.cpp:349

References AUTO_TRACE, Config_getBool, FALSE, forceEndCondSection(), g_debugMutex, g_updateGlobals, guessSection(), ImportLocalObjC, ImportSystemObjC, IncludeLocal, IncludeSystem, initPredefined(), Debug::isFlagSet(), Debug::Lex_pre, Doxygen::macroDefinitions, Debug::NoLineNo, p, Debug::Preprocessor, Debug::print(), qPrint(), setFileName(), QCString::sprintf(), and warn.

Referenced by parseFile().

Member Data Documentation

◆ p

std::unique_ptr<Private> Preprocessor::p
private

Definition at line 38 of file pre.h.

Referenced by addSearchDir(), Preprocessor(), processFile(), and ~Preprocessor().


The documentation for this class was generated from the following files: